move SPR set to qemu.py
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 27 May 2021 17:43:43 +0000 (18:43 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 27 May 2021 17:43:43 +0000 (18:43 +0100)
src/openpower/decoder/isa/pypowersim.py
src/openpower/simulator/qemu.py

index 159c7c56931a1449f7509cd30b3e338e6bf6e59a..92a019ef8856a00504f8bd227c491b6303943e04 100644 (file)
@@ -96,7 +96,7 @@ def qemu_register_compare(sim, q, regs, fprs):
     sim_lr = sim.spr['LR'].value
     print("qemu pc", hex(qpc))
     print("qemu cr", hex(qcr))
-    print("qemu lr", bin(qlr))
+    print("qemu lr", hex(qlr))
     print("qemu xer", bin(qxer))
     print("sim nia", hex(sim.pc.NIA.value))
     print("sim pc", hex(sim.pc.CIA.value))
index 2f77b9fc6879d223611c80e9797c24d0e2dfeaa5..8b8bc22bed8ca747d514f1d7b03ebaee0fec83f6 100644 (file)
@@ -247,14 +247,6 @@ def run_program(program, initial_mem=None, extra_break_addr=None,
     # delete the previous breakpoint so loops don't screw things up
     q.delete_breakpoint()
 
-    # can't do many of these - lr, ctr, etc. etc. later, just LR for now
-    if initial_sprs:
-        lr = initial_sprs.get('lr', None)
-        if lr is None:
-            lr = initial_sprs.get('LR', None)
-        if lr is not None:
-            q.set_lr(lr)
-
     # allow run to end
     q.break_address(start_addr + program.size())
     # or to trap (not ideal)
@@ -262,12 +254,26 @@ def run_program(program, initial_mem=None, extra_break_addr=None,
     # or to alternative (absolute) address)
     if extra_break_addr is not None:
         q.break_address(extra_break_addr)
-    if continuous_run:
-        q.gdb_continue()
+    # set endian before SPR set
     q.set_endian(bigendian)
+
+    # can't do many of these - lr, ctr, etc. etc. later, just LR for now
+    if initial_sprs:
+        lr = initial_sprs.get('lr', None)
+        if lr is None:
+            lr = initial_sprs.get('LR', None)
+        if lr is not None:
+            q.set_lr(lr)
+
+    # disassemble and dump 
     d = q.disasm(start_addr, start_addr + program.size())
     for line in d:
         print ("qemu disasm", line)
+
+    # start running
+    if continuous_run:
+        q.gdb_continue()
+
     return q