config/setup/imports
[ieee754fpu.git] / src / ieee754 / fpdiv / divstages.py
index c5f7683477f231c13eec20a20c35b08aaba7d461..112c9d8819bca3184d32d062fb5ae47f988184e4 100644 (file)
@@ -12,23 +12,24 @@ from nmutil.singlepipe import (StageChain, SimpleHandshake)
 from ieee754.fpcommon.fpbase import FPState
 from ieee754.fpcommon.denorm import FPSCData
 from ieee754.fpcommon.postcalc import FPAddStage1Data
+from ieee754.div_rem_sqrt_rsqrt.div_pipe import (DivPipeInterstageData,
+                                                 DivPipeSetupStage,
+                                                 DivPipeCalculateStage,
+                                                 DivPipeFinalStage,
+                                                )
 
 # TODO: write these
 from .div0 import FPDivStage0Mod
-from .div1 import FPDivStage1Mod # can be dropped entirely
-                                 # (replaced with DivPipeCalculateStage)
-                                 # note, yes, DivPipeCalculateStage *NOT*
-                                 # DivPipeCoreCalculateStage
 from .div2 import FPDivStage2Mod
-from .div0 import FPDivStage0Data
 
 
 class FPDivStagesSetup(FPState, SimpleHandshake):
 
-    def __init__(self, pspec, n_stages):
+    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()
 
@@ -37,16 +38,13 @@ class FPDivStagesSetup(FPState, SimpleHandshake):
         return FPSCData(self.pspec, False) # from denorm
 
     def ospec(self):
-        # XXX TODO: replace with "intermediary" (DivPipeInterstageData)
-        return FPDivStage0Data(self.pspec) # DIV ospec (loop)
+        return DivPipeInterstageData(self.pspec) # DIV ospec (loop)
 
     def setup(self, m, i):
         """ links module to inputs and outputs.
 
             note: this is a pure *combinatorial* module (StageChain).
             therefore each sub-module must also be combinatorial
-            (and not do too much: in particular, n_stages must be
-            reduced slightly when either self.end=True or self.begin=True)
         """
 
         divstages = []
@@ -56,22 +54,15 @@ class FPDivStagesSetup(FPState, SimpleHandshake):
 
         # does 1 "convert" (actual processing) from DivPipeInputData
         # into "intermediate" output (DivPipeInterstageData)
-        # vvvvvvv
-        # FIXME divstages.append(DivPipeSetupStage(something))
-        # ^^^^^^^
+        divstages.append(DivPipeSetupStage(self.pspec))
 
         # here is where the intermediary stages are added.
-        # n_stages is adjusted (in pipeline.py), reduced to take
-        # into account the extra processing that self.begin and self.end
-        # will add.
+        # n_stages is adjusted (by pipeline.py), reduced to take
+        # into account extra processing that FPDivStage0Mod and DivPipeSetup
+        # might add.
         for count in range(self.n_stages): # number of combinatorial stages
-            # XXX: this can actually be entirely dropped...
-            divstages.append(FPDivStage1Mod(self.pspec))
-
-            # ... and replaced with this.
-            # vvvvvvv
-            #divstages.append(DivPipeCalculateStage(core_config, count))
-            # ^^^^^^^
+            idx = count + self.stage_offs
+            divstages.append(DivPipeCalculateStage(self.pspec, idx))
 
         chain = StageChain(divstages)
         chain.setup(m, i)
@@ -87,31 +78,29 @@ class FPDivStagesSetup(FPState, SimpleHandshake):
         m.next = "normalise_1"
 
 
-class FPDivStagesIntermediary(FPState, SimpleHandshake):
+class FPDivStagesIntermediate(FPState, SimpleHandshake):
 
-    def __init__(self, pspec, n_stages):
+    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()
 
     def ispec(self):
         # TODO - this is for FPDivStage1Mod
-        # XXX TODO: replace with "intermediary" (DivPipeInterstageData)
-        return FPDivStage0Data(self.pspec) # DIV ispec (loop)
+        return DivPipeInterstageData(self.pspec) # DIV ispec (loop)
 
     def ospec(self):
         # TODO - this is for FPDivStage1Mod
-        # XXX TODO: replace with "intermediary" (DivPipeInterstageData)
-        return FPDivStage0Data(self.pspec) # DIV ospec (loop)
+        return DivPipeInterstageData(self.pspec) # DIV ospec (loop)
 
     def setup(self, m, i):
         """ links module to inputs and outputs.
 
             note: this is a pure *combinatorial* module (StageChain).
             therefore each sub-module must also be combinatorial
-            (and not do too much)
         """
 
         divstages = []
@@ -121,13 +110,8 @@ class FPDivStagesIntermediary(FPState, SimpleHandshake):
         # into account the extra processing that self.begin and self.end
         # will add.
         for count in range(self.n_stages): # number of combinatorial stages
-            # XXX: this can actually be entirely dropped...
-            divstages.append(FPDivStage1Mod(self.pspec))
-
-            # ... and replaced with this.
-            # vvvvvvv
-            #divstages.append(DivPipeCalculateStage(core_config, count))
-            # ^^^^^^^
+            idx = count + self.stage_offs
+            divstages.append(DivPipeCalculateStage(self.pspec, idx))
 
         chain = StageChain(divstages)
         chain.setup(m, i)
@@ -145,16 +129,16 @@ class FPDivStagesIntermediary(FPState, SimpleHandshake):
 
 class FPDivStagesFinal(FPState, SimpleHandshake):
 
-    def __init__(self, pspec, n_stages):
+    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()
 
     def ispec(self):
-        # XXX TODO: replace with "intermediary" (DivPipeInterstageData?)
-        return FPDivStage0Data(self.pspec) # DIV ispec (loop)
+        return DivPipeInterstageData(self.pspec) # DIV ispec (loop)
 
     def ospec(self):
         # REQUIRED.  do NOT change.
@@ -165,7 +149,6 @@ class FPDivStagesFinal(FPState, SimpleHandshake):
 
             note: this is a pure *combinatorial* module (StageChain).
             therefore each sub-module must also be combinatorial
-            (and not do too much)
         """
 
         # takes the DIV pipeline/chain data and munges it
@@ -178,18 +161,11 @@ class FPDivStagesFinal(FPState, SimpleHandshake):
         # into account the extra processing that self.begin and self.end
         # will add.
         for count in range(self.n_stages): # number of combinatorial stages
-            # XXX: this can actually be entirely dropped...
-            divstages.append(FPDivStage1Mod(self.pspec))
-
-            # ... and replaced with this.
-            # vvvvvvv
-            #divstages.append(DivPipeCalculateStage(core_config, count))
-            # ^^^^^^^
+            idx = count + self.stage_offs
+            divstages.append(DivPipeCalculateStage(self.pspec, idx))
 
         # does the final conversion from intermediary to output data
-        # vvvvvvv
-        # FIXME divstages.append(DivPipeFinalStage(something))
-        # ^^^^^^^
+        divstages.append(DivPipeFinalStage(self.pspec))
 
         # does conversion from DivPipeOutputData into
         # FPAddStage1Data format (bad name, TODO, doesn't matter),