From: Luke Kenneth Casson Leighton Date: Mon, 29 Jul 2019 13:41:29 +0000 (+0100) Subject: add FP32/64 coverage test for fpsqrt X-Git-Tag: ls180-24jan2020~680 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1d01bc0c890b10109d6a52782fd2b87ac8a573ed;p=ieee754fpu.git add FP32/64 coverage test for fpsqrt --- diff --git a/src/ieee754/fpcommon/test/case_gen.py b/src/ieee754/fpcommon/test/case_gen.py index 0b2a58ee..7ced5609 100644 --- a/src/ieee754/fpcommon/test/case_gen.py +++ b/src/ieee754/fpcommon/test/case_gen.py @@ -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 index 00000000..bd61182f --- /dev/null +++ b/src/ieee754/fpdiv/test/sqrt_data32.py @@ -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 index 00000000..b329244b --- /dev/null +++ b/src/ieee754/fpdiv/test/test_fpsqrt_pipe_32.py @@ -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 index 00000000..93f39ff7 --- /dev/null +++ b/src/ieee754/fpdiv/test/test_fpsqrt_pipe_64.py @@ -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()