Add test cases for 1<<r3 predication
authorCesar Strauss <cestrauss@gmail.com>
Sat, 10 Apr 2021 19:40:09 +0000 (16:40 -0300)
committerCesar Strauss <cestrauss@gmail.com>
Sat, 10 Apr 2021 19:41:46 +0000 (16:41 -0300)
src/soc/decoder/isa/test_caller_svp64_predication.py

index 5d42083e585144226db7d186b7d428a1f55bfc9a..eed0b79c4c6b2d5f66f4f413df670f974f3acf81 100644 (file)
@@ -449,6 +449,74 @@ class DecoderTestCase(FHDLTestCase):
             sim = self.run_tst_program(program, initial_regs, svstate)
             self._check_regs(sim, expected_regs)
 
+    def test_shift_one_by_r3_dest(self):
+        #   reg num        0 1 2 3 4 5 6 7 8 9 10 11
+        #   src r30=0b100                    N  N  Y
+        #                                          |
+        #                              +-----------+
+        #                              |
+        #   dest r3=1: 1<<r3=0b010   N Y N
+
+        isa = SVP64Asm(['sv.extsb/dm=1<<r3/sm=r30 5.v, 9.v'])
+        lst = list(isa)
+        print("listing", lst)
+
+        # initial values in GPR regfile
+        initial_regs = [0] * 32
+        initial_regs[3] = 1  # dest mask = 1<<r3 = 0b010
+        initial_regs[30] = 0b100  # source mask
+        initial_regs[9] = 0x90   # skipped
+        initial_regs[10] = 0x91  # skipped
+        initial_regs[11] = 0x92  # 3rd bit of r30 is 1
+        # SVSTATE (in this case, VL=3)
+        svstate = SVP64State()
+        svstate.vl[0:7] = 3  # VL
+        svstate.maxvl[0:7] = 3  # MAXVL
+        print("SVSTATE", bin(svstate.spr.asint()))
+        # copy before running
+        expected_regs = deepcopy(initial_regs)
+        expected_regs[5] = 0x0  # skip
+        expected_regs[6] = 0xffff_ffff_ffff_ff92  # r3 is 1, so this is used
+        expected_regs[7] = 0x0  # skip
+
+        with Program(lst, bigendian=False) as program:
+            sim = self.run_tst_program(program, initial_regs, svstate)
+            self._check_regs(sim, expected_regs)
+
+    def test_shift_one_by_r3_source(self):
+        #   reg num        0 1 2 3 4 5 6 7 8 9 10 11
+        #   src r3=2: 1<<r3=0b100            N  N  Y
+        #                                          |
+        #                              +-----------+
+        #                              |
+        #   dest r30=0b010           N Y N
+
+        isa = SVP64Asm(['sv.extsb/sm=1<<r3/dm=r30 5.v, 9.v'])
+        lst = list(isa)
+        print("listing", lst)
+
+        # initial values in GPR regfile
+        initial_regs = [0] * 32
+        initial_regs[3] = 2  # source mask = 1<<r3 = 0b100
+        initial_regs[30] = 0b010  # dest mask
+        initial_regs[9] = 0x90   # skipped
+        initial_regs[10] = 0x91  # skipped
+        initial_regs[11] = 0x92  # r3 is 2, so this will be used
+        # SVSTATE (in this case, VL=3)
+        svstate = SVP64State()
+        svstate.vl[0:7] = 3  # VL
+        svstate.maxvl[0:7] = 3  # MAXVL
+        print("SVSTATE", bin(svstate.spr.asint()))
+        # copy before running
+        expected_regs = deepcopy(initial_regs)
+        expected_regs[5] = 0x0  # skip
+        expected_regs[6] = 0xffff_ffff_ffff_ff92  # 2nd bit of r30 is 1
+        expected_regs[7] = 0x0  # skip
+
+        with Program(lst, bigendian=False) as program:
+            sim = self.run_tst_program(program, initial_regs, svstate)
+            self._check_regs(sim, expected_regs)
+
     def run_tst_program(self, prog, initial_regs=None,
                               svstate=None,
                               initial_cr=0):