create separate denormalisation class
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 21 Feb 2019 09:10:07 +0000 (09:10 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 21 Feb 2019 09:10:07 +0000 (09:10 +0000)
src/add/nmigen_add_experiment.py

index 4505269bd3ade6833d4b22dfa5a48ac7fffc0889..8c08652ff9115d90989cf14e8154c106f4a23677 100644 (file)
@@ -111,6 +111,15 @@ class FPAddSpecialCases(FPState):
             m.next = "denormalise"
 
 
+class FPAddDeNorm(FPState):
+
+    def action(self, m):
+        # Denormalised Number checks
+        m.next = "align"
+        self.denormalise(m, self.a)
+        self.denormalise(m, self.b)
+
+
 class FPADD(FPBase):
 
     def __init__(self, width, single_cycle=False):
@@ -156,6 +165,10 @@ class FPADD(FPBase):
         sc.set_inputs({"a": a, "b": b})
         sc.set_outputs({"z": z})
 
+        dn = FPAddDeNorm("denormalise")
+        dn.set_inputs({"a": a, "b": b})
+        dn.set_outputs({"a": a, "b": b}) # XXX outputs same as inputs
+
         with m.FSM() as fsm:
 
             # ******
@@ -183,10 +196,7 @@ class FPADD(FPBase):
             # denormalise.
 
             with m.State("denormalise"):
-                # Denormalised Number checks
-                m.next = "align"
-                self.denormalise(m, a)
-                self.denormalise(m, b)
+                dn.action(m)
 
             # ******
             # align.