create FPNumBaseRecord
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 16 Jun 2019 06:07:32 +0000 (07:07 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 16 Jun 2019 06:07:32 +0000 (07:07 +0100)
src/ieee754/fpcommon/denorm.py
src/ieee754/fpcommon/fpbase.py

index 2653e335b43cf7e65eacaa811f8bf2a4dc0709a0..44d5461ab751ca5c8017884c7860ea0224d6b9fa 100644 (file)
@@ -6,8 +6,8 @@ from nmigen import Module, Signal, Elaboratable
 from nmigen.cli import main, verilog
 from math import log
 
-from ieee754.fpcommon.fpbase import FPNumIn, FPNumOut, FPNumBase
-from ieee754.fpcommon.fpbase import FPState
+from ieee754.fpcommon.fpbase import FPNumIn, FPNumOut, FPNumBaseRecord
+from ieee754.fpcommon.fpbase import FPState, FPNumBase
 
 
 class FPSCData:
index 198ce0364483214485e02f2ae8b1297717cb0e16..4889407ff372f40e4bb78563e09081ad1a782716 100644 (file)
@@ -60,7 +60,7 @@ class MultiShift:
         return res
 
 
-class FPNumBase: #(Elaboratable):
+class FPNumBaseRecord:
     """ Floating-point Base Number Class
     """
     def __init__(self, width, m_extra=True):
@@ -96,6 +96,22 @@ class FPNumBase: #(Elaboratable):
         self.N127 = Const(-(e_max-1), (e_width, True))
         self.N126 = Const(-(e_max-2), (e_width, True))
 
+    def __iter__(self):
+        yield self.s
+        yield self.e
+        yield self.m
+
+    def eq(self, inp):
+        return [self.s.eq(inp.s), self.e.eq(inp.e), self.m.eq(inp.m)]
+
+
+class FPNumBase(FPNumBaseRecord): # Elaboratable
+    """ Floating-point Base Number Class
+    """
+    def __init__(self, width, m_extra=True):
+        FPNumBaseRecord.__init__(self, width, m_extra)
+        e_width = self.e_width
+
         self.is_nan = Signal(reset_less=True)
         self.is_zero = Signal(reset_less=True)
         self.is_inf = Signal(reset_less=True)
@@ -145,14 +161,6 @@ class FPNumBase: #(Elaboratable):
     def _is_denormalised(self):
         return (self.exp_n126) & (self.m_msbzero)
 
-    def __iter__(self):
-        yield self.s
-        yield self.e
-        yield self.m
-
-    def eq(self, inp):
-        return [self.s.eq(inp.s), self.e.eq(inp.e), self.m.eq(inp.m)]
-
 
 class FPNumOut(FPNumBase):
     """ Floating-point Number Class