add setting of qemu GPRs/FPRs in pypowersim
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 27 May 2021 10:28:38 +0000 (11:28 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 27 May 2021 10:28:38 +0000 (11:28 +0100)
src/openpower/decoder/isa/pypowersim.py
src/openpower/simulator/qemu.py

index 6f561309c75f6e6d5a92da2a140b3f2cff0aaf0c..9bdec27b07e6e0dc429c722025760e6b86ce89f4 100644 (file)
@@ -132,6 +132,13 @@ def run_tst(args, generator, qemu,
         qemu = run_program(generator, initial_mem=mem, 
                 bigendian=False, start_addr=initial_pc,
                 continuous_run=False)
+        # TODO: SPRs.  how??
+        if initial_regs is not None:
+            for reg, val in enumerate(initial_regs):
+                qemu.set_gpr(reg, val)
+        if initial_fprs is not None:
+            for fpr, val in enumerate(initial_fprs):
+                qemu.set_fpr(fpr, val)
 
     m = Module()
     comb = m.d.comb
index 830851e3dae878f80506780ca08df744e68e87a2..cdbee4f6e53fc0770acea9c712fe5861ab0f4b33 100644 (file)
@@ -125,11 +125,11 @@ class QemuController:
 
     def set_gpr(self, reg, val):
         self._rcache_trash('x %d' % reg)
-        self.gdb_eval('$r%d=%d' % (reg, pc))
+        self.gdb_eval('$r%d=%d' % (reg, val))
 
     def set_fpr(self, reg, val):
         self._rcache_trash('x %d' % (reg+32))
-        self.gdb_eval('$fp%d=%d' % (reg, pc))
+        self.gdb_eval('$fp%d=%d' % (reg, val))
 
     def set_pc(self, pc):
         self._rcache_trash('x 64')