add first (untested) version of ripple-LSB
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 7 Feb 2020 14:06:09 +0000 (14:06 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 7 Feb 2020 14:06:09 +0000 (14:06 +0000)
src/ieee754/part_cmp/eq_gt_ge.py
src/ieee754/part_cmp/ripple.py [new file with mode: 0644]

index e1f933fd185638b76e402cd41d1de8a25e1b7b6a..077f3aef1adc17f47084913347a0e3974afc22c3 100644 (file)
@@ -52,6 +52,7 @@ class PartitionedEqGtGe(Elaboratable):
         m.submodules.gtc = gtc = GTCombiner(self.mwidth)
 
         m.submodules.reorder = reorder = ReorderResults(self.mwidth)
+        m.submodules.ripple = ripple = RippleLSB(self.mwidth)
 
         # make a series of "eqs" and "gts", splitting a and b into
         # partition chunks
@@ -97,8 +98,10 @@ class PartitionedEqGtGe(Elaboratable):
 
         comb += reorder.results_in.eq(results)
         comb += reorder.gates.eq(self.partition_points.as_sig())
+        comb += ripple.results_in.eq(reorder.output)
+        comb += ripple.gates.eq(self.partition_points.as_sig())
 
-        comb += self.output.eq(reorder.output)
+        comb += self.output.eq(ripple.output)
 
         return m
 
diff --git a/src/ieee754/part_cmp/ripple.py b/src/ieee754/part_cmp/ripple.py
new file mode 100644 (file)
index 0000000..b758c28
--- /dev/null
@@ -0,0 +1,34 @@
+# need to ripple the starting LSB of each partition up through the
+# rest of the partition.  a Mux on the partition gate therefore selects
+# either the current "thing" being propagated, or, if the gate is set open,
+# will select the current bit from the input.
+#
+# this is actually a useful function, it's one of "set before first" or
+# "set after first" from vector predication processing.
+
+from nmigen import Signal, Module, Elaboratable, Mux
+
+
+class RippleLSB(Elaboratable):
+    def __init__(self, width):
+        self.width = width
+        self.results_in = Signal(width, reset_less=True)
+        self.gates = Signal(width-1, reset_less=True)
+
+        self.output = Signal(width, reset_less=True)
+
+    def elaborate(self, platform):
+        m = Module()
+        comb = m.d.comb
+        width = self.width
+
+        current_result = self.results_in[0]
+        comb += self.output[0].eq(current_result)
+
+        for i in range(width-1):
+            cur = Signal("cur%d" % i)
+            comb += cur.eq(current_result)
+            current_result = Mux(self.gates[i], self.results_in[i+1], cur)
+            comb += self.output[i+1].eq(current_result)
+
+        return m