2006-06-10 06:22:42 +02:00
|
|
|
# Simple test script
|
|
|
|
#
|
|
|
|
# Alpha: "m5 test.py"
|
2006-07-12 23:17:17 +02:00
|
|
|
# MIPS: "m5 test.py -c hello_mips"
|
2006-06-10 06:22:42 +02:00
|
|
|
|
2006-06-10 05:01:31 +02:00
|
|
|
import m5
|
2006-07-12 23:17:17 +02:00
|
|
|
import os, optparse, sys
|
|
|
|
m5.AddToPath('../common')
|
|
|
|
from SEConfig import *
|
2006-07-23 06:10:11 +02:00
|
|
|
from FullO3Config import *
|
2006-07-19 21:24:22 +02:00
|
|
|
from m5.objects import *
|
2006-06-10 05:01:31 +02:00
|
|
|
|
2006-07-23 06:10:11 +02:00
|
|
|
parser = optparse.OptionParser()
|
|
|
|
|
|
|
|
parser.add_option("-c", "--cmd", default="hello",
|
|
|
|
help="The binary to run in syscall emulation mode.")
|
|
|
|
parser.add_option("-o", "--options", default="",
|
|
|
|
help="The options to pass to the binary, use \" \" around the entire\
|
|
|
|
string.")
|
|
|
|
parser.add_option("-i", "--input", default="",
|
|
|
|
help="A file of input to give to the binary.")
|
|
|
|
parser.add_option("-d", "--detailed", action="store_true")
|
|
|
|
parser.add_option("-t", "--timing", action="store_true")
|
|
|
|
parser.add_option("-m", "--maxtick", type="int")
|
|
|
|
|
|
|
|
(options, args) = parser.parse_args()
|
|
|
|
|
|
|
|
if args:
|
|
|
|
print "Error: script doesn't take any positional arguments"
|
|
|
|
sys.exit(1)
|
|
|
|
|
2006-06-10 05:01:31 +02:00
|
|
|
this_dir = os.path.dirname(__file__)
|
|
|
|
|
2006-06-12 03:49:46 +02:00
|
|
|
process = LiveProcess()
|
2006-06-10 06:22:42 +02:00
|
|
|
process.executable = os.path.join(this_dir, options.cmd)
|
2006-06-26 22:50:19 +02:00
|
|
|
process.cmd = options.cmd + " " + options.options
|
|
|
|
if options.input != "":
|
|
|
|
process.input = options.input
|
2006-03-10 16:01:29 +01:00
|
|
|
|
2006-07-12 23:17:17 +02:00
|
|
|
if options.detailed:
|
2006-07-03 07:10:19 +02:00
|
|
|
#check for SMT workload
|
|
|
|
workloads = options.cmd.split(';')
|
|
|
|
if len(workloads) > 1:
|
|
|
|
process = []
|
|
|
|
smt_idx = 0
|
|
|
|
inputs = []
|
|
|
|
|
|
|
|
if options.input != "":
|
|
|
|
inputs = options.input.split(';')
|
|
|
|
|
|
|
|
for wrkld in workloads:
|
|
|
|
smt_process = LiveProcess()
|
|
|
|
smt_process.executable = os.path.join(this_dir, wrkld)
|
|
|
|
smt_process.cmd = wrkld + " " + options.options
|
|
|
|
if inputs and inputs[smt_idx]:
|
|
|
|
smt_process.input = inputs[smt_idx]
|
|
|
|
process += [smt_process, ]
|
|
|
|
smt_idx += 1
|
|
|
|
|
2006-07-23 06:10:11 +02:00
|
|
|
|
|
|
|
if options.timing:
|
|
|
|
cpu = TimingSimpleCPU()
|
|
|
|
elif options.detailed:
|
|
|
|
cpu = DetailedO3CPU()
|
|
|
|
else:
|
|
|
|
cpu = AtomicSimpleCPU()
|
|
|
|
|
|
|
|
root = MySESystem(cpu, process)
|
2006-06-10 05:01:31 +02:00
|
|
|
|
2006-07-13 21:48:17 +02:00
|
|
|
if options.timing or options.detailed:
|
2006-07-19 21:24:22 +02:00
|
|
|
root.system.mem_mode = 'timing'
|
2006-06-10 05:01:31 +02:00
|
|
|
|
2006-06-10 06:22:42 +02:00
|
|
|
# instantiate configuration
|
2006-06-10 05:01:31 +02:00
|
|
|
m5.instantiate(root)
|
|
|
|
|
2006-06-10 06:22:42 +02:00
|
|
|
# simulate until program terminates
|
2006-06-16 23:08:47 +02:00
|
|
|
if options.maxtick:
|
|
|
|
exit_event = m5.simulate(options.maxtick)
|
|
|
|
else:
|
|
|
|
exit_event = m5.simulate()
|
2006-06-10 05:01:31 +02:00
|
|
|
|
2006-06-18 21:58:14 +02:00
|
|
|
print 'Exiting @ tick', m5.curTick(), 'because', exit_event.getCause()
|
2006-06-10 05:01:31 +02:00
|
|
|
|