From: Luke Kenneth Casson Leighton Date: Wed, 31 Jul 2019 14:25:54 +0000 (+0100) Subject: move FPModBase and FPModBaseChain to nmutil X-Git-Tag: ls180-24jan2020~616 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5104d9bfc2df4104193a1e9e5930630242f11bf0;p=ieee754fpu.git move FPModBase and FPModBaseChain to nmutil --- diff --git a/src/ieee754/fclass/fclass.py b/src/ieee754/fclass/fclass.py index 3bad5c24..e3b7ff4c 100644 --- a/src/ieee754/fclass/fclass.py +++ b/src/ieee754/fclass/fclass.py @@ -3,7 +3,7 @@ from nmigen import Module, Signal, Cat -from ieee754.fpcommon.modbase import FPModBase +from nmutil.pipemodbase import FPModBase from ieee754.fpcommon.getop import FPADDBaseData from ieee754.fpcommon.pack import FPPackData from ieee754.fpcommon.fpbase import FPNumDecode, FPNumBaseRecord diff --git a/src/ieee754/fcvt/downsize.py b/src/ieee754/fcvt/downsize.py index 4a23adee..3561f197 100644 --- a/src/ieee754/fcvt/downsize.py +++ b/src/ieee754/fcvt/downsize.py @@ -4,7 +4,7 @@ from nmigen import Module, Signal, Const from nmigen.cli import main, verilog -from ieee754.fpcommon.modbase import FPModBase +from nmutil.pipemodbase import FPModBase from ieee754.fpcommon.getop import FPADDBaseData from ieee754.fpcommon.postcalc import FPAddStage1Data from ieee754.fpcommon.msbhigh import FPMSBHigh diff --git a/src/ieee754/fcvt/int2float.py b/src/ieee754/fcvt/int2float.py index 889c301c..4f559101 100644 --- a/src/ieee754/fcvt/int2float.py +++ b/src/ieee754/fcvt/int2float.py @@ -4,7 +4,7 @@ from nmigen import Module, Signal, Cat from nmigen.cli import main, verilog -from ieee754.fpcommon.modbase import FPModBase +from nmutil.pipemodbase import FPModBase from ieee754.fpcommon.getop import FPADDBaseData from ieee754.fpcommon.postcalc import FPAddStage1Data from ieee754.fpcommon.msbhigh import FPMSBHigh diff --git a/src/ieee754/fcvt/upsize.py b/src/ieee754/fcvt/upsize.py index e08aaf32..483ddbbc 100644 --- a/src/ieee754/fcvt/upsize.py +++ b/src/ieee754/fcvt/upsize.py @@ -8,7 +8,7 @@ import functools from nmigen import Module, Signal, Cat from nmigen.cli import main, verilog -from ieee754.fpcommon.modbase import FPModBase +from nmutil.pipemodbase import FPModBase from ieee754.fpcommon.getop import FPADDBaseData from ieee754.fpcommon.postcalc import FPAddStage1Data from ieee754.fpcommon.fpbase import FPNumDecode, FPNumBaseRecord diff --git a/src/ieee754/fpadd/add0.py b/src/ieee754/fpadd/add0.py index 9e69820f..0a77855b 100644 --- a/src/ieee754/fpadd/add0.py +++ b/src/ieee754/fpadd/add0.py @@ -7,7 +7,7 @@ Copyright (C) 2019 Luke Kenneth Casson Leighton from nmigen import Module, Signal, Cat from nmigen.cli import main, verilog -from ieee754.fpcommon.modbase import FPModBase +from nmutil.pipemodbase import FPModBase from ieee754.fpcommon.fpbase import FPNumBase, FPNumBaseRecord from ieee754.fpcommon.denorm import FPSCData diff --git a/src/ieee754/fpadd/add1.py b/src/ieee754/fpadd/add1.py index 8b2096e8..9004be8f 100644 --- a/src/ieee754/fpadd/add1.py +++ b/src/ieee754/fpadd/add1.py @@ -8,7 +8,7 @@ from nmigen import Module, Signal from nmigen.cli import main, verilog from math import log -from ieee754.fpcommon.modbase import FPModBase +from nmutil.pipemodbase import FPModBase from ieee754.fpcommon.postcalc import FPAddStage1Data from ieee754.fpadd.add0 import FPAddStage0Data diff --git a/src/ieee754/fpadd/addstages.py b/src/ieee754/fpadd/addstages.py index 170b37c6..b62d6d20 100644 --- a/src/ieee754/fpadd/addstages.py +++ b/src/ieee754/fpadd/addstages.py @@ -4,7 +4,7 @@ Copyright (C) 2019 Luke Kenneth Casson Leighton """ -from ieee754.fpcommon.modbase import FPModBaseChain +from nmutil.pipemodbase import FPModBaseChain from ieee754.fpadd.align import FPAddAlignSingleMod from ieee754.fpadd.add0 import FPAddStage0Mod diff --git a/src/ieee754/fpadd/align.py b/src/ieee754/fpadd/align.py index bd1b4c06..0cfc38d0 100644 --- a/src/ieee754/fpadd/align.py +++ b/src/ieee754/fpadd/align.py @@ -5,7 +5,7 @@ from nmigen import Module, Signal from nmigen.cli import main, verilog -from ieee754.fpcommon.modbase import FPModBase +from nmutil.pipemodbase import FPModBase from ieee754.fpcommon.fpbase import FPNumBaseRecord from ieee754.fpcommon.fpbase import MultiShiftRMerge from ieee754.fpcommon.denorm import FPSCData diff --git a/src/ieee754/fpadd/specialcases.py b/src/ieee754/fpadd/specialcases.py index 9846eabc..c11832dc 100644 --- a/src/ieee754/fpadd/specialcases.py +++ b/src/ieee754/fpadd/specialcases.py @@ -6,7 +6,7 @@ from nmigen import Module, Signal, Cat, Const from nmigen.cli import main, verilog from math import log -from ieee754.fpcommon.modbase import FPModBase, FPModBaseChain +from nmutil.pipemodbase import FPModBase, FPModBaseChain from ieee754.fpcommon.fpbase import FPNumDecode from ieee754.fpcommon.fpbase import FPNumBaseRecord diff --git a/src/ieee754/fpcommon/corrections.py b/src/ieee754/fpcommon/corrections.py index df7d97f5..2ac65d79 100644 --- a/src/ieee754/fpcommon/corrections.py +++ b/src/ieee754/fpcommon/corrections.py @@ -5,7 +5,7 @@ from nmigen import Module from nmigen.cli import main, verilog -from ieee754.fpcommon.modbase import FPModBase +from nmutil.pipemodbase import FPModBase from ieee754.fpcommon.fpbase import FPNumBase from ieee754.fpcommon.roundz import FPRoundData diff --git a/src/ieee754/fpcommon/denorm.py b/src/ieee754/fpcommon/denorm.py index 43e343ae..8210c019 100644 --- a/src/ieee754/fpcommon/denorm.py +++ b/src/ieee754/fpcommon/denorm.py @@ -6,7 +6,7 @@ from nmigen import Module, Signal from nmigen.cli import main, verilog from math import log -from ieee754.fpcommon.modbase import FPModBase +from nmutil.pipemodbase import FPModBase from ieee754.fpcommon.fpbase import FPNumBaseRecord from ieee754.fpcommon.fpbase import FPNumBase from ieee754.fpcommon.getop import FPPipeContext diff --git a/src/ieee754/fpcommon/modbase.py b/src/ieee754/fpcommon/modbase.py deleted file mode 100644 index 1ebe3a1a..00000000 --- a/src/ieee754/fpcommon/modbase.py +++ /dev/null @@ -1,54 +0,0 @@ -from nmigen import Elaboratable -from ieee754.pipeline import DynamicPipe -from nmutil.singlepipe import StageChain - - -class FPModBase(Elaboratable): - """FPModBase: common code between nearly every pipeline module - """ - def __init__(self, pspec, modname): - self.modname = modname # use this to give a name to this module - self.pspec = pspec - self.i = self.ispec() - self.o = self.ospec() - - def process(self, i): - return self.o - - def setup(self, m, i): - """ links module to inputs and outputs - """ - setattr(m.submodules, self.modname, self) - m.d.comb += self.i.eq(i) - - -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 - self.chain = self.get_chain() - super().__init__(pspec) - - def ispec(self): - """ returns the input spec of the first module in the chain - """ - return self.chain[0].ispec() - - def ospec(self): - """ returns the output spec of the last module in the chain - """ - return self.chain[-1].ospec() - - def process(self, i): - return self.o # ... returned here (see setup comment below) - - def setup(self, m, i): - """ links module to inputs and outputs - """ - StageChain(self.chain).setup(m, i) # input linked here, through chain - self.o = self.chain[-1].o # output is the last thing in the chain... diff --git a/src/ieee754/fpcommon/normtopack.py b/src/ieee754/fpcommon/normtopack.py index 9aea1803..33459a36 100644 --- a/src/ieee754/fpcommon/normtopack.py +++ b/src/ieee754/fpcommon/normtopack.py @@ -4,7 +4,7 @@ Copyright (C) 2019 Luke Kenneth Casson Leighton """ -from ieee754.fpcommon.modbase import FPModBaseChain +from nmutil.pipemodbase import FPModBaseChain from ieee754.fpcommon.postnormalise import FPNorm1ModSingle from ieee754.fpcommon.roundz import FPRoundMod from ieee754.fpcommon.corrections import FPCorrectionsMod diff --git a/src/ieee754/fpcommon/pack.py b/src/ieee754/fpcommon/pack.py index 610bc706..4553f531 100644 --- a/src/ieee754/fpcommon/pack.py +++ b/src/ieee754/fpcommon/pack.py @@ -5,7 +5,7 @@ from nmigen import Module, Signal from nmigen.cli import main, verilog -from ieee754.fpcommon.modbase import FPModBase +from nmutil.pipemodbase import FPModBase from ieee754.fpcommon.fpbase import FPNumBaseRecord, FPNumBase from ieee754.fpcommon.roundz import FPRoundData from ieee754.fpcommon.getop import FPPipeContext diff --git a/src/ieee754/fpcommon/postnormalise.py b/src/ieee754/fpcommon/postnormalise.py index 653fdac2..9f1720a2 100644 --- a/src/ieee754/fpcommon/postnormalise.py +++ b/src/ieee754/fpcommon/postnormalise.py @@ -6,7 +6,7 @@ from nmigen import Module, Signal, Cat, Mux from nmigen.cli import main, verilog from math import log -from ieee754.fpcommon.modbase import FPModBase +from nmutil.pipemodbase import FPModBase from ieee754.fpcommon.fpbase import (Overflow, OverflowMod, FPNumBase, FPNumBaseRecord) from ieee754.fpcommon.fpbase import FPState diff --git a/src/ieee754/fpcommon/roundz.py b/src/ieee754/fpcommon/roundz.py index a4077cfd..78a00d37 100644 --- a/src/ieee754/fpcommon/roundz.py +++ b/src/ieee754/fpcommon/roundz.py @@ -5,7 +5,7 @@ from nmigen import Module, Signal from nmigen.cli import main, verilog -from ieee754.fpcommon.modbase import FPModBase +from nmutil.pipemodbase import FPModBase from ieee754.fpcommon.fpbase import FPNumBase, FPNumBaseRecord from ieee754.fpcommon.getop import FPPipeContext from ieee754.fpcommon.postnormalise import FPNorm1Data diff --git a/src/ieee754/fpdiv/div0.py b/src/ieee754/fpdiv/div0.py index af0097c3..9d92ea39 100644 --- a/src/ieee754/fpdiv/div0.py +++ b/src/ieee754/fpdiv/div0.py @@ -13,7 +13,7 @@ Relevant bugreports: from nmigen import Module, Signal, Cat, Elaboratable, Const, Mux from nmigen.cli import main, verilog -from ieee754.fpcommon.modbase import FPModBase +from nmutil.pipemodbase import FPModBase from ieee754.fpcommon.fpbase import FPNumBaseRecord from ieee754.fpcommon.denorm import FPSCData from ieee754.fpcommon.getop import FPPipeContext diff --git a/src/ieee754/fpdiv/div2.py b/src/ieee754/fpdiv/div2.py index c8f26aa8..c1ffdee6 100644 --- a/src/ieee754/fpdiv/div2.py +++ b/src/ieee754/fpdiv/div2.py @@ -12,7 +12,7 @@ Relevant bugreports: from nmigen import Module, Signal, Cat from nmigen.cli import main, verilog -from ieee754.fpcommon.modbase import FPModBase +from nmutil.pipemodbase import FPModBase from ieee754.fpcommon.postcalc import FPAddStage1Data from ieee754.div_rem_sqrt_rsqrt.div_pipe import DivPipeOutputData diff --git a/src/ieee754/fpdiv/divstages.py b/src/ieee754/fpdiv/divstages.py index c26a74a0..a147b068 100644 --- a/src/ieee754/fpdiv/divstages.py +++ b/src/ieee754/fpdiv/divstages.py @@ -4,7 +4,7 @@ Relevant bugreport: http://bugs.libre-riscv.org/show_bug.cgi?id=99 """ -from ieee754.fpcommon.modbase import FPModBaseChain +from nmutil.pipemodbase import FPModBaseChain from ieee754.div_rem_sqrt_rsqrt.div_pipe import (DivPipeInterstageData, DivPipeSetupStage, DivPipeCalculateStage, diff --git a/src/ieee754/fpdiv/specialcases.py b/src/ieee754/fpdiv/specialcases.py index 1cedae4c..5b637020 100644 --- a/src/ieee754/fpdiv/specialcases.py +++ b/src/ieee754/fpdiv/specialcases.py @@ -13,7 +13,7 @@ from nmigen import Module, Signal from nmigen.cli import main, verilog from math import log -from ieee754.fpcommon.modbase import FPModBase, FPModBaseChain +from nmutil.pipemodbase import FPModBase, FPModBaseChain from ieee754.fpcommon.fpbase import FPNumDecode, FPNumBaseRecord from ieee754.fpcommon.getop import FPADDBaseData from ieee754.fpcommon.denorm import (FPSCData, FPAddDeNormMod) diff --git a/src/ieee754/fpmul/align.py b/src/ieee754/fpmul/align.py index 9284926b..507e21a4 100644 --- a/src/ieee754/fpmul/align.py +++ b/src/ieee754/fpmul/align.py @@ -4,7 +4,7 @@ from nmigen import Module, Signal, Cat, Mux from nmigen.cli import main, verilog from math import log -from ieee754.fpcommon.modbase import FPModBase +from nmutil.pipemodbase import FPModBase from ieee754.fpcommon.fpbase import FPNumBase from ieee754.fpcommon.getop import FPPipeContext from ieee754.fpcommon.msbhigh import FPMSBHigh diff --git a/src/ieee754/fpmul/mul0.py b/src/ieee754/fpmul/mul0.py index 0ed25035..398a953d 100644 --- a/src/ieee754/fpmul/mul0.py +++ b/src/ieee754/fpmul/mul0.py @@ -7,7 +7,7 @@ Copyright (C) 2019 Luke Kenneth Casson Leighton from nmigen import Module, Signal, Cat, Elaboratable from nmigen.cli import main, verilog -from ieee754.fpcommon.modbase import FPModBase +from nmutil.pipemodbase import FPModBase from ieee754.fpcommon.fpbase import FPNumBaseRecord from ieee754.fpcommon.denorm import FPSCData from ieee754.fpcommon.getop import FPPipeContext diff --git a/src/ieee754/fpmul/mul1.py b/src/ieee754/fpmul/mul1.py index 98374fa5..9f896315 100644 --- a/src/ieee754/fpmul/mul1.py +++ b/src/ieee754/fpmul/mul1.py @@ -7,7 +7,7 @@ Copyright (C) 2019 Luke Kenneth Casson Leighton from nmigen import Module, Signal, Elaboratable from nmigen.cli import main, verilog -from ieee754.fpcommon.modbase import FPModBase +from nmutil.pipemodbase import FPModBase from ieee754.fpcommon.postcalc import FPAddStage1Data from ieee754.fpmul.mul0 import FPMulStage0Data diff --git a/src/ieee754/fpmul/mulstages.py b/src/ieee754/fpmul/mulstages.py index fb809cbc..78844cf8 100644 --- a/src/ieee754/fpmul/mulstages.py +++ b/src/ieee754/fpmul/mulstages.py @@ -5,7 +5,7 @@ from nmigen.cli import main, verilog from nmutil.singlepipe import StageChain -from ieee754.fpcommon.modbase import FPModBaseChain +from nmutil.pipemodbase import FPModBaseChain from ieee754.fpcommon.denorm import FPSCData from ieee754.fpcommon.postcalc import FPAddStage1Data from ieee754.fpmul.mul0 import FPMulStage0Mod diff --git a/src/ieee754/fpmul/specialcases.py b/src/ieee754/fpmul/specialcases.py index 52b01fbb..97174430 100644 --- a/src/ieee754/fpmul/specialcases.py +++ b/src/ieee754/fpmul/specialcases.py @@ -6,7 +6,7 @@ from math import log from ieee754.fpcommon.fpbase import FPNumDecode, FPNumBaseRecord -from ieee754.fpcommon.modbase import FPModBase, FPModBaseChain +from nmutil.pipemodbase import FPModBase, FPModBaseChain from ieee754.fpcommon.getop import FPADDBaseData from ieee754.fpcommon.denorm import (FPSCData, FPAddDeNormMod) from ieee754.fpmul.align import FPAlignModSingle diff --git a/src/nmutil/pipemodbase.py b/src/nmutil/pipemodbase.py new file mode 100644 index 00000000..1ebe3a1a --- /dev/null +++ b/src/nmutil/pipemodbase.py @@ -0,0 +1,54 @@ +from nmigen import Elaboratable +from ieee754.pipeline import DynamicPipe +from nmutil.singlepipe import StageChain + + +class FPModBase(Elaboratable): + """FPModBase: common code between nearly every pipeline module + """ + def __init__(self, pspec, modname): + self.modname = modname # use this to give a name to this module + self.pspec = pspec + self.i = self.ispec() + self.o = self.ospec() + + def process(self, i): + return self.o + + def setup(self, m, i): + """ links module to inputs and outputs + """ + setattr(m.submodules, self.modname, self) + m.d.comb += self.i.eq(i) + + +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 + self.chain = self.get_chain() + super().__init__(pspec) + + def ispec(self): + """ returns the input spec of the first module in the chain + """ + return self.chain[0].ispec() + + def ospec(self): + """ returns the output spec of the last module in the chain + """ + return self.chain[-1].ospec() + + def process(self, i): + return self.o # ... returned here (see setup comment below) + + def setup(self, m, i): + """ links module to inputs and outputs + """ + StageChain(self.chain).setup(m, i) # input linked here, through chain + self.o = self.chain[-1].o # output is the last thing in the chain...