"""
-from nmigen import Module
-from nmigen.cli import main, verilog
-
-from nmutil.singlepipe import StageChain
-
-from ieee754.pipeline import DynamicPipe
-from ieee754.fpcommon.denorm import FPSCData
-from ieee754.fpcommon.postcalc import FPAddStage1Data
+from ieee754.fpcommon.modbase import FPModBaseChain
from ieee754.div_rem_sqrt_rsqrt.div_pipe import (DivPipeInterstageData,
DivPipeSetupStage,
DivPipeCalculateStage,
DivPipeFinalStage,
)
+from ieee754.fpdiv.div0 import FPDivStage0Mod
+from ieee754.fpdiv.div2 import FPDivStage2Mod
-# TODO: write these
-from .div0 import FPDivStage0Mod
-from .div2 import FPDivStage2Mod
-
-class FPDivStagesSetup(DynamicPipe):
+class FPDivStagesSetup(FPModBaseChain):
def __init__(self, pspec, n_stages, stage_offs):
- self.pspec = pspec
self.n_stages = n_stages # number of combinatorial stages
self.stage_offs = stage_offs # each CalcStage needs *absolute* idx
super().__init__(pspec)
- def ispec(self):
- # REQUIRED. do NOT change.
- return FPSCData(self.pspec, False) # from denorm
-
- def ospec(self):
- return DivPipeInterstageData(self.pspec) # DIV ospec (loop)
-
- def setup(self, m, i):
- """ links module to inputs and outputs.
+ def get_chain(self):
+ """ gets module chain
note: this is a pure *combinatorial* module (StageChain).
therefore each sub-module must also be combinatorial
idx = count + self.stage_offs
divstages.append(DivPipeCalculateStage(self.pspec, idx))
- chain = StageChain(divstages)
- chain.setup(m, i)
-
- # output is from the last pipe stage
- self.o = divstages[-1].o
+ return divstages
- def process(self, i):
- return self.o
-
-class FPDivStagesIntermediate(DynamicPipe):
+class FPDivStagesIntermediate(FPModBaseChain):
def __init__(self, pspec, n_stages, stage_offs):
- self.pspec = pspec
self.n_stages = n_stages # number of combinatorial stages
self.stage_offs = stage_offs # each CalcStage needs *absolute* idx
super().__init__(pspec)
- def ispec(self):
- # TODO - this is for FPDivStage1Mod
- return DivPipeInterstageData(self.pspec) # DIV ispec (loop)
-
- def ospec(self):
- # TODO - this is for FPDivStage1Mod
- return DivPipeInterstageData(self.pspec) # DIV ospec (loop)
-
- def setup(self, m, i):
- """ links module to inputs and outputs.
+ def get_chain(self):
+ """ gets module chain
note: this is a pure *combinatorial* module (StageChain).
therefore each sub-module must also be combinatorial
idx = count + self.stage_offs
divstages.append(DivPipeCalculateStage(self.pspec, idx))
- chain = StageChain(divstages)
- chain.setup(m, i)
-
- # output is from the last pipe stage
- self.o = divstages[-1].o
+ return divstages
- def process(self, i):
- return self.o
-
-class FPDivStagesFinal(DynamicPipe):
+class FPDivStagesFinal(FPModBaseChain):
def __init__(self, pspec, n_stages, stage_offs):
- self.pspec = pspec
self.n_stages = n_stages # number of combinatorial stages
self.stage_offs = stage_offs # each CalcStage needs *absolute* idx
super().__init__(pspec)
- def ispec(self):
- return DivPipeInterstageData(self.pspec) # DIV ispec (loop)
-
- def ospec(self):
- # REQUIRED. do NOT change.
- return FPAddStage1Data(self.pspec) # to post-norm
-
- def setup(self, m, i):
- """ links module to inputs and outputs.
+ def get_chain(self):
+ """ gets module chain
note: this is a pure *combinatorial* module (StageChain).
therefore each sub-module must also be combinatorial
# so that post-normalisation and corrections can take over
divstages.append(FPDivStage2Mod(self.pspec))
- chain = StageChain(divstages)
- chain.setup(m, i)
-
- # output is from the last pipe stage
- self.o = divstages[-1].o
-
- def process(self, i):
- return self.o
+ return divstages