1 """ test of FPDIVMuxInOut
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
9 from sfpy
import Float64
, Float32
, Float16
13 # FIXME: switch to correct implementation
14 # needs to use exact arithmetic and rounding only once at the end
15 return x
.__class
__(float(Float64(1.0) / x
.to_f64().sqrt()))
18 class TestDivPipe(unittest
.TestCase
):
19 def test_pipe_rsqrt_fp16(self
):
20 dut
= FPDIVMuxInOut(16, 8)
21 # don't forget to initialize opcode; don't use magic numbers
22 opcode
= int(DivPipeCoreOperation
.RSqrtRem
)
23 runfp(dut
, 16, "test_fprsqrt_pipe_fp16", Float16
, rsqrt
,
24 single_op
=True, opcode
=opcode
, n_vals
=100, cancel
=True)
26 def test_pipe_rsqrt_fp32(self
):
27 dut
= FPDIVMuxInOut(32, 8)
28 # don't forget to initialize opcode; don't use magic numbers
29 opcode
= int(DivPipeCoreOperation
.RSqrtRem
)
30 runfp(dut
, 32, "test_fprsqrt_pipe_fp32", Float32
, rsqrt
,
31 single_op
=True, opcode
=opcode
, n_vals
=100, cancel
=True)
33 @unittest.skip("rsqrt not implemented for fp64")
34 def test_pipe_rsqrt_fp64(self
):
35 dut
= FPDIVMuxInOut(64, 8)
36 # don't forget to initialize opcode; don't use magic numbers
37 opcode
= int(DivPipeCoreOperation
.RSqrtRem
)
38 runfp(dut
, 64, "test_fprsqrt_pipe_fp64", Float64
, rsqrt
,
39 single_op
=True, opcode
=opcode
, n_vals
=100, cancel
=True)
42 if __name__
== '__main__':