From d21edf16dee1b5ada2c6a689a5161760e50c866e Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sat, 15 Feb 2020 12:13:39 +0000 Subject: [PATCH] store shiftmask bits in temporary otherwise the expression gets duplicated --- src/ieee754/part_shift/part_shift_dynamic.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/ieee754/part_shift/part_shift_dynamic.py b/src/ieee754/part_shift/part_shift_dynamic.py index 5dd72ed7..95c07d63 100644 --- a/src/ieee754/part_shift/part_shift_dynamic.py +++ b/src/ieee754/part_shift/part_shift_dynamic.py @@ -63,12 +63,14 @@ class PartitionedDynamicShift(Elaboratable): for i in range(len(b_intervals)): mask = Signal(b_intervals[i].shape(), name="shift_mask%d" % i, reset_less=True) - bits = [] + bits = Signal(gates.width-i+1, name="bits%d" % i, reset_less=True) + bl = [] for j in range(i, gates.width): - if bits: - bits.append(~gates[j] & bits[-1]) + if bl: + bl.append(~gates[j] & bits[j-i-1]) else: - bits.append(~gates[j]) + bl.append(~gates[j]) + comb += bits.eq(Cat(*bl)) comb += mask.eq(Cat((1 << min_bits)-1, bits) & ((1 << max_bits)-1)) shifter_masks.append(mask) @@ -103,6 +105,10 @@ class PartitionedDynamicShift(Elaboratable): reset_less=True) comb += masked.eq(b_intervals[i] & shifter_masks[i]) element = Mux(gates[i-1], masked, element) + elmux = Signal(b_intervals[i].shape(), name="elmux%d" % i, + reset_less=True) + comb += elmux.eq(element) + element = elmux # This calculates which partition of b to select the # shifter from. According to the table above, the -- 2.30.2