Replace giant switch statement with mux chain
authorMichael Nolan <mtnolan2640@gmail.com>
Fri, 14 Feb 2020 14:22:59 +0000 (09:22 -0500)
committerMichael Nolan <mtnolan2640@gmail.com>
Fri, 14 Feb 2020 14:22:59 +0000 (09:22 -0500)
src/ieee754/part_shift/part_shift_dynamic.py

index a0dac157bbf31e8f68165ed08ce5dee8aabf8533..41bf16e3500eb47c65451aa5164ec657db89aa61 100644 (file)
@@ -100,15 +100,11 @@ class PartitionedDynamicShift(Elaboratable):
             s, e = intervals[i]
             index = gates[:i]  # selects the 'i' least significant bits
                                # of gates
-            element = Signal(matrix[0][i].width, name="element%d" % i)
-            for index in range(1<<i):
-                print(index)
-                with m.Switch(gates[:i]):
-                    with m.Case(index):
-                        index = math.ceil(math.log2(index + 1))
-                        comb += element.eq(matrix[index][i])
+            element = matrix[0][i]
+            for index in range(i):
+                element = Mux(gates[index], matrix[index+1][i], element)
             print(keys[i-1])
-            temp = Signal(element.width, name="intermed%d" % i)
+            temp = Signal(matrix[0][i].width, name="intermed%d" % i)
             print(intermed[keys[0]:])
             # XXX bit of a mess here, but rather than select
             # element or (element | intermed), select between 0 or intermed