se.py revision 3005
13005Sstever@eecs.umich.edu# Copyright (c) 2006 The Regents of The University of Michigan 23005Sstever@eecs.umich.edu# All rights reserved. 33005Sstever@eecs.umich.edu# 43005Sstever@eecs.umich.edu# Redistribution and use in source and binary forms, with or without 53005Sstever@eecs.umich.edu# modification, are permitted provided that the following conditions are 63005Sstever@eecs.umich.edu# met: redistributions of source code must retain the above copyright 73005Sstever@eecs.umich.edu# notice, this list of conditions and the following disclaimer; 83005Sstever@eecs.umich.edu# redistributions in binary form must reproduce the above copyright 93005Sstever@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the 103005Sstever@eecs.umich.edu# documentation and/or other materials provided with the distribution; 113005Sstever@eecs.umich.edu# neither the name of the copyright holders nor the names of its 123005Sstever@eecs.umich.edu# contributors may be used to endorse or promote products derived from 133005Sstever@eecs.umich.edu# this software without specific prior written permission. 143005Sstever@eecs.umich.edu# 153005Sstever@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 163005Sstever@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 173005Sstever@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 183005Sstever@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 193005Sstever@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 203005Sstever@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 213005Sstever@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 223005Sstever@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 233005Sstever@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 243005Sstever@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 253005Sstever@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 263005Sstever@eecs.umich.edu# 273005Sstever@eecs.umich.edu# Authors: Steve Reinhardt 283005Sstever@eecs.umich.edu 292710SN/A# Simple test script 302710SN/A# 313005Sstever@eecs.umich.edu# "m5 test.py" 322889SN/A 332667SN/Aimport m5 343005Sstever@eecs.umich.edufrom m5.objects import * 352856SN/Aimport os, optparse, sys 362917SN/Am5.AddToPath('../common') 372957SN/Afrom FullO3Config import * 382424SN/A 392957SN/Aparser = optparse.OptionParser() 402957SN/A 413005Sstever@eecs.umich.eduparser.add_option("-c", "--cmd", 423005Sstever@eecs.umich.edu default="../../tests/test-progs/hello/bin/alpha/linux/hello", 432957SN/A help="The binary to run in syscall emulation mode.") 442957SN/Aparser.add_option("-o", "--options", default="", 452957SN/A help="The options to pass to the binary, use \" \" around the entire\ 462957SN/A string.") 472957SN/Aparser.add_option("-i", "--input", default="", 482957SN/A help="A file of input to give to the binary.") 492957SN/Aparser.add_option("-d", "--detailed", action="store_true") 502957SN/Aparser.add_option("-t", "--timing", action="store_true") 512957SN/Aparser.add_option("-m", "--maxtick", type="int") 522957SN/A 532957SN/A(options, args) = parser.parse_args() 542957SN/A 552957SN/Aif args: 562957SN/A print "Error: script doesn't take any positional arguments" 572957SN/A sys.exit(1) 582957SN/A 592715SN/Aprocess = LiveProcess() 603005Sstever@eecs.umich.eduprocess.executable = options.cmd 612801SN/Aprocess.cmd = options.cmd + " " + options.options 622801SN/Aif options.input != "": 632801SN/A process.input = options.input 642418SN/A 652917SN/Aif options.detailed: 662833SN/A #check for SMT workload 672833SN/A workloads = options.cmd.split(';') 682833SN/A if len(workloads) > 1: 692833SN/A process = [] 702833SN/A smt_idx = 0 712833SN/A inputs = [] 722833SN/A 732833SN/A if options.input != "": 742833SN/A inputs = options.input.split(';') 752833SN/A 762833SN/A for wrkld in workloads: 772833SN/A smt_process = LiveProcess() 783005Sstever@eecs.umich.edu smt_process.executable = wrkld 792833SN/A smt_process.cmd = wrkld + " " + options.options 802833SN/A if inputs and inputs[smt_idx]: 812833SN/A smt_process.input = inputs[smt_idx] 822833SN/A process += [smt_process, ] 832833SN/A smt_idx += 1 842833SN/A 852957SN/A 862957SN/Aif options.timing: 872957SN/A cpu = TimingSimpleCPU() 882957SN/Aelif options.detailed: 892957SN/A cpu = DetailedO3CPU() 902957SN/Aelse: 912957SN/A cpu = AtomicSimpleCPU() 922957SN/A 933005Sstever@eecs.umich.educpu.workload = process 943005Sstever@eecs.umich.edu 953005Sstever@eecs.umich.edusystem = System(cpu = cpu, 963005Sstever@eecs.umich.edu physmem = PhysicalMemory(), 973005Sstever@eecs.umich.edu membus = Bus()) 983005Sstever@eecs.umich.edusystem.physmem.port = system.membus.port 993005Sstever@eecs.umich.edusystem.cpu.connectMemPorts(system.membus) 1003005Sstever@eecs.umich.edu 1013005Sstever@eecs.umich.eduroot = Root(system = system) 1022902SN/A 1032902SN/Aif options.timing or options.detailed: 1042925SN/A root.system.mem_mode = 'timing' 1052667SN/A 1062710SN/A# instantiate configuration 1072667SN/Am5.instantiate(root) 1082667SN/A 1092710SN/A# simulate until program terminates 1102733SN/Aif options.maxtick: 1112733SN/A exit_event = m5.simulate(options.maxtick) 1122733SN/Aelse: 1132733SN/A exit_event = m5.simulate() 1142667SN/A 1152787SN/Aprint 'Exiting @ tick', m5.curTick(), 'because', exit_event.getCause() 1162667SN/A 117