separate common functions into FPBase class
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 16 Feb 2019 09:47:55 +0000 (09:47 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 16 Feb 2019 09:47:55 +0000 (09:47 +0000)
src/add/nmigen_add_experiment.py

index 68b3a0935806959971ae548c423d71f1cd0ba84a..675ef4b3c84c3408453a7c9db8f683538f2852d3 100644 (file)
@@ -111,13 +111,13 @@ class Overflow:
         self.sticky = Signal()    # tot[0]
 
 
-class FPADD:
-    def __init__(self, width):
-        self.width = width
+class FPBase:
+    """ IEEE754 Floating Point Base Class
 
-        self.in_a  = FPOp(width)
-        self.in_b  = FPOp(width)
-        self.out_z = FPOp(width)
+        contains common functions for FP manipulation, such as
+        extracting and packing operands, normalisation, denormalisation,
+        rounding etc.
+    """
 
     def get_op(self, m, op, v, next_state):
         """ this function moves to the next state and copies the operand
@@ -222,6 +222,17 @@ class FPADD:
             m.d.sync += out_z.stb.eq(0)
             m.next = next_state
 
+
+class FPADD(FPBase):
+
+    def __init__(self, width):
+        FPBase.__init__(self)
+        self.width = width
+
+        self.in_a  = FPOp(width)
+        self.in_b  = FPOp(width)
+        self.out_z = FPOp(width)
+
     def get_fragment(self, platform=None):
         """ creates the HDL code-fragment for FPAdd
         """