From: Luke Kenneth Casson Leighton Date: Tue, 19 Feb 2019 06:41:50 +0000 (+0000) Subject: add shift up multi function X-Git-Tag: ls180-24jan2020~1874 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=223916b7bb72d4dc241c8fa275b6e1db173c01fe;p=ieee754fpu.git add shift up multi function --- diff --git a/src/add/fpbase.py b/src/add/fpbase.py index 48bfb822..977a00db 100644 --- a/src/add/fpbase.py +++ b/src/add/fpbase.py @@ -161,6 +161,17 @@ class FPNum: self.m.eq(Cat(stickybits, rs)) ] + def shift_up_multi(self, diff): + """ shifts a mantissa up. exponent is decreased to compensate + """ + sm = MultiShift(self.width) + mw = Const(self.m_width, len(diff)) + maxslen = Mux(diff > mw, mw, diff) + + return [self.e.eq(self.e - diff), + self.m.eq(sm.lshift(self.m, maxslen)) + ] + def nan(self, s): return self.create(s, self.P128, 1<<(self.e_start-1)) @@ -264,7 +275,7 @@ class FPBase: the extra mantissa bits coming from tot[0..2] """ with m.If((z.m[-1] == 0) & (z.e > z.N126)): - m.d.sync +=[ + m.d.sync += [ z.e.eq(z.e - 1), # DECREASE exponent z.m.eq(z.m << 1), # shift mantissa UP z.m[0].eq(of.guard), # steal guard bit (was tot[2])