From e699c535083d5034e70a20b59ed3c2a95e6236f2 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Mon, 8 Jul 2019 07:17:46 +0100 Subject: [PATCH] add create, inf, nan and zero to unit test code --- src/ieee754/fpcommon/test/unit_test_double.py | 12 ++++++++++++ src/ieee754/fpcommon/test/unit_test_half.py | 12 ++++++++++++ 2 files changed, 24 insertions(+) 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) -- 2.30.2