truncate max_bits in shiftermask
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 15 Feb 2020 15:12:41 +0000 (15:12 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 15 Feb 2020 15:12:41 +0000 (15:12 +0000)
src/ieee754/part_shift/part_shift_dynamic.py

index 96334e7cf34b2a4828291037dd81bc4e9f56f2b4..6cbf691a343f8e45e7495d8efcaa0b04b8aff563 100644 (file)
@@ -54,13 +54,13 @@ class PartitionedDynamicShift(Elaboratable):
             start = end
 
         min_bits = math.ceil(math.log2(intervals[0][1] - intervals[0][0]))
-        max_bits = math.ceil(math.log2(width))
 
         # shifts are normally done as (e.g. for 32 bit) result = a & (b&0b11111)
         # truncating the b input.  however here of course the size of the
         # partition varies dynamically.
         shifter_masks = []
         for i in range(len(b_intervals)):
+            max_bits = math.ceil(math.log2(width-intervals[i][0]))
             mask = Signal(b_intervals[i].shape(), name="shift_mask%d" % i,
                           reset_less=True)
             bits = Signal(pwid-i, name="bits%d" % i, reset_less=True)