From 0f623094c1018cbaf0945bafa043af3f6e67bc00 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Thu, 14 Feb 2019 06:20:23 +0000 Subject: [PATCH] add inf special case --- src/add/nmigen_add_experiment.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/add/nmigen_add_experiment.py b/src/add/nmigen_add_experiment.py index dcf7195a..2cb31c98 100644 --- a/src/add/nmigen_add_experiment.py +++ b/src/add/nmigen_add_experiment.py @@ -99,6 +99,22 @@ class FPADD: z[22].eq(1), # mantissa top bit: 1 z[0:22].eq(0) # mantissa rest: 0b0000... ] + # if a is inf return inf + with m.Elif(a_e == 128): + m.next = "put_z" + m.d.sync += [ + z[31].eq(a_s), # sign: a_s + z[23:31].eq(255), # exp: 0b11111... + z[0:23].eq(0) # mantissa rest: 0b0000... + ] + # if a is inf and signs don't match return NaN + with m.If((b_e == 128) & (a_s != b_s)): + m.d.sync += [ + z[31].eq(b_s), # sign: b_s + z[23:31].eq(255), # exp: 0b11111... + z[22].eq(1), # mantissa top bit: 1 + z[0:22].eq(0) # mantissa rest: 0b0000... + ] return m """ -- 2.30.2