add fpsqrt 16 coverage test
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 29 Jul 2019 13:18:26 +0000 (14:18 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 29 Jul 2019 13:18:41 +0000 (14:18 +0100)
src/ieee754/fpdiv/test/sqrt_data16.py [new file with mode: 0644]
src/ieee754/fpdiv/test/test_fpsqrt_pipe_16.py [new file with mode: 0644]

diff --git a/src/ieee754/fpdiv/test/sqrt_data16.py b/src/ieee754/fpdiv/test/sqrt_data16.py
new file mode 100644 (file)
index 0000000..d1a6740
--- /dev/null
@@ -0,0 +1,9 @@
+def regressions():
+    yield 0x3686,
+    yield 0x4400,
+    yield 0x4800,
+    yield 0x48f0,
+    yield 0x429,
+    yield 0x2631,
+    yield 0x3001,
+
diff --git a/src/ieee754/fpdiv/test/test_fpsqrt_pipe_16.py b/src/ieee754/fpdiv/test/test_fpsqrt_pipe_16.py
new file mode 100644 (file)
index 0000000..e1709c3
--- /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_half
+from ieee754.fpdiv.test.sqrt_data16 import regressions
+from ieee754.div_rem_sqrt_rsqrt.core import DivPipeCoreOperation
+
+import unittest
+from sfpy import Float16
+
+
+def sqrt(x):
+    return x.sqrt()
+
+
+class TestDivPipe(unittest.TestCase):
+    def test_pipe_sqrt_fp16(self):
+        dut = FPDIVMuxInOut(16, 4)
+        # don't forget to initialize opcode; don't use magic numbers
+        opcode = int(DivPipeCoreOperation.SqrtRem)
+        run_pipe_fp(dut, 16, "sqrt16", unit_test_half, Float16, regressions,
+                    sqrt, 100, single_op=True, opcode=opcode)
+
+if __name__ == '__main__':
+    unittest.main()