add __ge__ partsig operator
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 6 Feb 2020 14:31:42 +0000 (14:31 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 6 Feb 2020 14:31:42 +0000 (14:31 +0000)
src/ieee754/part/partsig.py

index 4740e68e2f6cc0f680bbf67aed2c64ab2f34f61b..097e4307e2df826afe150bbc73ad0593a4c8c8fc 100644 (file)
@@ -38,7 +38,7 @@ class PartitionedSignal:
         width = self.sig.shape()[0] # get signal width
         self.partpoints = make_partition(mask, width) # create partition points
         self.modnames = {}
-        for name in ['add', 'eq', 'gt']:
+        for name in ['add', 'eq', 'gt', 'ge']:
             self.modnames[name] = 0
 
     def set_module(self, m):
@@ -107,3 +107,17 @@ class PartitionedSignal:
         else:
             comb += pa.b.eq(other)
         return pa.output
+
+    def __ge__(self, other):
+        print ("ge", self, other)
+        shape = self.sig.shape()
+        pa = PartitionedEqGtGe(shape[0], self.partpoints)
+        setattr(self.m.submodules, self.get_modname('ge'), pa)
+        comb = self.m.d.comb
+        comb += pa.opcode.eq(PartitionedEqGtGe.GE) # set opcode to GE
+        comb += pa.a.eq(self.sig)
+        if isinstance(other, PartitionedSignal):
+            comb += pa.b.eq(other.sig)
+        else:
+            comb += pa.b.eq(other)
+        return pa.output