From 69e3e86a50ca7295268a0fa9bc97216cabe1896c Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sat, 16 Feb 2019 09:45:25 +0000 Subject: [PATCH] move denormalisation to function --- src/add/nmigen_add_experiment.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/add/nmigen_add_experiment.py b/src/add/nmigen_add_experiment.py index 38af9437..68b3a093 100644 --- a/src/add/nmigen_add_experiment.py +++ b/src/add/nmigen_add_experiment.py @@ -133,6 +133,14 @@ class FPADD: with m.Else(): m.d.sync += op.ack.eq(1) + def denormalise(self, m, a): + """ denormalises a number + """ + with m.If(a.e == a.N127): + m.d.sync += a.e.eq(-126) # limit a exponent + with m.Else(): + m.d.sync += a.m[-1].eq(1) # set top mantissa bit + def normalise_1(self, m, z, of, next_state): """ first stage normalisation @@ -285,16 +293,8 @@ class FPADD: # Denormalised Number checks with m.Else(): m.next = "align" - # denormalise a check - with m.If(a.e == a.N127): - m.d.sync += a.e.eq(-126) # limit a exponent - with m.Else(): - m.d.sync += a.m[-1].eq(1) # set top mantissa bit - # denormalise b check - with m.If(b.e == a.N127): - m.d.sync += b.e.eq(-126) # limit b exponent - with m.Else(): - m.d.sync += b.m[-1].eq(1) # set top mantissa bit + self.denormalise(m, a) + self.denormalise(m, b) # ****** # align. NOTE: this does *not* do single-cycle multi-shifting, -- 2.30.2