# ========== Copyright Header Begin ==========================================
# OpenSPARC T2 Processor File: sam_ss.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 ============================================
#### sam_@-arch-@.py is automatically generated from
### ss/api/sam/bin/sam_ss.py, do not modify sam_@-arch-@.py,
### make necessary changes in ss/api/sam/bin/sam_ss.py instead.
# startup file for @-arch-@ sam frontend
# This python script lives in the pfe/samfe subdirectory. That
# subdiractory is automatically added to the python search path.
# We need to add the pfe directory as well so do that here.
sys
.path
.append('/'.join(sys
.argv
[0].split('/')[:-2]))
# extended interface for sam
# modules/py/py_interface.cc::py_thread() { Py_InitModule((char*)"sam", py_methods); }
from @-ARCH
-@_Model import *
class SAM_Memory(Pfe_Memory
.Memory
):
Pfe_Memory
.Memory
.__init
__(self
)
def load(self
,filename
,base
=None):
sam
.ui_exec('load img '+filename
)
sam
.ui_exec('load bin '+filename
+' '+str(base
))
def save(self
,filename
,base
,size
):
sam
.ui_exec('memdump '+filename
+' '+str(base
)+' '+str(size
))
def __ldb__(self
,addr
): return sam
.mem_ld8(addr
)
def __ldh__(self
,addr
): return sam
.mem_ld16(addr
)
def __ldw__(self
,addr
): return sam
.mem_ld32(addr
)
def __ldx__(self
,addr
): return sam
.mem_ld64(addr
)
def __stb__(self
,addr
,data
): sam
.mem_st8(addr
,data
)
def __sth__(self
,addr
,data
): sam
.mem_st16(addr
,data
)
def __stw__(self
,addr
,data
): sam
.mem_st32(addr
,data
)
def __stx__(self
,addr
,data
): sam
.mem_st64(addr
,data
)
return @-ARCH
-@_Python.dis(opc
,vpc
)
sys
.stderr
.write('synopsis: [options] python scripts ... \n')
sys
.stderr
.write('options:\n')
sys
.stderr
.write(' -h : help\n')
sys
.stderr
.write(' -p X : python script file to be executed at the beginning\n')
sys
.stderr
.write(' -x diag.sam : startup config, combine with diag.conf to form config\n')
sys
.stderr
.write(' --ar X : n2\n')
sys
.stderr
.write(' --blaze X : n2\n')
sys
.stderr
.write(' --blazeopt "Xs" : blaze options\n')
sys
.stderr
.write(' --cpu X : number of cpus\n')
sys
.stderr
.write(' --pmask X : indicate enabled strands\n')
sys
.stderr
.write(' --rc riesling.rc : combination of diag.sam and diag.conf\n')
if __name__
== '__main__':
# if --blaze is specified, then Blaze_x_System should be used.
# if --blaze is not specified, but -DMOM is specified, then --blaze
# will be added to optdir.
# concatenate options embraced in double-quote, "..."
#sys.stderr.write('DBX: sys.argv=%s\n' % sys.argv) #DBX
if argMerge
== [] and arg
.startswith('"'):
elif argMerge
!= [] and arg
.endswith('"'):
argMerge
.append(arg
[:-1])
argv
.append(' '.join(argMerge
))
#sys.stderr.write('DBX: argv=%s\n' % argv) #DBX
optlist
, args
= getopt
.getopt(argv
[1:], 'hp:x:', ['ar=','pmask=','rc=','blaze=','blazeopt=','cpu='])
for (key
,value
) in optlist
:
if not optdir
.has_key('--ar') and optdir
.has_key('--blaze'):
optdir
['--ar'] = optdir
['--blaze']
optdir
['--ar'] = '@-arch-@'
#sys.stderr.write('DBX: optdir=%s\n' % optdir) #DBX
sim
= Model(SAM_Memory(),SS_Io
.Io(@-ARCH
-@_Python.get_io()),@-ARCH
-@_Python.@-arch
-@_model(sam
.sys_pntr(0)))
ncpu
= int(optdir
['--cpu'])
if (optdir
['--ar'] == 'n2' and (ncpu
!= 1)):
sys
.stderr
.write('ERROR: wrong number of %s cpus: %d\n' % (optdir
['--ar'].upper(), ncpu
))
#sys.stderr.write('DBX: ncpu=%d, cpus=%s\n' % (ncpu, cpus)) #DBX
SamFE
.init(sim
, optdir
, globals())