skip shiftermask when bitwid=0
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 23 Feb 2020 00:26:23 +0000 (00:26 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 23 Feb 2020 00:26:23 +0000 (00:26 +0000)
src/ieee754/part_shift/part_shift_dynamic.py

index 4f75cc86bb696cc067a153ff6c93a7469fce6531..93188618422c273b6e456ba7cfc36b3ca743d6f8 100644 (file)
@@ -140,10 +140,13 @@ class PartitionedDynamicShift(Elaboratable):
         # partition varies dynamically.
         shifter_masks = []
         for i in range(len(b_intervals)):
+            bwid = b_intervals[i].shape()[0]
             bitwid = pwid-i
+            if bitwid == 0:
+                shifter_masks.append(C((1<<min_bits)-1, bwid))
+                continue
             max_bits = math.ceil(math.log2(width-intervals[i][0]))
-            sm = ShifterMask(bitwid, b_intervals[i].shape()[0],
-                             max_bits, min_bits)
+            sm = ShifterMask(bitwid, bwid, max_bits, min_bits)
             setattr(m.submodules, "sm%d" % i, sm)
             if bitwid != 0:
                 comb += sm.gates.eq(gates[i:pwid])