convert to DynamicPipe (default class in PipelineSpec: SimpleHandshake)
[ieee754fpu.git] / src / ieee754 / fpdiv / divstages.py
index 914e77232a4d5dee11f62cec4530c867b96c95f1..81f9f3118f70963d54e8179300279a40995ef296 100644 (file)
@@ -7,9 +7,9 @@ Relevant bugreport: http://bugs.libre-riscv.org/show_bug.cgi?id=99
 from nmigen import Module
 from nmigen.cli import main, verilog
 
-from nmutil.singlepipe import (StageChain, SimpleHandshake)
+from nmutil.singlepipe import StageChain
 
-from ieee754.fpcommon.fpbase import FPState
+from ieee754.pipeline import DynamicPipe
 from ieee754.fpcommon.denorm import FPSCData
 from ieee754.fpcommon.postcalc import FPAddStage1Data
 from ieee754.div_rem_sqrt_rsqrt.div_pipe import (DivPipeInterstageData,
@@ -21,18 +21,15 @@ from ieee754.div_rem_sqrt_rsqrt.div_pipe import (DivPipeInterstageData,
 # TODO: write these
 from .div0 import FPDivStage0Mod
 from .div2 import FPDivStage2Mod
-from .div0 import FPDivStage0Data
 
 
-class FPDivStagesSetup(FPState, SimpleHandshake):
+class FPDivStagesSetup(DynamicPipe):
 
     def __init__(self, pspec, n_stages, stage_offs):
-        FPState.__init__(self, "divsetup")
         self.pspec = pspec
         self.n_stages = n_stages # number of combinatorial stages
         self.stage_offs = stage_offs # each CalcStage needs *absolute* idx
-        SimpleHandshake.__init__(self, self) # pipeline is its own stage
-        self.m1o = self.ospec()
+        super().__init__(pspec)
 
     def ispec(self):
         # REQUIRED.  do NOT change.
@@ -74,20 +71,14 @@ class FPDivStagesSetup(FPState, SimpleHandshake):
     def process(self, i):
         return self.o
 
-    def action(self, m):
-        m.d.sync += self.m1o.eq(self.process(None))
-        m.next = "normalise_1"
 
-
-class FPDivStagesIntermediate(FPState, SimpleHandshake):
+class FPDivStagesIntermediate(DynamicPipe):
 
     def __init__(self, pspec, n_stages, stage_offs):
-        FPState.__init__(self, "divintermediate")
         self.pspec = pspec
         self.n_stages = n_stages # number of combinatorial stages
         self.stage_offs = stage_offs # each CalcStage needs *absolute* idx
-        SimpleHandshake.__init__(self, self) # pipeline is its own stage
-        self.m1o = self.ospec()
+        super().__init__(pspec)
 
     def ispec(self):
         # TODO - this is for FPDivStage1Mod
@@ -123,20 +114,14 @@ class FPDivStagesIntermediate(FPState, SimpleHandshake):
     def process(self, i):
         return self.o
 
-    def action(self, m):
-        m.d.sync += self.m1o.eq(self.process(None))
-        m.next = "normalise_1"
-
 
-class FPDivStagesFinal(FPState, SimpleHandshake):
+class FPDivStagesFinal(DynamicPipe):
 
     def __init__(self, pspec, n_stages, stage_offs):
-        FPState.__init__(self, "divfinal")
         self.pspec = pspec
         self.n_stages = n_stages # number of combinatorial stages
         self.stage_offs = stage_offs # each CalcStage needs *absolute* idx
-        SimpleHandshake.__init__(self, self) # pipeline is its own stage
-        self.m1o = self.ospec()
+        super().__init__(pspec)
 
     def ispec(self):
         return DivPipeInterstageData(self.pspec) # DIV ispec (loop)
@@ -163,10 +148,10 @@ class FPDivStagesFinal(FPState, SimpleHandshake):
         # will add.
         for count in range(self.n_stages): # number of combinatorial stages
             idx = count + self.stage_offs
-            divstages.append(DivPipeCalculateStage(pspec, idx))
+            divstages.append(DivPipeCalculateStage(self.pspec, idx))
 
         # does the final conversion from intermediary to output data
-        divstages.append(DivPipeFinalStage(pspec))
+        divstages.append(DivPipeFinalStage(self.pspec))
 
         # does conversion from DivPipeOutputData into
         # FPAddStage1Data format (bad name, TODO, doesn't matter),
@@ -181,9 +166,3 @@ class FPDivStagesFinal(FPState, SimpleHandshake):
 
     def process(self, i):
         return self.o
-
-    def action(self, m):
-        m.d.sync += self.m1o.eq(self.process(None))
-        m.next = "normalise_1"
-
-