From: Luke Kenneth Casson Leighton Date: Sun, 3 Mar 2019 10:12:04 +0000 (+0000) Subject: small optimisation, move subtraction of -126 from exponent into FPNumBase module... X-Git-Tag: ls180-24jan2020~1753 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=17b7ad3644de8b7f25af107b5de362fdcef373f7;p=ieee754fpu.git small optimisation, move subtraction of -126 from exponent into FPNumBase module, use it there and in normalisation --- diff --git a/src/add/fpbase.py b/src/add/fpbase.py index d8073d53..58b4994a 100644 --- a/src/add/fpbase.py +++ b/src/add/fpbase.py @@ -96,6 +96,7 @@ class FPNumBase: self.is_overflowed = Signal(reset_less=True) self.is_denormalised = Signal(reset_less=True) self.exp_128 = Signal(reset_less=True) + self.exp_sub_n126 = Signal((e_width, True), reset_less=True) self.exp_lt_n126 = Signal(reset_less=True) self.exp_gt_n126 = Signal(reset_less=True) self.exp_gt127 = Signal(reset_less=True) @@ -112,8 +113,9 @@ class FPNumBase: m.d.comb += self.is_overflowed.eq(self._is_overflowed()) m.d.comb += self.is_denormalised.eq(self._is_denormalised()) m.d.comb += self.exp_128.eq(self.e == self.P128) - m.d.comb += self.exp_gt_n126.eq(self.e > self.N126) - m.d.comb += self.exp_lt_n126.eq(self.e < self.N126) + m.d.comb += self.exp_sub_n126.eq(self.e - self.N126) + m.d.comb += self.exp_gt_n126.eq(self.exp_sub_n126 > 0) + m.d.comb += self.exp_lt_n126.eq(self.exp_sub_n126 < 0) m.d.comb += self.exp_gt127.eq(self.e > self.P127) m.d.comb += self.exp_n127.eq(self.e == self.N127) m.d.comb += self.exp_n126.eq(self.e == self.N126) diff --git a/src/add/nmigen_add_experiment.py b/src/add/nmigen_add_experiment.py index 6e797c01..6e259fd9 100644 --- a/src/add/nmigen_add_experiment.py +++ b/src/add/nmigen_add_experiment.py @@ -610,8 +610,8 @@ class FPNorm1Mod: clz = Signal((len(in_z.e), True), reset_less=True) # make sure that the amount to decrease by does NOT # go below the minimum non-INF/NaN exponent - limclz = Mux(in_z.e - pe.o - in_z.N126 > 0, pe.o, - in_z.e - in_z.N126) + limclz = Mux(in_z.exp_sub_n126 > pe.o, pe.o, + in_z.exp_sub_n126) m.d.comb += [ # cat round and guard bits back into the mantissa temp_m.eq(Cat(in_of.round_bit,