Cache.py revision 12600
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 4612600Sodanrc@yahoo.com.brfrom ReplacementPolicies import * 479796SN/Afrom Tags import * 481615SN/A 492826SN/Aclass BaseCache(MemObject): 501366SN/A type = 'BaseCache' 5111053Sandreas.hansson@arm.com abstract = True 529338SN/A cxx_header = "mem/cache/base.hh" 5310816SN/A 5410816SN/A size = Param.MemorySize("Capacity") 5510816SN/A assoc = Param.Unsigned("Associativity") 5610816SN/A 5711722Ssophiane.senni@gmail.com tag_latency = Param.Cycles("Tag lookup latency") 5811722Ssophiane.senni@gmail.com data_latency = Param.Cycles("Data access latency") 5910816SN/A response_latency = Param.Cycles("Latency for the return path on a miss"); 6010816SN/A 6112513Sodanrc@yahoo.com.br warmup_percentage = Param.Percent(0, 6212513Sodanrc@yahoo.com.br "Percentage of tags to be touched to warm up the cache") 6312513Sodanrc@yahoo.com.br 641310SN/A max_miss_count = Param.Counter(0, 6510816SN/A "Number of misses to handle before calling exit") 6610816SN/A 6710816SN/A mshrs = Param.Unsigned("Number of MSHRs (max outstanding requests)") 6810816SN/A demand_mshr_reserve = Param.Unsigned(1, "MSHRs reserved for demand access") 6910816SN/A tgts_per_mshr = Param.Unsigned("Max number of accesses per MSHR") 7010816SN/A write_buffers = Param.Unsigned(8, "Number of write buffers") 7110816SN/A 7210884SN/A is_read_only = Param.Bool(False, "Is this cache read only (e.g. inst)") 7310816SN/A 7410816SN/A prefetcher = Param.BasePrefetcher(NULL,"Prefetcher attached to cache") 755875SN/A prefetch_on_access = Param.Bool(False, 7610816SN/A "Notify the hardware prefetcher on every access (not just misses)") 7710816SN/A 7812600Sodanrc@yahoo.com.br tags = Param.BaseTags(BaseSetAssoc(), "Tag store") 7912600Sodanrc@yahoo.com.br replacement_policy = Param.BaseReplacementPolicy(LRURP(), 8012600Sodanrc@yahoo.com.br "Replacement policy") 8112600Sodanrc@yahoo.com.br 8210025SN/A sequential_access = Param.Bool(False, 8310025SN/A "Whether to access tags and data sequentially") 8410816SN/A 8510816SN/A cpu_side = SlavePort("Upstream port closer to the CPU and/or device") 8610816SN/A mem_side = MasterPort("Downstream port closer to memory") 8710816SN/A 8810816SN/A addr_ranges = VectorParam.AddrRange([AllMemory], 8910816SN/A "Address range for the CPU-side port (to allow striping)") 9010816SN/A 9110816SN/A system = Param.System(Parent.any, "System we belong to") 9211053Sandreas.hansson@arm.com 9311197Sandreas.hansson@arm.com# Enum for cache clusivity, currently mostly inclusive or mostly 9411197Sandreas.hansson@arm.com# exclusive. 9511197Sandreas.hansson@arm.comclass Clusivity(Enum): vals = ['mostly_incl', 'mostly_excl'] 9611197Sandreas.hansson@arm.com 9711053Sandreas.hansson@arm.comclass Cache(BaseCache): 9811053Sandreas.hansson@arm.com type = 'Cache' 9911053Sandreas.hansson@arm.com cxx_header = 'mem/cache/cache.hh' 10011197Sandreas.hansson@arm.com 10111197Sandreas.hansson@arm.com # Control whether this cache should be mostly inclusive or mostly 10211197Sandreas.hansson@arm.com # exclusive with respect to upstream caches. The behaviour on a 10311197Sandreas.hansson@arm.com # fill is determined accordingly. For a mostly inclusive cache, 10411197Sandreas.hansson@arm.com # blocks are allocated on all fill operations. Thus, L1 caches 10511197Sandreas.hansson@arm.com # should be set as mostly inclusive even if they have no upstream 10611197Sandreas.hansson@arm.com # caches. In the case of a mostly exclusive cache, fills are not 10711197Sandreas.hansson@arm.com # allocating unless they came directly from a non-caching source, 10811197Sandreas.hansson@arm.com # e.g. a table walker. Additionally, on a hit from an upstream 10911197Sandreas.hansson@arm.com # cache a line is dropped for a mostly exclusive cache. 11011197Sandreas.hansson@arm.com clusivity = Param.Clusivity('mostly_incl', 11111197Sandreas.hansson@arm.com "Clusivity with upstream cache") 11211199Sandreas.hansson@arm.com 11311199Sandreas.hansson@arm.com # Determine if this cache sends out writebacks for clean lines, or 11411199Sandreas.hansson@arm.com # simply clean evicts. In cases where a downstream cache is mostly 11511199Sandreas.hansson@arm.com # exclusive with respect to this cache (acting as a victim cache), 11611199Sandreas.hansson@arm.com # the clean writebacks are essential for performance. In general 11711199Sandreas.hansson@arm.com # this should be set to True for anything but the last-level 11811199Sandreas.hansson@arm.com # cache. 11911199Sandreas.hansson@arm.com writeback_clean = Param.Bool(False, "Writeback clean lines") 120