Merge ktlim@zizzer:/bk/newmem
[gem5.git] / configs / test / test.py
1 # Simple test script
2 #
3 # Alpha: "m5 test.py"
4 # MIPS: "m5 test.py -a Mips -c hello_mips"
5
6 import os, optparse, sys
7 import m5
8 from m5.objects import *
9 from FullO3Config import *
10
11 # parse command-line arguments
12 parser = optparse.OptionParser(option_list=m5.standardOptions)
13
14 parser.add_option("-c", "--cmd", default="hello")
15 parser.add_option("-t", "--timing", action="store_true")
16 parser.add_option("-d", "--detailed", action="store_true")
17 parser.add_option("-m", "--maxtick", type="int")
18
19 (options, args) = parser.parse_args()
20 m5.setStandardOptions(options)
21
22 if args:
23 print "Error: script doesn't take any positional arguments"
24 sys.exit(1)
25
26 # build configuration
27 this_dir = os.path.dirname(__file__)
28
29 process = LiveProcess()
30 process.executable = os.path.join(this_dir, options.cmd)
31 process.cmd = options.cmd
32
33 magicbus = Bus()
34 mem = PhysicalMemory()
35
36 if options.timing:
37 cpu = TimingSimpleCPU()
38 elif options.detailed:
39 cpu = DetailedO3CPU()
40 else:
41 cpu = AtomicSimpleCPU()
42 cpu.workload = process
43 cpu.mem = magicbus
44
45 system = System(physmem = mem, cpu = cpu)
46 mem.port = magicbus.port
47 root = Root(system = system)
48
49 # instantiate configuration
50 m5.instantiate(root)
51
52 # simulate until program terminates
53 if options.maxtick:
54 exit_event = m5.simulate(options.maxtick)
55 else:
56 exit_event = m5.simulate()
57
58 print 'Exiting @ cycle', m5.curTick(), 'because', exit_event.getCause()
59