From: Luke Kenneth Casson Leighton Date: Mon, 8 Jul 2019 06:17:46 +0000 (+0100) Subject: add create, inf, nan and zero to unit test code X-Git-Tag: ls180-24jan2020~884 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e699c535083d5034e70a20b59ed3c2a95e6236f2;p=ieee754fpu.git add create, inf, nan and zero to unit test code --- diff --git a/src/ieee754/fpcommon/test/unit_test_double.py b/src/ieee754/fpcommon/test/unit_test_double.py index ac7ab7b6..bfa949dc 100644 --- a/src/ieee754/fpcommon/test/unit_test_double.py +++ b/src/ieee754/fpcommon/test/unit_test_double.py @@ -33,6 +33,18 @@ def match(x, y): (x == y) ) +def create(s, e, x): + return (s<<63) | ((e+1023) << 52) | m + +def inf(s): + return create(s, 1024, 0) + +def nan(s): + return create(s, 1024, 1<<52) + +def zero(s): + return s<<63 + def get_case(dut, a, b): yield dut.in_a.v.eq(a) yield dut.in_a.stb.eq(1) diff --git a/src/ieee754/fpcommon/test/unit_test_half.py b/src/ieee754/fpcommon/test/unit_test_half.py index 50c9c24e..9f640846 100644 --- a/src/ieee754/fpcommon/test/unit_test_half.py +++ b/src/ieee754/fpcommon/test/unit_test_half.py @@ -33,6 +33,18 @@ def match(x, y): (x == y) ) +def create(s, e, x): + return (s<<15) | ((e+15) << 11) | m + +def inf(s): + return create(s, 16, 0) + +def nan(s): + return create(s, 16, 1<<11) + +def zero(s): + return s<<15 + def get_case(dut, a, b): yield dut.in_a.v.eq(a) yield dut.in_a.stb.eq(1)