4 # MIPS: "m5 test.py -a Mips -c hello_mips"
6 import os
, optparse
, sys
8 from m5
.objects
import *
9 from FullO3Config
import *
11 # parse command-line arguments
12 parser
= optparse
.OptionParser(option_list
=m5
.standardOptions
)
14 parser
.add_option("-c", "--cmd", default
="hello",
15 help="The binary to run in syscall emulation mode.")
16 parser
.add_option("-o", "--options", default
="",
17 help="The options to pass to the binary, use \" \" around the entire\
19 parser
.add_option("-i", "--input", default
="",
20 help="A file of input to give to the binary.")
21 parser
.add_option("-t", "--timing", action
="store_true",
22 help="Use simple timing CPU.")
23 parser
.add_option("-d", "--detailed", action
="store_true",
24 help="Use detailed CPU.")
25 parser
.add_option("-m", "--maxtick", type="int",
26 help="Set the maximum number of ticks to run for")
28 (options
, args
) = parser
.parse_args()
29 m5
.setStandardOptions(options
)
32 print "Error: script doesn't take any positional arguments"
36 this_dir
= os
.path
.dirname(__file__
)
38 process
= LiveProcess()
39 process
.executable
= os
.path
.join(this_dir
, options
.cmd
)
40 process
.cmd
= options
.cmd
+ " " + options
.options
41 if options
.input != "":
42 process
.input = options
.input
45 mem
= PhysicalMemory()
47 if options
.timing
and options
.detailed
:
48 print "Error: you may only specify one cpu model";
52 cpu
= TimingSimpleCPU()
53 elif options
.detailed
:
54 #check for SMT workload
55 workloads
= options
.cmd
.split(';')
56 if len(workloads
) > 1:
61 if options
.input != "":
62 inputs
= options
.input.split(';')
64 for wrkld
in workloads
:
65 smt_process
= LiveProcess()
66 smt_process
.executable
= os
.path
.join(this_dir
, wrkld
)
67 smt_process
.cmd
= wrkld
+ " " + options
.options
68 if inputs
and inputs
[smt_idx
]:
69 smt_process
.input = inputs
[smt_idx
]
70 process
+= [smt_process
, ]
75 cpu
= AtomicSimpleCPU()
76 cpu
.workload
= process
79 system
= System(physmem
= mem
, cpu
= cpu
)
80 mem
.port
= magicbus
.port
81 root
= Root(system
= system
)
83 # instantiate configuration
86 # simulate until program terminates
88 exit_event
= m5
.simulate(options
.maxtick
)
90 exit_event
= m5
.simulate()
92 print 'Exiting @ tick', m5
.curTick(), 'because', exit_event
.getCause()