From: Luke Kenneth Casson Leighton Date: Fri, 29 Mar 2019 11:54:45 +0000 (+0000) Subject: split out normtopack to separate module X-Git-Tag: ls180-24jan2020~1397 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6d7f448a7ba1f400e724eaafc2d56ee3532b549b;p=ieee754fpu.git split out normtopack to separate module --- diff --git a/src/add/fpcommon/normtopack.py b/src/add/fpcommon/normtopack.py new file mode 100644 index 00000000..2eb44592 --- /dev/null +++ b/src/add/fpcommon/normtopack.py @@ -0,0 +1,59 @@ +# IEEE Floating Point Adder (Single Precision) +# Copyright (C) Jonathan P Dawson 2013 +# 2013-12-12 + +from nmigen import Module, Signal, Cat, Mux, Array, Const +from nmigen.lib.coding import PriorityEncoder +from nmigen.cli import main, verilog +from math import log + +from fpbase import FPNumIn, FPNumOut, FPOp, Overflow, FPBase, FPNumBase +from fpbase import MultiShiftRMerge, Trigger +from singlepipe import (ControlBase, StageChain, UnbufferedPipeline, + PassThroughStage) +from multipipe import CombMuxOutPipe +from multipipe import PriorityCombMuxInPipe + +from fpbase import FPState, FPID +from fpcommon.postcalc import FPAddStage1Data +from fpcommon.postnormalise import FPNorm1ModSingle +from fpcommon.roundz import FPRoundMod +from fpcommon.corrections import FPCorrectionsMod +from fpcommon.pack import FPPackData, FPPackMod + + +class FPNormToPack(FPState, UnbufferedPipeline): + + def __init__(self, width, id_wid): + FPState.__init__(self, "normalise_1") + self.id_wid = id_wid + self.width = width + UnbufferedPipeline.__init__(self, self) # pipeline is its own stage + + def ispec(self): + return FPAddStage1Data(self.width, self.id_wid) # Norm1ModSingle ispec + + def ospec(self): + return FPPackData(self.width, self.id_wid) # FPPackMod ospec + + def setup(self, m, i): + """ links module to inputs and outputs + """ + + # Normalisation, Rounding Corrections, Pack - in a chain + nmod = FPNorm1ModSingle(self.width, self.id_wid) + rmod = FPRoundMod(self.width, self.id_wid) + cmod = FPCorrectionsMod(self.width, self.id_wid) + pmod = FPPackMod(self.width, self.id_wid) + chain = StageChain([nmod, rmod, cmod, pmod]) + chain.setup(m, i) + self.out_z = pmod.ospec() + + self.o = pmod.o + + 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/add/nmigen_add_experiment.py b/src/add/nmigen_add_experiment.py index 22e9e991..f828a67a 100644 --- a/src/add/nmigen_add_experiment.py +++ b/src/add/nmigen_add_experiment.py @@ -23,6 +23,7 @@ from fpcommon.postnormalise import (FPNorm1Data, FPNorm1ModSingle, from fpcommon.roundz import (FPRoundData, FPRoundMod, FPRound) from fpcommon.corrections import (FPCorrectionsMod, FPCorrections) from fpcommon.pack import (FPPackData, FPPackMod, FPPack) +from fpcommon.normtopack import FPNormToPack class FPAddSpecialCasesMod: @@ -637,43 +638,6 @@ class FPAddStage1(FPState): m.next = "normalise_1" -class FPNormToPack(FPState, UnbufferedPipeline): - - def __init__(self, width, id_wid): - FPState.__init__(self, "normalise_1") - self.id_wid = id_wid - self.width = width - UnbufferedPipeline.__init__(self, self) # pipeline is its own stage - - def ispec(self): - return FPAddStage1Data(self.width, self.id_wid) # Norm1ModSingle ispec - - def ospec(self): - return FPPackData(self.width, self.id_wid) # FPPackMod ospec - - def setup(self, m, i): - """ links module to inputs and outputs - """ - - # Normalisation, Rounding Corrections, Pack - in a chain - nmod = FPNorm1ModSingle(self.width, self.id_wid) - rmod = FPRoundMod(self.width, self.id_wid) - cmod = FPCorrectionsMod(self.width, self.id_wid) - pmod = FPPackMod(self.width, self.id_wid) - chain = StageChain([nmod, rmod, cmod, pmod]) - chain.setup(m, i) - self.out_z = pmod.ospec() - - self.o = pmod.o - - 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" - - class FPPutZ(FPState):