d8e47235f3ed68c7a851173a046a4422077dccdc
[ieee754fpu.git] / src / ieee754 / fpdiv / test / test_fprsqrt_pipe.py
1 """ test of FPDIVMuxInOut
2 """
3
4 from ieee754.fpdiv.pipeline import (FPDIVMuxInOut,)
5 from ieee754.fpcommon.test.fpmux import runfp
6
7 import unittest
8 from sfpy import Float64, Float32, Float16
9
10
11 def rsqrt(x):
12 # FIXME: switch to correct implementation (rounding once)
13 return x.__class__(1.0) / x.sqrt()
14
15
16 class TestDivPipe(unittest.TestCase):
17 def test_pipe_rsqrt_fp16(self):
18 dut = FPDIVMuxInOut(16, 4)
19 runfp(dut, 16, "test_fprsqrt_pipe_fp16", Float16, rsqrt,
20 single_op=True, opcode=2, n_vals=100)
21
22 def test_pipe_rsqrt_fp32(self):
23 dut = FPDIVMuxInOut(32, 4)
24 runfp(dut, 32, "test_fprsqrt_pipe_fp32", Float32, rsqrt,
25 single_op=True, opcode=2, n_vals=100)
26
27 def test_pipe_rsqrt_fp64(self):
28 dut = FPDIVMuxInOut(64, 4)
29 runfp(dut, 64, "test_fprsqrt_pipe_fp64", Float64, rsqrt,
30 single_op=True, opcode=2, n_vals=100)
31
32
33 if __name__ == '__main__':
34 unittest.main()