Two updates that got combined into one ChangeSet accidentally. They're both pretty...
[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("-f", "--full", action="store_true")
17 parser.add_option("-m", "--maxtick", type="int")
18
19 (options, args) = parser.parse_args()
20
21 if args:
22 print "Error: script doesn't take any positional arguments"
23 sys.exit(1)
24
25 # build configuration
26 this_dir = os.path.dirname(__file__)
27
28 process = LiveProcess()
29 process.executable = os.path.join(this_dir, options.cmd)
30 process.cmd = options.cmd
31
32 magicbus = Bus()
33 mem = PhysicalMemory()
34
35 if options.timing:
36 cpu = TimingSimpleCPU()
37 elif options.full:
38 cpu = DetailedO3CPU()
39 else:
40 cpu = AtomicSimpleCPU()
41 cpu.workload = process
42 cpu.mem = magicbus
43
44 system = System(physmem = mem, cpu = cpu)
45 system.c1 = Connector(side_a = mem, side_b = magicbus)
46 root = Root(system = system)
47
48 # instantiate configuration
49 m5.instantiate(root)
50
51 # simulate until program terminates
52 if options.maxtick:
53 exit_event = m5.simulate(options.maxtick)
54 else:
55 exit_event = m5.simulate()
56
57 print 'Exiting @', m5.curTick(), 'because', exit_event.getCause()
58