from ieee754.fpdiv.pipeline import (FPDIVMuxInOut,)
from ieee754.fpcommon.test.fpmux import runfp
+from ieee754.div_rem_sqrt_rsqrt.core import DivPipeCoreOperation
import unittest
from sfpy import Float64, Float32, Float16
class TestDivPipe(unittest.TestCase):
def test_pipe_div_fp16(self):
dut = FPDIVMuxInOut(16, 4)
- runfp(dut, 16, "test_fpdiv_pipe_fp16", Float16, div)
+ # don't forget to initialize opcode; don't use magic numbers
+ opcode = int(DivPipeCoreOperation.UDivRem)
+ runfp(dut, 16, "test_fpdiv_pipe_fp16", Float16, div,
+ opcode=opcode)
def test_pipe_div_fp32(self):
dut = FPDIVMuxInOut(32, 4)
- runfp(dut, 32, "test_fpdiv_pipe_fp32", Float32, div)
+ # don't forget to initialize opcode; don't use magic numbers
+ opcode = int(DivPipeCoreOperation.UDivRem)
+ runfp(dut, 32, "test_fpdiv_pipe_fp32", Float32, div,
+ opcode=opcode)
def test_pipe_div_fp64(self):
dut = FPDIVMuxInOut(64, 4)
- runfp(dut, 64, "test_fpdiv_pipe_fp64", Float64, div)
+ # don't forget to initialize opcode; don't use magic numbers
+ opcode = int(DivPipeCoreOperation.UDivRem)
+ runfp(dut, 64, "test_fpdiv_pipe_fp64", Float64, div,
+ opcode=opcode)
if __name__ == '__main__':
from ieee754.fpcommon.test.case_gen import run_pipe_fp
from ieee754.fpcommon.test import unit_test_half
from ieee754.fpdiv.test.div_data16 import regressions
+from ieee754.div_rem_sqrt_rsqrt.core import DivPipeCoreOperation
import unittest
from sfpy import Float16
class TestDivPipe(unittest.TestCase):
def test_pipe_fp16(self):
dut = FPDIVMuxInOut(16, 4)
+ # don't forget to initialize opcode; don't use magic numbers
+ opcode = int(DivPipeCoreOperation.UDivRem)
run_pipe_fp(dut, 16, "div16", unit_test_half, Float16,
- regressions, div, 10)
+ regressions, div, 10, opcode=opcode)
if __name__ == '__main__':
from ieee754.fpcommon.test.case_gen import run_pipe_fp
from ieee754.fpcommon.test import unit_test_single
from ieee754.fpdiv.test.div_data32 import regressions
+from ieee754.div_rem_sqrt_rsqrt.core import DivPipeCoreOperation
import unittest
from sfpy import Float32
class TestDivPipe(unittest.TestCase):
def test_pipe_fp32(self):
dut = FPDIVMuxInOut(32, 4)
+ # don't forget to initialize opcode; don't use magic numbers
+ opcode = int(DivPipeCoreOperation.UDivRem)
run_pipe_fp(dut, 32, "div32", unit_test_single, Float32,
- regressions, div, 10)
+ regressions, div, 10, opcode=opcode)
if __name__ == '__main__':
from ieee754.fpdiv.pipeline import (FPDIVMuxInOut,)
from ieee754.fpcommon.test.fpmux import runfp
+from ieee754.div_rem_sqrt_rsqrt.core import DivPipeCoreOperation
import unittest
from sfpy import Float64, Float32, Float16
def rsqrt(x):
- # FIXME: switch to correct implementation (rounding once)
- return x.__class__(1.0) / x.sqrt()
+ # FIXME: switch to correct implementation
+ # needs to use exact arithmetic and rounding only once at the end
+ return x.__class__(float(Float64(1.0) / x.to_f64().sqrt()))
class TestDivPipe(unittest.TestCase):
def test_pipe_rsqrt_fp16(self):
dut = FPDIVMuxInOut(16, 4)
+ # don't forget to initialize opcode; don't use magic numbers
+ opcode = int(DivPipeCoreOperation.RSqrtRem)
runfp(dut, 16, "test_fprsqrt_pipe_fp16", Float16, rsqrt,
- single_op=True, opcode=2, n_vals=100)
+ single_op=True, opcode=opcode, n_vals=100)
def test_pipe_rsqrt_fp32(self):
dut = FPDIVMuxInOut(32, 4)
+ # don't forget to initialize opcode; don't use magic numbers
+ opcode = int(DivPipeCoreOperation.RSqrtRem)
runfp(dut, 32, "test_fprsqrt_pipe_fp32", Float32, rsqrt,
- single_op=True, opcode=2, n_vals=100)
+ single_op=True, opcode=opcode, n_vals=100)
+ @unittest.skip("rsqrt not implemented for fp64")
def test_pipe_rsqrt_fp64(self):
dut = FPDIVMuxInOut(64, 4)
+ # don't forget to initialize opcode; don't use magic numbers
+ opcode = int(DivPipeCoreOperation.RSqrtRem)
runfp(dut, 64, "test_fprsqrt_pipe_fp64", Float64, rsqrt,
- single_op=True, opcode=2, n_vals=100)
+ single_op=True, opcode=opcode, n_vals=100)
if __name__ == '__main__':
from ieee754.fpdiv.pipeline import (FPDIVMuxInOut,)
from ieee754.fpcommon.test.fpmux import runfp
+from ieee754.div_rem_sqrt_rsqrt.core import DivPipeCoreOperation
import unittest
from sfpy import Float64, Float32, Float16
class TestDivPipe(unittest.TestCase):
def test_pipe_sqrt_fp16(self):
dut = FPDIVMuxInOut(16, 4)
+ # don't forget to initialize opcode; don't use magic numbers
+ opcode = int(DivPipeCoreOperation.SqrtRem)
runfp(dut, 16, "test_fpsqrt_pipe_fp16", Float16, sqrt,
- single_op=True, opcode=1, n_vals=100)
+ single_op=True, opcode=opcode, n_vals=100)
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)
runfp(dut, 32, "test_fpsqrt_pipe_fp32", Float32, sqrt,
- single_op=True, opcode=1, n_vals=100)
+ single_op=True, opcode=opcode, n_vals=100)
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)
runfp(dut, 64, "test_fpsqrt_pipe_fp64", Float64, sqrt,
- single_op=True, opcode=1, n_vals=100)
+ single_op=True, opcode=opcode, n_vals=100)
if __name__ == '__main__':