X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fsoc%2Ffu%2Fdiv%2Fsetup_stage.py;h=5fe049786ae9074e30e39a48fe4939b0e7382ba3;hb=8aaa3876cc22950271d8e4cf622d1658efe93aef;hp=0625159e123b67658a7e667327835ec637b2a038;hpb=fb3528750f912a762984a79654cce6601c52a994;p=soc.git diff --git a/src/soc/fu/div/setup_stage.py b/src/soc/fu/div/setup_stage.py index 0625159e..5fe04978 100644 --- a/src/soc/fu/div/setup_stage.py +++ b/src/soc/fu/div/setup_stage.py @@ -27,6 +27,7 @@ class DivSetupStage(PipeModBase): return CoreInputData(self.pspec) def elaborate(self, platform): + XLEN = self.pspec.XLEN m = Module() comb = m.d.comb # convenience variables @@ -42,14 +43,15 @@ class DivSetupStage(PipeModBase): # work out if a/b are negative (check 32-bit / signed) comb += dividend_neg_o.eq(Mux(op.is_32bit, - a[31], a[63]) & op.is_signed) - comb += divisor_neg_o.eq(Mux(op.is_32bit, b[31], b[63]) & op.is_signed) + a[31], a[XLEN-1]) & op.is_signed) + comb += divisor_neg_o.eq(Mux(op.is_32bit, + b[31], b[XLEN-1]) & op.is_signed) # 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_dor = Signal(64, reset_less=True) # absolute of divisor - abs_dend = Signal(64, reset_less=True) # absolute of dividend + abs_dor = Signal(XLEN, reset_less=True) # absolute of divisor + abs_dend = Signal(XLEN, reset_less=True) # absolute of dividend comb += abs_dor.eq(Mux(divisor_neg_o, -b, b)) comb += abs_dend.eq(Mux(dividend_neg_o, -a, a)) @@ -78,7 +80,7 @@ class DivSetupStage(PipeModBase): with m.If(op.is_32bit): comb += dividend_o.eq(abs_dend[0:32] << 32) with m.Else(): - comb += dividend_o.eq(abs_dend[0:64] << 64) + comb += dividend_o.eq(abs_dend[0:XLEN] << XLEN) ###### sticky overflow and context, both pass-through #####