ruby_random_test.py revision 8845
13534Sgblack@eecs.umich.edu# Copyright (c) 2006-2007 The Regents of The University of Michigan 23534Sgblack@eecs.umich.edu# Copyright (c) 2009 Advanced Micro Devices, Inc. 33534Sgblack@eecs.umich.edu# All rights reserved. 43534Sgblack@eecs.umich.edu# 53534Sgblack@eecs.umich.edu# Redistribution and use in source and binary forms, with or without 63534Sgblack@eecs.umich.edu# modification, are permitted provided that the following conditions are 73534Sgblack@eecs.umich.edu# met: redistributions of source code must retain the above copyright 83534Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer; 93534Sgblack@eecs.umich.edu# redistributions in binary form must reproduce the above copyright 103534Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the 113534Sgblack@eecs.umich.edu# documentation and/or other materials provided with the distribution; 123534Sgblack@eecs.umich.edu# neither the name of the copyright holders nor the names of its 133534Sgblack@eecs.umich.edu# contributors may be used to endorse or promote products derived from 143534Sgblack@eecs.umich.edu# this software without specific prior written permission. 153534Sgblack@eecs.umich.edu# 163534Sgblack@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 173534Sgblack@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 183534Sgblack@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 193534Sgblack@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 203534Sgblack@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 213534Sgblack@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 223534Sgblack@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 233534Sgblack@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 243534Sgblack@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 253534Sgblack@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 263534Sgblack@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 273534Sgblack@eecs.umich.edu# 283534Sgblack@eecs.umich.edu# Authors: Ron Dreslinski 293534Sgblack@eecs.umich.edu# Brad Beckmann 303534Sgblack@eecs.umich.edu 313534Sgblack@eecs.umich.eduimport m5 324202Sbinkertn@umich.edufrom m5.objects import * 333534Sgblack@eecs.umich.edufrom m5.defines import buildEnv 349850Sandreas.hansson@arm.comfrom m5.util import addToPath 357768SAli.Saidi@ARM.comimport os, optparse, sys 367768SAli.Saidi@ARM.comaddToPath('../common') 378739Sgblack@eecs.umich.eduaddToPath('../ruby') 388739Sgblack@eecs.umich.edu 398739Sgblack@eecs.umich.eduimport Ruby 408739Sgblack@eecs.umich.edu 418739Sgblack@eecs.umich.edu# Get paths we might need. It's expected this file is in m5/configs/example. 428739Sgblack@eecs.umich.educonfig_path = os.path.dirname(os.path.abspath(__file__)) 438739Sgblack@eecs.umich.educonfig_root = os.path.dirname(config_path) 448739Sgblack@eecs.umich.edum5_root = os.path.dirname(config_root) 458739Sgblack@eecs.umich.edu 468739Sgblack@eecs.umich.eduparser = optparse.OptionParser() 478739Sgblack@eecs.umich.edu 484486Sbinkertn@umich.eduparser.add_option("-l", "--checks", metavar="N", default=100, 498739Sgblack@eecs.umich.edu help="Stop after N checks (loads)") 508739Sgblack@eecs.umich.eduparser.add_option("-f", "--wakeup_freq", metavar="N", default=10, 518739Sgblack@eecs.umich.edu help="Wakeup every N cycles") 529016Sandreas.hansson@arm.com 538739Sgblack@eecs.umich.edu# 548739Sgblack@eecs.umich.edu# Add the ruby specific and protocol specific options 558739Sgblack@eecs.umich.edu# 568739Sgblack@eecs.umich.eduRuby.define_options(parser) 578739Sgblack@eecs.umich.edu 588739Sgblack@eecs.umich.eduexecfile(os.path.join(config_root, "common", "Options.py")) 598739Sgblack@eecs.umich.edu 608739Sgblack@eecs.umich.edu(options, args) = parser.parse_args() 618739Sgblack@eecs.umich.edu 628739Sgblack@eecs.umich.edu# 638739Sgblack@eecs.umich.edu# Set the default cache size and associativity to be very small to encourage 648739Sgblack@eecs.umich.edu# races between requests and writebacks. 658739Sgblack@eecs.umich.edu# 668739Sgblack@eecs.umich.eduoptions.l1d_size="256B" 678739Sgblack@eecs.umich.eduoptions.l1i_size="256B" 688739Sgblack@eecs.umich.eduoptions.l2_size="512B" 698739Sgblack@eecs.umich.eduoptions.l3_size="1kB" 708739Sgblack@eecs.umich.eduoptions.l1d_assoc=2 718739Sgblack@eecs.umich.eduoptions.l1i_assoc=2 728739Sgblack@eecs.umich.eduoptions.l2_assoc=2 738739Sgblack@eecs.umich.eduoptions.l3_assoc=2 748739Sgblack@eecs.umich.edu 758739Sgblack@eecs.umich.eduif args: 768739Sgblack@eecs.umich.edu print "Error: script doesn't take any positional arguments" 778739Sgblack@eecs.umich.edu sys.exit(1) 785192Ssaidi@eecs.umich.edu 798739Sgblack@eecs.umich.edu# 808739Sgblack@eecs.umich.edu# Create the ruby random tester 818739Sgblack@eecs.umich.edu# 828739Sgblack@eecs.umich.edu 838739Sgblack@eecs.umich.edu# Check the protocol 848739Sgblack@eecs.umich.educheck_flush = False 858739Sgblack@eecs.umich.eduif buildEnv['PROTOCOL'] == 'MOESI_hammer': 868739Sgblack@eecs.umich.edu check_flush = True 878739Sgblack@eecs.umich.edu 888739Sgblack@eecs.umich.edutester = RubyTester(check_flush = check_flush, 898739Sgblack@eecs.umich.edu checks_to_complete = options.checks, 908739Sgblack@eecs.umich.edu wakeup_frequency = options.wakeup_freq) 918739Sgblack@eecs.umich.edu 928739Sgblack@eecs.umich.edu# 938739Sgblack@eecs.umich.edu# Create the M5 system. Note that the PhysicalMemory Object isn't 948739Sgblack@eecs.umich.edu# actually used by the rubytester, but is included to support the 958739Sgblack@eecs.umich.edu# M5 memory size == Ruby memory size checks 968739Sgblack@eecs.umich.edu# 978739Sgblack@eecs.umich.edusystem = System(tester = tester, physmem = PhysicalMemory()) 988739Sgblack@eecs.umich.edu 998739Sgblack@eecs.umich.eduRuby.create_system(options, system) 1008739Sgblack@eecs.umich.edu 1018739Sgblack@eecs.umich.eduassert(options.num_cpus == len(system.ruby._cpu_ruby_ports)) 1028739Sgblack@eecs.umich.edu 1038739Sgblack@eecs.umich.edu# 1045192Ssaidi@eecs.umich.edu# The tester is most effective when randomization is turned on and 1058739Sgblack@eecs.umich.edu# artifical delay is randomly inserted on messages 1068739Sgblack@eecs.umich.edu# 1078739Sgblack@eecs.umich.edusystem.ruby.randomization = True 1088739Sgblack@eecs.umich.edu 1098739Sgblack@eecs.umich.edufor ruby_port in system.ruby._cpu_ruby_ports: 1108739Sgblack@eecs.umich.edu # 1118739Sgblack@eecs.umich.edu # Tie the ruby tester ports to the ruby cpu ports 112 # 113 tester.cpuPort = ruby_port.slave 114 115 # 116 # Tell each sequencer this is the ruby tester so that it 117 # copies the subblock back to the checker 118 # 119 ruby_port.using_ruby_tester = True 120 121 # 122 # Ruby doesn't need the backing image of memory when running with 123 # the tester. 124 # 125 ruby_port.access_phys_mem = False 126 127# ----------------------- 128# run simulation 129# ----------------------- 130 131root = Root( full_system = False, system = system ) 132root.system.mem_mode = 'timing' 133 134# Not much point in this being higher than the L1 latency 135m5.ticks.setGlobalFrequency('1ns') 136 137# instantiate configuration 138m5.instantiate() 139 140# simulate until program terminates 141exit_event = m5.simulate(options.maxtick) 142 143print 'Exiting @ tick', m5.curTick(), 'because', exit_event.getCause() 144