Tags.py revision 13938:14f80b6b37c1
16145Snate@binkert.org# Copyright (c) 2012-2013 ARM Limited
26145Snate@binkert.org# All rights reserved.
36145Snate@binkert.org#
46145Snate@binkert.org# The license below extends only to copyright in the software and shall
56145Snate@binkert.org# not be construed as granting a license to any other intellectual
66145Snate@binkert.org# property including but not limited to intellectual property relating
76145Snate@binkert.org# to a hardware implementation of the functionality of the software
86145Snate@binkert.org# licensed hereunder.  You may use the software subject to the license
96145Snate@binkert.org# terms below provided that you ensure that this notice is replicated
106145Snate@binkert.org# unmodified and in its entirety in all distributions of the software,
116145Snate@binkert.org# modified or unmodified, in source code or in binary form.
126145Snate@binkert.org#
136145Snate@binkert.org# Redistribution and use in source and binary forms, with or without
146145Snate@binkert.org# modification, are permitted provided that the following conditions are
156145Snate@binkert.org# met: redistributions of source code must retain the above copyright
166145Snate@binkert.org# notice, this list of conditions and the following disclaimer;
176145Snate@binkert.org# redistributions in binary form must reproduce the above copyright
186145Snate@binkert.org# notice, this list of conditions and the following disclaimer in the
196145Snate@binkert.org# documentation and/or other materials provided with the distribution;
206145Snate@binkert.org# neither the name of the copyright holders nor the names of its
216145Snate@binkert.org# contributors may be used to endorse or promote products derived from
226145Snate@binkert.org# this software without specific prior written permission.
236145Snate@binkert.org#
246145Snate@binkert.org# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
256145Snate@binkert.org# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
266145Snate@binkert.org# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
276145Snate@binkert.org# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
286145Snate@binkert.org# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
297832Snate@binkert.org# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
307832Snate@binkert.org# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
317054Snate@binkert.org# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
327054Snate@binkert.org# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
336154Snate@binkert.org# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
346154Snate@binkert.org# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
357054Snate@binkert.org#
367054Snate@binkert.org# Authors: Prakash Ramrakhyani
376154Snate@binkert.org
386145Snate@binkert.orgfrom m5.params import *
397055Snate@binkert.orgfrom m5.proxy import *
407055Snate@binkert.orgfrom m5.objects.ClockedObject import ClockedObject
416145Snate@binkert.orgfrom m5.objects.IndexingPolicies import *
426145Snate@binkert.org
436145Snate@binkert.orgclass BaseTags(ClockedObject):
446145Snate@binkert.org    type = 'BaseTags'
456145Snate@binkert.org    abstract = True
466145Snate@binkert.org    cxx_header = "mem/cache/tags/base.hh"
476145Snate@binkert.org
486145Snate@binkert.org    # Get system to which it belongs
496145Snate@binkert.org    system = Param.System(Parent.any, "System we belong to")
507054Snate@binkert.org
517054Snate@binkert.org    # Get the size from the parent (cache)
526145Snate@binkert.org    size = Param.MemorySize(Parent.size, "capacity in bytes")
537054Snate@binkert.org
547054Snate@binkert.org    # Get the block size from the parent (system)
556145Snate@binkert.org    block_size = Param.Int(Parent.cache_line_size, "block size in bytes")
566145Snate@binkert.org
577054Snate@binkert.org    # Get the tag lookup latency from the parent (cache)
587054Snate@binkert.org    tag_latency = Param.Cycles(Parent.tag_latency,
596145Snate@binkert.org                               "The tag lookup latency for this cache")
607054Snate@binkert.org
617054Snate@binkert.org    # Get the warmup percentage from the parent (cache)
626145Snate@binkert.org    warmup_percentage = Param.Percent(Parent.warmup_percentage,
636145Snate@binkert.org        "Percentage of tags to be touched to warm up the cache")
647054Snate@binkert.org
657054Snate@binkert.org    sequential_access = Param.Bool(Parent.sequential_access,
666145Snate@binkert.org        "Whether to access tags and data sequentially")
677054Snate@binkert.org
687054Snate@binkert.org    # Get indexing policy
696145Snate@binkert.org    indexing_policy = Param.BaseIndexingPolicy(SetAssociative(),
707832Snate@binkert.org        "Indexing policy")
717054Snate@binkert.org
727054Snate@binkert.org    # Set the indexing entry size as the block size
736145Snate@binkert.org    entry_size = Param.Int(Parent.cache_line_size,
747054Snate@binkert.org                           "Indexing entry size in bytes")
757054Snate@binkert.org
766145Snate@binkert.orgclass BaseSetAssoc(BaseTags):
776145Snate@binkert.org    type = 'BaseSetAssoc'
787054Snate@binkert.org    cxx_header = "mem/cache/tags/base_set_assoc.hh"
797054Snate@binkert.org
806145Snate@binkert.org    # Get the cache associativity
817054Snate@binkert.org    assoc = Param.Int(Parent.assoc, "associativity")
827054Snate@binkert.org
837054Snate@binkert.org    # Get replacement policy from the parent (cache)
847054Snate@binkert.org    replacement_policy = Param.BaseReplacementPolicy(
856145Snate@binkert.org        Parent.replacement_policy, "Replacement policy")
866145Snate@binkert.org
877054Snate@binkert.orgclass SectorTags(BaseTags):
887454Snate@binkert.org    type = 'SectorTags'
897454Snate@binkert.org    cxx_header = "mem/cache/tags/sector_tags.hh"
906145Snate@binkert.org
917054Snate@binkert.org    # Get the cache associativity
927054Snate@binkert.org    assoc = Param.Int(Parent.assoc, "associativity")
937054Snate@binkert.org
947054Snate@binkert.org    # Number of sub-sectors (data blocks) per sector
956145Snate@binkert.org    num_blocks_per_sector = Param.Int(1, "Number of sub-sectors per sector");
967454Snate@binkert.org
977054Snate@binkert.org    # The indexing entry now is a sector block
987454Snate@binkert.org    entry_size = Parent.cache_line_size * Self.num_blocks_per_sector
997054Snate@binkert.org
1007054Snate@binkert.org    # Get replacement policy from the parent (cache)
1017054Snate@binkert.org    replacement_policy = Param.BaseReplacementPolicy(
1026145Snate@binkert.org        Parent.replacement_policy, "Replacement policy")
1036145Snate@binkert.org
1046145Snate@binkert.orgclass CompressedTags(SectorTags):
1057054Snate@binkert.org    type = 'CompressedTags'
1067054Snate@binkert.org    cxx_header = "mem/cache/tags/compressed_tags.hh"
1076145Snate@binkert.org
1087454Snate@binkert.org    # Maximum number of compressed blocks per tag
1097454Snate@binkert.org    max_compression_ratio = Param.Int(2,
1107454Snate@binkert.org        "Maximum number of compressed blocks per tag.")
1116145Snate@binkert.org
1127054Snate@binkert.org    # We simulate superblock as sector blocks
1137054Snate@binkert.org    num_blocks_per_sector = Self.max_compression_ratio
1147054Snate@binkert.org
1157054Snate@binkert.org    # We virtually increase the number of data blocks per tag by multiplying
1167054Snate@binkert.org    # the cache size by the compression ratio
1177054Snate@binkert.org    size = Parent.size * Self.max_compression_ratio
1186145Snate@binkert.org
1196145Snate@binkert.orgclass FALRU(BaseTags):
1207054Snate@binkert.org    type = 'FALRU'
1217054Snate@binkert.org    cxx_class = 'FALRU'
1226145Snate@binkert.org    cxx_header = "mem/cache/tags/fa_lru.hh"
1237054Snate@binkert.org
1247054Snate@binkert.org    min_tracked_cache_size = Param.MemorySize("128kB", "Minimum cache size for"
1257054Snate@binkert.org                                              " which we track statistics")
1266145Snate@binkert.org
1277054Snate@binkert.org    # This tag uses its own embedded indexing
1287054Snate@binkert.org    indexing_policy = NULL
1297054Snate@binkert.org