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-10 06:22:42 +02:00
|
|
|
parser.add_option("-c", "--cmd", default="hello")
|
2006-06-26 22:50:19 +02:00
|
|
|
parser.add_option("-o", "--options", default="")
|
|
|
|
parser.add_option("-i", "--input", default="")
|
2006-06-10 05:01:31 +02:00
|
|
|
parser.add_option("-t", "--timing", action="store_true")
|
2006-06-17 00:04:34 +02:00
|
|
|
parser.add_option("-d", "--detailed", action="store_true")
|
2006-06-16 23:08:47 +02:00
|
|
|
parser.add_option("-m", "--maxtick", type="int")
|
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
|
|
|
|
|
|
|
if options.timing:
|
|
|
|
cpu = TimingSimpleCPU()
|
2006-06-17 00:04:34 +02:00
|
|
|
elif options.detailed:
|
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
|
|
|
|