From: Luke Kenneth Casson Leighton Date: Thu, 27 May 2021 11:15:19 +0000 (+0100) Subject: get full qemu list of registers, on each cycle, saves time X-Git-Tag: xlen-bcd~532 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=284d8f33d0bf2888c30201cfc52e3d1bd9cb9a35;p=openpower-isa.git get full qemu list of registers, on each cycle, saves time --- diff --git a/src/openpower/decoder/isa/pypowersim.py b/src/openpower/decoder/isa/pypowersim.py index 788867ca..5cd9353a 100644 --- a/src/openpower/decoder/isa/pypowersim.py +++ b/src/openpower/decoder/isa/pypowersim.py @@ -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 diff --git a/src/openpower/simulator/qemu.py b/src/openpower/simulator/qemu.py index cdbee4f6..04a338d1 100644 --- a/src/openpower/simulator/qemu.py +++ b/src/openpower/simulator/qemu.py @@ -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,