From 7d494e2b0299f26bbc5898ef6279138cef64bb72 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Fri, 21 May 2021 18:34:42 +0100 Subject: [PATCH] add demo --load option to pypowersim --- src/openpower/decoder/isa/mem.py | 11 ++++++- src/openpower/decoder/isa/pypowersim.py | 44 +++++++++++++++++++++---- src/test/basic_pypowersim/Makefile | 6 ++-- 3 files changed, 52 insertions(+), 9 deletions(-) diff --git a/src/openpower/decoder/isa/mem.py b/src/openpower/decoder/isa/mem.py index 64309477..008370a9 100644 --- a/src/openpower/decoder/isa/mem.py +++ b/src/openpower/decoder/isa/mem.py @@ -132,4 +132,13 @@ class Mem: print("memassign", addr, sz, val) self.st(addr.value, val.value, sz, swap=False) - + def dump(self, printout=True): + keys = list(self.mem.keys()) + keys.sort() + res = [] + for k in keys: + res.append(((k*8), self.mem[k])) + if not printout: + continue + print ("%016x: %016x" % ((k*8) & 0xffffffffffffffff, self.mem[k])) + return res diff --git a/src/openpower/decoder/isa/pypowersim.py b/src/openpower/decoder/isa/pypowersim.py index 1c631630..83831a66 100644 --- a/src/openpower/decoder/isa/pypowersim.py +++ b/src/openpower/decoder/isa/pypowersim.py @@ -2,6 +2,7 @@ from nmigen import Module, Signal from nmigen.back.pysim import Simulator, Delay, Settle import sys import getopt +import struct from openpower.decoder.power_decoder import create_pdecode from openpower.decoder.power_decoder2 import (PowerDecode2) from openpower.simulator.program import Program @@ -10,6 +11,21 @@ from openpower.decoder.orderedset import OrderedSet from openpower.decoder.isa.all import ISA +def read_data(fname, offset=0): + """reads binary data and returns a dictionary of address: contents, + each entry is 8 bytes. input file *must* be 8-byte-aligned + """ + res = {} + with open(fname, "rb") as f: + while True: + b = f.read(8) + print (repr(b)) + if not b: + return res + res[offset] = struct.unpack(' test.bin + echo -n -e \\0060\\0000\\0061\\0000 >> test.bin + pypowersim --load test.bin:0 -g gpr.list -i kernel.bin clean: rm *.o *.elf *.bin -kernel.elf: square.o +kernel.elf: test.o $(TOOLCHAIN)-ld $^ -EL -o $@ -T memmap kernel.bin: kernel.elf -- 2.30.2