add rudimentary sv.setvl unit test to just check that the syntax
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 12 Sep 2022 15:26:28 +0000 (16:26 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 12 Sep 2022 15:26:28 +0000 (16:26 +0100)
is correct.  going beyond RT=0..31 currently fails

src/openpower/decoder/isa/caller.py
src/openpower/decoder/isa/test_caller_setvl.py

index 757527c4c91cc6312cd45450b0927519e8c91255..9b1ba07fc10f0bd50c40212e3d1b700d11ebb03a 100644 (file)
@@ -363,7 +363,7 @@ def get_pdecode_idx_in(dec2, name):
     log("get_pdecode_idx_in FRC in3", name, in3_sel, In3Sel.FRC.value,
         in3, in3_isvec)
     # identify which regnames map to in1/2/3
-    if name == 'RA':
+    if name == 'RA' or name == 'RA_OR_ZERO':
         if (in1_sel == In1Sel.RA.value or
                 (in1_sel == In1Sel.RA_OR_ZERO.value and in1 != 0)):
             return in1, in1_isvec
@@ -470,6 +470,8 @@ def get_pdecode_idx_out(dec2, name):
             dec2.dec.RT)
         if out_sel == OutSel.RT.value:
             return out, o_isvec
+        if out_sel == OutSel.RT_OR_ZERO.value and out != 0:
+            return out, o_isvec
     elif name == 'RT_OR_ZERO':
         log("get_pdecode_idx_out", out_sel, OutSel.RT.value,
             OutSel.RT_OR_ZERO.value, out, o_isvec,
index 0f25218bc1a7fd4def52b465d47441bd3d079711..542e652bb909b9d13eff3c2d752a96b859ffcbcc 100644 (file)
@@ -262,6 +262,43 @@ class DecoderTestCase(FHDLTestCase):
             self.assertEqual(CR0[CRFields.GT], 1)
             self.assertEqual(CR0[CRFields.SO], 1)
 
+    def test_sv_sv_setvl(self):
+        """test sv.setvl instruction works.  WARNING, going beyond
+        RT=0..31 does not work, bug in PowerDecoder2 / ISACaller,
+        related to RT_OR_ZERO and to simplev.mdwn pseudocode having
+        _RT not be EXTRA-extended properly
+        """
+        lst = SVP64Asm(["sv.setvl 8, 31, 10, 0, 1, 1", # setvl into RT=8
+                        ])
+        lst = list(lst)
+
+        # SVSTATE (in this case, VL=4) which is going to get erased by setvl
+        svstate = SVP64State()
+        svstate.vl = 4 # VL
+        svstate.maxvl = 4 # MAXVL
+        print ("SVSTATE", bin(svstate.asint()))
+
+        initial_regs = [0] * 64
+        initial_regs[31] = 200
+
+        with Program(lst, bigendian=False) as program:
+            sim = self.run_tst_program(program, initial_regs=initial_regs,
+                                                svstate=svstate)
+            print ("SVSTATE after", bin(sim.svstate.asint()))
+            print ("        vl", bin(sim.svstate.vl))
+            print ("        mvl", bin(sim.svstate.maxvl))
+            print ("    srcstep", bin(sim.svstate.srcstep))
+            print ("    dststep", bin(sim.svstate.dststep))
+            print ("     vfirst", bin(sim.svstate.vfirst))
+            self.assertEqual(sim.svstate.vl, 10)
+            self.assertEqual(sim.svstate.maxvl, 10)
+            self.assertEqual(sim.svstate.srcstep, 0)
+            self.assertEqual(sim.svstate.dststep, 0)
+            self.assertEqual(sim.svstate.vfirst, 0)
+            print("      gpr31", sim.gpr(31))
+            print("      gpr8", sim.gpr(8))
+            self.assertEqual(sim.gpr(8), SelectableInt(10, 64))
+
     def test_svstep_1(self):
         lst = SVP64Asm(["setvl 0, 0, 10, 1, 1, 1", # actual setvl (VF mode)
                         "setvl 0, 0, 1, 1, 0, 0", # svstep