X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fsoc%2Ffu%2Fmul%2Fpre_stage.py;h=a8a7fb4e5201ad479d22a9a61c7d7bb7dfa14034;hb=8aaa3876cc22950271d8e4cf622d1658efe93aef;hp=c5e696ae415afbe03e294c4f386c22316c34c7d0;hpb=fb3528750f912a762984a79654cce6601c52a994;p=soc.git diff --git a/src/soc/fu/mul/pre_stage.py b/src/soc/fu/mul/pre_stage.py index c5e696ae..a8a7fb4e 100644 --- a/src/soc/fu/mul/pre_stage.py +++ b/src/soc/fu/mul/pre_stage.py @@ -18,6 +18,7 @@ class MulMainStage1(PipeModBase): return MulIntermediateData(self.pspec) # pipeline stage output format def elaborate(self, platform): + XLEN = self.pspec.XLEN m = Module() comb = m.d.comb @@ -35,8 +36,8 @@ class MulMainStage1(PipeModBase): comb += is_32bit.eq(op.is_32bit) # work out if a/b are negative (check 32-bit / signed) - comb += sign_a.eq(Mux(op.is_32bit, a[31], a[63]) & op.is_signed) - comb += sign_b.eq(Mux(op.is_32bit, b[31], b[63]) & op.is_signed) + comb += sign_a.eq(Mux(op.is_32bit, a[31], a[XLEN-1]) & op.is_signed) + comb += sign_b.eq(Mux(op.is_32bit, b[31], b[XLEN-1]) & op.is_signed) comb += sign32_a.eq(a[31] & op.is_signed) comb += sign32_b.eq(b[31] & op.is_signed) @@ -47,8 +48,8 @@ class MulMainStage1(PipeModBase): # negation of a 64-bit value produces the same lower 32-bit # result as negation of just the lower 32-bits, so we don't # need to do anything special before negating - abs_a = Signal(64, reset_less=True) - abs_b = Signal(64, reset_less=True) + abs_a = Signal(XLEN, reset_less=True) + abs_b = Signal(XLEN, reset_less=True) comb += abs_a.eq(Mux(sign_a, -a, a)) comb += abs_b.eq(Mux(sign_b, -b, b))