From 015ea842f6b4ceb6a276160938b5ca82f6ec42a3 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Fri, 21 May 2021 13:10:17 +0100 Subject: [PATCH] add pypowersim to commands installed --- setup.py | 3 ++- src/openpower/decoder/isa/pypowersim.py | 23 +++++++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/setup.py b/setup.py index 50188557..fbe317b0 100644 --- a/setup.py +++ b/setup.py @@ -60,7 +60,8 @@ setup( 'console_scripts': [ 'pywriter=openpower.decoder.pseudo.pywriter:pywriter', 'pyfnwriter=openpower.decoder.pseudo.pyfnwriter:pyfnwriter', - 'sv_analysis=openpower.sv.sv_analysis:process_csvs' + 'sv_analysis=openpower.sv.sv_analysis:process_csvs', + 'pypowersim=openpower.decoder.isa.pypowersim:run_simulation' ] } ) diff --git a/src/openpower/decoder/isa/pypowersim.py b/src/openpower/decoder/isa/pypowersim.py index ab03138b..9bee15a5 100644 --- a/src/openpower/decoder/isa/pypowersim.py +++ b/src/openpower/decoder/isa/pypowersim.py @@ -1,6 +1,5 @@ from nmigen import Module, Signal from nmigen.back.pysim import Simulator, Delay, Settle -import string import sys import getopt from openpower.decoder.power_decoder import create_pdecode @@ -31,7 +30,7 @@ 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(string.strip, line.strip().split(":")) + line = map(str.strip, line.strip().split(":")) assert len(line) == 2, "regfile line must be formatted 'x : y'" reg, val = line reg = convert_to_num(reg) @@ -70,6 +69,8 @@ def run_tst(args, generator, initial_regs, insncode = generator.assembly.splitlines() instructions = list(zip(gen, insncode)) + print ("instructions", instructions) + m.submodules.pdecode2 = pdecode2 = PowerDecode2(pdecode) simulator = ISA(pdecode2, initial_regs, initial_sprs, initial_cr, initial_insns=gen, respect_pc=True, @@ -111,7 +112,12 @@ def run_tst(args, generator, initial_regs, return simulator -if __name__ == "__main__": +def help(): + print ("TODO help") + exit(-1) + + +def run_simulation(): binaryname = None initial_regs = None @@ -124,7 +130,7 @@ if __name__ == "__main__": except: sys.stderr.write("Command-line Error\n") - exit(-1) + help() for opt, arg in opts: if opt in ['-i', '--binary']: @@ -136,11 +142,11 @@ if __name__ == "__main__": if binaryname is None and lst is None: sys.stderr.write("Must give binary or listing\n") - exit(-1) + help() if lst: with open(lst, "r") as f: - lst = list(f.readlines()) + lst = list(map(str.strip, f.readlines())) if binaryname: with open(binaryname, "rb") as f: @@ -154,3 +160,8 @@ if __name__ == "__main__": initial_fprs=None) simulator.gpr.dump() simulator.fpr.dump() + + +if __name__ == "__main__": + run_simulation() + -- 2.30.2