X-Git-Url: https://git.libre-soc.org/?p=ieee754fpu.git;a=blobdiff_plain;f=src%2Fieee754%2Ffpadd%2Falign.py;h=16f6da3977f0da32ef447c86701ebcb8c3ac3d1b;hp=0e2ad11904e3a2f1c606ad8b66f23f9f730fa12d;hb=b3829ddc6d2a352d02d068351a361b39e1410c8b;hpb=f9f55e1c0f3593bc23d91ba8bf7ef0489da2cfd6 diff --git a/src/ieee754/fpadd/align.py b/src/ieee754/fpadd/align.py index 0e2ad119..16f6da39 100644 --- a/src/ieee754/fpadd/align.py +++ b/src/ieee754/fpadd/align.py @@ -85,38 +85,37 @@ class FPAddAlignSingleMod(PipeModBase): elz = Signal(reset_less=True) egz = Signal(reset_less=True) - with m.If(~self.i.out_do_z): - # connect multi-shifter to t_inp/out mantissa (and tdiff) - # (only one: input/output is muxed) - comb += msr.inp.eq(t_inp.m) - comb += msr.diff.eq(tdiff) - comb += t_out.m.eq(msr.m) - comb += t_out.e.eq(t_inp.e + tdiff) - comb += t_out.s.eq(t_inp.s) - - comb += ediff.eq(self.i.a.e - self.i.b.e) # a - b - comb += ediffr.eq(-ediff) # b - a - comb += elz.eq(self.i.a.e < self.i.b.e) # ae < be - comb += egz.eq(self.i.a.e > self.i.b.e) # ae > be - - # default: A-exp == B-exp, A and B untouched (fall through) - comb += self.o.a.eq(self.i.a) - comb += self.o.b.eq(self.i.b) - - # exponent of a greater than b: shift b down - with m.If(egz): - comb += [t_inp.eq(self.i.b), - tdiff.eq(ediff), - self.o.b.eq(t_out), - self.o.b.s.eq(self.i.b.s), # whoops forgot sign - ] - # exponent of b greater than a: shift a down - with m.Elif(elz): - comb += [t_inp.eq(self.i.a), - tdiff.eq(ediffr), - self.o.a.eq(t_out), - self.o.a.s.eq(self.i.a.s), # whoops forgot sign - ] + # connect multi-shifter to t_inp/out mantissa (and tdiff) + # (only one: input/output is muxed) + comb += msr.inp.eq(t_inp.m) + comb += msr.diff.eq(tdiff) + comb += t_out.m.eq(msr.m) + comb += t_out.e.eq(t_inp.e + tdiff) + comb += t_out.s.eq(t_inp.s) + + comb += ediff.eq(self.i.a.e - self.i.b.e) # a - b + comb += ediffr.eq(-ediff) # b - a + comb += elz.eq(self.i.a.e < self.i.b.e) # ae < be + comb += egz.eq(self.i.a.e > self.i.b.e) # ae > be + + # default: A-exp == B-exp, A and B untouched (fall through) + comb += self.o.a.eq(self.i.a) + comb += self.o.b.eq(self.i.b) + + # exponent of a greater than b: shift b down + with m.If(egz): + comb += [t_inp.eq(self.i.b), + tdiff.eq(ediff), + self.o.b.eq(t_out), + self.o.b.s.eq(self.i.b.s), # whoops forgot sign + ] + # exponent of b greater than a: shift a down + with m.Elif(elz): + comb += [t_inp.eq(self.i.a), + tdiff.eq(ediffr), + self.o.a.eq(t_out), + self.o.a.s.eq(self.i.a.s), # whoops forgot sign + ] comb += self.o.ctx.eq(self.i.ctx) comb += self.o.z.eq(self.i.z)