convert mul test to use Power Decode subset
[soc.git] / src / soc / fu / mul / test / test_pipe_caller.py
index 3033e2a5f596ef5231b2a55ba1e77a6a582be887..1c2ad912e3e7904a5bb9f42591a2cf1607915e6a 100644 (file)
@@ -160,149 +160,12 @@ class MulTestCase(TestAccumulatorBase):
             initial_regs[2] = random.randint(0, (1 << 64)-1)
             self.add_case(Program(lst, bigendian), initial_regs)
 
-    def case_all(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
-        ]
-
-        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
-                    # use "with" so as to close the files used
-                    with Program(l, bigendian) as prog:
-                        self.add_case(prog, initial_regs)
-
-    def case_all_rb_randint(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
-        ]
-
-        for instr in instrs:
-            l = [f"{instr} 3, 1, 2"]
-            for ra in test_values:
-                initial_regs = [0] * 32
-                initial_regs[1] = ra
-                initial_regs[2] = random.randint(0, (1 << 64)-1)
-                # use "with" so as to close the files used
-                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
-        ]
-
-        for instr in instrs:
-            for i in range(20):
-                x = 0x7fffffff + random.randint(0, 1)
-                ra = random.randint(0, (1 << 32)-1)
-                rb = x // ra
-
-                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)
-
-    def case_mulli(self):
-
-        test_values = [-32768, -32767, -32766, -2, -1, 0, 1, 2, 32766, 32767,
-                       random.randint(-1 << 15, (1 << 15)-1), random.randint(
-                       -1 << 15, (1 << 15) - 1), random.randint(-1 << 15,
-                       (1 << 15)-1), random.randint(-1 << 15, (1 << 15)-1),
-                       random.randint(-1 << 15, (1 << 15)-1)
-                      ]
-
-        l = ["mulli 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
-                # use "with" so as to close the files used
-                with Program(l, bigendian) as prog:
-                    self.add_case(prog, initial_regs)
+    def case_0_mullhw_regression(self):
+        lst = [f"mulhwu 3, 1, 2"]
+        initial_regs = [0] * 32
+        initial_regs[1] = 0x4000000000000000
+        initial_regs[2] = 0x0000000000000002
+        self.add_case(Program(lst, bigendian), initial_regs)
 
 # TODO add test case for these 3 operand cases (madd
 # needs to be implemented)
@@ -326,9 +189,11 @@ class TestRunner(unittest.TestCase):
         comb = m.d.comb
         instruction = Signal(32)
 
-        pdecode = create_pdecode()
+        fn_name = "MUL"
+        opkls = MulPipeSpec.opsubsetkls
 
-        m.submodules.pdecode2 = pdecode2 = PowerDecode2(pdecode)
+        m.submodules.pdecode2 = pdecode2 = PowerDecode2(None, opkls, fn_name)
+        pdecode = pdecode2.dec
 
         pspec = MulPipeSpec(id_wid=2)
         m.submodules.alu = alu = MulBasePipe(pspec)
@@ -398,7 +263,7 @@ class TestRunner(unittest.TestCase):
 
     def check_alu_outputs(self, alu, dec2, sim, code):
 
-        rc = yield dec2.e.do.rc.data
+        rc = yield dec2.e.do.rc.rc
         cridx_ok = yield dec2.e.write_cr.ok
         cridx = yield dec2.e.write_cr.data