class list all commands intended for blaze in a blaze-riesling
def __init__ (self
, blaze
=None):
# 5/25/05: penable/pdisable will update CMP registers and step() will check
# core_running_status before execution, so blaze has no need to handle penable/
# pdisable any more, it should consider all strands are enabled at all time,
# and let riesling strand.step() decide whenther it should step or not.
# 9/2/05: pmask is used to control which blaze cpus will be enabled, this is
# to work around CMP to get user a better control of cpu execution.
'ssi', # riesling command, turn it to nop in sam
'runfast', # riesling command, ditto
def issueCmd (self
, cmd
, output
, riesReposit
):
if tokens
[0] in self
.cmdMap
:
# process the file line-by-line
return 'execfile("%s")' % (tokens
[1])
if ((tokens
[0] == 'ssi') or (tokens
[0] == 'runfast')):
sys
.stderr
.write('ERROR: command %s is not supported in SAM, use "stepi N" or "run N" instead\n' % (tokens
[0]))
elif (tokens
[0] == 'run'):
# 'run' is a non-blocking call, if we see 'run N',
# convert that to 'stepi N'
cmd
= 'stepi ' + ' '.join(tokens
[1:])
# 'run' alone becomes a non-blocking call, we should
# get UI prompt back right the way
elif (tokens
[0] == 'pmask'):
sys
.stderr
.write('%#x\n' % riesReposit
.pmask
)
sys
.stderr
.write('Simulator is running, issue "stop" before changing pmask\n')
# set blaze penable accordingly
newMask
= long(tokens
[1], 16)
toDisable
= riesReposit
.pmask
& (~newMask
& 0xffffffffffffffffL
)
toEnable
= (~riesReposit
.pmask
& 0xffffffffffffffffL
) & newMask
#sys.stderr.write('DBX: newMask=%#x toDisable=%#x toEnable=%#x\n' % (newMask, toDisable, toEnable))
# disable currently enabled, but to be disabled strands
for i
in range(riesReposit
.blazeNumcpu
):
if ((toDisable
>> i
) &0x1) == 0x1:
cmd
= 'pdisable th%d' % i
#sys.stderr.write('DBX: cmd=%s\n' % cmd)
# disable currently disabled, but to be enabled strands
for i
in range(riesReposit
.blazeNumcpu
):
if ((toEnable
>> i
) &0x1) == 0x1:
#sys.stderr.write('DBX: cmd=%s\n' % cmd)
riesReposit
.pmask
= newMask
if type(output
) is types
.ListType
:
#output = output.append(self.blaze.command(cmd))
#print "start running...."
#elif (cmd == 'stop') or (cmd.startswith('stepi ')):
# don't check 'stepi' here. If we first do 'run', then
# enter either 'run N' or 'stepi N', blaze will issue
# 'is running' and return without doing anything, at this
# time blaze is still in the first 'run', so we cannot
# set running to 0 for 'run N' or 'stepi N', as they may
# not be executed at all.
#print "stop command was issued."
if len(tokens
) > 2 and (tokens
[0] == 'mod' and
# mod load xxx yyy, register 'xxx' as a command prefix, as all
# module 'yyy' related commands will use that prefix
if not tokens
[2] in self
.cmdMap
:
self
.cmdMap
.append(tokens
[2])
if __name__
== "__main__":