se.py revision 2801
16313Sgblack@eecs.umich.edu# Simple test script
26313Sgblack@eecs.umich.edu#
36313Sgblack@eecs.umich.edu# Alpha: "m5 test.py"
46313Sgblack@eecs.umich.edu# MIPS: "m5 test.py -a Mips -c hello_mips"
56313Sgblack@eecs.umich.edu
66313Sgblack@eecs.umich.eduimport os, optparse, sys
76313Sgblack@eecs.umich.eduimport m5
86313Sgblack@eecs.umich.edufrom m5.objects import *
96313Sgblack@eecs.umich.edufrom FullO3Config import *
106313Sgblack@eecs.umich.edu
116313Sgblack@eecs.umich.edu# parse command-line arguments
126313Sgblack@eecs.umich.eduparser = optparse.OptionParser(option_list=m5.standardOptions)
136313Sgblack@eecs.umich.edu
146313Sgblack@eecs.umich.eduparser.add_option("-c", "--cmd", default="hello")
156313Sgblack@eecs.umich.eduparser.add_option("-o", "--options", default="")
166313Sgblack@eecs.umich.eduparser.add_option("-i", "--input", default="")
176313Sgblack@eecs.umich.eduparser.add_option("-t", "--timing", action="store_true")
186313Sgblack@eecs.umich.eduparser.add_option("-d", "--detailed", action="store_true")
196313Sgblack@eecs.umich.eduparser.add_option("-m", "--maxtick", type="int")
206313Sgblack@eecs.umich.edu
216313Sgblack@eecs.umich.edu(options, args) = parser.parse_args()
226313Sgblack@eecs.umich.edum5.setStandardOptions(options)
236313Sgblack@eecs.umich.edu
246313Sgblack@eecs.umich.eduif args:
256313Sgblack@eecs.umich.edu    print "Error: script doesn't take any positional arguments"
266313Sgblack@eecs.umich.edu    sys.exit(1)
276313Sgblack@eecs.umich.edu
286313Sgblack@eecs.umich.edu# build configuration
296313Sgblack@eecs.umich.eduthis_dir = os.path.dirname(__file__)
306313Sgblack@eecs.umich.edu
317678Sgblack@eecs.umich.eduprocess = LiveProcess()
327678Sgblack@eecs.umich.eduprocess.executable = os.path.join(this_dir, options.cmd)
336313Sgblack@eecs.umich.eduprocess.cmd = options.cmd + " " + options.options
346330Sgblack@eecs.umich.eduif options.input != "":
356313Sgblack@eecs.umich.edu    process.input = options.input
367680Sgblack@eecs.umich.edu
376313Sgblack@eecs.umich.edumagicbus = Bus()
386313Sgblack@eecs.umich.edumem = PhysicalMemory()
396313Sgblack@eecs.umich.edu
406313Sgblack@eecs.umich.eduif options.timing:
416313Sgblack@eecs.umich.edu    cpu = TimingSimpleCPU()
426678Sgblack@eecs.umich.eduelif options.detailed:
436313Sgblack@eecs.umich.edu    cpu = DetailedO3CPU()
446330Sgblack@eecs.umich.eduelse:
456330Sgblack@eecs.umich.edu    cpu = AtomicSimpleCPU()
466330Sgblack@eecs.umich.educpu.workload = process
476330Sgblack@eecs.umich.educpu.mem = magicbus
486330Sgblack@eecs.umich.edu
496313Sgblack@eecs.umich.edusystem = System(physmem = mem, cpu = cpu)
506313Sgblack@eecs.umich.edumem.port = magicbus.port
516313Sgblack@eecs.umich.eduroot = Root(system = system)
526678Sgblack@eecs.umich.edu
536313Sgblack@eecs.umich.edu# instantiate configuration
546330Sgblack@eecs.umich.edum5.instantiate(root)
556330Sgblack@eecs.umich.edu
566330Sgblack@eecs.umich.edu# simulate until program terminates
576330Sgblack@eecs.umich.eduif options.maxtick:
586330Sgblack@eecs.umich.edu    exit_event = m5.simulate(options.maxtick)
596330Sgblack@eecs.umich.eduelse:
606330Sgblack@eecs.umich.edu    exit_event = m5.simulate()
616330Sgblack@eecs.umich.edu
626330Sgblack@eecs.umich.eduprint 'Exiting @ cycle', m5.curTick(), 'because', exit_event.getCause()
636330Sgblack@eecs.umich.edu
646330Sgblack@eecs.umich.edu