split out normtopack to separate module
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 29 Mar 2019 11:54:45 +0000 (11:54 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 29 Mar 2019 11:54:45 +0000 (11:54 +0000)
src/add/fpcommon/normtopack.py [new file with mode: 0644]
src/add/nmigen_add_experiment.py

diff --git a/src/add/fpcommon/normtopack.py b/src/add/fpcommon/normtopack.py
new file mode 100644 (file)
index 0000000..2eb4459
--- /dev/null
@@ -0,0 +1,59 @@
+# IEEE Floating Point Adder (Single Precision)
+# Copyright (C) Jonathan P Dawson 2013
+# 2013-12-12
+
+from nmigen import Module, Signal, Cat, Mux, Array, Const
+from nmigen.lib.coding import PriorityEncoder
+from nmigen.cli import main, verilog
+from math import log
+
+from fpbase import FPNumIn, FPNumOut, FPOp, Overflow, FPBase, FPNumBase
+from fpbase import MultiShiftRMerge, Trigger
+from singlepipe import (ControlBase, StageChain, UnbufferedPipeline,
+                        PassThroughStage)
+from multipipe import CombMuxOutPipe
+from multipipe import PriorityCombMuxInPipe
+
+from fpbase import FPState, FPID
+from fpcommon.postcalc import FPAddStage1Data
+from fpcommon.postnormalise import FPNorm1ModSingle
+from fpcommon.roundz import FPRoundMod
+from fpcommon.corrections import FPCorrectionsMod
+from fpcommon.pack import FPPackData, FPPackMod
+
+
+class FPNormToPack(FPState, UnbufferedPipeline):
+
+    def __init__(self, width, id_wid):
+        FPState.__init__(self, "normalise_1")
+        self.id_wid = id_wid
+        self.width = width
+        UnbufferedPipeline.__init__(self, self) # pipeline is its own stage
+
+    def ispec(self):
+        return FPAddStage1Data(self.width, self.id_wid) # Norm1ModSingle ispec
+
+    def ospec(self):
+        return FPPackData(self.width, self.id_wid) # FPPackMod ospec
+
+    def setup(self, m, i):
+        """ links module to inputs and outputs
+        """
+
+        # Normalisation, Rounding Corrections, Pack - in a chain
+        nmod = FPNorm1ModSingle(self.width, self.id_wid)
+        rmod = FPRoundMod(self.width, self.id_wid)
+        cmod = FPCorrectionsMod(self.width, self.id_wid)
+        pmod = FPPackMod(self.width, self.id_wid)
+        chain = StageChain([nmod, rmod, cmod, pmod])
+        chain.setup(m, i)
+        self.out_z = pmod.ospec()
+
+        self.o = pmod.o
+
+    def process(self, i):
+        return self.o
+
+    def action(self, m):
+        m.d.sync += self.out_z.eq(self.process(None))
+        m.next = "pack_put_z"
index 22e9e991144d9f953a48718bf7b532c79c6c8286..f828a67ae0142d16884d34552ce7b9e87c031c65 100644 (file)
@@ -23,6 +23,7 @@ from fpcommon.postnormalise import (FPNorm1Data, FPNorm1ModSingle,
 from fpcommon.roundz import (FPRoundData, FPRoundMod, FPRound)
 from fpcommon.corrections import (FPCorrectionsMod, FPCorrections)
 from fpcommon.pack import (FPPackData, FPPackMod, FPPack)
+from fpcommon.normtopack import FPNormToPack
 
 
 class FPAddSpecialCasesMod:
@@ -637,43 +638,6 @@ class FPAddStage1(FPState):
         m.next = "normalise_1"
 
 
-class FPNormToPack(FPState, UnbufferedPipeline):
-
-    def __init__(self, width, id_wid):
-        FPState.__init__(self, "normalise_1")
-        self.id_wid = id_wid
-        self.width = width
-        UnbufferedPipeline.__init__(self, self) # pipeline is its own stage
-
-    def ispec(self):
-        return FPAddStage1Data(self.width, self.id_wid) # Norm1ModSingle ispec
-
-    def ospec(self):
-        return FPPackData(self.width, self.id_wid) # FPPackMod ospec
-
-    def setup(self, m, i):
-        """ links module to inputs and outputs
-        """
-
-        # Normalisation, Rounding Corrections, Pack - in a chain
-        nmod = FPNorm1ModSingle(self.width, self.id_wid)
-        rmod = FPRoundMod(self.width, self.id_wid)
-        cmod = FPCorrectionsMod(self.width, self.id_wid)
-        pmod = FPPackMod(self.width, self.id_wid)
-        chain = StageChain([nmod, rmod, cmod, pmod])
-        chain.setup(m, i)
-        self.out_z = pmod.ospec()
-
-        self.o = pmod.o
-
-    def process(self, i):
-        return self.o
-
-    def action(self, m):
-        m.d.sync += self.out_z.eq(self.process(None))
-        m.next = "pack_put_z"
-
-
 
 class FPPutZ(FPState):