From: Luke Kenneth Casson Leighton Date: Thu, 14 Feb 2019 08:49:48 +0000 (+0000) Subject: add align phase X-Git-Tag: ls180-24jan2020~2020^2~1 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0cb5bcb2f90da200924108bbe2b2ba0e598a1248;p=ieee754fpu.git add align phase --- diff --git a/src/add/nmigen_add_experiment.py b/src/add/nmigen_add_experiment.py index 5eb20770..e23bb8a7 100644 --- a/src/add/nmigen_add_experiment.py +++ b/src/add/nmigen_add_experiment.py @@ -40,10 +40,10 @@ class FPADD: b_m = Signal(27) # ??? seems to be 1 bit extra?? z_m = Signal(24) - # Exponent - a_e = Signal(10) - b_e = Signal(10) - z_e = Signal(10) + # Exponent: 10 bits, signed (the exponent bias is subtracted) + a_e = Signal((10, True)) + b_e = Signal((10, True)) + z_e = Signal((10, True)) # Sign a_s = Signal() @@ -184,6 +184,29 @@ class FPADD: with m.Else(): m.d.sync += b_m[26].eq(1) # set highest mantissa bit + # ****** + # align. NOTE: this does *not* do single-cycle multi-shifting, + # it *STAYS* in the align state until the exponents match + + with m.State("align"): + # exponent of a greater than b: increment b exp, shift b mant + with m.If(a_e > b_e): + m.d.sync += [ + b_e.eq(b_e + 1), + b_m.eq(b_m >> 1), + b_m[0].eq(b_m[0] | b_m[1]) # moo?? + ] + # exponent of b greater than a: increment a exp, shift a mant + with m.Elif(a_e < b_e): + m.d.sync += [ + a_e.eq(a_e + 1), + a_m.eq(a_m >> 1), + a_m[0].eq(a_m[0] | a_m[1]) # moo?? + ] + # exponents equal: move to next stage. + with m.Else(): + m.next = "add_0" + # ****** # First stage of add