X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fsoc%2Ffu%2Flogical%2Fmain_stage.py;h=6a90395783e798165bd55576c769c9bf73144952;hb=2adbe7711bec6c228e9cb6ffb7c7ef30b1621c8f;hp=253664032fc16a1401665416a70e33688c6caa65;hpb=8d0c40fdf6335120e440a6bdba9aa0875239e843;p=soc.git diff --git a/src/soc/fu/logical/main_stage.py b/src/soc/fu/logical/main_stage.py index 25366403..6a903957 100644 --- a/src/soc/fu/logical/main_stage.py +++ b/src/soc/fu/logical/main_stage.py @@ -6,6 +6,8 @@ # to the output stage # Copyright (C) 2020 Michael Nolan +# Copyright (C) 2020, 2021 Luke Kenneth Casson Leighton + from nmigen import (Module, Signal, Cat, Repl, Mux, Const, Array) from nmutil.pipemodbase import PipeModBase from nmutil.clz import CLZ @@ -33,14 +35,15 @@ class LogicalMainStage(PipeModBase): return LogicalOutputData(self.pspec) def elaborate(self, platform): + XLEN = self.pspec.XLEN m = Module() comb = m.d.comb op, a, b, o = self.i.ctx.op, self.i.a, self.i.b, self.o.o comb += o.ok.eq(1) # overridden if no op activates - m.submodules.bpermd = bpermd = Bpermd(64) - m.submodules.popcount = popcount = Popcount() + m.submodules.bpermd = bpermd = Bpermd(XLEN) + m.submodules.popcount = popcount = Popcount(XLEN) ########################## # main switch for logic ops AND, OR and XOR, cmpb, parity, and popcount @@ -84,12 +87,14 @@ class LogicalMainStage(PipeModBase): par0 = Signal(reset_less=True) par1 = Signal(reset_less=True) comb += par0.eq(Cat(a[0], a[8], a[16], a[24]).xor()) - comb += par1.eq(Cat(a[32], a[40], a[48], a[56]).xor()) + if XLEN == 64: + comb += par1.eq(Cat(a[32], a[40], a[48], a[56]).xor()) with m.If(op.data_len[3] == 1): comb += o.data.eq(par0 ^ par1) with m.Else(): comb += o[0].eq(par0) - comb += o[32].eq(par1) + if XLEN == 64: + comb += o[32].eq(par1) ################### ###### cntlz v3.0B p99 @@ -99,7 +104,7 @@ class LogicalMainStage(PipeModBase): count_right = Signal(reset_less=True) comb += count_right.eq(XO[-1]) - cntz_i = Signal(64, reset_less=True) + cntz_i = Signal(XLEN, reset_less=True) a32 = Signal(32, reset_less=True) comb += a32.eq(a[0:32]) @@ -108,7 +113,7 @@ class LogicalMainStage(PipeModBase): with m.Else(): comb += cntz_i.eq(Mux(count_right, a[::-1], a)) - m.submodules.clz = clz = CLZ(64) + m.submodules.clz = clz = CLZ(XLEN) comb += clz.sig_in.eq(cntz_i) comb += o.data.eq(Mux(op.is_32bit, clz.lz-32, clz.lz))