add AddReduceData class
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Wed, 21 Aug 2019 07:27:56 +0000 (08:27 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Wed, 21 Aug 2019 07:27:56 +0000 (08:27 +0100)
src/ieee754/part_mul_add/multiply.py

index 269ff8b7a9015135d165d27e902c5f1d1b43ec84..de40a89dd7e7cb6a79986f9c74660f8a8c141629 100644 (file)
@@ -300,6 +300,22 @@ class PartitionedAdder(Elaboratable):
 
 FULL_ADDER_INPUT_COUNT = 3
 
+class AddReduceData:
+
+    def __init__(self, ppoints, output_width, n_parts)
+        self.part_ops = [Signal(2, name=f"part_ops_{i}")
+                          for i in range(n_parts)]
+        self.inputs = [Signal(output_width, name=f"inputs[{i}]")
+            for i in range(len(self.inputs))]
+        self.reg_partition_points = partition_points.like()
+
+    def eq(self, rhs):
+        return [self.reg_partition_points.eq(rhs.reg_partition_points)] + \
+               [self.inputs[i].eq(rhs.inputs[i])
+                                     for i in range(len(self.inputs))] + \
+               [self.part_ops[i].eq(rhs.part_ops[i])
+                                     for i in range(len(self.part_ops))]
+
 
 class AddReduceSingle(Elaboratable):
     """Add list of numbers together.