19796Sprakash.ramrakhyani@arm.com# Copyright (c) 2012-2013 ARM Limited
29796Sprakash.ramrakhyani@arm.com# All rights reserved.
39796Sprakash.ramrakhyani@arm.com#
49796Sprakash.ramrakhyani@arm.com# The license below extends only to copyright in the software and shall
59796Sprakash.ramrakhyani@arm.com# not be construed as granting a license to any other intellectual
69796Sprakash.ramrakhyani@arm.com# property including but not limited to intellectual property relating
79796Sprakash.ramrakhyani@arm.com# to a hardware implementation of the functionality of the software
89796Sprakash.ramrakhyani@arm.com# licensed hereunder.  You may use the software subject to the license
99796Sprakash.ramrakhyani@arm.com# terms below provided that you ensure that this notice is replicated
109796Sprakash.ramrakhyani@arm.com# unmodified and in its entirety in all distributions of the software,
119796Sprakash.ramrakhyani@arm.com# modified or unmodified, in source code or in binary form.
129796Sprakash.ramrakhyani@arm.com#
139796Sprakash.ramrakhyani@arm.com# Redistribution and use in source and binary forms, with or without
149796Sprakash.ramrakhyani@arm.com# modification, are permitted provided that the following conditions are
159796Sprakash.ramrakhyani@arm.com# met: redistributions of source code must retain the above copyright
169796Sprakash.ramrakhyani@arm.com# notice, this list of conditions and the following disclaimer;
179796Sprakash.ramrakhyani@arm.com# redistributions in binary form must reproduce the above copyright
189796Sprakash.ramrakhyani@arm.com# notice, this list of conditions and the following disclaimer in the
199796Sprakash.ramrakhyani@arm.com# documentation and/or other materials provided with the distribution;
209796Sprakash.ramrakhyani@arm.com# neither the name of the copyright holders nor the names of its
219796Sprakash.ramrakhyani@arm.com# contributors may be used to endorse or promote products derived from
229796Sprakash.ramrakhyani@arm.com# this software without specific prior written permission.
239796Sprakash.ramrakhyani@arm.com#
249796Sprakash.ramrakhyani@arm.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
259796Sprakash.ramrakhyani@arm.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
269796Sprakash.ramrakhyani@arm.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
279796Sprakash.ramrakhyani@arm.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
289796Sprakash.ramrakhyani@arm.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
299796Sprakash.ramrakhyani@arm.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
309796Sprakash.ramrakhyani@arm.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
319796Sprakash.ramrakhyani@arm.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
329796Sprakash.ramrakhyani@arm.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
339796Sprakash.ramrakhyani@arm.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
349796Sprakash.ramrakhyani@arm.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
359796Sprakash.ramrakhyani@arm.com#
369796Sprakash.ramrakhyani@arm.com# Authors: Prakash Ramrakhyani
379796Sprakash.ramrakhyani@arm.com
389796Sprakash.ramrakhyani@arm.comfrom m5.params import *
399796Sprakash.ramrakhyani@arm.comfrom m5.proxy import *
4013665Sandreas.sandberg@arm.comfrom m5.objects.ClockedObject import ClockedObject
4113665Sandreas.sandberg@arm.comfrom m5.objects.IndexingPolicies import *
429796Sprakash.ramrakhyani@arm.com
439796Sprakash.ramrakhyani@arm.comclass BaseTags(ClockedObject):
449796Sprakash.ramrakhyani@arm.com    type = 'BaseTags'
459796Sprakash.ramrakhyani@arm.com    abstract = True
469796Sprakash.ramrakhyani@arm.com    cxx_header = "mem/cache/tags/base.hh"
4713419Sodanrc@yahoo.com.br
4813419Sodanrc@yahoo.com.br    # Get system to which it belongs
4913419Sodanrc@yahoo.com.br    system = Param.System(Parent.any, "System we belong to")
5013419Sodanrc@yahoo.com.br
519796Sprakash.ramrakhyani@arm.com    # Get the size from the parent (cache)
529796Sprakash.ramrakhyani@arm.com    size = Param.MemorySize(Parent.size, "capacity in bytes")
539796Sprakash.ramrakhyani@arm.com
549814Sandreas.hansson@arm.com    # Get the block size from the parent (system)
559814Sandreas.hansson@arm.com    block_size = Param.Int(Parent.cache_line_size, "block size in bytes")
569796Sprakash.ramrakhyani@arm.com
5711722Ssophiane.senni@gmail.com    # Get the tag lookup latency from the parent (cache)
5811722Ssophiane.senni@gmail.com    tag_latency = Param.Cycles(Parent.tag_latency,
5911722Ssophiane.senni@gmail.com                               "The tag lookup latency for this cache")
6011722Ssophiane.senni@gmail.com
6112513Sodanrc@yahoo.com.br    # Get the warmup percentage from the parent (cache)
6212513Sodanrc@yahoo.com.br    warmup_percentage = Param.Percent(Parent.warmup_percentage,
6312513Sodanrc@yahoo.com.br        "Percentage of tags to be touched to warm up the cache")
6412513Sodanrc@yahoo.com.br
6511722Ssophiane.senni@gmail.com    sequential_access = Param.Bool(Parent.sequential_access,
6611722Ssophiane.senni@gmail.com        "Whether to access tags and data sequentially")
679796Sprakash.ramrakhyani@arm.com
6813219Sodanrc@yahoo.com.br    # Get indexing policy
6913219Sodanrc@yahoo.com.br    indexing_policy = Param.BaseIndexingPolicy(SetAssociative(),
7013219Sodanrc@yahoo.com.br        "Indexing policy")
7113219Sodanrc@yahoo.com.br
7213219Sodanrc@yahoo.com.br    # Set the indexing entry size as the block size
7313219Sodanrc@yahoo.com.br    entry_size = Param.Int(Parent.cache_line_size,
7413219Sodanrc@yahoo.com.br                           "Indexing entry size in bytes")
7513219Sodanrc@yahoo.com.br
7610263Satgutier@umich.educlass BaseSetAssoc(BaseTags):
7710263Satgutier@umich.edu    type = 'BaseSetAssoc'
7810263Satgutier@umich.edu    cxx_header = "mem/cache/tags/base_set_assoc.hh"
7912752Sodanrc@yahoo.com.br
8012752Sodanrc@yahoo.com.br    # Get the cache associativity
8110263Satgutier@umich.edu    assoc = Param.Int(Parent.assoc, "associativity")
8210263Satgutier@umich.edu
8312600Sodanrc@yahoo.com.br    # Get replacement policy from the parent (cache)
8412600Sodanrc@yahoo.com.br    replacement_policy = Param.BaseReplacementPolicy(
8512600Sodanrc@yahoo.com.br        Parent.replacement_policy, "Replacement policy")
869796Sprakash.ramrakhyani@arm.com
8712752Sodanrc@yahoo.com.brclass SectorTags(BaseTags):
8812752Sodanrc@yahoo.com.br    type = 'SectorTags'
8912752Sodanrc@yahoo.com.br    cxx_header = "mem/cache/tags/sector_tags.hh"
9012752Sodanrc@yahoo.com.br
9112752Sodanrc@yahoo.com.br    # Get the cache associativity
9212752Sodanrc@yahoo.com.br    assoc = Param.Int(Parent.assoc, "associativity")
9312752Sodanrc@yahoo.com.br
9412752Sodanrc@yahoo.com.br    # Number of sub-sectors (data blocks) per sector
9512752Sodanrc@yahoo.com.br    num_blocks_per_sector = Param.Int(1, "Number of sub-sectors per sector");
9612752Sodanrc@yahoo.com.br
9713219Sodanrc@yahoo.com.br    # The indexing entry now is a sector block
9813219Sodanrc@yahoo.com.br    entry_size = Parent.cache_line_size * Self.num_blocks_per_sector
9913219Sodanrc@yahoo.com.br
10012752Sodanrc@yahoo.com.br    # Get replacement policy from the parent (cache)
10112752Sodanrc@yahoo.com.br    replacement_policy = Param.BaseReplacementPolicy(
10212752Sodanrc@yahoo.com.br        Parent.replacement_policy, "Replacement policy")
10312752Sodanrc@yahoo.com.br
10413938Sodanrc@yahoo.com.brclass CompressedTags(SectorTags):
10513938Sodanrc@yahoo.com.br    type = 'CompressedTags'
10613938Sodanrc@yahoo.com.br    cxx_header = "mem/cache/tags/compressed_tags.hh"
10713938Sodanrc@yahoo.com.br
10813938Sodanrc@yahoo.com.br    # Maximum number of compressed blocks per tag
10913938Sodanrc@yahoo.com.br    max_compression_ratio = Param.Int(2,
11013938Sodanrc@yahoo.com.br        "Maximum number of compressed blocks per tag.")
11113938Sodanrc@yahoo.com.br
11213938Sodanrc@yahoo.com.br    # We simulate superblock as sector blocks
11313938Sodanrc@yahoo.com.br    num_blocks_per_sector = Self.max_compression_ratio
11413938Sodanrc@yahoo.com.br
11513938Sodanrc@yahoo.com.br    # We virtually increase the number of data blocks per tag by multiplying
11613938Sodanrc@yahoo.com.br    # the cache size by the compression ratio
11713938Sodanrc@yahoo.com.br    size = Parent.size * Self.max_compression_ratio
11813938Sodanrc@yahoo.com.br
1199796Sprakash.ramrakhyani@arm.comclass FALRU(BaseTags):
1209796Sprakash.ramrakhyani@arm.com    type = 'FALRU'
1219796Sprakash.ramrakhyani@arm.com    cxx_class = 'FALRU'
1229796Sprakash.ramrakhyani@arm.com    cxx_header = "mem/cache/tags/fa_lru.hh"
12312665Snikos.nikoleris@arm.com
12412665Snikos.nikoleris@arm.com    min_tracked_cache_size = Param.MemorySize("128kB", "Minimum cache size for"
12512665Snikos.nikoleris@arm.com                                              " which we track statistics")
12613219Sodanrc@yahoo.com.br
12713219Sodanrc@yahoo.com.br    # This tag uses its own embedded indexing
12813219Sodanrc@yahoo.com.br    indexing_policy = NULL
129