ruby_random_test.py revision 9108:ad76a669e9d9
15081Sgblack@eecs.umich.edu# Copyright (c) 2006-2007 The Regents of The University of Michigan 25081Sgblack@eecs.umich.edu# Copyright (c) 2009 Advanced Micro Devices, Inc. 35081Sgblack@eecs.umich.edu# All rights reserved. 45081Sgblack@eecs.umich.edu# 55081Sgblack@eecs.umich.edu# Redistribution and use in source and binary forms, with or without 65081Sgblack@eecs.umich.edu# modification, are permitted provided that the following conditions are 75081Sgblack@eecs.umich.edu# met: redistributions of source code must retain the above copyright 85081Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer; 95081Sgblack@eecs.umich.edu# redistributions in binary form must reproduce the above copyright 105081Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the 115081Sgblack@eecs.umich.edu# documentation and/or other materials provided with the distribution; 125081Sgblack@eecs.umich.edu# neither the name of the copyright holders nor the names of its 135081Sgblack@eecs.umich.edu# contributors may be used to endorse or promote products derived from 145081Sgblack@eecs.umich.edu# this software without specific prior written permission. 155081Sgblack@eecs.umich.edu# 165081Sgblack@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 175081Sgblack@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 185081Sgblack@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 195081Sgblack@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 205081Sgblack@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 215081Sgblack@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 225081Sgblack@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 235081Sgblack@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 245081Sgblack@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 255081Sgblack@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 265081Sgblack@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 275081Sgblack@eecs.umich.edu# 285081Sgblack@eecs.umich.edu# Authors: Ron Dreslinski 295081Sgblack@eecs.umich.edu# Brad Beckmann 305081Sgblack@eecs.umich.edu 315081Sgblack@eecs.umich.eduimport m5 325081Sgblack@eecs.umich.edufrom m5.objects import * 335081Sgblack@eecs.umich.edufrom m5.defines import buildEnv 345081Sgblack@eecs.umich.edufrom m5.util import addToPath 355081Sgblack@eecs.umich.eduimport os, optparse, sys 365081Sgblack@eecs.umich.eduaddToPath('../common') 375081Sgblack@eecs.umich.eduaddToPath('../ruby') 385081Sgblack@eecs.umich.eduaddToPath('../topologies') 395081Sgblack@eecs.umich.edu 405081Sgblack@eecs.umich.eduimport Options 415081Sgblack@eecs.umich.eduimport Ruby 425081Sgblack@eecs.umich.edu 435081Sgblack@eecs.umich.edu# Get paths we might need. It's expected this file is in m5/configs/example. 445081Sgblack@eecs.umich.educonfig_path = os.path.dirname(os.path.abspath(__file__)) 455081Sgblack@eecs.umich.educonfig_root = os.path.dirname(config_path) 465081Sgblack@eecs.umich.edum5_root = os.path.dirname(config_root) 475081Sgblack@eecs.umich.edu 485081Sgblack@eecs.umich.eduparser = optparse.OptionParser() 495081Sgblack@eecs.umich.eduOptions.addCommonOptions(parser) 505081Sgblack@eecs.umich.edu 515081Sgblack@eecs.umich.eduparser.add_option("-l", "--checks", metavar="N", default=100, 525081Sgblack@eecs.umich.edu help="Stop after N checks (loads)") 535081Sgblack@eecs.umich.eduparser.add_option("-f", "--wakeup_freq", metavar="N", default=10, 545081Sgblack@eecs.umich.edu help="Wakeup every N cycles") 555081Sgblack@eecs.umich.edu 565081Sgblack@eecs.umich.edu# 576588Sgblack@eecs.umich.edu# Add the ruby specific and protocol specific options 586588Sgblack@eecs.umich.edu# 596588Sgblack@eecs.umich.eduRuby.define_options(parser) 606588Sgblack@eecs.umich.edu 616588Sgblack@eecs.umich.eduexecfile(os.path.join(config_root, "common", "Options.py")) 626588Sgblack@eecs.umich.edu 636588Sgblack@eecs.umich.edu(options, args) = parser.parse_args() 646588Sgblack@eecs.umich.edu 656588Sgblack@eecs.umich.edu# 666588Sgblack@eecs.umich.edu# Set the default cache size and associativity to be very small to encourage 676588Sgblack@eecs.umich.edu# races between requests and writebacks. 686588Sgblack@eecs.umich.edu# 696588Sgblack@eecs.umich.eduoptions.l1d_size="256B" 706588Sgblack@eecs.umich.eduoptions.l1i_size="256B" 716588Sgblack@eecs.umich.eduoptions.l2_size="512B" 726588Sgblack@eecs.umich.eduoptions.l3_size="1kB" 736588Sgblack@eecs.umich.eduoptions.l1d_assoc=2 746588Sgblack@eecs.umich.eduoptions.l1i_assoc=2 756588Sgblack@eecs.umich.eduoptions.l2_assoc=2 766588Sgblack@eecs.umich.eduoptions.l3_assoc=2 776588Sgblack@eecs.umich.edu 786588Sgblack@eecs.umich.eduif args: 796588Sgblack@eecs.umich.edu print "Error: script doesn't take any positional arguments" 806588Sgblack@eecs.umich.edu sys.exit(1) 816588Sgblack@eecs.umich.edu 826588Sgblack@eecs.umich.edu# 836588Sgblack@eecs.umich.edu# Create the ruby random tester 846588Sgblack@eecs.umich.edu# 856588Sgblack@eecs.umich.edu 865081Sgblack@eecs.umich.edu# Check the protocol 875081Sgblack@eecs.umich.educheck_flush = False 88if buildEnv['PROTOCOL'] == 'MOESI_hammer': 89 check_flush = True 90 91tester = RubyTester(check_flush = check_flush, 92 checks_to_complete = options.checks, 93 wakeup_frequency = options.wakeup_freq) 94 95# 96# Create the M5 system. Note that the Memory Object isn't 97# actually used by the rubytester, but is included to support the 98# M5 memory size == Ruby memory size checks 99# 100system = System(tester = tester, physmem = SimpleMemory()) 101 102Ruby.create_system(options, system) 103 104assert(options.num_cpus == len(system.ruby._cpu_ruby_ports)) 105 106tester.num_cpus = len(system.ruby._cpu_ruby_ports) 107 108# 109# The tester is most effective when randomization is turned on and 110# artifical delay is randomly inserted on messages 111# 112system.ruby.randomization = True 113 114for ruby_port in system.ruby._cpu_ruby_ports: 115 # 116 # Tie the ruby tester ports to the ruby cpu read and write ports 117 # 118 if ruby_port.support_data_reqs: 119 tester.cpuDataPort = ruby_port.slave 120 if ruby_port.support_inst_reqs: 121 tester.cpuInstPort = ruby_port.slave 122 123 # 124 # Tell each sequencer this is the ruby tester so that it 125 # copies the subblock back to the checker 126 # 127 ruby_port.using_ruby_tester = True 128 129 # 130 # Ruby doesn't need the backing image of memory when running with 131 # the tester. 132 # 133 ruby_port.access_phys_mem = False 134 135# ----------------------- 136# run simulation 137# ----------------------- 138 139root = Root( full_system = False, system = system ) 140root.system.mem_mode = 'timing' 141 142# Not much point in this being higher than the L1 latency 143m5.ticks.setGlobalFrequency('1ns') 144 145# instantiate configuration 146m5.instantiate() 147 148# simulate until program terminates 149exit_event = m5.simulate(options.maxtick) 150 151print 'Exiting @ tick', m5.curTick(), 'because', exit_event.getCause() 152