2006-06-10 06:22:42 +02:00
|
|
|
# Simple test script
|
|
|
|
#
|
|
|
|
# Alpha: "m5 test.py"
|
|
|
|
# MIPS: "m5 test.py -a Mips -c hello_mips"
|
|
|
|
|
2006-06-10 05:01:31 +02:00
|
|
|
import os, optparse, sys
|
|
|
|
import m5
|
|
|
|
from m5.objects import *
|
2006-06-13 20:15:24 +02:00
|
|
|
from FullO3Config import *
|
2006-03-10 16:01:29 +01:00
|
|
|
|
2006-06-10 06:22:42 +02:00
|
|
|
# parse command-line arguments
|
2006-06-10 05:01:31 +02:00
|
|
|
parser = optparse.OptionParser(option_list=m5.standardOptions)
|
|
|
|
|
2006-06-27 20:58:46 +02:00
|
|
|
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("-t", "--timing", action="store_true",
|
|
|
|
help="Use simple timing CPU.")
|
|
|
|
parser.add_option("-d", "--detailed", action="store_true",
|
|
|
|
help="Use detailed CPU.")
|
|
|
|
parser.add_option("-m", "--maxtick", type="int",
|
|
|
|
help="Set the maximum number of ticks to run for")
|
2006-06-10 05:01:31 +02:00
|
|
|
|
|
|
|
(options, args) = parser.parse_args()
|
2006-06-17 15:58:10 +02:00
|
|
|
m5.setStandardOptions(options)
|
2006-06-10 05:01:31 +02:00
|
|
|
|
|
|
|
if args:
|
|
|
|
print "Error: script doesn't take any positional arguments"
|
|
|
|
sys.exit(1)
|
|
|
|
|
2006-06-10 06:22:42 +02:00
|
|
|
# build configuration
|
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-03-26 00:34:50 +01:00
|
|
|
magicbus = Bus()
|
2006-03-30 00:39:20 +02:00
|
|
|
mem = PhysicalMemory()
|
2006-06-10 05:01:31 +02:00
|
|
|
|
2006-06-27 20:58:46 +02:00
|
|
|
if options.timing and options.detailed:
|
|
|
|
print "Error: you may only specify one cpu model";
|
|
|
|
sys.exit(1)
|
|
|
|
|
2006-06-10 05:01:31 +02:00
|
|
|
if options.timing:
|
|
|
|
cpu = TimingSimpleCPU()
|
2006-06-17 00:04:34 +02:00
|
|
|
elif 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-06-16 23:08:47 +02:00
|
|
|
cpu = DetailedO3CPU()
|
2006-06-10 05:01:31 +02:00
|
|
|
else:
|
|
|
|
cpu = AtomicSimpleCPU()
|
|
|
|
cpu.workload = process
|
|
|
|
cpu.mem = magicbus
|
|
|
|
|
|
|
|
system = System(physmem = mem, cpu = cpu)
|
2006-06-14 05:19:28 +02:00
|
|
|
mem.port = magicbus.port
|
2006-06-10 05:01:31 +02:00
|
|
|
root = Root(system = system)
|
|
|
|
|
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
|
|
|
|