Move SimObject creation and Port connection loops
[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
18 (options, args) = parser.parse_args()
19
20 if args:
21 print "Error: script doesn't take any positional arguments"
22 sys.exit(1)
23
24 # build configuration
25 this_dir = os.path.dirname(__file__)
26
27 process = LiveProcess()
28 process.executable = os.path.join(this_dir, options.cmd)
29 process.cmd = options.cmd
30
31 magicbus = Bus()
32 mem = PhysicalMemory()
33
34 if options.timing:
35 cpu = TimingSimpleCPU()
36 elif options.full:
37 cpu = DetailedCPU()
38 else:
39 cpu = AtomicSimpleCPU()
40 cpu.workload = process
41 cpu.mem = magicbus
42
43 system = System(physmem = mem, cpu = cpu)
44 mem.port = magicbus.port
45 root = Root(system = system)
46
47 # instantiate configuration
48 m5.instantiate(root)
49
50 # simulate until program terminates
51 exit_event = m5.simulate()
52
53 print 'Exiting @', m5.curTick(), 'because', exit_event.getCause()
54