get full qemu list of registers, on each cycle, saves time
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 27 May 2021 11:15:19 +0000 (12:15 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 27 May 2021 11:15:19 +0000 (12:15 +0100)
src/openpower/decoder/isa/pypowersim.py
src/openpower/simulator/qemu.py

index 788867ca6e8e4838ccb22c9adb2b23073e1a7d6d..5cd9353a80629ea7fe546966b1c44efac210fdf5 100644 (file)
@@ -105,7 +105,7 @@ def qemu_register_compare(sim, qemu, regs, fprs):
         qemu_val = qemu.get_gpr(reg)
         sim_val = sim.gpr(reg).value
         if qemu_val != sim_val:
-            log("expect gpr %d %x got %x" % (gpr, qemu_val, sim_val))
+            log("expect gpr %d %x got %x" % (reg, qemu_val, sim_val))
         #self.assertEqual(qemu_val, sim_val,
         #                 "expect %x got %x" % (qemu_val, sim_val))
     for fpr in fprs:
@@ -141,6 +141,8 @@ def run_tst(args, generator, qemu,
         if initial_fprs is not None:
             for fpr, val in enumerate(initial_fprs):
                 qemu.set_fpr(fpr, val)
+        for reg, val in qemu._get_registers().items():
+            print (reg, val)
 
     m = Module()
     comb = m.d.comb
index cdbee4f6e53fc0770acea9c712fe5861ab0f4b33..04a338d1ef10a169b8f03a260c78d7118715b4cf 100644 (file)
@@ -87,10 +87,27 @@ class QemuController:
                 return res
         return None
 
-    def get_registers(self):
-        return self.gdb.write('-data-list-register-values x')
+    def _get_registers(self):
+        res = self.gdb.write('-data-list-register-values x')
+        self._reg_cache = {}
+        for x in res:
+            if(x["type"] == "result"):
+                assert 'register-values' in x['payload']
+                rlist = x['payload']['register-values']
+                for rdict in rlist:
+                    regnum = int(rdict['number'])
+                    regval = rdict['value']
+                    if regval.startswith("{"): # TODO, VSX
+                        continue
+                    self._reg_cache["x %d" % regnum] = int(regval, 0)
+        return self._reg_cache
 
     def _get_register(self, fmt):
+        if fmt not in self._reg_cache:
+            self._get_registers()
+        return self._reg_cache[fmt] # return cached reg value
+
+    def _get_single_register(self, fmt):
         if fmt in self._reg_cache:
             return self._reg_cache[fmt] # return cached reg value
         res = self.gdb.write('-data-list-register-values '+fmt,