From e9ef7709bf7955693ab4c9ed74e87f81f4f45632 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sat, 16 Feb 2019 09:05:53 +0000 Subject: [PATCH] move normalise_2 to function --- src/add/nmigen_add_experiment.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/add/nmigen_add_experiment.py b/src/add/nmigen_add_experiment.py index fef643c8..af947149 100644 --- a/src/add/nmigen_add_experiment.py +++ b/src/add/nmigen_add_experiment.py @@ -141,6 +141,18 @@ class FPADD: with m.Else(): m.next = next_state + def normalise_2(self, m, z, of, next_state): + with m.If(z.e < z.N126): + m.d.sync +=[ + z.e.eq(z.e + 1), # INCREASE exponent + z.m.eq(z.m >> 1), # shift mantissa DOWN + of.guard.eq(z.m[0]), + of.round_bit.eq(of.guard), + of.sticky.eq(of.sticky | of.round_bit) + ] + with m.Else(): + m.next = next_state + def get_fragment(self, platform=None): m = Module() @@ -311,16 +323,7 @@ class FPADD: # the extra mantissa bits coming from tot[0..2] with m.State("normalise_2"): - with m.If(z.e < z.N126): - m.d.sync +=[ - z.e.eq(z.e + 1), # INCREASE exponent - z.m.eq(z.m >> 1), # shift mantissa DOWN - of.guard.eq(z.m[0]), - of.round_bit.eq(of.guard), - of.sticky.eq(of.sticky | of.round_bit) - ] - with m.Else(): - m.next = "round" + self.normalise_2(m, z, of, "round") # ****** # rounding stage -- 2.30.2