quite a lot of corrections to div special cases
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 18 Feb 2019 18:05:38 +0000 (18:05 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 18 Feb 2019 18:05:38 +0000 (18:05 +0000)
src/add/nmigen_div_experiment.py
src/add/test_div.py

index 3ae7a51f6f001f9bc2fc78a249e44f755d0ceaba..f5adb9dbd63b9edaf81b35359b74e57d04f484f0 100644 (file)
@@ -77,37 +77,33 @@ class FPDIV(FPBase):
                     m.d.sync += z.nan(1)
 
                 # if a is Inf and b is Inf return NaN
-                with m.Elif(a.is_inf() | b.is_inf()):
+                with m.Elif(a.is_inf() & b.is_inf()):
                     m.next = "put_z"
                     m.d.sync += z.nan(1)
 
                 # if a is inf return inf (or NaN if b is zero)
                 with m.Elif(a.is_inf()):
                     m.next = "put_z"
-                    # if b is zero return NaN
-                    with m.If(b.is_zero()):
-                        m.d.sync += z.nan(1)
-                    with m.Else():
-                        m.d.sync += z.inf(a.s ^ b.s)
+                    m.d.sync += z.inf(a.s ^ b.s)
 
                 # if b is inf return zero
                 with m.Elif(b.is_inf()):
                     m.next = "put_z"
                     m.d.sync += z.zero(a.s ^ b.s)
 
-                # if a is inf return zero (or NaN if b is zero)
-                with m.Elif(a.is_inf()):
+                # if a is zero return zero (or NaN if b is zero)
+                with m.Elif(a.is_zero()):
                     m.next = "put_z"
                     # if b is zero return NaN
                     with m.If(b.is_zero()):
                         m.d.sync += z.nan(1)
                     with m.Else():
-                        m.d.sync += z.inf(a.s ^ b.s)
+                        m.d.sync += z.zero(a.s ^ b.s)
 
                 # if b is zero return Inf
                 with m.Elif(b.is_zero()):
                     m.next = "put_z"
-                    m.d.sync += z.zero(a.s ^ b.s)
+                    m.d.sync += z.inf(a.s ^ b.s)
 
                 # Denormalised Number checks
                 with m.Else():
index 61882e585466438dbf495f30e5fa257352f03892..58bc714c03b2355ac2684e712748d3d5262077c0 100644 (file)
@@ -15,7 +15,9 @@ from unit_test_single import (get_mantissa, get_exponent, get_sign, is_nan,
 
 
 def testbench(dut):
-    yield from check_case(dut, 0x2b017, 0xff3807ab, 0x80000000)
+    yield from check_case(dut, 0x80000000, 0x00000000, 0xffc00000)
+    yield from check_case(dut, 0x00000000, 0x80000000, 0xffc00000)
+    yield from check_case(dut, 0x0002b017, 0xff3807ab, 0x80000000)
     yield from check_case(dut, 0x40000000, 0x3F800000, 0x40000000)
     yield from check_case(dut, 0x3F800000, 0x40000000, 0x3F000000)
     yield from check_case(dut, 0x3F800000, 0x40400000, 0x3EAAAAAB)