From ff31c39db52d051b86e03ef2c806ccf4699ffdb0 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Mon, 8 Jul 2019 12:50:59 +0100 Subject: [PATCH] add fp64 mul unit test --- src/ieee754/fpcommon/test/unit_test_double.py | 2 +- src/ieee754/fpmul/test/mul_data64.py | 7 +++++++ src/ieee754/fpmul/test/test_fpmul_pipe_64.py | 20 +++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/ieee754/fpmul/test/mul_data64.py create mode 100644 src/ieee754/fpmul/test/test_fpmul_pipe_64.py diff --git a/src/ieee754/fpcommon/test/unit_test_double.py b/src/ieee754/fpcommon/test/unit_test_double.py index 56cb8018..2714273e 100644 --- a/src/ieee754/fpcommon/test/unit_test_double.py +++ b/src/ieee754/fpcommon/test/unit_test_double.py @@ -13,7 +13,7 @@ def get_exponent(x): return ((x & 0x7ff0000000000000) >> 52) - 1023 def set_exponent(x, e): - return (x & ~0x7ff0000000000000) | ((e+1023) << 23) + return (x & ~0x7ff0000000000000) | ((e+1023) << 52) def get_sign(x): return ((x & 0x8000000000000000) >> 63) diff --git a/src/ieee754/fpmul/test/mul_data64.py b/src/ieee754/fpmul/test/mul_data64.py new file mode 100644 index 00000000..3049477a --- /dev/null +++ b/src/ieee754/fpmul/test/mul_data64.py @@ -0,0 +1,7 @@ +def regressions(): + yield 0xff80000000000000, 0x7f80000000000000 + yield 0x3351099a0528e138, 0xd651a9a9986af2b5 + #yield 0x80000003ff800000, 0x4f0365445543ae3f + #yield 0x0004e1b1e94ef100, 0x42e1b4e00b65f134 + #yield 0x80000003ff800000, 0xd249a98a4b9a6950 + diff --git a/src/ieee754/fpmul/test/test_fpmul_pipe_64.py b/src/ieee754/fpmul/test/test_fpmul_pipe_64.py new file mode 100644 index 00000000..5670737a --- /dev/null +++ b/src/ieee754/fpmul/test/test_fpmul_pipe_64.py @@ -0,0 +1,20 @@ +""" test of FPMULMuxInOut +""" + +from ieee754.fpmul.pipeline import (FPMULMuxInOut,) +from ieee754.fpcommon.test.case_gen import run_pipe_fp +from ieee754.fpcommon.test import unit_test_double +from ieee754.fpmul.test.mul_data64 import regressions + +from sfpy import Float64 +from operator import mul + + +def test_pipe_fp64(): + dut = FPMULMuxInOut(64, 4) + run_pipe_fp(dut, 64, "mul", unit_test_double, Float64, + regressions, mul, 10) + + +if __name__ == '__main__': + test_pipe_fp64() -- 2.30.2