# ========== Copyright Header Begin ==========================================
# OpenSPARC T2 Processor File: SS_Main.py
# Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
# The above named program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public
# License version 2 as published by the Free Software Foundation.
# The above named program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# You should have received a copy of the GNU General Public
# License along with this work; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
# ========== Copyright Header End ============================================
##***********************************************************************
## Copyright (C) 2006, Sun Microsystems, Inc.
## Sun considers its source code as an unpublished, proprietary
## trade secret and it is available only under strict license provisions.
## This copyright notice is placed here only to protect Sun in the event
## the source is deemed a published work. Disassembly, decompilation,
## or other means of reducing the object code to human readable form
## is prohibited by the license agreement under which this code is
## provided to the user or company in possession of this copy.
##***********************************************************************
### @-ARCH-@_Main.py is automatically generated from
### ss/exe/nas/bin/SS_Main.py, do not modify @-ARCH-@_Main.py,
### make necessary changes in ss/exe/nas/bin/Bl_Main.py instead.
from optparse
import OptionParser
from @-ARCH
-@_Model import *
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)
# this must happen before the Model() is created, otherwise frontend model
# object won't have the same cpu-core-strand structure as the backend
@-arch
-@.init(int(opts
.record
),int(opts
.replay
))
sim
= Model(SS_Memory
.Memory(SS_Ram
.get_memory()),SS_Io
.Io(@-ARCH
-@_Python.get_io()),@-ARCH
-@_Python.@-arch
-@_model(@-arch
-@.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
if opts
.trace
or @-arch
-@.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,
# when invoke lstmode() in cosim mode, we should always use lstmode(1), and
# rely on cosim -sas_run_args=-DPLI_DEBUG option to control the level of data
# in nas-fe mode, use the information in -x to conduct the execution
fe_opts
['-x'] = opts
.diag_simics
[-1]
fe_opts
['--ar'] = '@-arch-@'
SamFE
.init(sim
, fe_opts
, globals())
elif not opts
.interactive
:
os
.environ
['PYTHONINSPECT'] = 'inspect'