Allow partsig to take in a PartitionPoints directly
authorMichael Nolan <mtnolan2640@gmail.com>
Fri, 8 May 2020 17:01:38 +0000 (13:01 -0400)
committerMichael Nolan <mtnolan2640@gmail.com>
Fri, 8 May 2020 17:01:38 +0000 (13:01 -0400)
src/ieee754/part/partsig.py

index 1fc7d4b052aa85becb9113b891563106450bcd80..a5f95140d38aeef8a571693328b2721ef0e68f19 100644 (file)
@@ -20,7 +20,7 @@ from ieee754.part_mul_add.adder import PartitionedAdder
 from ieee754.part_cmp.eq_gt_ge import PartitionedEqGtGe
 from ieee754.part_shift.part_shift_dynamic import PartitionedDynamicShift
 from ieee754.part_shift.part_shift_scalar import PartitionedScalarShift
-from ieee754.part_mul_add.partpoints import make_partition
+from ieee754.part_mul_add.partpoints import make_partition, PartitionPoints
 from operator import or_, xor, and_, not_
 
 from nmigen import (Signal, Const)
@@ -41,7 +41,10 @@ class PartitionedSignal:
         self.sig = Signal(*args, **kwargs)
         width = self.sig.shape()[0]  # get signal width
         # create partition points
-        self.partpoints = make_partition(mask, width)
+        if isinstance(mask, PartitionPoints):
+            self.partpoints = mask
+        else:
+            self.partpoints = make_partition(mask, width)
         self.modnames = {}
         for name in ['add', 'eq', 'gt', 'ge', 'ls']:
             self.modnames[name] = 0