From: Luke Kenneth Casson Leighton Date: Sat, 16 Feb 2019 10:48:47 +0000 (+0000) Subject: add op_normalise function X-Git-Tag: ls180-24jan2020~1951 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b5819d705aa1b840221ccd7a8045a614a694947f;p=ieee754fpu.git add op_normalise function --- diff --git a/src/add/nmigen_add_experiment.py b/src/add/nmigen_add_experiment.py index 795bd7c9..9cacf325 100644 --- a/src/add/nmigen_add_experiment.py +++ b/src/add/nmigen_add_experiment.py @@ -143,6 +143,19 @@ class FPBase: with m.Else(): m.d.sync += a.m[-1].eq(1) # set top mantissa bit + def op_normalise(self, m, op, of, next_state): + """ operand normalisation + NOTE: just like "align", this one keeps going round every clock + until the result's exponent is within acceptable "range" + """ + with m.If((op.m[-1] == 0)): # check last bit of mantissa + m.d.sync +=[ + op.e.eq(op.e - 1), # DECREASE exponent + op.m.eq(op.m << 1), # shift mantissa UP + ] + with m.Else(): + m.next = next_state + def normalise_1(self, m, z, of, next_state): """ first stage normalisation