store shiftmask bits in temporary otherwise the expression gets duplicated
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 15 Feb 2020 12:13:39 +0000 (12:13 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 15 Feb 2020 12:13:39 +0000 (12:13 +0000)
src/ieee754/part_shift/part_shift_dynamic.py

index 5dd72ed792f9bc9c58526eaf2b0ebc4d37c7eaa0..95c07d639679595d16b2d644291c6e8698807384 100644 (file)
@@ -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