1 # IEEE Floating Point Adder (Single Precision)
2 # Copyright (C) Jonathan P Dawson 2013
5 from nmigen
import Module
, Signal
6 from nmigen
.cli
import main
, verilog
8 from nmutil
.pipemodbase
import PipeModBase
9 from ieee754
.fpcommon
.fpbase
import FPNumBaseRecord
, FPNumBase
10 from ieee754
.fpcommon
.roundz
import FPRoundData
11 from ieee754
.fpcommon
.getop
import FPPipeContext
12 from ieee754
.fpcommon
.packdata
import FPPackData
15 class FPPackMod(PipeModBase
):
17 def __init__(self
, pspec
):
18 super().__init
__(pspec
, "pack")
21 return FPRoundData(self
.pspec
)
24 return FPPackData(self
.pspec
)
26 def elaborate(self
, platform
):
30 z
= FPNumBaseRecord(self
.pspec
.width
, False, name
="z")
31 m
.submodules
.pack_in_z
= in_z
= FPNumBase(self
.i
.z
)
33 with m
.If(~self
.i
.out_do_z
):
34 with m
.If(in_z
.is_overflowed
):
35 comb
+= z
.inf(self
.i
.z
.s
)
37 comb
+= z
.create(self
.i
.z
.s
, self
.i
.z
.e
, self
.i
.z
.m
)
39 comb
+= z
.v
.eq(self
.i
.oz
)
41 comb
+= self
.o
.ctx
.eq(self
.i
.ctx
)
42 comb
+= self
.o
.z
.eq(z
.v
)