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)
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"
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
#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)
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"
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,
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.
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
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)
def process(self, i):
return self.o
-
- def action(self, m):
- m.d.sync += self.m1o.eq(self.process(None))
- m.next = "normalise_1"
-
-
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
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):
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"
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)
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):
def process(self, i):
return self.o
- def action(self, m):
- m.d.sync += self.m1o.eq(self.process(None))
- m.next = "normalise_1"
-
-
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
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):
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"
-
-