from ieee754.fpcommon.getop import FPPipeContext
from ieee754.fpcommon.msbhigh import FPMSBHigh
from ieee754.fpcommon.denorm import FPSCData
-from ieee754.fpcommon.postcalc import FPAddStage1Data
+from ieee754.fpcommon.postcalc import FPPostCalcData
class FPAlignModSingle(PipeModBase):
insel_a.m.name = "i_a_m"
insel_b.m.name = "i_b_m"
+ # FPMSBHigh makes sure that the MSB is HI (duh).
+ # it does so (in a single cycle) by counting the leading zeros
+ # and performing a shift on the mantissa. the same count is then
+ # subtracted from the exponent.
mwid = self.o.z.m_width
msb_a = FPMSBHigh(mwid, len(insel_a.e))
msb_b = FPMSBHigh(mwid, len(insel_b.e))
comb += msb_b.m_in.eq(insel_b.m)
comb += msb_b.e_in.eq(insel_b.e)
- # copy input to output (overridden below)
- comb += self.o.a.eq(insel_a)
- comb += self.o.b.eq(insel_b)
+ # copy input to output sign
+ comb += self.o.a.s.eq(insel_a.s)
+ comb += self.o.b.s.eq(insel_b.s)
# normalisation increase/decrease conditions
decrease_a = Signal(reset_less=True)
comb += decrease_b.eq(insel_b.m_msbzero)
# ok this is near-identical to FPNorm: use same class (FPMSBHigh)
- with m.If(~self.i.out_do_z):
- with m.If(decrease_a):
- comb += [
- self.o.a.e.eq(msb_a.e_out),
- self.o.a.m.eq(msb_a.m_out),
- ]
- with m.If(decrease_b):
- comb += [
- self.o.b.e.eq(msb_b.e_out),
- self.o.b.m.eq(msb_b.m_out),
- ]
+ comb += [
+ self.o.a.e.eq(Mux(decrease_a, msb_a.e_out, insel_a.e)),
+ self.o.a.m.eq(Mux(decrease_a, msb_a.m_out, insel_a.m))
+ ]
+ comb += [
+ self.o.b.e.eq(Mux(decrease_b, msb_b.e_out, insel_b.e)),
+ self.o.b.m.eq(Mux(decrease_b, msb_b.m_out, insel_b.m))
+ ]
comb += self.o.ctx.eq(self.i.ctx)
comb += self.o.out_do_z.eq(self.i.out_do_z)