Add test case_all_rb_close_to_ov
authorCole Poirier <colepoirier@gmail.com>
Wed, 5 Aug 2020 21:58:07 +0000 (14:58 -0700)
committerCole Poirier <colepoirier@gmail.com>
Wed, 5 Aug 2020 21:58:07 +0000 (14:58 -0700)
src/soc/fu/mul/test/test_pipe_caller.py

index 18db8e76357481bdd7cb5e22a827a1c80d8de1ab..c7e18e3c5c8fa26c1f4d8f1a7247c5b513d4cb37 100644 (file)
@@ -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)