use opcode rather than magic constants (will need a class, later)
[ieee754fpu.git] / src / ieee754 / fpdiv / test / test_fpsqrt_pipe.py
1 """ test of FPDIVMuxInOut
2 """
3
4 from ieee754.fpdiv.pipeline import (FPDIVMuxInOut,)
5 from ieee754.fpcommon.test.fpmux import runfp
6 from ieee754.div_rem_sqrt_rsqrt.core import DivPipeCoreOperation
7
8 import unittest
9 from sfpy import Float64, Float32, Float16
10
11
12 def sqrt(x):
13 return x.sqrt()
14
15
16 class TestDivPipe(unittest.TestCase):
17 def test_pipe_sqrt_fp16(self):
18 dut = FPDIVMuxInOut(16, 4)
19 # don't forget to initialize opcode; don't use magic numbers
20 opcode = int(DivPipeCoreOperation.SqrtRem)
21 runfp(dut, 16, "test_fpsqrt_pipe_fp16", Float16, sqrt,
22 single_op=True, opcode=opcode, n_vals=100)
23
24 def test_pipe_sqrt_fp32(self):
25 dut = FPDIVMuxInOut(32, 4)
26 # don't forget to initialize opcode; don't use magic numbers
27 opcode = int(DivPipeCoreOperation.SqrtRem)
28 runfp(dut, 32, "test_fpsqrt_pipe_fp32", Float32, sqrt,
29 single_op=True, opcode=opcode, n_vals=100)
30
31 def test_pipe_sqrt_fp64(self):
32 dut = FPDIVMuxInOut(64, 4)
33 # don't forget to initialize opcode; don't use magic numbers
34 opcode = int(DivPipeCoreOperation.SqrtRem)
35 runfp(dut, 64, "test_fpsqrt_pipe_fp64", Float64, sqrt,
36 single_op=True, opcode=opcode, n_vals=100)
37
38
39 if __name__ == '__main__':
40 unittest.main()