From 8a4c0adc73233c47c90fcca15d43904a92f795b0 Mon Sep 17 00:00:00 2001 From: Cole Poirier Date: Wed, 5 Aug 2020 14:58:07 -0700 Subject: [PATCH] Add test case_all_rb_close_to_ov --- src/soc/fu/mul/test/test_pipe_caller.py | 56 ++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 6 deletions(-) diff --git a/src/soc/fu/mul/test/test_pipe_caller.py b/src/soc/fu/mul/test/test_pipe_caller.py index 18db8e76..c7e18e3c 100644 --- a/src/soc/fu/mul/test/test_pipe_caller.py +++ b/src/soc/fu/mul/test/test_pipe_caller.py @@ -161,7 +161,7 @@ class MulTestCase(TestAccumulatorBase): self.add_case(Program(lst, bigendian), initial_regs) def case_all(self): - instrs = [,"mulhw", + instrs = ["mulhw", "mulhw.","mullw", "mullw.","mullwo", "mullwo.","mulhwu", @@ -171,11 +171,6 @@ class MulTestCase(TestAccumulatorBase): "mulhd.","mulhdu", "mulhdu."] -# TODO add special test case for "mulli" - -# TODO add test case for these 3 operand cases -# ,"maddhd","maddhdu","maddld" - test_values = [ 0x0, 0x1, @@ -246,6 +241,55 @@ class MulTestCase(TestAccumulatorBase): with Program(l, bigendian) as prog: self.add_case(prog, initial_regs) + def case_all_rb_close_to_ov(self): + instrs = ["mulhw", + "mulhw.","mullw", + "mullw.","mullwo", + "mullwo.","mulhwu", + "mulhwu.","mulld", + "mulld.","mulldo", + "mulldo.","mulhd", + "mulhd.","mulhdu", + "mulhdu."] + + test_values = [ + 0x0, + 0x1, + 0x2, + 0xFFFF_FFFF_FFFF_FFFF, + 0xFFFF_FFFF_FFFF_FFFE, + 0x7FFF_FFFF_FFFF_FFFF, + 0x8000_0000_0000_0000, + 0x1234_5678_0000_0000, + 0x1234_5678_8000_0000, + 0x1234_5678_FFFF_FFFF, + 0x1234_5678_7FFF_FFFF, + 0xffffffff, + 0x7fffffff, + 0x80000000, + 0xfffffffe, + 0xfffffffd + ] + + x = 0x7fffffff + random.randint(0,1) + ra = random.randint(0, (1 << 64)-1) + rb = x // ra + + for instr in instrs: + l = [f"{instr} 3, 1, 2"] + initial_regs = [0] * 32 + initial_regs[1] = ra + initial_regs[2] = rb + # use "with" so as to close the files used + with Program(l, bigendian) as prog: + self.add_case(prog, initial_regs) + +# TODO add special test case for "mulli" + +# TODO add test case for these 3 operand cases (madd +# needs to be implemented) +# "maddhd","maddhdu","maddld" + def case_ilang(self): pspec = MulPipeSpec(id_wid=2) alu = MulBasePipe(pspec) -- 2.30.2