add fp64 mul unit test
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 8 Jul 2019 11:50:59 +0000 (12:50 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 8 Jul 2019 11:50:59 +0000 (12:50 +0100)
src/ieee754/fpcommon/test/unit_test_double.py
src/ieee754/fpmul/test/mul_data64.py [new file with mode: 0644]
src/ieee754/fpmul/test/test_fpmul_pipe_64.py [new file with mode: 0644]

index 56cb80189f34a2981d1460182dea3f42e70db3c1..2714273ec19cf5e16c0c8fa0b32324cb5ff3fa68 100644 (file)
@@ -13,7 +13,7 @@ def get_exponent(x):
     return ((x & 0x7ff0000000000000) >> 52) - 1023
 
 def set_exponent(x, e):
-    return (x & ~0x7ff0000000000000) | ((e+1023) << 23)
+    return (x & ~0x7ff0000000000000) | ((e+1023) << 52)
 
 def get_sign(x):
     return ((x & 0x8000000000000000) >> 63)
diff --git a/src/ieee754/fpmul/test/mul_data64.py b/src/ieee754/fpmul/test/mul_data64.py
new file mode 100644 (file)
index 0000000..3049477
--- /dev/null
@@ -0,0 +1,7 @@
+def regressions():
+    yield 0xff80000000000000, 0x7f80000000000000
+    yield 0x3351099a0528e138, 0xd651a9a9986af2b5
+    #yield 0x80000003ff800000, 0x4f0365445543ae3f
+    #yield 0x0004e1b1e94ef100, 0x42e1b4e00b65f134
+    #yield 0x80000003ff800000, 0xd249a98a4b9a6950
+
diff --git a/src/ieee754/fpmul/test/test_fpmul_pipe_64.py b/src/ieee754/fpmul/test/test_fpmul_pipe_64.py
new file mode 100644 (file)
index 0000000..5670737
--- /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_double
+from ieee754.fpmul.test.mul_data64 import regressions
+
+from sfpy import Float64
+from operator import mul
+
+
+def test_pipe_fp64():
+    dut = FPMULMuxInOut(64, 4)
+    run_pipe_fp(dut, 64, "mul", unit_test_double, Float64,
+                   regressions, mul, 10)
+
+
+if __name__ == '__main__':
+    test_pipe_fp64()