ruby_direct_test.py revision 7538
15659Sgblack@eecs.umich.edu# Copyright (c) 2006-2007 The Regents of The University of Michigan 25659Sgblack@eecs.umich.edu# Copyright (c) 2009 Advanced Micro Devices, Inc. 35659Sgblack@eecs.umich.edu# All rights reserved. 45659Sgblack@eecs.umich.edu# 55659Sgblack@eecs.umich.edu# Redistribution and use in source and binary forms, with or without 65659Sgblack@eecs.umich.edu# modification, are permitted provided that the following conditions are 75659Sgblack@eecs.umich.edu# met: redistributions of source code must retain the above copyright 85659Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer; 95659Sgblack@eecs.umich.edu# redistributions in binary form must reproduce the above copyright 105659Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the 115659Sgblack@eecs.umich.edu# documentation and/or other materials provided with the distribution; 125659Sgblack@eecs.umich.edu# neither the name of the copyright holders nor the names of its 135659Sgblack@eecs.umich.edu# contributors may be used to endorse or promote products derived from 145659Sgblack@eecs.umich.edu# this software without specific prior written permission. 155659Sgblack@eecs.umich.edu# 165659Sgblack@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 175659Sgblack@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 185659Sgblack@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 195659Sgblack@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 205659Sgblack@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 215659Sgblack@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 225659Sgblack@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 235659Sgblack@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 245659Sgblack@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 255659Sgblack@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 265659Sgblack@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 275659Sgblack@eecs.umich.edu# 285659Sgblack@eecs.umich.edu# Authors: Ron Dreslinski 295659Sgblack@eecs.umich.edu# Brad Beckmann 305659Sgblack@eecs.umich.edu 315659Sgblack@eecs.umich.eduimport m5 325659Sgblack@eecs.umich.edufrom m5.objects import * 335659Sgblack@eecs.umich.edufrom m5.defines import buildEnv 345659Sgblack@eecs.umich.edufrom m5.util import addToPath 355659Sgblack@eecs.umich.eduimport os, optparse, sys 365659Sgblack@eecs.umich.eduaddToPath('../common') 375659Sgblack@eecs.umich.eduaddToPath('../ruby') 385659Sgblack@eecs.umich.edu 395659Sgblack@eecs.umich.eduimport Ruby 405659Sgblack@eecs.umich.edu 415659Sgblack@eecs.umich.eduif buildEnv['FULL_SYSTEM']: 425659Sgblack@eecs.umich.edu panic("This script requires system-emulation mode (*_SE).") 435659Sgblack@eecs.umich.edu 445659Sgblack@eecs.umich.edu# Get paths we might need. It's expected this file is in m5/configs/example. 455659Sgblack@eecs.umich.educonfig_path = os.path.dirname(os.path.abspath(__file__)) 465659Sgblack@eecs.umich.educonfig_root = os.path.dirname(config_path) 475659Sgblack@eecs.umich.edum5_root = os.path.dirname(config_root) 485659Sgblack@eecs.umich.edu 495659Sgblack@eecs.umich.eduparser = optparse.OptionParser() 505659Sgblack@eecs.umich.edu 515659Sgblack@eecs.umich.eduparser.add_option("-l", "--checks", metavar="N", default=100, 525659Sgblack@eecs.umich.edu help="Stop after N checks (loads)") 535659Sgblack@eecs.umich.eduparser.add_option("-f", "--wakeup_freq", metavar="N", default=10, 545659Sgblack@eecs.umich.edu help="Wakeup every N cycles") 555659Sgblack@eecs.umich.edu 565659Sgblack@eecs.umich.edu# 575659Sgblack@eecs.umich.edu# Add the ruby specific and protocol specific options 585659Sgblack@eecs.umich.edu# 595659Sgblack@eecs.umich.eduRuby.define_options(parser) 605659Sgblack@eecs.umich.edu 615659Sgblack@eecs.umich.eduexecfile(os.path.join(config_root, "common", "Options.py")) 625659Sgblack@eecs.umich.edu 635659Sgblack@eecs.umich.edu(options, args) = parser.parse_args() 645659Sgblack@eecs.umich.edu 655659Sgblack@eecs.umich.edu# 666040Sgblack@eecs.umich.edu# Set the default cache size and associativity to be very small to encourage 675659Sgblack@eecs.umich.edu# races between requests and writebacks. 685659Sgblack@eecs.umich.edu# 695659Sgblack@eecs.umich.eduoptions.l1d_size="256B" 705659Sgblack@eecs.umich.eduoptions.l1i_size="256B" 715659Sgblack@eecs.umich.eduoptions.l2_size="512B" 725659Sgblack@eecs.umich.eduoptions.l3_size="1kB" 735659Sgblack@eecs.umich.eduoptions.l1d_assoc=2 745659Sgblack@eecs.umich.eduoptions.l1i_assoc=2 755659Sgblack@eecs.umich.eduoptions.l2_assoc=2 765659Sgblack@eecs.umich.eduoptions.l3_assoc=2 775659Sgblack@eecs.umich.edu 785659Sgblack@eecs.umich.eduif args: 795659Sgblack@eecs.umich.edu print "Error: script doesn't take any positional arguments" 805659Sgblack@eecs.umich.edu sys.exit(1) 815659Sgblack@eecs.umich.edu 825659Sgblack@eecs.umich.edu# 835659Sgblack@eecs.umich.edu# Create the ruby random tester 845659Sgblack@eecs.umich.edu# 855659Sgblack@eecs.umich.edutester = RubyTester(checks_to_complete = options.checks, 865659Sgblack@eecs.umich.edu wakeup_frequency = options.wakeup_freq) 875659Sgblack@eecs.umich.edu 885659Sgblack@eecs.umich.edu# 895659Sgblack@eecs.umich.edu# Create the M5 system. Note that the PhysicalMemory Object isn't 905659Sgblack@eecs.umich.edu# actually used by the rubytester, but is included to support the 915659Sgblack@eecs.umich.edu# M5 memory size == Ruby memory size checks 926052Sgblack@eecs.umich.edu# 935659Sgblack@eecs.umich.edusystem = System(physmem = PhysicalMemory()) 945659Sgblack@eecs.umich.edu 955659Sgblack@eecs.umich.edusystem.ruby = Ruby.create_system(options, system.physmem) 965659Sgblack@eecs.umich.edu 975659Sgblack@eecs.umich.eduassert(options.num_cpus == len(system.ruby.cpu_ruby_ports)) 985659Sgblack@eecs.umich.edu 995659Sgblack@eecs.umich.edu# 1005659Sgblack@eecs.umich.edu# The tester is most effective when randomization is turned on and 1015659Sgblack@eecs.umich.edu# artifical delay is randomly inserted on messages 1025659Sgblack@eecs.umich.edu# 1035659Sgblack@eecs.umich.edusystem.ruby.randomization = True 1045659Sgblack@eecs.umich.edu 1055659Sgblack@eecs.umich.edufor ruby_port in system.ruby.cpu_ruby_ports: 1065659Sgblack@eecs.umich.edu # 1075659Sgblack@eecs.umich.edu # Tie the ruby tester ports to the ruby cpu ports 1085659Sgblack@eecs.umich.edu # 1095659Sgblack@eecs.umich.edu tester.cpuPort = ruby_port.port 1105659Sgblack@eecs.umich.edu 1115659Sgblack@eecs.umich.edu # 1125659Sgblack@eecs.umich.edu # Tell each sequencer this is the ruby tester so that it 1135659Sgblack@eecs.umich.edu # copies the subblock back to the checker 1145659Sgblack@eecs.umich.edu # 1155659Sgblack@eecs.umich.edu ruby_port.using_ruby_tester = True 1165659Sgblack@eecs.umich.edu 1175659Sgblack@eecs.umich.edu# ----------------------- 1185659Sgblack@eecs.umich.edu# run simulation 1195659Sgblack@eecs.umich.edu# ----------------------- 1205659Sgblack@eecs.umich.edu 1215659Sgblack@eecs.umich.eduroot = Root( system = system ) 1225659Sgblack@eecs.umich.eduroot.system.mem_mode = 'timing' 1235659Sgblack@eecs.umich.edu 1245659Sgblack@eecs.umich.edu# Not much point in this being higher than the L1 latency 1255659Sgblack@eecs.umich.edum5.ticks.setGlobalFrequency('1ns') 1265659Sgblack@eecs.umich.edu 1275659Sgblack@eecs.umich.edu# instantiate configuration 1285659Sgblack@eecs.umich.edum5.instantiate() 1295659Sgblack@eecs.umich.edu 1305659Sgblack@eecs.umich.edu# simulate until program terminates 1315659Sgblack@eecs.umich.eduexit_event = m5.simulate(options.maxtick) 1325659Sgblack@eecs.umich.edu 1335659Sgblack@eecs.umich.eduprint 'Exiting @ tick', m5.curTick(), 'because', exit_event.getCause() 1345659Sgblack@eecs.umich.edu