From: Luke Kenneth Casson Leighton Date: Mon, 8 Jul 2019 11:43:08 +0000 (+0100) Subject: add fpmul tests X-Git-Tag: ls180-24jan2020~871 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d51b614a773055c7ca319856a458e955ca594b7b;p=ieee754fpu.git add fpmul tests --- diff --git a/src/ieee754/fpcommon/test/case_gen.py b/src/ieee754/fpcommon/test/case_gen.py index d667f340..26b6cd62 100644 --- a/src/ieee754/fpcommon/test/case_gen.py +++ b/src/ieee754/fpcommon/test/case_gen.py @@ -103,6 +103,7 @@ class PipeFPCase: def run_regressions(self, regressions_fn): vals = repeat(self.dut.num_rows, regressions_fn()) + print ("regressions", vals) tname = "test_fp%s_pipe_fp%d_regressions" % (self.name, self.width) runfp(self.dut, self.width, tname, self.fmod, self.fpfn, vals=vals) diff --git a/src/ieee754/fpmul/specialcases.py b/src/ieee754/fpmul/specialcases.py index c84eed71..cd457018 100644 --- a/src/ieee754/fpmul/specialcases.py +++ b/src/ieee754/fpmul/specialcases.py @@ -75,7 +75,7 @@ class FPMulSpecialCasesMod(Elaboratable): m.d.comb += self.o.z.inf(sabx) # b is zero return NaN with m.If(b1.is_zero): - m.d.comb += self.o.z.nan(1) + m.d.comb += self.o.z.nan(0) # if b is inf return inf (or NaN) with m.Elif(b1.is_inf): @@ -83,7 +83,7 @@ class FPMulSpecialCasesMod(Elaboratable): m.d.comb += self.o.z.inf(sabx) # a is zero return NaN with m.If(a1.is_zero): - m.d.comb += self.o.z.nan(1) + m.d.comb += self.o.z.nan(0) # if a is zero or b zero return signed-a/b with m.Elif(obz): diff --git a/src/ieee754/fpmul/test/mul_data16.py b/src/ieee754/fpmul/test/mul_data16.py index fb13fbb9..151c8d9a 100644 --- a/src/ieee754/fpmul/test/mul_data16.py +++ b/src/ieee754/fpmul/test/mul_data16.py @@ -1,5 +1,6 @@ def regressions(): yield 0x0000, 0xfc00 + yield 0xfc00, 0x0000 yield 0xe7bb, 0x81ce yield 0xe225, 0x8181 yield 0x0201, 0x4901 diff --git a/src/ieee754/fpmul/test/mul_data32.py b/src/ieee754/fpmul/test/mul_data32.py new file mode 100644 index 00000000..88dbbdfc --- /dev/null +++ b/src/ieee754/fpmul/test/mul_data32.py @@ -0,0 +1,12 @@ +def regressions(): + yield 0x40000000, 0x40000000 + yield 0x41400000, 0x40A00000 + yield 0xffcaeefa, 0x3f803262 + yield 0xae430313, 0x901c3214 + yield 0x0a4504d7, 0xb4658540 + yield 0xba57711a, 0xee1818c5 + yield 0xbf9b1e94, 0xc038ed3a + yield 0x34082401, 0xb328cd45 + yield 0x05e8ef81, 0x114f3db + yield 0x5c75da81, 0x2f642a39 + yield 0x0002b017, 0xff3807ab diff --git a/src/ieee754/fpmul/test/test_fpmul_pipe_16.py b/src/ieee754/fpmul/test/test_fpmul_pipe_16.py new file mode 100644 index 00000000..66d10901 --- /dev/null +++ b/src/ieee754/fpmul/test/test_fpmul_pipe_16.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_half +from ieee754.fpmul.test.mul_data16 import regressions + +from sfpy import Float16 +from operator import mul + + +def test_pipe_fp16(): + dut = FPMULMuxInOut(16, 4) + run_pipe_fp(dut, 16, "mul", unit_test_half, Float16, + regressions, mul, 10) + + +if __name__ == '__main__': + test_pipe_fp16() diff --git a/src/ieee754/fpmul/test/test_fpmul_pipe_32.py b/src/ieee754/fpmul/test/test_fpmul_pipe_32.py new file mode 100644 index 00000000..cebf97ff --- /dev/null +++ b/src/ieee754/fpmul/test/test_fpmul_pipe_32.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_single +from ieee754.fpmul.test.mul_data32 import regressions + +from sfpy import Float32 +from operator import mul + + +def test_pipe_fp32(): + dut = FPMULMuxInOut(32, 4) + run_pipe_fp(dut, 32, "mul", unit_test_single, Float32, + regressions, mul, 10) + + +if __name__ == '__main__': + test_pipe_fp32()