### N2_Main.py is automatically generated from
### ss/exe/nas/bin/Bl_Main.py, do not modify N2_Main.py,
### make necessary changes in ss/exe/nas/bin/Bl_Main.py instead.
from optparse
import OptionParser
argv_parser
= OptionParser(usage
="usage: "+prog
+" [options]",version
=Pfe_Version
.version())
argv_parser
.disable_interspersed_args()
action
="store_true",dest
="record",default
=False,
help="Record pli socket i/o for replay")
action
="store_true",dest
="ras_enable",default
=False,
action
="store_true",dest
="format",default
=False,
help="Output in n2 sas.log format if -f is specified.")
action
="store_true",dest
="interactive",default
=False,
help="switch to interactive (inspect) mode")
action
="store_true",dest
="samfe",default
=False,
help="Invoke nas-fe command parser in batch & interactive modes")
action
="store_true",dest
="replay",default
=False,
help="Replay and verify from a previous run.")
action
="store",type="string",dest
="release",default
='',
metavar
="VERSION",help="Release version of this tool")
action
="append",type="string",dest
="riesling_conf",default
=["riesling.conf"],
metavar
="FILE",help="Default riesling.conf")
action
="store_true",dest
="trace",default
=False,
help="Trace instruction stepping to stdout.")
action
="append",type="string",dest
="diag_simics",default
=["diag.simics"],
metavar
="FILE",help="Default diag.simics")
(opts
,args
) = argv_parser
.parse_args()
histfile
= '/home/'+os
.environ
["USER"]+'/'+name
readline
.read_history_file(histfile
)
atexit
.register(readline
.write_history_file
,histfile
)
sys
.stdout
.write('# %s\n' % (time
.ctime()))
sys
.stdout
.write('# %s\n' % (commands
.getoutput('uname -a')))
#sys.stdout.write('# Python %s\n' % sys.version)
sys
.stdout
.write('# NAS release %s\n' % ('nas,'+opts
.release
))
#sys.stdout.write('# PATH %s\n' % sys.path)
sim
= Model(SS_Memory
.Memory(SS_Ram
.get_memory()),SS_Io
.Io(N2_Python
.get_io()),N2_Python
.n2_model(n2
.model()))
if os
.path
.exists('mem.image.gz'):
sim
.mem
.load('mem.image.gz')
elif os
.path
.exists('mem.image'):
sim
.mem
.load('mem.image')
sys
.stderr
.write('WARNING: mem.image is not loaded\n')
# when() is used in combination with run()
# when(e) expects e to be a function that returns true when e() evaluates to true
# run() steps the cosim environement forever until a when clause
# evaluates to true. ok>0 means we hits a breakpoint, ok==0 means
# all's fine and we keep going, ok==-1 means we saw PLI_QUIT, ok<-1
# means something is messed up ... e.g. pli socket read error
# step() steps the cosim environment n (default n=1) steps forward
# Which strand is stepped is controlled by the RTL testbench or
n2
.init(int(opts
.record
),int(opts
.replay
))
if opts
.trace
or n2
.trace():
s
.set_format(opts
.format
)
# if -sas_run_args=-DPLI_DEBUG is not used, let -t decide the trace
# otherwise rely on -sas_run_args=-DPLI_DEBUG to decide the level of
# reset trace mode: 0 - silent, 1 - trap, 2 - trap+instr, 3 - trap+instr+delta,
# others - silent (except [91,92,93,94], those are used by -sas_run_args=-DPLI_DEBUG)
# in nas-fe mode, use the information in -x to conduct the execution
fe_opts
['-x'] = opts
.diag_simics
[-1]
SamFE
.init(sim
, fe_opts
, globals())
elif not opts
.interactive
:
os
.environ
['PYTHONINSPECT'] = 'inspect'