From 5107bbe121ee49a600b48f6467502a69a29d1df4 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sat, 16 Feb 2019 09:12:14 +0000 Subject: [PATCH] create pack function --- src/add/nmigen_add_experiment.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/add/nmigen_add_experiment.py b/src/add/nmigen_add_experiment.py index 676d8381..8a7ef0ea 100644 --- a/src/add/nmigen_add_experiment.py +++ b/src/add/nmigen_add_experiment.py @@ -160,6 +160,15 @@ class FPADD: with m.If(z.m == z.m1s): # all 1s m.d.sync += z.e.eq(z.e + 1) # exponent rounds up + def corrections(self, m, z, next_state): + m.next = next_state + # denormalised, correct exponent to zero + with m.If(z.is_denormalised()): + m.d.sync += z.m.eq(-127) + # FIX SIGN BUG: -a + a = +0. + with m.If((z.e == z.N126) & (z.m[0:] == 0)): + m.d.sync += z.s.eq(0) + def get_fragment(self, platform=None): m = Module() @@ -342,13 +351,7 @@ class FPADD: # correction stage with m.State("corrections"): - m.next = "pack" - # denormalised, correct exponent to zero - with m.If(z.is_denormalised()): - m.d.sync += z.m.eq(-127) - # FIX SIGN BUG: -a + a = +0. - with m.If((z.e == z.N126) & (z.m[0:] == 0)): - m.d.sync += z.s.eq(0) + self.corrections(m, z, "pack") # ****** # pack stage -- 2.30.2