Cache.py revision 11197
110816SN/A# Copyright (c) 2012-2013, 2015 ARM Limited
29288SN/A# All rights reserved.
39288SN/A#
49288SN/A# The license below extends only to copyright in the software and shall
59288SN/A# not be construed as granting a license to any other intellectual
69288SN/A# property including but not limited to intellectual property relating
79288SN/A# to a hardware implementation of the functionality of the software
89288SN/A# licensed hereunder.  You may use the software subject to the license
99288SN/A# terms below provided that you ensure that this notice is replicated
109288SN/A# unmodified and in its entirety in all distributions of the software,
119288SN/A# modified or unmodified, in source code or in binary form.
129288SN/A#
134486SN/A# Copyright (c) 2005-2007 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
4011053Sandreas.hansson@arm.com#          Andreas Hansson
414486SN/A
423102SN/Afrom m5.params import *
438833SN/Afrom m5.proxy import *
442826SN/Afrom MemObject import MemObject
458831SN/Afrom Prefetcher import BasePrefetcher
469796SN/Afrom Tags import *
471615SN/A
482826SN/Aclass BaseCache(MemObject):
491366SN/A    type = 'BaseCache'
5011053Sandreas.hansson@arm.com    abstract = True
519338SN/A    cxx_header = "mem/cache/base.hh"
5210816SN/A
5310816SN/A    size = Param.MemorySize("Capacity")
5410816SN/A    assoc = Param.Unsigned("Associativity")
5510816SN/A
5610816SN/A    hit_latency = Param.Cycles("Hit latency")
5710816SN/A    response_latency = Param.Cycles("Latency for the return path on a miss");
5810816SN/A
591310SN/A    max_miss_count = Param.Counter(0,
6010816SN/A        "Number of misses to handle before calling exit")
6110816SN/A
6210816SN/A    mshrs = Param.Unsigned("Number of MSHRs (max outstanding requests)")
6310816SN/A    demand_mshr_reserve = Param.Unsigned(1, "MSHRs reserved for demand access")
6410816SN/A    tgts_per_mshr = Param.Unsigned("Max number of accesses per MSHR")
6510816SN/A    write_buffers = Param.Unsigned(8, "Number of write buffers")
6610816SN/A
676122SN/A    forward_snoops = Param.Bool(True,
6810816SN/A        "Forward snoops from mem side to cpu side")
6910884SN/A    is_read_only = Param.Bool(False, "Is this cache read only (e.g. inst)")
7010816SN/A
7110816SN/A    prefetcher = Param.BasePrefetcher(NULL,"Prefetcher attached to cache")
725875SN/A    prefetch_on_access = Param.Bool(False,
7310816SN/A         "Notify the hardware prefetcher on every access (not just misses)")
7410816SN/A
7510816SN/A    tags = Param.BaseTags(LRU(), "Tag store (replacement policy)")
7610025SN/A    sequential_access = Param.Bool(False,
7710025SN/A        "Whether to access tags and data sequentially")
7810816SN/A
7910816SN/A    cpu_side = SlavePort("Upstream port closer to the CPU and/or device")
8010816SN/A    mem_side = MasterPort("Downstream port closer to memory")
8110816SN/A
8210816SN/A    addr_ranges = VectorParam.AddrRange([AllMemory],
8310816SN/A         "Address range for the CPU-side port (to allow striping)")
8410816SN/A
8510816SN/A    system = Param.System(Parent.any, "System we belong to")
8611053Sandreas.hansson@arm.com
8711197Sandreas.hansson@arm.com# Enum for cache clusivity, currently mostly inclusive or mostly
8811197Sandreas.hansson@arm.com# exclusive.
8911197Sandreas.hansson@arm.comclass Clusivity(Enum): vals = ['mostly_incl', 'mostly_excl']
9011197Sandreas.hansson@arm.com
9111053Sandreas.hansson@arm.comclass Cache(BaseCache):
9211053Sandreas.hansson@arm.com    type = 'Cache'
9311053Sandreas.hansson@arm.com    cxx_header = 'mem/cache/cache.hh'
9411197Sandreas.hansson@arm.com
9511197Sandreas.hansson@arm.com    # Control whether this cache should be mostly inclusive or mostly
9611197Sandreas.hansson@arm.com    # exclusive with respect to upstream caches. The behaviour on a
9711197Sandreas.hansson@arm.com    # fill is determined accordingly. For a mostly inclusive cache,
9811197Sandreas.hansson@arm.com    # blocks are allocated on all fill operations. Thus, L1 caches
9911197Sandreas.hansson@arm.com    # should be set as mostly inclusive even if they have no upstream
10011197Sandreas.hansson@arm.com    # caches. In the case of a mostly exclusive cache, fills are not
10111197Sandreas.hansson@arm.com    # allocating unless they came directly from a non-caching source,
10211197Sandreas.hansson@arm.com    # e.g. a table walker. Additionally, on a hit from an upstream
10311197Sandreas.hansson@arm.com    # cache a line is dropped for a mostly exclusive cache.
10411197Sandreas.hansson@arm.com    clusivity = Param.Clusivity('mostly_incl',
10511197Sandreas.hansson@arm.com                                "Clusivity with upstream cache")
106