resolve awful meta-class hacking (with thanks to jsbueno on stackexchange)
[ieee754fpu.git] / src / ieee754 / fpadd / addstages.py
index 45688c1c308a18b1972812d9869825a9688f4ab7..f875ef920247243e9bfd3265055c66cd87584e1c 100644 (file)
@@ -5,40 +5,38 @@
 from nmigen import Module
 from nmigen.cli import main, verilog
 
-from nmutil.singlepipe import (StageChain, SimpleHandshake,
-                        PassThroughStage)
+from nmutil.singlepipe import StageChain
+from ieee754.pipeline import DynamicPipe
 
 from ieee754.fpcommon.fpbase import FPState
 from ieee754.fpcommon.denorm import FPSCData
 from ieee754.fpcommon.postcalc import FPAddStage1Data
-from .align import FPAddAlignSingleMod
-from .add0 import FPAddStage0Mod
-from .add1 import FPAddStage1Mod
+from ieee754.fpadd.align import FPAddAlignSingleMod
+from ieee754.fpadd.add0 import FPAddStage0Mod
+from ieee754.fpadd.add1 import FPAddStage1Mod
 
+class FPAddAlignSingleAdd(DynamicPipe):
 
-class FPAddAlignSingleAdd(FPState, SimpleHandshake):
-
-    def __init__(self, width, pspec):
-        FPState.__init__(self, "align")
-        self.width = width
+    def __init__(self, pspec):
+        #FPState.__init__(self, "align")
         self.pspec = pspec
-        SimpleHandshake.__init__(self, self) # pipeline is its own stage
+        super().__init__(pspec)
         self.a1o = self.ospec()
 
     def ispec(self):
-        return FPSCData(self.width, self.pspec, True)
+        return FPSCData(self.pspec, True)
 
     def ospec(self):
-        return FPAddStage1Data(self.width, self.pspec) # AddStage1 ospec
+        return FPAddStage1Data(self.pspec) # AddStage1 ospec
 
     def setup(self, m, i):
         """ links module to inputs and outputs
         """
 
         # chain AddAlignSingle, AddStage0 and AddStage1
-        mod = FPAddAlignSingleMod(self.width, self.pspec)
-        a0mod = FPAddStage0Mod(self.width, self.pspec)
-        a1mod = FPAddStage1Mod(self.width, self.pspec)
+        mod = FPAddAlignSingleMod(self.pspec)
+        a0mod = FPAddStage0Mod(self.pspec)
+        a1mod = FPAddStage1Mod(self.pspec)
 
         chain = StageChain([mod, a0mod, a1mod])
         chain.setup(m, i)