AMD_Base_Constructor.py revision 12647:6d7e2f321496
12623SN/A# Copyright (c) 2015-2017 Advanced Micro Devices, Inc.
22623SN/A# All rights reserved.
32623SN/A#
42623SN/A# For use for simulation and test purposes only
52623SN/A#
62623SN/A# Redistribution and use in source and binary forms, with or without
72623SN/A# modification, are permitted provided that the following conditions are met:
82623SN/A#
92623SN/A# 1. Redistributions of source code must retain the above copyright notice,
102623SN/A# this list of conditions and the following disclaimer.
112623SN/A#
122623SN/A# 2. Redistributions in binary form must reproduce the above copyright notice,
132623SN/A# this list of conditions and the following disclaimer in the documentation
142623SN/A# and/or other materials provided with the distribution.
152623SN/A#
162623SN/A# 3. Neither the name of the copyright holder nor the names of its
172623SN/A# contributors may be used to endorse or promote products derived from this
182623SN/A# software without specific prior written permission.
192623SN/A#
202623SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
212623SN/A# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
222623SN/A# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
232623SN/A# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
242623SN/A# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
252623SN/A# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
262623SN/A# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
272665Ssaidi@eecs.umich.edu# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
282665Ssaidi@eecs.umich.edu# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
292623SN/A# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
302623SN/A# POSSIBILITY OF SUCH DAMAGE.
312623SN/A#
322623SN/A# Authors: Sooraj Puthoor,
332623SN/A#          Lisa Hsu
342623SN/A
352623SN/Aimport math
362901Ssaidi@eecs.umich.eduimport m5
372623SN/Afrom m5.objects import *
382623SN/Afrom m5.defines import buildEnv
392623SN/Afrom m5.util import convert
402623SN/Afrom CntrlBase import *
412856Srdreslin@umich.edufrom topologies.Cluster import Cluster
422856Srdreslin@umich.edu
432856Srdreslin@umich.edu#
442856Srdreslin@umich.edu# Note: the L1 Cache latency is only used by the sequencer on fast path hits
452856Srdreslin@umich.edu#
462856Srdreslin@umich.educlass L1Cache(RubyCache):
472856Srdreslin@umich.edu    latency = 1
482856Srdreslin@umich.edu    resourceStalls = False
492856Srdreslin@umich.edu    def create(self, size, assoc, options):
502856Srdreslin@umich.edu        self.size = MemorySize(size)
512623SN/A        self.assoc = assoc
522623SN/A        self.replacement_policy = PseudoLRUReplacementPolicy()
532623SN/A
542623SN/A#
552623SN/A# Note: the L2 Cache latency is not currently used
562623SN/A#
572680Sktlim@umich.educlass L2Cache(RubyCache):
582680Sktlim@umich.edu    latency = 10
592623SN/A    resourceStalls = False
602623SN/A    def create(self, size, assoc, options):
612680Sktlim@umich.edu        self.size = MemorySize(size)
622623SN/A        self.assoc = assoc
632623SN/A        self.replacement_policy = PseudoLRUReplacementPolicy()
642623SN/Aclass CPCntrl(AMD_Base_Controller, CntrlBase):
652623SN/A
662623SN/A    def create(self, options, ruby_system, system):
672630SN/A        self.version = self.versionCount()
682623SN/A        self.cntrl_id = self.cntrlCount()
692623SN/A
702623SN/A        self.L1Icache = L1Cache()
712623SN/A        self.L1Icache.create(options.l1i_size, options.l1i_assoc, options)
722623SN/A        self.L1D0cache = L1Cache()
732623SN/A        self.L1D0cache.create(options.l1d_size, options.l1d_assoc, options)
742630SN/A        self.L1D1cache = L1Cache()
752623SN/A        self.L1D1cache.create(options.l1d_size, options.l1d_assoc, options)
762623SN/A        self.L2cache = L2Cache()
772623SN/A        self.L2cache.create(options.l2_size, options.l2_assoc, options)
782623SN/A
792623SN/A        self.sequencer = RubySequencer()
802623SN/A        self.sequencer.version = self.seqCount()
812623SN/A        self.sequencer.icache = self.L1Icache
822631SN/A        self.sequencer.dcache = self.L1D0cache
832631SN/A        self.sequencer.ruby_system = ruby_system
842631SN/A        self.sequencer.coreid = 0
852623SN/A        self.sequencer.is_cpu_sequencer = True
862623SN/A
872623SN/A        self.sequencer1 = RubySequencer()
882948Ssaidi@eecs.umich.edu        self.sequencer1.version = self.seqCount()
892948Ssaidi@eecs.umich.edu        self.sequencer1.icache = self.L1Icache
902948Ssaidi@eecs.umich.edu        self.sequencer1.dcache = self.L1D1cache
912948Ssaidi@eecs.umich.edu        self.sequencer1.ruby_system = ruby_system
922948Ssaidi@eecs.umich.edu        self.sequencer1.coreid = 1
932948Ssaidi@eecs.umich.edu        self.sequencer1.is_cpu_sequencer = True
942948Ssaidi@eecs.umich.edu
952948Ssaidi@eecs.umich.edu        self.issue_latency = options.cpu_to_dir_latency
962623SN/A        self.send_evictions = send_evicts(options)
972948Ssaidi@eecs.umich.edu
982623SN/A        self.ruby_system = ruby_system
992623SN/A
1002623SN/A        if options.recycle_latency:
1012839Sktlim@umich.edu            self.recycle_latency = options.recycle_latency
1022867Sktlim@umich.edu
1033222Sktlim@umich.edudef define_options(parser):
1042901Ssaidi@eecs.umich.edu    parser.add_option("--cpu-to-dir-latency", type="int", default=15)
1052623SN/A
1062623SN/Adef construct(options, system, ruby_system):
1072623SN/A    if (buildEnv['PROTOCOL'] != 'GPU_VIPER' or
1082623SN/A        buildEnv['PROTOCOL'] != 'GPU_VIPER_Region' or
1092623SN/A        buildEnv['PROTOCOL'] != 'GPU_VIPER_Baseline'):
1102623SN/A        panic("This script requires VIPER based protocols \
1112623SN/A        to be built.")
1122623SN/A    cpu_sequencers = []
1132623SN/A    cpuCluster = None
1142623SN/A    cpuCluster = Cluster(name="CPU Cluster", extBW = 8, intBW=8) # 16 GB/s
1152915Sktlim@umich.edu    for i in xrange((options.num_cpus + 1) / 2):
1162915Sktlim@umich.edu
1172623SN/A        cp_cntrl = CPCntrl()
1182623SN/A        cp_cntrl.create(options, ruby_system, system)
1192623SN/A
1202623SN/A        # Connect the CP controllers to the ruby network
1212623SN/A        cp_cntrl.requestFromCore = ruby_system.network.slave
1222623SN/A        cp_cntrl.responseFromCore = ruby_system.network.slave
1232915Sktlim@umich.edu        cp_cntrl.unblockFromCore = ruby_system.network.slave
1242915Sktlim@umich.edu        cp_cntrl.probeToCore = ruby_system.network.master
1252623SN/A        cp_cntrl.responseToCore = ruby_system.network.master
1262798Sktlim@umich.edu
1272798Sktlim@umich.edu        exec("system.cp_cntrl%d = cp_cntrl" % i)
1282901Ssaidi@eecs.umich.edu        #
1292839Sktlim@umich.edu        # Add controllers and sequencers to the appropriate lists
1302798Sktlim@umich.edu        #
1312839Sktlim@umich.edu        cpu_sequencers.extend([cp_cntrl.sequencer, cp_cntrl.sequencer1])
1322798Sktlim@umich.edu        cpuCluster.add(cp_cntrl)
1332798Sktlim@umich.edu    return cpu_sequencers, cpuCluster
1342901Ssaidi@eecs.umich.edu