attempting to get test_trap_sim working, seems to switch mode
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 12 Jul 2020 21:08:45 +0000 (22:08 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 12 Jul 2020 21:08:45 +0000 (22:08 +0100)
src/soc/simulator/qemu.py
src/soc/simulator/test_trap_sim.py

index 747e4a941b23100afe22aae65b4439c708bec201..41ef169096ead466fb67de0efcc7393cc1f9c056 100644 (file)
@@ -11,6 +11,11 @@ launch_args_le = ['qemu-system-ppc64le',
                '-nographic',
                '-s', '-S']
 
+def swap_order(x, nbytes):
+    x = x.to_bytes(nbytes, byteorder='little')
+    x = int.from_bytes(x, byteorder='big', signed=False)
+    return x
+
 
 class QemuController:
     def __init__(self, kernel, bigendian):
@@ -22,6 +27,7 @@ class QemuController:
                                            stdout=subprocess.PIPE,
                                            stdin=subprocess.PIPE)
         self.gdb = GdbController(gdb_path='powerpc64-linux-gnu-gdb')
+        self.bigendian = bigendian
 
     def __enter__(self):
         return self
@@ -79,7 +85,9 @@ class QemuController:
         for x in res:
             if(x["type"]=="result"):
                 assert 'register-values' in x['payload']
-                return int(x['payload']['register-values'][0]['value'], 0)
+                res = int(x['payload']['register-values'][0]['value'], 0)
+                return res
+                #return swap_order(res, 8)
         return None
 
     # TODO: use -data-list-register-names instead of hardcoding the values
index b69561e3808fa9613de9d301368f29ab5422629a..dfb4faa277281f67018da30e3460f82d5175abc6 100644 (file)
@@ -14,7 +14,7 @@ from soc.simulator.qemu import run_program
 from soc.decoder.isa.all import ISA
 from soc.fu.test.common import TestCase
 from soc.simulator.test_sim import DecoderBase
-
+from soc.config.endian import bigendian
 
 
 class TrapSimTestCases(FHDLTestCase):
@@ -28,14 +28,14 @@ class TrapSimTestCases(FHDLTestCase):
         lst = ["addi 1, 0, 0x5678",
                "twi  4, 1, 0x5677",
                ]
-        with Program(lst) as program:
+        with Program(lst, bigendian) as program:
             self.run_tst_program(program, [1])
 
     def test_1_twi_eq(self):
         lst = ["addi 1, 0, 0x5678",
                "twi  4, 1, 0x5678",
                ]
-        with Program(lst) as program:
+        with Program(lst, bigendian) as program:
             self.run_tst_program(program, [1])
 
     def run_tst_program(self, prog, initial_regs=None, initial_sprs=None,