1cda87659aab349853de9ce13d5e6806fabc852a
1 # IEEE Floating Point Adder (Single Precision)
2 # Copyright (C) Jonathan P Dawson 2013
5 #from nmigen.cli import main, verilog
7 from nmutil
.singlepipe
import StageChain
, SimpleHandshake
9 from ieee754
.fpcommon
.fpbase
import FPState
, FPID
10 from .postcalc
import FPAddStage1Data
11 from .postnormalise
import FPNorm1ModSingle
12 from .roundz
import FPRoundMod
13 from .corrections
import FPCorrectionsMod
14 from .pack
import FPPackData
, FPPackMod
17 class FPNormToPack(FPState
, SimpleHandshake
):
19 def __init__(self
, width
, pspec
):
20 FPState
.__init
__(self
, "normalise_1")
21 print ("normtopack", pspec
)
24 SimpleHandshake
.__init
__(self
, self
) # pipeline is its own stage
27 return FPAddStage1Data(self
.width
, self
.pspec
)
30 return FPPackData(self
.width
, self
.pspec
) # FPPackMod
32 def setup(self
, m
, i
):
33 """ links module to inputs and outputs
36 # Normalisation, Rounding Corrections, Pack - in a chain
37 nmod
= FPNorm1ModSingle(self
.width
, self
.pspec
)
38 rmod
= FPRoundMod(self
.width
, self
.pspec
)
39 cmod
= FPCorrectionsMod(self
.width
, self
.pspec
)
40 pmod
= FPPackMod(self
.width
, self
.pspec
)
41 stages
= [nmod
, rmod
, cmod
, pmod
]
42 chain
= StageChain(stages
)
44 self
.out_z
= pmod
.ospec()
52 m
.d
.sync
+= self
.out_z
.eq(self
.process(None))