sigh, update setvl tests, to spec, and ISACaller
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 26 Aug 2022 15:02:18 +0000 (16:02 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 26 Aug 2022 15:02:18 +0000 (16:02 +0100)
https://libre-soc.org/openpower/sv/setvl/
see Rc=1 section: it is possible to have Rc=1, RT=0, RA!=0 which
means "set VL but do not set RT" which *still* requires that Rc=1
be updated - not from RT but from VL

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

index b19e3af6046b6ca61b48d61a8a07036217770dd3..7d60e90111358507df333a9b8716fec265a0b8fd 100644 (file)
@@ -29,7 +29,7 @@ Pseudo-code:
     if (vf & (¬vs) & ¬(ms)) = 1 then
         step <- SVSTATE_NEXT(SVi, 0b0)
         if _RT != 0 then
-           RT <- [0]*57 || step
+           GPR(_RT) <- [0]*57 || step
     else
         overflow <- 0b0
         VLimm <- SVi + 1
@@ -56,7 +56,7 @@ Pseudo-code:
         SVSTATE[0:6] <- MVL
         SVSTATE[7:13] <- VL
         if _RT != 0 then
-           RT <- [0]*57 || VL
+           GPR(_RT) <- [0]*57 || VL
         if ((¬vs) & ¬(ms)) = 0 then
             # set requested Vertical-First mode, clear persist
             SVSTATE[63] <- vf
index bb928aba1c5e5f21a1c6fe6a692ee5fe12fbb758..58d2dc3f532fb4dedfe0a928608c814df5877c96 100644 (file)
@@ -1440,7 +1440,12 @@ class ISACaller(ISACallerHelper, ISAFPHelpers):
                 rc_en = yield self.dec2.e.do.rc.rc
         if rc_en and ins_name not in ['svstep']:
             regnum, is_vec = yield from get_pdecode_cr_out(self.dec2, "CR0")
-            self.handle_comparison(results, regnum, overflow)
+            cmps = results
+            # hang on... for `setvl` actually you want to test SVSTATE.VL
+            if ins_name == 'setvl':
+                vl = results[0].vl
+                cmps = (SelectableInt(vl, 64), overflow,)
+            self.handle_comparison(cmps, regnum, overflow)
 
         # any modified return results?
         if info.write_regs:
index 3b2097cfc3bc45c9db31ed70e8aa9475ec7e0fa9..c6ddffcd912870279740e24280dd9c2d791b04c3 100644 (file)
@@ -220,6 +220,48 @@ class DecoderTestCase(FHDLTestCase):
             self.assertEqual(CR0[CRFields.GT], 1)
             self.assertEqual(CR0[CRFields.SO], 0)
 
+    def test_5_setvl_rt0_rc1(self):
+        """odd one. Rc=1, RT=0, RA!=0, so RT does not get set, but VL does.
+        confirms that when Rc=1 and RT is unmodified that CR0 still is updated
+        """
+        lst = SVP64Asm(["setvl. 0, 4, 5, 0, 1, 1",
+                        ])
+        lst = list(lst)
+
+        # SVSTATE (in this case, MAXVL=5) which is going to get erased by setvl
+        # r4 (RA) is 4. and Rc=1. therefore, CR0 should be set to GT
+        svstate = SVP64State()
+        svstate.maxvl = 5 # MAXVL
+        print ("SVSTATE", bin(svstate.asint()))
+
+        initial_regs = [0] * 32
+        initial_regs[4] = 127 # overlimit, should set CR0.SO=1, and CR0.GT=1
+
+        with Program(lst, bigendian=False) as program:
+            sim = self.run_tst_program(program, svstate=svstate,
+                                       initial_regs=initial_regs)
+            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, 5)
+            self.assertEqual(sim.svstate.maxvl, 5)
+            self.assertEqual(sim.svstate.srcstep, 0)
+            self.assertEqual(sim.svstate.dststep, 0)
+            self.assertEqual(sim.svstate.vfirst, 0)
+            print("      gpr0", sim.gpr(0))
+            self.assertEqual(sim.gpr(0), SelectableInt(0, 64)) # unmodified
+            print("      gpr4", sim.gpr(4))
+            self.assertEqual(sim.gpr(4), SelectableInt(127, 64)) # unmodified
+            CR0 = sim.crl[0]
+            print("      CR0", bin(CR0.get_range().value))
+            self.assertEqual(CR0[CRFields.EQ], 0)
+            self.assertEqual(CR0[CRFields.LT], 0)
+            self.assertEqual(CR0[CRFields.GT], 1)
+            self.assertEqual(CR0[CRFields.SO], 1)
+
     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