add FP32/64 coverage test for fpsqrt
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 29 Jul 2019 13:41:29 +0000 (14:41 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 29 Jul 2019 13:41:29 +0000 (14:41 +0100)
src/ieee754/fpcommon/test/case_gen.py
src/ieee754/fpdiv/test/sqrt_data32.py [new file with mode: 0644]
src/ieee754/fpdiv/test/test_fpsqrt_pipe_32.py [new file with mode: 0644]
src/ieee754/fpdiv/test/test_fpsqrt_pipe_64.py [new file with mode: 0644]

index 0b2a58eed3ca74a20bd57888ad685d31ed340168..7ced56094d598b3dece6aa5079bd0160c1966be2 100644 (file)
@@ -166,7 +166,8 @@ def run_pipe_fp(dut, width, name, mod, fmod, regressions, fpfn, count,
                 single_op=False,
                 opcode=None):
     pc = PipeFPCase(dut, name, mod, fmod, width, fpfn, count, single_op, opcode)
-    pc.run_regressions(regressions)
+    if regressions:
+        pc.run_regressions(regressions)
     pc.run_cornercases()
     pc.run("rand1", get_rand1)
     pc.run("n127", get_n127)
diff --git a/src/ieee754/fpdiv/test/sqrt_data32.py b/src/ieee754/fpdiv/test/sqrt_data32.py
new file mode 100644 (file)
index 0000000..bd61182
--- /dev/null
@@ -0,0 +1,4 @@
+def regressions():
+    yield 0x3f2ad8eb,
+    yield 0,
+
diff --git a/src/ieee754/fpdiv/test/test_fpsqrt_pipe_32.py b/src/ieee754/fpdiv/test/test_fpsqrt_pipe_32.py
new file mode 100644 (file)
index 0000000..b329244
--- /dev/null
@@ -0,0 +1,27 @@
+""" test of FPDIVMuxInOut
+"""
+
+from ieee754.fpdiv.pipeline import (FPDIVMuxInOut,)
+from ieee754.fpcommon.test.case_gen import run_pipe_fp
+from ieee754.fpcommon.test import unit_test_single
+from ieee754.fpdiv.test.sqrt_data32 import regressions
+from ieee754.div_rem_sqrt_rsqrt.core import DivPipeCoreOperation
+
+import unittest
+from sfpy import Float32
+
+
+def sqrt(x):
+    return x.sqrt()
+
+
+class TestDivPipe(unittest.TestCase):
+    def test_pipe_sqrt_fp32(self):
+        dut = FPDIVMuxInOut(32, 4)
+        # don't forget to initialize opcode; don't use magic numbers
+        opcode = int(DivPipeCoreOperation.SqrtRem)
+        run_pipe_fp(dut, 32, "sqrt32", unit_test_single, Float32, regressions,
+                    sqrt, 100, single_op=True, opcode=opcode)
+
+if __name__ == '__main__':
+    unittest.main()
diff --git a/src/ieee754/fpdiv/test/test_fpsqrt_pipe_64.py b/src/ieee754/fpdiv/test/test_fpsqrt_pipe_64.py
new file mode 100644 (file)
index 0000000..93f39ff
--- /dev/null
@@ -0,0 +1,27 @@
+""" test of FPDIVMuxInOut
+"""
+
+from ieee754.fpdiv.pipeline import (FPDIVMuxInOut,)
+from ieee754.fpcommon.test.case_gen import run_pipe_fp
+from ieee754.fpcommon.test import unit_test_double
+#from ieee754.fpdiv.test.sqrt_data64 import regressions
+from ieee754.div_rem_sqrt_rsqrt.core import DivPipeCoreOperation
+
+import unittest
+from sfpy import Float64
+
+
+def sqrt(x):
+    return x.sqrt()
+
+
+class TestDivPipe(unittest.TestCase):
+    def test_pipe_sqrt_fp64(self):
+        dut = FPDIVMuxInOut(64, 4)
+        # don't forget to initialize opcode; don't use magic numbers
+        opcode = int(DivPipeCoreOperation.SqrtRem)
+        run_pipe_fp(dut, 64, "sqrt64", unit_test_double, Float64, None,
+                    sqrt, 100, single_op=True, opcode=opcode)
+
+if __name__ == '__main__':
+    unittest.main()