add name to Overflow class, also recreate OverflowMod
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 13 Jul 2019 08:45:25 +0000 (09:45 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 13 Jul 2019 08:45:25 +0000 (09:45 +0100)
src/ieee754/fpcommon/fpbase.py

index 5e086fe1b65344f22d7994a348388cb99341c00c..02a854242f2a3a19889cf2dd842ae67778e959ee 100644 (file)
@@ -588,11 +588,13 @@ class FPOpOut(NextControl):
 
 
 class Overflow:  # (Elaboratable):
-    def __init__(self):
-        self.guard = Signal(reset_less=True)     # tot[2]
-        self.round_bit = Signal(reset_less=True)  # tot[1]
-        self.sticky = Signal(reset_less=True)    # tot[0]
-        self.m0 = Signal(reset_less=True)        # mantissa zero bit
+    def __init__(self, name=None):
+        if name is None:
+            name = ""
+        self.guard = Signal(reset_less=True, name=name+"guard")     # tot[2]
+        self.round_bit = Signal(reset_less=True, name=name+"round") # tot[1]
+        self.sticky = Signal(reset_less=True, name=name+"sticky")   # tot[0]
+        self.m0 = Signal(reset_less=True, name=name+"m0") # mantissa bit 0
 
         #self.roundz = Signal(reset_less=True)
 
@@ -613,6 +615,26 @@ class Overflow:  # (Elaboratable):
         return self.guard & (self.round_bit | self.sticky | self.m0)
 
 
+class OverflowMod(Elaboratable, Overflow):
+    def __init__(self, name=None):
+        Overflow.__init__(self, name)
+        if name is None:
+            name = ""
+        self.roundz_out = Signal(reset_less=True, name=name+"roundz_out")
+
+    def __iter__(self):
+        yield from Overflow.__iter__(self)
+        yield self.roundz_out
+
+    def eq(self, inp):
+        return [self.roundz_out.eq(inp.roundz_out)] + Overflow.eq(self)
+
+    def elaborate(self, platform):
+        m = Module()
+        m.d.comb += self.roundz_out.eq(self.roundz)
+        return m
+
+
 class FPBase:
     """ IEEE754 Floating Point Base Class