XBar.py revision 12341
112341Snikos.nikoleris@arm.com# Copyright (c) 2012, 2015, 2017 ARM Limited
29036SN/A# All rights reserved.
39036SN/A#
49036SN/A# The license below extends only to copyright in the software and shall
59036SN/A# not be construed as granting a license to any other intellectual
69036SN/A# property including but not limited to intellectual property relating
79036SN/A# to a hardware implementation of the functionality of the software
89036SN/A# licensed hereunder.  You may use the software subject to the license
99036SN/A# terms below provided that you ensure that this notice is replicated
109036SN/A# unmodified and in its entirety in all distributions of the software,
119036SN/A# modified or unmodified, in source code or in binary form.
129036SN/A#
135354SN/A# Copyright (c) 2005-2008 The Regents of The University of Michigan
144486SN/A# All rights reserved.
154486SN/A#
164486SN/A# Redistribution and use in source and binary forms, with or without
174486SN/A# modification, are permitted provided that the following conditions are
184486SN/A# met: redistributions of source code must retain the above copyright
194486SN/A# notice, this list of conditions and the following disclaimer;
204486SN/A# redistributions in binary form must reproduce the above copyright
214486SN/A# notice, this list of conditions and the following disclaimer in the
224486SN/A# documentation and/or other materials provided with the distribution;
234486SN/A# neither the name of the copyright holders nor the names of its
244486SN/A# contributors may be used to endorse or promote products derived from
254486SN/A# this software without specific prior written permission.
264486SN/A#
274486SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
284486SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
294486SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
304486SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
314486SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
324486SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
334486SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
344486SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
354486SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
364486SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
374486SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
384486SN/A#
394486SN/A# Authors: Nathan Binkert
409036SN/A#          Andreas Hansson
414486SN/A
429036SN/Afrom MemObject import MemObject
439524SN/Afrom System import System
443102SN/Afrom m5.params import *
459524SN/Afrom m5.proxy import *
4610399SN/Afrom m5.SimObject import SimObject
474486SN/A
4810405Sandreas.hansson@arm.comclass BaseXBar(MemObject):
4910405Sandreas.hansson@arm.com    type = 'BaseXBar'
509036SN/A    abstract = True
5110405Sandreas.hansson@arm.com    cxx_header = "mem/xbar.hh"
5210719SMarco.Balboni@ARM.com
5310719SMarco.Balboni@ARM.com    slave = VectorSlavePort("Vector port for connecting masters")
5410719SMarco.Balboni@ARM.com    master = VectorMasterPort("Vector port for connecting slaves")
5510719SMarco.Balboni@ARM.com
5610719SMarco.Balboni@ARM.com    # Latencies governing the time taken for the variuos paths a
5710719SMarco.Balboni@ARM.com    # packet has through the crossbar. Note that the crossbar itself
5810719SMarco.Balboni@ARM.com    # does not add the latency due to assumptions in the coherency
5910719SMarco.Balboni@ARM.com    # mechanism. Instead the latency is annotated on the packet and
6010719SMarco.Balboni@ARM.com    # left to the neighbouring modules.
6110719SMarco.Balboni@ARM.com    #
6210719SMarco.Balboni@ARM.com    # A request incurs the frontend latency, possibly snoop filter
6310719SMarco.Balboni@ARM.com    # lookup latency, and forward latency. A response incurs the
6410719SMarco.Balboni@ARM.com    # response latency. Frontend latency encompasses arbitration and
6510719SMarco.Balboni@ARM.com    # deciding what to do when a request arrives. the forward latency
6610719SMarco.Balboni@ARM.com    # is the latency involved once a decision is made to forward the
6710719SMarco.Balboni@ARM.com    # request. The response latency, is similar to the forward
6810719SMarco.Balboni@ARM.com    # latency, but for responses rather than requests.
6910720Sandreas.hansson@arm.com    frontend_latency = Param.Cycles("Frontend latency")
7010720Sandreas.hansson@arm.com    forward_latency = Param.Cycles("Forward latency")
7110720Sandreas.hansson@arm.com    response_latency = Param.Cycles("Response latency")
7210719SMarco.Balboni@ARM.com
7310719SMarco.Balboni@ARM.com    # Width governing the throughput of the crossbar
7410720Sandreas.hansson@arm.com    width = Param.Unsigned("Datapath width per port (bytes)")
759036SN/A
769036SN/A    # The default port can be left unconnected, or be used to connect
779036SN/A    # a default slave port
789036SN/A    default = MasterPort("Port for connecting an optional default slave")
799036SN/A
809036SN/A    # The default port can be used unconditionally, or based on
819036SN/A    # address range, in which case it may overlap with other
829036SN/A    # ports. The default range is always checked first, thus creating
839036SN/A    # a two-level hierarchical lookup. This is useful e.g. for the PCI
8410405Sandreas.hansson@arm.com    # xbar configuration.
859036SN/A    use_default_range = Param.Bool(False, "Perform address mapping for " \
869036SN/A                                       "the default port")
879036SN/A
8810405Sandreas.hansson@arm.comclass NoncoherentXBar(BaseXBar):
8910405Sandreas.hansson@arm.com    type = 'NoncoherentXBar'
9010405Sandreas.hansson@arm.com    cxx_header = "mem/noncoherent_xbar.hh"
919036SN/A
9210405Sandreas.hansson@arm.comclass CoherentXBar(BaseXBar):
9310405Sandreas.hansson@arm.com    type = 'CoherentXBar'
9410405Sandreas.hansson@arm.com    cxx_header = "mem/coherent_xbar.hh"
959524SN/A
9610719SMarco.Balboni@ARM.com    # The coherent crossbar additionally has snoop responses that are
9710719SMarco.Balboni@ARM.com    # forwarded after a specific latency.
9810720Sandreas.hansson@arm.com    snoop_response_latency = Param.Cycles("Snoop response latency")
9910719SMarco.Balboni@ARM.com
10010719SMarco.Balboni@ARM.com    # An optional snoop filter
10110719SMarco.Balboni@ARM.com    snoop_filter = Param.SnoopFilter(NULL, "Selected snoop filter")
10210719SMarco.Balboni@ARM.com
10311334Sandreas.hansson@arm.com    # Determine how this crossbar handles packets where caches have
10411334Sandreas.hansson@arm.com    # already committed to responding, by establishing if the crossbar
10511334Sandreas.hansson@arm.com    # is the point of coherency or not.
10611334Sandreas.hansson@arm.com    point_of_coherency = Param.Bool(False, "Consider this crossbar the " \
10711334Sandreas.hansson@arm.com                                    "point of coherency")
10811334Sandreas.hansson@arm.com
10912341Snikos.nikoleris@arm.com    # Specify whether this crossbar is the point of unification.
11012341Snikos.nikoleris@arm.com    point_of_unification = Param.Bool(False, "Consider this crossbar the " \
11112341Snikos.nikoleris@arm.com                                      "point of unification")
11212341Snikos.nikoleris@arm.com
11310405Sandreas.hansson@arm.com    system = Param.System(Parent.any, "System that the crossbar belongs to.")
11410399SN/A
11510399SN/Aclass SnoopFilter(SimObject):
11610399SN/A    type = 'SnoopFilter'
11710399SN/A    cxx_header = "mem/snoop_filter.hh"
11810719SMarco.Balboni@ARM.com
11910719SMarco.Balboni@ARM.com    # Lookup latency of the snoop filter, added to requests that pass
12010719SMarco.Balboni@ARM.com    # through a coherent crossbar.
12110719SMarco.Balboni@ARM.com    lookup_latency = Param.Cycles(1, "Lookup latency")
12210399SN/A
12310405Sandreas.hansson@arm.com    system = Param.System(Parent.any, "System that the crossbar belongs to.")
12410720Sandreas.hansson@arm.com
12511132Sali.jafri@arm.com    # Sanity check on max capacity to track, adjust if needed.
12611132Sali.jafri@arm.com    max_capacity = Param.MemorySize('8MB', "Maximum capacity of snoop filter")
12711132Sali.jafri@arm.com
12810720Sandreas.hansson@arm.com# We use a coherent crossbar to connect multiple masters to the L2
12910720Sandreas.hansson@arm.com# caches. Normally this crossbar would be part of the cache itself.
13010720Sandreas.hansson@arm.comclass L2XBar(CoherentXBar):
13110720Sandreas.hansson@arm.com    # 256-bit crossbar by default
13210720Sandreas.hansson@arm.com    width = 32
13310720Sandreas.hansson@arm.com
13410720Sandreas.hansson@arm.com    # Assume that most of this is covered by the cache latencies, with
13510720Sandreas.hansson@arm.com    # no more than a single pipeline stage for any packet.
13610720Sandreas.hansson@arm.com    frontend_latency = 1
13710720Sandreas.hansson@arm.com    forward_latency = 0
13810720Sandreas.hansson@arm.com    response_latency = 1
13910720Sandreas.hansson@arm.com    snoop_response_latency = 1
14010720Sandreas.hansson@arm.com
14111132Sali.jafri@arm.com    # Use a snoop-filter by default, and set the latency to zero as
14211132Sali.jafri@arm.com    # the lookup is assumed to overlap with the frontend latency of
14311132Sali.jafri@arm.com    # the crossbar
14411132Sali.jafri@arm.com    snoop_filter = SnoopFilter(lookup_latency = 0)
14511132Sali.jafri@arm.com
14612341Snikos.nikoleris@arm.com    # This specialisation of the coherent crossbar is to be considered
14712341Snikos.nikoleris@arm.com    # the point of unification, it connects the dcache and the icache
14812341Snikos.nikoleris@arm.com    # to the first level of unified cache.
14912341Snikos.nikoleris@arm.com    point_of_unification = True
15012341Snikos.nikoleris@arm.com
15110720Sandreas.hansson@arm.com# One of the key coherent crossbar instances is the system
15210720Sandreas.hansson@arm.com# interconnect, tying together the CPU clusters, GPUs, and any I/O
15310720Sandreas.hansson@arm.com# coherent masters, and DRAM controllers.
15410720Sandreas.hansson@arm.comclass SystemXBar(CoherentXBar):
15510720Sandreas.hansson@arm.com    # 128-bit crossbar by default
15610720Sandreas.hansson@arm.com    width = 16
15710720Sandreas.hansson@arm.com
15810720Sandreas.hansson@arm.com    # A handful pipeline stages for each portion of the latency
15910720Sandreas.hansson@arm.com    # contributions.
16010720Sandreas.hansson@arm.com    frontend_latency = 3
16110720Sandreas.hansson@arm.com    forward_latency = 4
16210720Sandreas.hansson@arm.com    response_latency = 2
16310720Sandreas.hansson@arm.com    snoop_response_latency = 4
16410720Sandreas.hansson@arm.com
16511604Sandreas.hansson@arm.com    # Use a snoop-filter by default
16611604Sandreas.hansson@arm.com    snoop_filter = SnoopFilter(lookup_latency = 1)
16711604Sandreas.hansson@arm.com
16811334Sandreas.hansson@arm.com    # This specialisation of the coherent crossbar is to be considered
16911334Sandreas.hansson@arm.com    # the point of coherency, as there are no (coherent) downstream
17011334Sandreas.hansson@arm.com    # caches.
17111334Sandreas.hansson@arm.com    point_of_coherency = True
17211334Sandreas.hansson@arm.com
17312341Snikos.nikoleris@arm.com    # This specialisation of the coherent crossbar is to be considered
17412341Snikos.nikoleris@arm.com    # the point of unification, it connects the dcache and the icache
17512341Snikos.nikoleris@arm.com    # to the first level of unified cache. This is needed for systems
17612341Snikos.nikoleris@arm.com    # without caches where the SystemXBar is also the point of
17712341Snikos.nikoleris@arm.com    # unification.
17812341Snikos.nikoleris@arm.com    point_of_unification = True
17912341Snikos.nikoleris@arm.com
18010720Sandreas.hansson@arm.com# In addition to the system interconnect, we typically also have one
18110720Sandreas.hansson@arm.com# or more on-chip I/O crossbars. Note that at some point we might want
18210720Sandreas.hansson@arm.com# to also define an off-chip I/O crossbar such as PCIe.
18310720Sandreas.hansson@arm.comclass IOXBar(NoncoherentXBar):
18410720Sandreas.hansson@arm.com    # 128-bit crossbar by default
18510720Sandreas.hansson@arm.com    width = 16
18610720Sandreas.hansson@arm.com
18710720Sandreas.hansson@arm.com    # Assume a simpler datapath than a coherent crossbar, incuring
18810720Sandreas.hansson@arm.com    # less pipeline stages for decision making and forwarding of
18910720Sandreas.hansson@arm.com    # requests.
19010720Sandreas.hansson@arm.com    frontend_latency = 2
19110720Sandreas.hansson@arm.com    forward_latency = 1
19210720Sandreas.hansson@arm.com    response_latency = 2
193