use Mux in fp corrections
[ieee754fpu.git] / src / ieee754 / fpcommon / corrections.py
1 # IEEE Floating Point Adder (Single Precision)
2 # Copyright (C) Jonathan P Dawson 2013
3 # 2013-12-12
4
5 from nmigen import Module, Mux
6 from nmigen.cli import main, verilog
7
8 from nmutil.pipemodbase import PipeModBase
9 from ieee754.fpcommon.fpbase import FPNumBase
10 from ieee754.fpcommon.roundz import FPRoundData
11
12
13 class FPCorrectionsMod(PipeModBase):
14
15 def __init__(self, pspec):
16 super().__init__(pspec, "corrections")
17
18 def ispec(self):
19 return FPRoundData(self.pspec)
20
21 def ospec(self):
22 return FPRoundData(self.pspec)
23
24 def elaborate(self, platform):
25 m = Module()
26 comb = m.d.comb
27 m.submodules.corr_in_z = in_z = FPNumBase(self.i.z)
28 comb += self.o.eq(self.i) # copies mid, z, out_do_z
29 comb += self.o.z.e.eq(Mux(in_z.is_denormalised,
30 self.i.z.N127, self.i.z.e))
31 return m
32
33