add all div* and mod* instructions to test_pipe_caller
authorJacob Lifshay <programmerjake@gmail.com>
Thu, 23 Jul 2020 00:42:37 +0000 (17:42 -0700)
committerJacob Lifshay <programmerjake@gmail.com>
Thu, 23 Jul 2020 00:42:37 +0000 (17:42 -0700)
src/soc/fu/div/test/test_pipe_caller.py

index e971492..a6ee550 100644 (file)
@@ -164,17 +164,7 @@ class DivTestCases:
         initial_regs[2] = 0xffffffff
         self.run_test_program(Program(lst, bigendian), initial_regs)
 
-    def tst_rand_divw(self):
-        insns = ["divw", "divw.", "divwo", "divwo."]
-        for i in range(40):
-            choice = random.choice(insns)
-            lst = [f"{choice} 3, 1, 2"]
-            initial_regs = [0] * 32
-            initial_regs[1] = log_rand(32)
-            initial_regs[2] = log_rand(32)
-            self.run_test_program(Program(lst, bigendian), initial_regs)
-
-    def test_divwuo_regression_1(self):
+    def tst_divwuo_regression_1(self):
         lst = ["divwuo. 3, 1, 2"]
         initial_regs = [0] * 32
         initial_regs[1] = 0x7591a398c4e32b68
@@ -188,6 +178,39 @@ class DivTestCases:
         initial_regs[2] = 0x2
         self.run_test_program(Program(lst, bigendian), initial_regs)
 
+    def test_all(self):
+        instrs = []
+        for width in ("w", "d"):
+            for sign in ("", "u"):
+                for ov in ("", "o"):
+                    for cnd in ("", "."):
+                        instrs += ["div" + width + sign + ov + cnd,
+                                   "div" + width + "e" + sign + ov + cnd]
+            for sign in ("s", "u"):
+                instrs += ["mod" + sign + width]
+        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,
+        ]
+        for instr in instrs:
+            l = [f"{instr} 3, 1, 2"]
+            for ra in test_values:
+                for rb in test_values:
+                    initial_regs = [0] * 32
+                    initial_regs[1] = ra
+                    initial_regs[2] = rb
+                    prog = Program(l, bigendian)
+                    self.run_test_program(prog, initial_regs)
+
     def tst_rand_divwu(self):
         insns = ["divwu", "divwu.", "divwuo", "divwuo."]
         for i in range(40):
@@ -198,6 +221,16 @@ class DivTestCases:
             initial_regs[2] = log_rand(32)
             self.run_test_program(Program(lst, bigendian), initial_regs)
 
+    def tst_rand_divw(self):
+        insns = ["divw", "divw.", "divwo", "divwo."]
+        for i in range(40):
+            choice = random.choice(insns)
+            lst = [f"{choice} 3, 1, 2"]
+            initial_regs = [0] * 32
+            initial_regs[1] = log_rand(32)
+            initial_regs[2] = log_rand(32)
+            self.run_test_program(Program(lst, bigendian), initial_regs)
+
 
 class TestRunner(unittest.TestCase):
     def write_ilang(self, div_pipe_kind):