1 # IEEE Floating Point Adder (Single Precision)
2 # Copyright (C) Jonathan P Dawson 2013
5 from nmigen
import Module
, Signal
, Cat
, Mux
, Array
, Const
6 from nmigen
.lib
.coding
import PriorityEncoder
7 from nmigen
.cli
import main
, verilog
10 from fpbase
import FPNumIn
, FPNumOut
, FPOp
, Overflow
, FPBase
, FPNumBase
11 from fpbase
import MultiShiftRMerge
, Trigger
12 from singlepipe
import (ControlBase
, StageChain
, UnbufferedPipeline
,
14 from multipipe
import CombMuxOutPipe
15 from multipipe
import PriorityCombMuxInPipe
17 from fpbase
import FPState
, FPID
18 from fpcommon
.postcalc
import FPAddStage1Data
19 from fpcommon
.postnormalise
import FPNorm1ModSingle
20 from fpcommon
.roundz
import FPRoundMod
21 from fpcommon
.corrections
import FPCorrectionsMod
22 from fpcommon
.pack
import FPPackData
, FPPackMod
25 class FPNormToPack(FPState
, UnbufferedPipeline
):
27 def __init__(self
, width
, id_wid
):
28 FPState
.__init
__(self
, "normalise_1")
31 UnbufferedPipeline
.__init
__(self
, self
) # pipeline is its own stage
34 return FPAddStage1Data(self
.width
, self
.id_wid
) # Norm1ModSingle ispec
37 return FPPackData(self
.width
, self
.id_wid
) # FPPackMod ospec
39 def setup(self
, m
, i
):
40 """ links module to inputs and outputs
43 # Normalisation, Rounding Corrections, Pack - in a chain
44 nmod
= FPNorm1ModSingle(self
.width
, self
.id_wid
)
45 rmod
= FPRoundMod(self
.width
, self
.id_wid
)
46 cmod
= FPCorrectionsMod(self
.width
, self
.id_wid
)
47 pmod
= FPPackMod(self
.width
, self
.id_wid
)
48 chain
= StageChain([nmod
, rmod
, cmod
, pmod
])
50 self
.out_z
= pmod
.ospec()
58 m
.d
.sync
+= self
.out_z
.eq(self
.process(None))