ruby_random_test.py revision 10519
1955SN/A# Copyright (c) 2006-2007 The Regents of The University of Michigan 2955SN/A# Copyright (c) 2009 Advanced Micro Devices, Inc. 31762SN/A# All rights reserved. 4955SN/A# 5955SN/A# Redistribution and use in source and binary forms, with or without 6955SN/A# modification, are permitted provided that the following conditions are 7955SN/A# met: redistributions of source code must retain the above copyright 8955SN/A# notice, this list of conditions and the following disclaimer; 9955SN/A# redistributions in binary form must reproduce the above copyright 10955SN/A# notice, this list of conditions and the following disclaimer in the 11955SN/A# documentation and/or other materials provided with the distribution; 12955SN/A# neither the name of the copyright holders nor the names of its 13955SN/A# contributors may be used to endorse or promote products derived from 14955SN/A# this software without specific prior written permission. 15955SN/A# 16955SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17955SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18955SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19955SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20955SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21955SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22955SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23955SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24955SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25955SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26955SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27955SN/A# 282665Ssaidi@eecs.umich.edu# Authors: Ron Dreslinski 294762Snate@binkert.org# Brad Beckmann 30955SN/A 315522Snate@binkert.orgimport m5 326143Snate@binkert.orgfrom m5.objects import * 334762Snate@binkert.orgfrom m5.defines import buildEnv 345522Snate@binkert.orgfrom m5.util import addToPath 35955SN/Aimport os, optparse, sys 365522Snate@binkert.orgaddToPath('../common') 37955SN/AaddToPath('../ruby') 385522Snate@binkert.orgaddToPath('../topologies') 394202Sbinkertn@umich.edu 405742Snate@binkert.orgimport Options 41955SN/Aimport Ruby 424381Sbinkertn@umich.edu 434381Sbinkertn@umich.edu# Get paths we might need. It's expected this file is in m5/configs/example. 44955SN/Aconfig_path = os.path.dirname(os.path.abspath(__file__)) 45955SN/Aconfig_root = os.path.dirname(config_path) 46955SN/Am5_root = os.path.dirname(config_root) 474202Sbinkertn@umich.edu 48955SN/Aparser = optparse.OptionParser() 494382Sbinkertn@umich.eduOptions.addCommonOptions(parser) 504382Sbinkertn@umich.edu 514382Sbinkertn@umich.eduparser.add_option("--maxloads", metavar="N", default=100, 526654Snate@binkert.org help="Stop after N loads") 535517Snate@binkert.orgparser.add_option("-f", "--wakeup_freq", metavar="N", default=10, 547674Snate@binkert.org help="Wakeup every N cycles") 557674Snate@binkert.org 566143Snate@binkert.org# 576143Snate@binkert.org# Add the ruby specific and protocol specific options 586143Snate@binkert.org# 596143Snate@binkert.orgRuby.define_options(parser) 606143Snate@binkert.org 616143Snate@binkert.orgexecfile(os.path.join(config_root, "common", "Options.py")) 626143Snate@binkert.org 636143Snate@binkert.org(options, args) = parser.parse_args() 646143Snate@binkert.org 656143Snate@binkert.org# 666143Snate@binkert.org# Set the default cache size and associativity to be very small to encourage 676143Snate@binkert.org# races between requests and writebacks. 686143Snate@binkert.org# 696143Snate@binkert.orgoptions.l1d_size="256B" 706143Snate@binkert.orgoptions.l1i_size="256B" 714762Snate@binkert.orgoptions.l2_size="512B" 726143Snate@binkert.orgoptions.l3_size="1kB" 736143Snate@binkert.orgoptions.l1d_assoc=2 746143Snate@binkert.orgoptions.l1i_assoc=2 756143Snate@binkert.orgoptions.l2_assoc=2 766143Snate@binkert.orgoptions.l3_assoc=2 776143Snate@binkert.org 786143Snate@binkert.orgif args: 796143Snate@binkert.org print "Error: script doesn't take any positional arguments" 806143Snate@binkert.org sys.exit(1) 816143Snate@binkert.org 826143Snate@binkert.org# 836143Snate@binkert.org# Create the ruby random tester 846143Snate@binkert.org# 856143Snate@binkert.org 866143Snate@binkert.org# Check the protocol 876143Snate@binkert.orgcheck_flush = False 886143Snate@binkert.orgif buildEnv['PROTOCOL'] == 'MOESI_hammer': 896143Snate@binkert.org check_flush = True 906143Snate@binkert.org 916143Snate@binkert.orgtester = RubyTester(check_flush = check_flush, 926143Snate@binkert.org checks_to_complete = options.maxloads, 937065Snate@binkert.org wakeup_frequency = options.wakeup_freq) 946143Snate@binkert.org 956143Snate@binkert.org# 966143Snate@binkert.org# Create the M5 system. Note that the Memory Object isn't 976143Snate@binkert.org# actually used by the rubytester, but is included to support the 986143Snate@binkert.org# M5 memory size == Ruby memory size checks 996143Snate@binkert.org# 1006143Snate@binkert.orgsystem = System(cpu = tester, physmem = SimpleMemory(), 1016143Snate@binkert.org mem_ranges = [AddrRange(options.mem_size)]) 1026143Snate@binkert.org 1036143Snate@binkert.org# Create a top-level voltage domain and clock domain 1046143Snate@binkert.orgsystem.voltage_domain = VoltageDomain(voltage = options.sys_voltage) 1056143Snate@binkert.org 1066143Snate@binkert.orgsystem.clk_domain = SrcClockDomain(clock = options.sys_clock, 1076143Snate@binkert.org voltage_domain = system.voltage_domain) 1086143Snate@binkert.org 1096143Snate@binkert.orgRuby.create_system(options, False, system) 1106143Snate@binkert.org 1116143Snate@binkert.org# Create a seperate clock domain for Ruby 1126143Snate@binkert.orgsystem.ruby.clk_domain = SrcClockDomain(clock = options.ruby_clock, 1136143Snate@binkert.org voltage_domain = system.voltage_domain) 1146143Snate@binkert.org 1155522Snate@binkert.orgassert(options.num_cpus == len(system.ruby._cpu_ports)) 1166143Snate@binkert.org 1176143Snate@binkert.orgtester.num_cpus = len(system.ruby._cpu_ports) 1186143Snate@binkert.org 1196143Snate@binkert.org# 1206143Snate@binkert.org# The tester is most effective when randomization is turned on and 1216143Snate@binkert.org# artifical delay is randomly inserted on messages 1226143Snate@binkert.org# 1236143Snate@binkert.orgsystem.ruby.randomization = True 1246143Snate@binkert.org 1256143Snate@binkert.orgfor ruby_port in system.ruby._cpu_ports: 1265522Snate@binkert.org # 1275522Snate@binkert.org # Tie the ruby tester ports to the ruby cpu read and write ports 1285522Snate@binkert.org # 1295522Snate@binkert.org if ruby_port.support_data_reqs: 1305604Snate@binkert.org tester.cpuDataPort = ruby_port.slave 1315604Snate@binkert.org if ruby_port.support_inst_reqs: 1326143Snate@binkert.org tester.cpuInstPort = ruby_port.slave 1336143Snate@binkert.org 1344762Snate@binkert.org # 1354762Snate@binkert.org # Tell each sequencer this is the ruby tester so that it 1366143Snate@binkert.org # copies the subblock back to the checker 1376727Ssteve.reinhardt@amd.com # 1386727Ssteve.reinhardt@amd.com ruby_port.using_ruby_tester = True 1396727Ssteve.reinhardt@amd.com 1404762Snate@binkert.org# ----------------------- 1416143Snate@binkert.org# run simulation 1426143Snate@binkert.org# ----------------------- 1436143Snate@binkert.org 1446143Snate@binkert.orgroot = Root( full_system = False, system = system ) 1456727Ssteve.reinhardt@amd.comroot.system.mem_mode = 'timing' 1466143Snate@binkert.org 1477674Snate@binkert.org# Not much point in this being higher than the L1 latency 1487674Snate@binkert.orgm5.ticks.setGlobalFrequency('1ns') 1495604Snate@binkert.org 1506143Snate@binkert.org# instantiate configuration 1516143Snate@binkert.orgm5.instantiate() 1526143Snate@binkert.org 1534762Snate@binkert.org# simulate until program terminates 1546143Snate@binkert.orgexit_event = m5.simulate(options.abs_max_tick) 1554762Snate@binkert.org 1564762Snate@binkert.orgprint 'Exiting @ tick', m5.curTick(), 'because', exit_event.getCause() 1574762Snate@binkert.org