3a06916741b564a53db64e2709478f77e8d421e2
[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
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 m.submodules.corr_in_z = in_z = FPNumBase(self.i.z)
27 m.d.comb += self.o.eq(self.i) # copies mid, z, out_do_z
28 with m.If(~self.i.out_do_z):
29 with m.If(in_z.is_denormalised):
30 m.d.comb += self.o.z.e.eq(self.i.z.N127)
31 return m
32
33