got fpmul working (potential bug in softfloat NaN handling)
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 3 May 2019 05:02:39 +0000 (06:02 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 3 May 2019 05:02:39 +0000 (06:02 +0100)
src/ieee754/fpcommon/postnormalise.py
src/ieee754/fpmul/specialcases.py
src/ieee754/fpmul/test/test_mul.py

index 4ab6639cf95da4d0c53d73ee5fbd6a349bc8c96e..4ef879e33665c01f6eb62a4488af55be4235b551 100644 (file)
@@ -16,7 +16,7 @@ from .postcalc import FPAddStage1Data
 class FPNorm1Data:
 
     def __init__(self, width, id_wid):
-        self.roundz = Signal(reset_less=True)
+        self.roundz = Signal(reset_less=True, name="norm1_roundz")
         self.z = FPNumBase(width, False)
         self.out_do_z = Signal(reset_less=True)
         self.oz = Signal(width, reset_less=True)
@@ -120,11 +120,11 @@ class FPNorm1ModSingle(Elaboratable):
                     msr.inp.eq(temp_m),
                     msr.diff.eq(ediff_n126),
                     self.o.z.m.eq(msr.m[3:]),
-                    of.m0.eq(temp_s[3]),   # copy of mantissa[0]
+                    of.m0.eq(msr.m[3]),   # copy of mantissa[0]
                     # overflow in bits 0..1: got shifted too (leave sticky)
-                    of.guard.eq(temp_s[2]),     # guard
-                    of.round_bit.eq(temp_s[1]), # round
-                    of.sticky.eq(temp_s[0]),    # sticky
+                    of.guard.eq(msr.m[2]),     # guard
+                    of.round_bit.eq(msr.m[1]), # round
+                    of.sticky.eq(msr.m[0]),    # sticky
                     self.o.z.e.eq(i.z.e + ediff_n126),
                 ]
 
index 57b6f16810421f21c19fc47d68fba172db1de21b..83f82558b9e6c8015bd4f83c1b15811d5b0819fe 100644 (file)
@@ -56,7 +56,7 @@ class FPMulSpecialCasesMod(Elaboratable):
                     ]
 
         obz = Signal(reset_less=True)
-        m.d.comb += obz.eq(a1.is_zero & b1.is_zero)
+        m.d.comb += obz.eq(a1.is_zero | b1.is_zero)
 
         sabx = Signal(reset_less=True)   # sign a xor b (sabx, get it?)
         m.d.comb += sabx.eq(a1.s ^ b1.s)
index 72ec4a0ac917d6b282fc5e486461e03b4d0f69b0..ea655109162f257652470754598da869340066f7 100644 (file)
@@ -16,16 +16,19 @@ from ieee754.fpcommon.test.unit_test_single import (get_mantissa, get_exponent,
 
 
 def tbench(dut, maxcount, num_loops):
-    yield from check_case(dut, 0x40000000, 0x40000000, 0x40800000)
-    yield from check_case(dut, 0x41400000, 0x40A00000, 0x42700000)
+
+    yield from check_case(dut, 0x40000000, 0x40000000, 0x40800000, 0xffcaeefa)
+    yield from check_case(dut, 0x41400000, 0x40A00000, 0x42700000, 0x3f803262)
 
     count = 0
 
     #regression tests
 
-    stimulus_a = [0xa4504d7, 0xba57711a, 0xbf9b1e94, 0x34082401, 0x5e8ef81,
+    stimulus_a = [0xffcaeefa, 0xae430313, 0xa4504d7,
+                  0xba57711a, 0xbf9b1e94, 0x34082401, 0x5e8ef81,
                   0x5c75da81, 0x2b017]
-    stimulus_b = [0xb4658540, 0xee1818c5, 0xc038ed3a, 0xb328cd45, 0x114f3db,
+    stimulus_b = [0x3f803262, 0x901c3214, 0xb4658540,
+                  0xee1818c5, 0xc038ed3a, 0xb328cd45, 0x114f3db,
                   0x2f642a39, 0xff3807ab]
     yield from run_fpunit(dut, stimulus_a, stimulus_b, mul, get_case)
     count += len(stimulus_a)