From: Luke Kenneth Casson Leighton Date: Wed, 31 Jul 2019 09:47:53 +0000 (+0100) Subject: convert to DynamicPipe (default class in PipelineSpec: SimpleHandshake) X-Git-Tag: ls180-24jan2020~653 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=13951944cd9713421060449211684e03c8b162b2;p=ieee754fpu.git convert to DynamicPipe (default class in PipelineSpec: SimpleHandshake) --- diff --git a/src/ieee754/fpadd/specialcases.py b/src/ieee754/fpadd/specialcases.py index 3221e9cc..33b1811a 100644 --- a/src/ieee754/fpadd/specialcases.py +++ b/src/ieee754/fpadd/specialcases.py @@ -10,7 +10,7 @@ from ieee754.fpcommon.fpbase import FPNumDecode from nmutil.singlepipe import StageChain from ieee754.pipeline import DynamicPipe -from ieee754.fpcommon.fpbase import FPState, FPID, FPNumBaseRecord +from ieee754.fpcommon.fpbase import FPNumBaseRecord from ieee754.fpcommon.getop import FPADDBaseData from ieee754.fpcommon.denorm import (FPSCData, FPAddDeNormMod) @@ -146,33 +146,6 @@ class FPAddSpecialCasesMod(Elaboratable): return m -class FPAddSpecialCases(FPState): - """ special cases: NaNs, infs, zeros, denormalised - NOTE: some of these are unique to add. see "Special Operations" - https://steve.hollasch.net/cgindex/coding/ieeefloat.html - """ - - def __init__(self, width, id_wid): - FPState.__init__(self, "special_cases") - self.mod = FPAddSpecialCasesMod(width) - self.out_z = self.mod.ospec() - self.out_do_z = Signal(reset_less=True) - - def setup(self, m, i): - """ links module to inputs and outputs - """ - self.mod.setup(m, i, self.out_do_z) - m.d.sync += self.out_z.v.eq(self.mod.out_z.v) # only take the output - m.d.sync += self.out_z.ctx.eq(self.mod.o.ctx) # (and mid) - - def action(self, m): - self.idsync(m) - with m.If(self.out_do_z): - m.next = "put_z" - with m.Else(): - m.next = "denormalise" - - class FPAddSpecialCasesDeNorm(DynamicPipe): """ special cases: NaNs, infs, zeros, denormalised NOTE: some of these are unique to add. see "Special Operations" diff --git a/src/ieee754/fpcommon/getop.py b/src/ieee754/fpcommon/getop.py index fb7f3b26..1bf971e7 100644 --- a/src/ieee754/fpcommon/getop.py +++ b/src/ieee754/fpcommon/getop.py @@ -9,7 +9,7 @@ from math import log from ieee754.fpcommon.fpbase import FPNumIn, FPNumOut, FPOpIn, Overflow, FPBase, FPNumBase from ieee754.fpcommon.fpbase import MultiShiftRMerge, Trigger -from nmutil.singlepipe import (ControlBase, StageChain, SimpleHandshake, +from nmutil.singlepipe import (ControlBase, StageChain, PassThroughStage, PrevControl) from nmutil.multipipe import CombMuxOutPipe from nmutil.multipipe import PriorityCombMuxInPipe diff --git a/src/ieee754/fpcommon/normtopack.py b/src/ieee754/fpcommon/normtopack.py index b90d0232..453c5c22 100644 --- a/src/ieee754/fpcommon/normtopack.py +++ b/src/ieee754/fpcommon/normtopack.py @@ -4,24 +4,23 @@ #from nmigen.cli import main, verilog -from nmutil.singlepipe import StageChain, SimpleHandshake +from nmutil.singlepipe import StageChain -from ieee754.fpcommon.fpbase import FPState, FPID -from .postcalc import FPAddStage1Data -from .postnormalise import FPNorm1ModSingle -from .roundz import FPRoundMod -from .corrections import FPCorrectionsMod -from .pack import FPPackData, FPPackMod +from ieee754.pipeline import DynamicPipe +from ieee754.fpcommon.postcalc import FPAddStage1Data +from ieee754.fpcommon.postnormalise import FPNorm1ModSingle +from ieee754.fpcommon.roundz import FPRoundMod +from ieee754.fpcommon.corrections import FPCorrectionsMod +from ieee754.fpcommon.pack import FPPackData, FPPackMod -class FPNormToPack(FPState, SimpleHandshake): +class FPNormToPack(DynamicPipe): def __init__(self, pspec, e_extra=False): - FPState.__init__(self, "normalise_1") #print ("normtopack", pspec) self.pspec = pspec self.e_extra = e_extra - SimpleHandshake.__init__(self, self) # pipeline is its own stage + super().__init__(pspec) def ispec(self): return FPAddStage1Data(self.pspec, e_extra=self.e_extra) @@ -47,7 +46,3 @@ class FPNormToPack(FPState, SimpleHandshake): def process(self, i): return self.o - - def action(self, m): - m.d.sync += self.out_z.eq(self.process(None)) - m.next = "pack_put_z" diff --git a/src/ieee754/fpdiv/divstages.py b/src/ieee754/fpdiv/divstages.py index 112c9d88..81f9f311 100644 --- a/src/ieee754/fpdiv/divstages.py +++ b/src/ieee754/fpdiv/divstages.py @@ -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, @@ -23,15 +23,13 @@ from .div0 import FPDivStage0Mod from .div2 import FPDivStage2Mod -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. @@ -73,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 @@ -122,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) @@ -180,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" - - diff --git a/src/ieee754/fpdiv/specialcases.py b/src/ieee754/fpdiv/specialcases.py index f8318866..feed87f7 100644 --- a/src/ieee754/fpdiv/specialcases.py +++ b/src/ieee754/fpdiv/specialcases.py @@ -14,9 +14,9 @@ from nmigen.cli import main, verilog from math import log from ieee754.fpcommon.fpbase import FPNumDecode, FPNumBaseRecord -from nmutil.singlepipe import SimpleHandshake, StageChain +from nmutil.singlepipe import StageChain -from ieee754.fpcommon.fpbase import FPState, FPID +from ieee754.pipeline import DynamicPipe from ieee754.fpcommon.getop import FPADDBaseData from ieee754.fpcommon.denorm import (FPSCData, FPAddDeNormMod) from ieee754.fpmul.align import FPAlignModSingle @@ -174,41 +174,13 @@ class FPDIVSpecialCasesMod(Elaboratable): return m -class FPDIVSpecialCases(FPState): +class FPDIVSpecialCasesDeNorm(DynamicPipe): """ special cases: NaNs, infs, zeros, denormalised - NOTE: some of these are unique to div. see "Special Operations" - https://steve.hollasch.net/cgindex/coding/ieeefloat.html """ def __init__(self, pspec): - FPState.__init__(self, "special_cases") - self.mod = FPDIVSpecialCasesMod(pspec) - self.out_z = self.mod.ospec() - self.out_do_z = Signal(reset_less=True) - - def setup(self, m, i): - """ links module to inputs and outputs - """ - self.mod.setup(m, i, self.out_do_z) - m.d.sync += self.out_z.v.eq(self.mod.out_z.v) # only take the output - m.d.sync += self.out_z.mid.eq(self.mod.o.mid) # (and mid) - - def action(self, m): - self.idsync(m) - with m.If(self.out_do_z): - m.next = "put_z" - with m.Else(): - m.next = "denormalise" - - -class FPDIVSpecialCasesDeNorm(FPState, SimpleHandshake): - """ special cases: NaNs, infs, zeros, denormalised - """ - - def __init__(self, pspec): - FPState.__init__(self, "special_cases") self.pspec = pspec - SimpleHandshake.__init__(self, self) # pipe is its own stage + super().__init__(pspec) self.out = self.ospec() def ispec(self): @@ -234,11 +206,3 @@ class FPDIVSpecialCasesDeNorm(FPState, SimpleHandshake): def process(self, i): return self.o - - def action(self, m): - # for break-out (early-out) - #with m.If(self.out_do_z): - # m.next = "put_z" - #with m.Else(): - m.d.sync += self.out.eq(self.process(None)) - m.next = "align" diff --git a/src/ieee754/fpmul/align.py b/src/ieee754/fpmul/align.py index 2f578e9e..a32024e0 100644 --- a/src/ieee754/fpmul/align.py +++ b/src/ieee754/fpmul/align.py @@ -4,7 +4,7 @@ from nmigen import Module, Signal, Cat, Mux, Elaboratable from nmigen.cli import main, verilog from math import log -from nmutil.singlepipe import (StageChain, SimpleHandshake) +from nmutil.singlepipe import StageChain from ieee754.fpcommon.fpbase import (Overflow, OverflowMod, FPNumBase, FPNumBaseRecord) diff --git a/src/ieee754/fpmul/mulstages.py b/src/ieee754/fpmul/mulstages.py index 415ed8ef..2e96ed3b 100644 --- a/src/ieee754/fpmul/mulstages.py +++ b/src/ieee754/fpmul/mulstages.py @@ -3,21 +3,20 @@ 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 .mul0 import FPMulStage0Mod -from .mul1 import FPMulStage1Mod +from ieee754.fpmul.mul0 import FPMulStage0Mod +from ieee754.fpmul.mul1 import FPMulStage1Mod -class FPMulStages(FPState, SimpleHandshake): +class FPMulStages(DynamicPipe): def __init__(self, pspec): - FPState.__init__(self, "mulstages") self.pspec = pspec - SimpleHandshake.__init__(self, self) # pipeline is its own stage + super().__init__(pspec) self.m1o = self.ospec() def ispec(self): @@ -42,8 +41,3 @@ class FPMulStages(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" - - diff --git a/src/ieee754/fpmul/specialcases.py b/src/ieee754/fpmul/specialcases.py index 8e0fada2..eb3fe50a 100644 --- a/src/ieee754/fpmul/specialcases.py +++ b/src/ieee754/fpmul/specialcases.py @@ -5,9 +5,9 @@ from nmigen.cli import main, verilog from math import log from ieee754.fpcommon.fpbase import FPNumDecode, FPNumBaseRecord -from nmutil.singlepipe import SimpleHandshake, StageChain +from nmutil.singlepipe import StageChain -from ieee754.fpcommon.fpbase import FPState, FPID +from ieee754.pipeline import DynamicPipe from ieee754.fpcommon.getop import FPADDBaseData from ieee754.fpcommon.denorm import (FPSCData, FPAddDeNormMod) from ieee754.fpmul.align import FPAlignModSingle @@ -101,41 +101,13 @@ class FPMulSpecialCasesMod(Elaboratable): return m -class FPMulSpecialCases(FPState): - """ special cases: NaNs, infs, zeros, denormalised - NOTE: some of these are unique to add. see "Special Operations" - https://steve.hollasch.net/cgindex/coding/ieeefloat.html - """ - - def __init__(self, width, id_wid): - FPState.__init__(self, "special_cases") - self.mod = FPMulSpecialCasesMod(width) - self.out_z = self.mod.ospec() - self.out_do_z = Signal(reset_less=True) - - def setup(self, m, i): - """ links module to inputs and outputs - """ - self.mod.setup(m, i, self.out_do_z) - m.d.sync += self.out_z.v.eq(self.mod.out_z.v) # only take the output - m.d.sync += self.out_z.ctx.eq(self.mod.o.ctx) # (and context) - - def action(self, m): - self.idsync(m) - with m.If(self.out_do_z): - m.next = "put_z" - with m.Else(): - m.next = "denormalise" - - -class FPMulSpecialCasesDeNorm(FPState, SimpleHandshake): +class FPMulSpecialCasesDeNorm(DynamicPipe): """ special cases: NaNs, infs, zeros, denormalised """ def __init__(self, pspec): - FPState.__init__(self, "special_cases") self.pspec = pspec - SimpleHandshake.__init__(self, self) # pipe is its own stage + super().__init__(pspec) self.out = self.ospec() def ispec(self): @@ -162,12 +134,3 @@ class FPMulSpecialCasesDeNorm(FPState, SimpleHandshake): def process(self, i): return self.o - def action(self, m): - # for break-out (early-out) - #with m.If(self.out_do_z): - # m.next = "put_z" - #with m.Else(): - m.d.sync += self.out.eq(self.process(None)) - m.next = "align" - -