se.py revision 2856
1# Simple test script 2# 3# Alpha: "m5 test.py" 4# MIPS: "m5 test.py -a Mips -c hello_mips" 5 6import os, optparse, sys 7import m5 8from m5.objects import * 9from FullO3Config import * 10 11# parse command-line arguments 12parser = optparse.OptionParser(option_list=m5.standardOptions) 13 14parser.add_option("-c", "--cmd", default="hello", 15 help="The binary to run in syscall emulation mode.") 16parser.add_option("-o", "--options", default="", 17 help="The options to pass to the binary, use \" \" around the entire\ 18 string.") 19parser.add_option("-i", "--input", default="", 20 help="A file of input to give to the binary.") 21parser.add_option("-t", "--timing", action="store_true", 22 help="Use simple timing CPU.") 23parser.add_option("-d", "--detailed", action="store_true", 24 help="Use detailed CPU.") 25parser.add_option("-m", "--maxtick", type="int", 26 help="Set the maximum number of ticks to run for") 27 28(options, args) = parser.parse_args() 29m5.setStandardOptions(options) 30 31if args: 32 print "Error: script doesn't take any positional arguments" 33 sys.exit(1) 34 35# build configuration 36this_dir = os.path.dirname(__file__) 37 38process = LiveProcess() 39process.executable = os.path.join(this_dir, options.cmd) 40process.cmd = options.cmd + " " + options.options 41if options.input != "": 42 process.input = options.input 43 44magicbus = Bus() 45mem = PhysicalMemory() 46 47if options.timing and options.detailed: 48 print "Error: you may only specify one cpu model"; 49 sys.exit(1) 50 51if options.timing: 52 cpu = TimingSimpleCPU() 53elif options.detailed: 54 #check for SMT workload 55 workloads = options.cmd.split(';') 56 if len(workloads) > 1: 57 process = [] 58 smt_idx = 0 59 inputs = [] 60 61 if options.input != "": 62 inputs = options.input.split(';') 63 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, ] 71 smt_idx += 1 72 73 cpu = DetailedO3CPU() 74else: 75 cpu = AtomicSimpleCPU() 76cpu.workload = process 77cpu.mem = magicbus 78cpu.icache_port=magicbus.port 79cpu.dcache_port=magicbus.port 80 81system = System(physmem = mem, cpu = cpu) 82mem.port = magicbus.port 83root = Root(system = system) 84 85# instantiate configuration 86m5.instantiate(root) 87 88# simulate until program terminates 89if options.maxtick: 90 exit_event = m5.simulate(options.maxtick) 91else: 92 exit_event = m5.simulate() 93 94print 'Exiting @ tick', m5.curTick(), 'because', exit_event.getCause() 95 96