From c38f65b414462f20570db2beec17241d0f944d5f Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Mon, 8 Jul 2019 12:19:45 +0100 Subject: [PATCH] add test_add fp16 --- src/ieee754/fpadd/test/add_data16.py | 18 ++++++++++++++++++ src/ieee754/fpadd/test/test_fpadd_pipe_16.py | 20 ++++++++++++++++++++ src/ieee754/fpcommon/test/case_gen.py | 15 +++++++++------ src/ieee754/fpcommon/test/unit_test_half.py | 2 +- 4 files changed, 48 insertions(+), 7 deletions(-) create mode 100644 src/ieee754/fpadd/test/add_data16.py create mode 100644 src/ieee754/fpadd/test/test_fpadd_pipe_16.py diff --git a/src/ieee754/fpadd/test/add_data16.py b/src/ieee754/fpadd/test/add_data16.py new file mode 100644 index 00000000..07653f4a --- /dev/null +++ b/src/ieee754/fpadd/test/add_data16.py @@ -0,0 +1,18 @@ +def regressions(): + + yield 0x7800, 0xff6f + yield 0x0000, 0x7c32 + yield 0x0000, 0x7da9 + yield 0x0000, 0x7ea0 + yield 0x7c9a, 0x8000 + yield 0x7d5e, 0x0000 + yield 0x8000, 0x7c8c + yield 0x8000, 0xfc55 + yield 0x8000, 0x7e1a + + yield 0x8000, 0xfc01 + yield 0xfc00, 0x7c00 + yield 0x8000, 0 + yield 0, 0 + + yield 0x8000, 0 diff --git a/src/ieee754/fpadd/test/test_fpadd_pipe_16.py b/src/ieee754/fpadd/test/test_fpadd_pipe_16.py new file mode 100644 index 00000000..3e6273e3 --- /dev/null +++ b/src/ieee754/fpadd/test/test_fpadd_pipe_16.py @@ -0,0 +1,20 @@ +""" test of FPADDMuxInOut +""" + +from ieee754.fpadd.pipeline import (FPADDMuxInOut,) +from ieee754.fpcommon.test.case_gen import run_pipe_fp +from ieee754.fpcommon.test import unit_test_half +from ieee754.fpadd.test.add_data16 import regressions + +from sfpy import Float16 +from operator import add + + +def test_pipe_fp16(): + dut = FPADDMuxInOut(16, 4) + run_pipe_fp(dut, 16, "add", unit_test_half, Float16, + regressions, add, 10) + + +if __name__ == '__main__': + test_pipe_fp16() diff --git a/src/ieee754/fpcommon/test/case_gen.py b/src/ieee754/fpcommon/test/case_gen.py index 441b093e..5a1661a1 100644 --- a/src/ieee754/fpcommon/test/case_gen.py +++ b/src/ieee754/fpcommon/test/case_gen.py @@ -25,17 +25,20 @@ def replicate(fixed_num, maxcount): else: return fixed_num +def get_rval(width): + mval = (1<