From: Luke Kenneth Casson Leighton Date: Fri, 21 May 2021 14:08:39 +0000 (+0100) Subject: add GPRs to pypowersim demo X-Git-Tag: xlen-bcd~575 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7e6fbc29659b47e42677fac3ceb72e53b4c222ce;p=openpower-isa.git add GPRs to pypowersim demo --- diff --git a/src/openpower/decoder/isa/pypowersim.py b/src/openpower/decoder/isa/pypowersim.py index d4e85585..50d58c07 100644 --- a/src/openpower/decoder/isa/pypowersim.py +++ b/src/openpower/decoder/isa/pypowersim.py @@ -13,11 +13,11 @@ from openpower.decoder.isa.all import ISA def convert_to_num(num): # detect number types if num.isdigit(): - return int(reg) + return int(num) if num.startswith("0b"): - return int(value[2], 2) - if value.startswith("0x"): - return int(value[2], 16) + return int(num[2:], 2) + if num.startswith("0x"): + return int(num[2:], 16) return num @@ -30,8 +30,9 @@ def read_entries(fname, listqty=None): with open(fname) as f: for line in f.readlines(): # split line "x : y" into ["x", "y"], remove spaces - line = map(str.strip, line.strip().split(":")) + line = list(map(str.strip, line.strip().split(":"))) assert len(line) == 2, "regfile line must be formatted 'x : y'" + # check and convert format reg, val = line reg = convert_to_num(reg) val = convert_to_num(val) @@ -129,12 +130,14 @@ def run_simulation(): binaryname = None initial_regs = None + initial_fprs = None + initial_sprs = None lst = None try: - opts, args = getopt.getopt(sys.argv[1:], "i:l:g:f:", + opts, args = getopt.getopt(sys.argv[1:], "i:l:g:f:s:", ["binary", "listing", - "intregs"]) + "intregs", "fpregs", "sprs"]) except: sys.stderr.write("Command-line Error\n") @@ -145,8 +148,12 @@ def run_simulation(): binaryname = arg elif opt in ['-l', '--listing']: lst = arg - elif opt in ['g', '--intregs']: + elif opt in ['-g', '--intregs']: initial_regs = read_entries(arg, 32) + elif opt in ['-f', '--fpregs']: + initial_fprs = read_entries(arg, 32) + elif opt in ['-s', '--sprs']: + initial_sprs = read_entries(arg, 32) if binaryname is None and lst is None: sys.stderr.write("Must give binary or listing\n") @@ -163,9 +170,10 @@ def run_simulation(): with Program(lst, bigendian=False) as prog: simulator = run_tst(None, prog, initial_regs, - initial_sprs=None, svstate=0, mmu=False, + initial_sprs=initial_sprs, + svstate=0, mmu=False, initial_cr=0, mem=None, - initial_fprs=None) + initial_fprs=initial_fprs) print ("GPRs") simulator.gpr.dump() print ("FPRs") diff --git a/src/test/basic_pypowersim/Makefile b/src/test/basic_pypowersim/Makefile index cff37389..80870f57 100644 --- a/src/test/basic_pypowersim/Makefile +++ b/src/test/basic_pypowersim/Makefile @@ -6,7 +6,7 @@ AFLAGS=-mpwr9 all: sim sim: kernel.bin - pypowersim -i kernel.bin + pypowersim -g gpr.list -i kernel.bin clean: rm *.o *.elf *.bin diff --git a/src/test/basic_pypowersim/gpr.list b/src/test/basic_pypowersim/gpr.list new file mode 100644 index 00000000..8b29e3be --- /dev/null +++ b/src/test/basic_pypowersim/gpr.list @@ -0,0 +1,3 @@ +8: 0x5005 +12: 0b1010 +15: 5