add fpmul tests
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 8 Jul 2019 11:43:08 +0000 (12:43 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 8 Jul 2019 11:43:08 +0000 (12:43 +0100)
src/ieee754/fpcommon/test/case_gen.py
src/ieee754/fpmul/specialcases.py
src/ieee754/fpmul/test/mul_data16.py
src/ieee754/fpmul/test/mul_data32.py [new file with mode: 0644]
src/ieee754/fpmul/test/test_fpmul_pipe_16.py [new file with mode: 0644]
src/ieee754/fpmul/test/test_fpmul_pipe_32.py [new file with mode: 0644]

index d667f340efe3698901b1a94ad2e3b8f27e2367e4..26b6cd624725b426a6ace696ab98d689a29344fb 100644 (file)
@@ -103,6 +103,7 @@ class PipeFPCase:
 
     def run_regressions(self, regressions_fn):
         vals = repeat(self.dut.num_rows, regressions_fn())
+        print ("regressions", vals)
         tname = "test_fp%s_pipe_fp%d_regressions" % (self.name, self.width)
         runfp(self.dut, self.width, tname, self.fmod, self.fpfn, vals=vals)
 
index c84eed7113f4a25c00b5aa1858b992ace488622d..cd45701819af4ee63b3c1f3a11dd63510db5c0a4 100644 (file)
@@ -75,7 +75,7 @@ class FPMulSpecialCasesMod(Elaboratable):
             m.d.comb += self.o.z.inf(sabx)
             # b is zero return NaN
             with m.If(b1.is_zero):
-                m.d.comb += self.o.z.nan(1)
+                m.d.comb += self.o.z.nan(0)
 
         # if b is inf return inf (or NaN)
         with m.Elif(b1.is_inf):
@@ -83,7 +83,7 @@ class FPMulSpecialCasesMod(Elaboratable):
             m.d.comb += self.o.z.inf(sabx)
             # a is zero return NaN
             with m.If(a1.is_zero):
-                m.d.comb += self.o.z.nan(1)
+                m.d.comb += self.o.z.nan(0)
 
         # if a is zero or b zero return signed-a/b
         with m.Elif(obz):
index fb13fbb9d34a8eb218d4591b96ba9e9d345c92f7..151c8d9a17b95fe5454bb15b390ff05d5ba1938a 100644 (file)
@@ -1,5 +1,6 @@
 def regressions():
     yield 0x0000, 0xfc00
+    yield 0xfc00, 0x0000
     yield 0xe7bb, 0x81ce
     yield 0xe225, 0x8181
     yield 0x0201, 0x4901
diff --git a/src/ieee754/fpmul/test/mul_data32.py b/src/ieee754/fpmul/test/mul_data32.py
new file mode 100644 (file)
index 0000000..88dbbdf
--- /dev/null
@@ -0,0 +1,12 @@
+def regressions():
+    yield 0x40000000, 0x40000000
+    yield 0x41400000, 0x40A00000
+    yield 0xffcaeefa, 0x3f803262
+    yield 0xae430313, 0x901c3214
+    yield 0x0a4504d7, 0xb4658540
+    yield 0xba57711a, 0xee1818c5
+    yield 0xbf9b1e94, 0xc038ed3a
+    yield 0x34082401, 0xb328cd45
+    yield 0x05e8ef81, 0x114f3db
+    yield 0x5c75da81, 0x2f642a39
+    yield 0x0002b017, 0xff3807ab
diff --git a/src/ieee754/fpmul/test/test_fpmul_pipe_16.py b/src/ieee754/fpmul/test/test_fpmul_pipe_16.py
new file mode 100644 (file)
index 0000000..66d1090
--- /dev/null
@@ -0,0 +1,20 @@
+""" test of FPMULMuxInOut
+"""
+
+from ieee754.fpmul.pipeline import (FPMULMuxInOut,)
+from ieee754.fpcommon.test.case_gen import run_pipe_fp
+from ieee754.fpcommon.test import unit_test_half
+from ieee754.fpmul.test.mul_data16 import regressions
+
+from sfpy import Float16
+from operator import mul
+
+
+def test_pipe_fp16():
+    dut = FPMULMuxInOut(16, 4)
+    run_pipe_fp(dut, 16, "mul", unit_test_half, Float16,
+                   regressions, mul, 10)
+
+
+if __name__ == '__main__':
+    test_pipe_fp16()
diff --git a/src/ieee754/fpmul/test/test_fpmul_pipe_32.py b/src/ieee754/fpmul/test/test_fpmul_pipe_32.py
new file mode 100644 (file)
index 0000000..cebf97f
--- /dev/null
@@ -0,0 +1,20 @@
+""" test of FPMULMuxInOut
+"""
+
+from ieee754.fpmul.pipeline import (FPMULMuxInOut,)
+from ieee754.fpcommon.test.case_gen import run_pipe_fp
+from ieee754.fpcommon.test import unit_test_single
+from ieee754.fpmul.test.mul_data32 import regressions
+
+from sfpy import Float32
+from operator import mul
+
+
+def test_pipe_fp32():
+    dut = FPMULMuxInOut(32, 4)
+    run_pipe_fp(dut, 32, "mul", unit_test_single, Float32,
+                   regressions, mul, 10)
+
+
+if __name__ == '__main__':
+    test_pipe_fp32()