From: Luke Kenneth Casson Leighton Date: Wed, 31 Jul 2019 12:13:11 +0000 (+0100) Subject: tidyup, use FPModBaseChain and FPModBase X-Git-Tag: ls180-24jan2020~634 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=aeb61d3e0b90b4aed14fe32161ec84598fed4047;p=ieee754fpu.git tidyup, use FPModBaseChain and FPModBase --- diff --git a/src/ieee754/fpcommon/modbase.py b/src/ieee754/fpcommon/modbase.py index 1b338747..b8bd1a91 100644 --- a/src/ieee754/fpcommon/modbase.py +++ b/src/ieee754/fpcommon/modbase.py @@ -24,6 +24,10 @@ class FPModBase(Elaboratable): class FPModBaseChain(DynamicPipe): """FPModBaseChain: common code between stage-chained pipes + + Links a set of combinatorial modules (get_chain) together + and uses pspec.pipekls to dynamically select the pipeline type + Also conforms to the Pipeline Stage API """ def __init__(self, pspec): self.pspec = pspec diff --git a/src/ieee754/fpdiv/divstages.py b/src/ieee754/fpdiv/divstages.py index 81f9f311..c26a74a0 100644 --- a/src/ieee754/fpdiv/divstages.py +++ b/src/ieee754/fpdiv/divstages.py @@ -4,42 +4,25 @@ 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 - -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 @@ -62,34 +45,18 @@ class FPDivStagesSetup(DynamicPipe): 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 @@ -105,33 +72,18 @@ class FPDivStagesIntermediate(DynamicPipe): 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 @@ -158,11 +110,4 @@ class FPDivStagesFinal(DynamicPipe): # 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