Reduce width of b operand to minimum size needed
authorMichael Nolan <mtnolan2640@gmail.com>
Wed, 12 Feb 2020 19:12:26 +0000 (14:12 -0500)
committerMichael Nolan <mtnolan2640@gmail.com>
Wed, 12 Feb 2020 19:12:26 +0000 (14:12 -0500)
src/ieee754/part_shift/part_shift_dynamic.py

index 2eb6a4994ad23ae8010ad3769910a4b3be003459..97be1118e016164896d5f35927b36deb9f32e560 100644 (file)
@@ -71,7 +71,9 @@ class PartitionedDynamicShift(Elaboratable):
             start = 0
             for j, a in enumerate(a_intervals):
                 end = keys[i]
-                comb += matrix[i][j].eq(a << b)
+                result_width = matrix[i][j].width
+                bwidth = math.ceil(math.log2(result_width + 1))
+                comb += matrix[i][j].eq(a << b[:bwidth])
                 start = end
 
         # now create a switch statement which sums the relevant partial results