add pypowersim to commands installed
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 21 May 2021 12:10:17 +0000 (13:10 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 21 May 2021 12:10:17 +0000 (13:10 +0100)
setup.py
src/openpower/decoder/isa/pypowersim.py

index 501885572411cbcf81b17a484f2c99a8da3c955e..fbe317b040365d658474506bbd517c73b3b06dd1 100644 (file)
--- 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'
         ]
     }
 )
index ab03138b587cfe45c602b19521c545c868f63c87..9bee15a585ca1962457abeab473c77ee83bfc658 100644 (file)
@@ -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()
+