add first version fcvt int to fp16/32/64
[ieee754fpu.git] / src / ieee754 / fcvt / test / test_fcvt_int_pipe.py
1 """ test of FPCVTMuxInOut
2 """
3
4 from ieee754.fcvt.pipeline import (FPCVTIntMuxInOut,)
5 from ieee754.fpcommon.test.fpmux import runfp
6
7 import sfpy
8 from sfpy import Float64, Float32, Float16
9
10 def to_uint16(x):
11 return x
12
13 def to_uint32(x):
14 return x
15
16 def fcvt_64(x):
17 return sfpy.float.ui32_to_f64(x)
18
19 def fcvt_32(x):
20 return sfpy.float.ui32_to_f32(x)
21
22 def test_int_pipe_fp16_32():
23 dut = FPCVTIntMuxInOut(16, 32, 4)
24 runfp(dut, 16, "test_fcvt_int_pipe_fp16_32", to_uint16, fcvt_32, True,
25 n_vals=100)
26
27 def test_int_pipe_fp16_64():
28 dut = FPCVTIntMuxInOut(16, 64, 4)
29 runfp(dut, 16, "test_fcvt_int_pipe_fp16_64", to_uint16, fcvt_64, True,
30 n_vals=100)
31
32 def test_int_pipe_fp32_64():
33 dut = FPCVTIntMuxInOut(32, 64, 4)
34 runfp(dut, 32, "test_fcvt_int_pipe_fp32_64", to_uint32, fcvt_64, True,
35 n_vals=100)
36
37 if __name__ == '__main__':
38 for i in range(200):
39 test_int_pipe_fp16_32()
40 test_int_pipe_fp16_64()
41 test_int_pipe_fp32_64()
42