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
10 # parse command-line arguments
11 parser = optparse.OptionParser(option_list=m5.standardOptions)
12
13 parser.add_option("-c", "--cmd", default="hello")
14 parser.add_option("-t", "--timing", action="store_true")
15
16 (options, args) = parser.parse_args()
17
18 if args:
19 print "Error: script doesn't take any positional arguments"
20 sys.exit(1)
21
22 # build configuration
23 this_dir = os.path.dirname(__file__)
24
25 process = LiveProcess()
26 process.executable = os.path.join(this_dir, options.cmd)
27 process.cmd = options.cmd
28
29 magicbus = Bus()
30 mem = PhysicalMemory()
31
32 if options.timing:
33 cpu = TimingSimpleCPU()
34 else:
35 cpu = AtomicSimpleCPU()
36 cpu.workload = process
37 cpu.mem = magicbus
38
39 system = System(physmem = mem, cpu = cpu)
40 system.c1 = Connector(side_a = mem, side_b = magicbus)
41 root = Root(system = system)
42
43 # instantiate configuration
44 m5.instantiate(root)
45
46 # simulate until program terminates
47 exit_event = m5.simulate()
48
49 print 'Exiting @', m5.curTick(), 'because', exit_event.getCause()
50