test_caches.py revision 12610:ce4e3b0639b2
1# -*- coding: utf-8 -*- 2# Copyright (c) 2017 Jason Power 3# All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions are 7# met: redistributions of source code must retain the above copyright 8# notice, this list of conditions and the following disclaimer; 9# redistributions in binary form must reproduce the above copyright 10# notice, this list of conditions and the following disclaimer in the 11# documentation and/or other materials provided with the distribution; 12# neither the name of the copyright holders nor the names of its 13# contributors may be used to endorse or promote products derived from 14# this software without specific prior written permission. 15# 16# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27# 28# Authors: Jason Power 29 30""" This file creates a set of Ruby caches, the Ruby network, and a simple 31point-to-point topology for the RubyRandomTester to use. 32See Part 3 in the Learning gem5 book: learning.gem5.org/book/part3 33 34IMPORTANT: If you modify this file, it's likely that the Learning gem5 book 35 also needs to be updated. For now, email Jason <jason@lowepower.com> 36 37""" 38 39from m5.defines import buildEnv 40from m5.util import fatal 41 42from m5.objects import * 43 44from msi_caches import L1Cache, DirController, MyNetwork 45 46class TestCacheSystem(RubySystem): 47 48 def __init__(self): 49 if buildEnv['PROTOCOL'] != 'MSI': 50 fatal("This system assumes MSI from learning gem5!") 51 52 super(TestCacheSystem, self).__init__() 53 54 def setup(self, system, tester, mem_ctrls): 55 """Set up the Ruby cache subsystem. Note: This can't be done in the 56 constructor because many of these items require a pointer to the 57 ruby system (self). This causes infinite recursion in initialize() 58 if we do this in the __init__. 59 Setting up for running the RubyRandomTester is a little different 60 than when we're using CPUs. 61 """ 62 num_testers = tester.num_cpus 63 64 # Ruby's global network. 65 self.network = MyNetwork(self) 66 67 # MSI uses 3 virtual networks 68 self.number_of_virtual_networks = 3 69 self.network.number_of_virtual_networks = 3 70 71 self.controllers = \ 72 [L1Cache(system, self, self) for i in range(num_testers)] + \ 73 [DirController(self, system.mem_ranges, mem_ctrls)] 74 75 self.sequencers = [RubySequencer(version = i, 76 # I/D cache is combined and grab from ctrl 77 icache = self.controllers[i].cacheMemory, 78 dcache = self.controllers[i].cacheMemory, 79 clk_domain = self.clk_domain, 80 ) for i in range(num_testers)] 81 82 for i,c in enumerate(self.controllers[0:len(self.sequencers)]): 83 c.sequencer = self.sequencers[i] 84 85 self.num_of_sequencers = len(self.sequencers) 86 87 # Create the network and connect the controllers. 88 # NOTE: This is quite different if using Garnet! 89 self.network.connectControllers(self.controllers) 90 self.network.setup_buffers() 91 92 # Set up a proxy port for the system_port. Used for load binaries and 93 # other functional-only things. 94 self.sys_port_proxy = RubyPortProxy() 95 system.system_port = self.sys_port_proxy.slave 96 97 # Connect up the sequencers to the random tester 98 for seq in self.sequencers: 99 if seq.support_data_reqs and seq.support_inst_reqs: 100 tester.cpuInstDataPort = seq.slave 101 elif seq.support_data_reqs: 102 tester.cpuDataPort = seq.slave 103 elif seq.support_inst_reqs: 104 tester.cpuInstDataPort = seq.slave 105 106 # Do not automatically retry stalled Ruby requests 107 seq.no_retry_on_stall = True 108 109 # Tell each sequencer this is the ruby tester so that it 110 # copies the subblock back to the checker 111 seq.using_ruby_tester = True 112