fs.py revision 3005
15450Sgblack@eecs.umich.edu# Copyright (c) 2006 The Regents of The University of Michigan 25450Sgblack@eecs.umich.edu# All rights reserved. 35450Sgblack@eecs.umich.edu# 45450Sgblack@eecs.umich.edu# Redistribution and use in source and binary forms, with or without 55450Sgblack@eecs.umich.edu# modification, are permitted provided that the following conditions are 65450Sgblack@eecs.umich.edu# met: redistributions of source code must retain the above copyright 75450Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer; 85450Sgblack@eecs.umich.edu# redistributions in binary form must reproduce the above copyright 95450Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the 105450Sgblack@eecs.umich.edu# documentation and/or other materials provided with the distribution; 115450Sgblack@eecs.umich.edu# neither the name of the copyright holders nor the names of its 125450Sgblack@eecs.umich.edu# contributors may be used to endorse or promote products derived from 135450Sgblack@eecs.umich.edu# this software without specific prior written permission. 145450Sgblack@eecs.umich.edu# 155450Sgblack@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 165450Sgblack@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 175450Sgblack@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 185450Sgblack@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 195450Sgblack@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 205450Sgblack@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 215450Sgblack@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 225450Sgblack@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 235450Sgblack@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 245450Sgblack@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 255450Sgblack@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 265450Sgblack@eecs.umich.edu# 275450Sgblack@eecs.umich.edu# Authors: Ali Saidi 285450Sgblack@eecs.umich.edu 295450Sgblack@eecs.umich.eduimport optparse, os, sys 305450Sgblack@eecs.umich.edu 315450Sgblack@eecs.umich.eduimport m5 325450Sgblack@eecs.umich.edufrom m5.objects import * 335450Sgblack@eecs.umich.edum5.AddToPath('../common') 345450Sgblack@eecs.umich.edufrom FSConfig import * 355450Sgblack@eecs.umich.edufrom SysPaths import * 365450Sgblack@eecs.umich.edufrom Benchmarks import * 375450Sgblack@eecs.umich.edu 385450Sgblack@eecs.umich.eduparser = optparse.OptionParser() 395450Sgblack@eecs.umich.edu 405450Sgblack@eecs.umich.eduparser.add_option("-d", "--detailed", action="store_true") 415450Sgblack@eecs.umich.eduparser.add_option("-t", "--timing", action="store_true") 425450Sgblack@eecs.umich.eduparser.add_option("-m", "--maxtick", type="int") 435450Sgblack@eecs.umich.eduparser.add_option("--maxtime", type="float") 445450Sgblack@eecs.umich.eduparser.add_option("--dual", action="store_true", 455450Sgblack@eecs.umich.edu help="Simulate two systems attached with an ethernet link") 465450Sgblack@eecs.umich.eduparser.add_option("-b", "--benchmark", action="store", type="string", 475450Sgblack@eecs.umich.edu dest="benchmark", 485450Sgblack@eecs.umich.edu help="Specify the benchmark to run. Available benchmarks: %s"\ 495450Sgblack@eecs.umich.edu % DefinedBenchmarks) 505450Sgblack@eecs.umich.edu 515450Sgblack@eecs.umich.edu(options, args) = parser.parse_args() 525450Sgblack@eecs.umich.edu 535450Sgblack@eecs.umich.eduif args: 545450Sgblack@eecs.umich.edu print "Error: script doesn't take any positional arguments" 555450Sgblack@eecs.umich.edu sys.exit(1) 565450Sgblack@eecs.umich.edu 575450Sgblack@eecs.umich.eduif options.detailed: 585450Sgblack@eecs.umich.edu cpu = DetailedO3CPU() 595450Sgblack@eecs.umich.edu cpu2 = DetailedO3CPU() 605450Sgblack@eecs.umich.edu mem_mode = 'timing' 615610Snate@binkert.orgelif options.timing: 625450Sgblack@eecs.umich.edu cpu = TimingSimpleCPU() 635450Sgblack@eecs.umich.edu cpu2 = TimingSimpleCPU() 645450Sgblack@eecs.umich.edu mem_mode = 'timing' 655450Sgblack@eecs.umich.eduelse: 665450Sgblack@eecs.umich.edu cpu = AtomicSimpleCPU() 675450Sgblack@eecs.umich.edu cpu2 = AtomicSimpleCPU() 685450Sgblack@eecs.umich.edu mem_mode = 'atomic' 695610Snate@binkert.org 705450Sgblack@eecs.umich.educpu.clock = '2GHz' 715450Sgblack@eecs.umich.educpu2.clock = '2GHz' 72 73if options.benchmark: 74 if options.benchmark not in Benchmarks: 75 print "Error benchmark %s has not been defined." % options.benchmark 76 print "Valid benchmarks are: %s" % DefinedBenchmarks 77 sys.exit(1) 78 79 bm = Benchmarks[options.benchmark] 80else: 81 if options.dual: 82 bm = [Machine(), Machine()] 83 else: 84 bm = [Machine()] 85 86if len(bm) == 2: 87 s1 = makeLinuxAlphaSystem(mem_mode, bm[0]) 88 s1.cpu = cpu 89 cpu.connectMemPorts(s1.membus) 90 s2 = makeLinuxAlphaSystem(mem_mode, bm[1]) 91 s2.cpu = cpu2 92 cpu2.connectMemPorts(s2.membus) 93 root = makeDualRoot(s1, s2) 94elif len(bm) == 1: 95 root = Root(clock = '1THz', 96 system = makeLinuxAlphaSystem(mem_mode, bm[0])) 97 root.system.cpu = cpu 98 cpu.connectMemPorts(root.system.membus) 99else: 100 print "Error I don't know how to create more than 2 systems." 101 sys.exit(1) 102 103m5.instantiate(root) 104 105#exit_event = m5.simulate(2600000000000) 106#if exit_event.getCause() != "user interrupt received": 107# m5.checkpoint(root, 'cpt') 108# exit_event = m5.simulate(300000000000) 109# if exit_event.getCause() != "user interrupt received": 110# m5.checkpoint(root, 'cptA') 111 112 113if options.maxtick: 114 exit_event = m5.simulate(options.maxtick) 115elif options.maxtime: 116 simtime = int(options.maxtime * root.clock.value) 117 print "simulating for: ", simtime 118 exit_event = m5.simulate(simtime) 119else: 120 exit_event = m5.simulate() 121 122print 'Exiting @ cycle', m5.curTick(), 'because', exit_event.getCause() 123