fa_lru.hh revision 13216
12810Srdreslin@umich.edu/*
212665Snikos.nikoleris@arm.com * Copyright (c) 2012-2013,2016,2018 ARM Limited
39347SAndreas.Sandberg@arm.com * All rights reserved.
49347SAndreas.Sandberg@arm.com *
59347SAndreas.Sandberg@arm.com * The license below extends only to copyright in the software and shall
69347SAndreas.Sandberg@arm.com * not be construed as granting a license to any other intellectual
79347SAndreas.Sandberg@arm.com * property including but not limited to intellectual property relating
89347SAndreas.Sandberg@arm.com * to a hardware implementation of the functionality of the software
99347SAndreas.Sandberg@arm.com * licensed hereunder.  You may use the software subject to the license
109347SAndreas.Sandberg@arm.com * terms below provided that you ensure that this notice is replicated
119347SAndreas.Sandberg@arm.com * unmodified and in its entirety in all distributions of the software,
129347SAndreas.Sandberg@arm.com * modified or unmodified, in source code or in binary form.
139347SAndreas.Sandberg@arm.com *
142810Srdreslin@umich.edu * Copyright (c) 2003-2005 The Regents of The University of Michigan
152810Srdreslin@umich.edu * All rights reserved.
162810Srdreslin@umich.edu *
172810Srdreslin@umich.edu * Redistribution and use in source and binary forms, with or without
182810Srdreslin@umich.edu * modification, are permitted provided that the following conditions are
192810Srdreslin@umich.edu * met: redistributions of source code must retain the above copyright
202810Srdreslin@umich.edu * notice, this list of conditions and the following disclaimer;
212810Srdreslin@umich.edu * redistributions in binary form must reproduce the above copyright
222810Srdreslin@umich.edu * notice, this list of conditions and the following disclaimer in the
232810Srdreslin@umich.edu * documentation and/or other materials provided with the distribution;
242810Srdreslin@umich.edu * neither the name of the copyright holders nor the names of its
252810Srdreslin@umich.edu * contributors may be used to endorse or promote products derived from
262810Srdreslin@umich.edu * this software without specific prior written permission.
272810Srdreslin@umich.edu *
282810Srdreslin@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
292810Srdreslin@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
302810Srdreslin@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
312810Srdreslin@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
322810Srdreslin@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
332810Srdreslin@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
342810Srdreslin@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
352810Srdreslin@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
362810Srdreslin@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
372810Srdreslin@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
382810Srdreslin@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
392810Srdreslin@umich.edu *
402810Srdreslin@umich.edu * Authors: Erik Hallnor
4112665Snikos.nikoleris@arm.com *          Nikos Nikoleris
422810Srdreslin@umich.edu */
432810Srdreslin@umich.edu
442810Srdreslin@umich.edu/**
452810Srdreslin@umich.edu * @file
462810Srdreslin@umich.edu * Declaration of a fully associative LRU tag store.
472810Srdreslin@umich.edu */
482810Srdreslin@umich.edu
496216Snate@binkert.org#ifndef __MEM_CACHE_TAGS_FA_LRU_HH__
506216Snate@binkert.org#define __MEM_CACHE_TAGS_FA_LRU_HH__
512810Srdreslin@umich.edu
5212727Snikos.nikoleris@arm.com#include <cstdint>
5312728Snikos.nikoleris@arm.com#include <functional>
5412727Snikos.nikoleris@arm.com#include <string>
5511168Sandreas.hansson@arm.com#include <unordered_map>
5613163Sodanrc@yahoo.com.br#include <vector>
572810Srdreslin@umich.edu
5812727Snikos.nikoleris@arm.com#include "base/bitfield.hh"
5912665Snikos.nikoleris@arm.com#include "base/intmath.hh"
6012727Snikos.nikoleris@arm.com#include "base/logging.hh"
6112727Snikos.nikoleris@arm.com#include "base/statistics.hh"
6212727Snikos.nikoleris@arm.com#include "base/types.hh"
6311486Snikos.nikoleris@arm.com#include "mem/cache/blk.hh"
648229Snate@binkert.org#include "mem/cache/tags/base.hh"
659796Sprakash.ramrakhyani@arm.com#include "params/FALRU.hh"
662810Srdreslin@umich.edu
6712665Snikos.nikoleris@arm.com// Uncomment to enable sanity checks for the FALRU cache and the
6812665Snikos.nikoleris@arm.com// TrackedCaches class
6912665Snikos.nikoleris@arm.com//#define FALRU_DEBUG
7012665Snikos.nikoleris@arm.com
7113216Sodanrc@yahoo.com.brclass BaseCache;
7212773Sodanrc@yahoo.com.brclass ReplaceableEntry;
7312773Sodanrc@yahoo.com.br
7412665Snikos.nikoleris@arm.com// A bitmask of the caches we are keeping track of. Currently the
7512665Snikos.nikoleris@arm.com// lowest bit is the smallest cache we are tracking, as it is
7612665Snikos.nikoleris@arm.com// specified by the corresponding parameter. The rest of the bits are
7712665Snikos.nikoleris@arm.com// for exponentially growing cache sizes.
7812665Snikos.nikoleris@arm.comtypedef uint32_t CachesMask;
7912665Snikos.nikoleris@arm.com
802810Srdreslin@umich.edu/**
812810Srdreslin@umich.edu * A fully associative cache block.
822810Srdreslin@umich.edu */
832810Srdreslin@umich.educlass FALRUBlk : public CacheBlk
842810Srdreslin@umich.edu{
8512636Sodanrc@yahoo.com.br  public:
8613162Sodanrc@yahoo.com.br    FALRUBlk() : CacheBlk(), prev(nullptr), next(nullptr), inCachesMask(0) {}
8713162Sodanrc@yahoo.com.br
882810Srdreslin@umich.edu    /** The previous block in LRU order. */
892810Srdreslin@umich.edu    FALRUBlk *prev;
902810Srdreslin@umich.edu    /** The next block in LRU order. */
912810Srdreslin@umich.edu    FALRUBlk *next;
922810Srdreslin@umich.edu
9312665Snikos.nikoleris@arm.com    /** A bit mask of the caches that fit this block. */
9412665Snikos.nikoleris@arm.com    CachesMask inCachesMask;
952810Srdreslin@umich.edu};
962810Srdreslin@umich.edu
972810Srdreslin@umich.edu/**
982810Srdreslin@umich.edu * A fully associative LRU cache. Keeps statistics for accesses to a number of
992810Srdreslin@umich.edu * cache sizes at once.
1002810Srdreslin@umich.edu */
1012810Srdreslin@umich.educlass FALRU : public BaseTags
1022810Srdreslin@umich.edu{
1032810Srdreslin@umich.edu  public:
1042810Srdreslin@umich.edu    /** Typedef the block type used in this class. */
1052810Srdreslin@umich.edu    typedef FALRUBlk BlkType;
1066227Snate@binkert.org
1072810Srdreslin@umich.edu  protected:
1082810Srdreslin@umich.edu    /** The cache blocks. */
1092810Srdreslin@umich.edu    FALRUBlk *blks;
1102810Srdreslin@umich.edu
1112810Srdreslin@umich.edu    /** The MRU block. */
1122810Srdreslin@umich.edu    FALRUBlk *head;
1132810Srdreslin@umich.edu    /** The LRU block. */
1142810Srdreslin@umich.edu    FALRUBlk *tail;
1152810Srdreslin@umich.edu
1162810Srdreslin@umich.edu    /** Hash table type mapping addresses to cache block pointers. */
11712775Snikos.nikoleris@arm.com    struct PairHash
11812775Snikos.nikoleris@arm.com    {
11912775Snikos.nikoleris@arm.com        template <class T1, class T2>
12012775Snikos.nikoleris@arm.com        std::size_t operator()(const std::pair<T1, T2> &p) const
12112775Snikos.nikoleris@arm.com        {
12212775Snikos.nikoleris@arm.com            return std::hash<T1>()(p.first) ^ std::hash<T2>()(p.second);
12312775Snikos.nikoleris@arm.com        }
12412775Snikos.nikoleris@arm.com    };
12512775Snikos.nikoleris@arm.com    typedef std::pair<Addr, bool> TagHashKey;
12612775Snikos.nikoleris@arm.com    typedef std::unordered_map<TagHashKey, FALRUBlk *, PairHash> TagHash;
1272810Srdreslin@umich.edu
1282810Srdreslin@umich.edu    /** The address hash table. */
12912775Snikos.nikoleris@arm.com    TagHash tagHash;
1302810Srdreslin@umich.edu
1312810Srdreslin@umich.edu    /**
1322810Srdreslin@umich.edu     * Move a cache block to the MRU position.
13312648Sodanrc@yahoo.com.br     *
1342810Srdreslin@umich.edu     * @param blk The block to promote.
1352810Srdreslin@umich.edu     */
1362810Srdreslin@umich.edu    void moveToHead(FALRUBlk *blk);
1372810Srdreslin@umich.edu
1382810Srdreslin@umich.edu    /**
13912648Sodanrc@yahoo.com.br     * Move a cache block to the LRU position.
14012648Sodanrc@yahoo.com.br     *
14112648Sodanrc@yahoo.com.br     * @param blk The block to demote.
14212648Sodanrc@yahoo.com.br     */
14312648Sodanrc@yahoo.com.br    void moveToTail(FALRUBlk *blk);
14412648Sodanrc@yahoo.com.br
14512636Sodanrc@yahoo.com.br  public:
1469796Sprakash.ramrakhyani@arm.com    typedef FALRUParams Params;
1479796Sprakash.ramrakhyani@arm.com
1482810Srdreslin@umich.edu    /**
1492810Srdreslin@umich.edu     * Construct and initialize this cache tagstore.
1502810Srdreslin@umich.edu     */
1519796Sprakash.ramrakhyani@arm.com    FALRU(const Params *p);
1529086Sandreas.hansson@arm.com    ~FALRU();
1532810Srdreslin@umich.edu
1542810Srdreslin@umich.edu    /**
15513216Sodanrc@yahoo.com.br     * Initialize blocks and set the parent cache back pointer.
15613216Sodanrc@yahoo.com.br     *
15713216Sodanrc@yahoo.com.br     * @param _cache Pointer to parent cache.
15813216Sodanrc@yahoo.com.br     */
15913216Sodanrc@yahoo.com.br    void init(BaseCache *_cache) override;
16013216Sodanrc@yahoo.com.br
16113216Sodanrc@yahoo.com.br    /**
1622810Srdreslin@umich.edu     * Register the stats for this object.
1632810Srdreslin@umich.edu     */
16411169Sandreas.hansson@arm.com    void regStats() override;
1652810Srdreslin@umich.edu
1662810Srdreslin@umich.edu    /**
1673862Sstever@eecs.umich.edu     * Invalidate a cache block.
1683862Sstever@eecs.umich.edu     * @param blk The block to invalidate.
1692810Srdreslin@umich.edu     */
17011169Sandreas.hansson@arm.com    void invalidate(CacheBlk *blk) override;
1712810Srdreslin@umich.edu
1722810Srdreslin@umich.edu    /**
17311483Snikos.nikoleris@arm.com     * Access block and update replacement data.  May not succeed, in which
17411484Snikos.nikoleris@arm.com     * case nullptr pointer is returned.  This has all the implications of a
17511484Snikos.nikoleris@arm.com     * cache access and should only be used as such.
17612665Snikos.nikoleris@arm.com     * Returns the access latency and inCachesMask flags as a side effect.
1772810Srdreslin@umich.edu     * @param addr The address to look for.
17810028SGiacomo.Gabrielli@arm.com     * @param is_secure True if the target memory space is secure.
1792810Srdreslin@umich.edu     * @param lat The latency of the access.
18012665Snikos.nikoleris@arm.com     * @param in_cache_mask Mask indicating the caches in which the blk fits.
1812810Srdreslin@umich.edu     * @return Pointer to the cache block.
1822810Srdreslin@umich.edu     */
18310815Sdavid.guillen@arm.com    CacheBlk* accessBlock(Addr addr, bool is_secure, Cycles &lat,
18412665Snikos.nikoleris@arm.com                          CachesMask *in_cache_mask);
18510815Sdavid.guillen@arm.com
18610815Sdavid.guillen@arm.com    /**
18710815Sdavid.guillen@arm.com     * Just a wrapper of above function to conform with the base interface.
18810815Sdavid.guillen@arm.com     */
18911870Snikos.nikoleris@arm.com    CacheBlk* accessBlock(Addr addr, bool is_secure, Cycles &lat) override;
1902810Srdreslin@umich.edu
1912810Srdreslin@umich.edu    /**
1922810Srdreslin@umich.edu     * Find the block in the cache, do not update the replacement data.
1932810Srdreslin@umich.edu     * @param addr The address to look for.
19410028SGiacomo.Gabrielli@arm.com     * @param is_secure True if the target memory space is secure.
1952810Srdreslin@umich.edu     * @param asid The address space ID.
1962810Srdreslin@umich.edu     * @return Pointer to the cache block.
1972810Srdreslin@umich.edu     */
19811169Sandreas.hansson@arm.com    CacheBlk* findBlock(Addr addr, bool is_secure) const override;
1992810Srdreslin@umich.edu
2002810Srdreslin@umich.edu    /**
20112743Sodanrc@yahoo.com.br     * Find a block given set and way.
20212743Sodanrc@yahoo.com.br     *
20312743Sodanrc@yahoo.com.br     * @param set The set of the block.
20412743Sodanrc@yahoo.com.br     * @param way The way of the block.
20512743Sodanrc@yahoo.com.br     * @return The block.
20612743Sodanrc@yahoo.com.br     */
20712743Sodanrc@yahoo.com.br    ReplaceableEntry* findBlockBySetAndWay(int set, int way) const override;
20812743Sodanrc@yahoo.com.br
20912743Sodanrc@yahoo.com.br    /**
21012744Sodanrc@yahoo.com.br     * Find replacement victim based on address. The list of evicted blocks
21112744Sodanrc@yahoo.com.br     * only contains the victim.
21212600Sodanrc@yahoo.com.br     *
21312600Sodanrc@yahoo.com.br     * @param addr Address to find a victim for.
21412746Sodanrc@yahoo.com.br     * @param is_secure True if the target memory space is secure.
21512744Sodanrc@yahoo.com.br     * @param evict_blks Cache blocks to be evicted.
21612600Sodanrc@yahoo.com.br     * @return Cache block to be replaced.
2172810Srdreslin@umich.edu     */
21812746Sodanrc@yahoo.com.br    CacheBlk* findVictim(Addr addr, const bool is_secure,
21912746Sodanrc@yahoo.com.br                         std::vector<CacheBlk*>& evict_blks) const override;
2205717Shsul@eecs.umich.edu
22112636Sodanrc@yahoo.com.br    /**
22212636Sodanrc@yahoo.com.br     * Insert the new block into the cache and update replacement data.
22312636Sodanrc@yahoo.com.br     *
22413215Sodanrc@yahoo.com.br     * @param addr Address of the block.
22513215Sodanrc@yahoo.com.br     * @param is_secure Whether the block is in secure space or not.
22613215Sodanrc@yahoo.com.br     * @param src_master_ID The source requestor ID.
22713215Sodanrc@yahoo.com.br     * @param task_ID The new task ID.
22812636Sodanrc@yahoo.com.br     * @param blk The block to update.
22912636Sodanrc@yahoo.com.br     */
23013215Sodanrc@yahoo.com.br    void insertBlock(const Addr addr, const bool is_secure,
23113215Sodanrc@yahoo.com.br                     const int src_master_ID, const uint32_t task_ID,
23213215Sodanrc@yahoo.com.br                     CacheBlk *blk) override;
2332810Srdreslin@umich.edu
2342810Srdreslin@umich.edu    /**
2352810Srdreslin@umich.edu     * Generate the tag from the addres. For fully associative this is just the
2362810Srdreslin@umich.edu     * block address.
2372810Srdreslin@umich.edu     * @param addr The address to get the tag from.
2382810Srdreslin@umich.edu     * @return The tag.
2392810Srdreslin@umich.edu     */
24011169Sandreas.hansson@arm.com    Addr extractTag(Addr addr) const override
2412810Srdreslin@umich.edu    {
2422810Srdreslin@umich.edu        return blkAlign(addr);
2432810Srdreslin@umich.edu    }
2442810Srdreslin@umich.edu
2452810Srdreslin@umich.edu    /**
24612574Sodanrc@yahoo.com.br     * Regenerate the block address from the tag.
24712574Sodanrc@yahoo.com.br     *
24812574Sodanrc@yahoo.com.br     * @param block The block.
2492810Srdreslin@umich.edu     * @return the block address.
2502810Srdreslin@umich.edu     */
25112574Sodanrc@yahoo.com.br    Addr regenerateBlkAddr(const CacheBlk* blk) const override
2522810Srdreslin@umich.edu    {
25312574Sodanrc@yahoo.com.br        return blk->tag;
2542810Srdreslin@umich.edu    }
2557612SGene.Wu@arm.com
25612728Snikos.nikoleris@arm.com    void forEachBlk(std::function<void(CacheBlk &)> visitor) override {
25712728Snikos.nikoleris@arm.com        for (int i = 0; i < numBlocks; i++) {
25812728Snikos.nikoleris@arm.com            visitor(blks[i]);
25912728Snikos.nikoleris@arm.com        }
26012728Snikos.nikoleris@arm.com    }
2619663Suri.wiener@arm.com
26212728Snikos.nikoleris@arm.com    bool anyBlk(std::function<bool(CacheBlk &)> visitor) override {
2639347SAndreas.Sandberg@arm.com        for (int i = 0; i < numBlocks; i++) {
26412728Snikos.nikoleris@arm.com            if (visitor(blks[i])) {
26512728Snikos.nikoleris@arm.com                return true;
26612728Snikos.nikoleris@arm.com            }
2679347SAndreas.Sandberg@arm.com        }
26812728Snikos.nikoleris@arm.com        return false;
2699347SAndreas.Sandberg@arm.com    }
27012665Snikos.nikoleris@arm.com
27112665Snikos.nikoleris@arm.com  private:
27212665Snikos.nikoleris@arm.com    /**
27312665Snikos.nikoleris@arm.com     * Mechanism that allows us to simultaneously collect miss
27412665Snikos.nikoleris@arm.com     * statistics for multiple caches. Currently, we keep track of
27512665Snikos.nikoleris@arm.com     * caches from a set minimum size of interest up to the actual
27612665Snikos.nikoleris@arm.com     * cache size.
27712665Snikos.nikoleris@arm.com     */
27812665Snikos.nikoleris@arm.com    class CacheTracking
27912665Snikos.nikoleris@arm.com    {
28012665Snikos.nikoleris@arm.com      public:
28112665Snikos.nikoleris@arm.com        CacheTracking(unsigned min_size, unsigned max_size,
28212665Snikos.nikoleris@arm.com                      unsigned block_size)
28312665Snikos.nikoleris@arm.com            : blkSize(block_size),
28412665Snikos.nikoleris@arm.com              minTrackedSize(min_size),
28512665Snikos.nikoleris@arm.com              numTrackedCaches(max_size > min_size ?
28612665Snikos.nikoleris@arm.com                               floorLog2(max_size) - floorLog2(min_size) : 0),
28712665Snikos.nikoleris@arm.com              inAllCachesMask(mask(numTrackedCaches)),
28813163Sodanrc@yahoo.com.br              boundaries(numTrackedCaches)
28912665Snikos.nikoleris@arm.com        {
29012665Snikos.nikoleris@arm.com            fatal_if(numTrackedCaches > sizeof(CachesMask) * 8,
29112665Snikos.nikoleris@arm.com                     "Not enough bits (%s) in type CachesMask type to keep "
29212665Snikos.nikoleris@arm.com                     "track of %d caches\n", sizeof(CachesMask),
29312665Snikos.nikoleris@arm.com                     numTrackedCaches);
29412665Snikos.nikoleris@arm.com        }
29512665Snikos.nikoleris@arm.com
29612665Snikos.nikoleris@arm.com        /**
29712665Snikos.nikoleris@arm.com         * Initialiaze cache blocks and the tracking mechanism
29812665Snikos.nikoleris@arm.com         *
29912665Snikos.nikoleris@arm.com         * All blocks in the cache need to be initialized once.
30012665Snikos.nikoleris@arm.com         *
30112665Snikos.nikoleris@arm.com         * @param blk the MRU block
30212665Snikos.nikoleris@arm.com         * @param blk the LRU block
30312665Snikos.nikoleris@arm.com         */
30412665Snikos.nikoleris@arm.com        void init(FALRUBlk *head, FALRUBlk *tail);
30512665Snikos.nikoleris@arm.com
30612665Snikos.nikoleris@arm.com        /**
30712665Snikos.nikoleris@arm.com         * Update boundaries as a block will be moved to the MRU.
30812665Snikos.nikoleris@arm.com         *
30912665Snikos.nikoleris@arm.com         * For all caches that didn't fit the block before moving it,
31012665Snikos.nikoleris@arm.com         * we move their boundaries one block closer to the MRU. We
31112665Snikos.nikoleris@arm.com         * also update InCacheMasks as neccessary.
31212665Snikos.nikoleris@arm.com         *
31312665Snikos.nikoleris@arm.com         * @param blk the block that will be moved to the head
31412665Snikos.nikoleris@arm.com         */
31512665Snikos.nikoleris@arm.com        void moveBlockToHead(FALRUBlk *blk);
31612665Snikos.nikoleris@arm.com
31712665Snikos.nikoleris@arm.com        /**
31812665Snikos.nikoleris@arm.com         * Update boundaries as a block will be moved to the LRU.
31912665Snikos.nikoleris@arm.com         *
32012665Snikos.nikoleris@arm.com         * For all caches that fitted the block before moving it, we
32112665Snikos.nikoleris@arm.com         * move their boundaries one block closer to the LRU. We
32212665Snikos.nikoleris@arm.com         * also update InCacheMasks as neccessary.
32312665Snikos.nikoleris@arm.com         *
32412665Snikos.nikoleris@arm.com         * @param blk the block that will be moved to the head
32512665Snikos.nikoleris@arm.com         */
32612665Snikos.nikoleris@arm.com        void moveBlockToTail(FALRUBlk *blk);
32712665Snikos.nikoleris@arm.com
32812665Snikos.nikoleris@arm.com        /**
32912665Snikos.nikoleris@arm.com         * Notify of a block access.
33012665Snikos.nikoleris@arm.com         *
33112665Snikos.nikoleris@arm.com         * This should be called every time a block is accessed and it
33212665Snikos.nikoleris@arm.com         * updates statistics. If the input block is nullptr then we
33312665Snikos.nikoleris@arm.com         * treat the access as a miss. The block's InCacheMask
33412665Snikos.nikoleris@arm.com         * determines the caches in which the block fits.
33512665Snikos.nikoleris@arm.com         *
33612665Snikos.nikoleris@arm.com         * @param blk the block to record the access for
33712665Snikos.nikoleris@arm.com         */
33812665Snikos.nikoleris@arm.com        void recordAccess(FALRUBlk *blk);
33912665Snikos.nikoleris@arm.com
34012665Snikos.nikoleris@arm.com        /**
34112665Snikos.nikoleris@arm.com         * Check that the tracking mechanism is in consistent state.
34212665Snikos.nikoleris@arm.com         *
34312665Snikos.nikoleris@arm.com         * Iterate from the head (MRU) to the tail (LRU) of the list
34412665Snikos.nikoleris@arm.com         * of blocks and assert the inCachesMask and the boundaries
34512665Snikos.nikoleris@arm.com         * are in consistent state.
34612665Snikos.nikoleris@arm.com         *
34712665Snikos.nikoleris@arm.com         * @param head the MRU block of the actual cache
34812665Snikos.nikoleris@arm.com         * @param head the LRU block of the actual cache
34912665Snikos.nikoleris@arm.com         */
35013164Sodanrc@yahoo.com.br        void check(const FALRUBlk *head, const FALRUBlk *tail) const;
35112665Snikos.nikoleris@arm.com
35212665Snikos.nikoleris@arm.com        /**
35312665Snikos.nikoleris@arm.com         * Register the stats for this object.
35412665Snikos.nikoleris@arm.com         */
35512665Snikos.nikoleris@arm.com        void regStats(std::string name);
35612665Snikos.nikoleris@arm.com
35712665Snikos.nikoleris@arm.com      private:
35812665Snikos.nikoleris@arm.com        /** The size of the cache block */
35912665Snikos.nikoleris@arm.com        const unsigned blkSize;
36012665Snikos.nikoleris@arm.com        /** The smallest cache we are tracking */
36112665Snikos.nikoleris@arm.com        const unsigned minTrackedSize;
36212665Snikos.nikoleris@arm.com        /** The number of different size caches being tracked. */
36312665Snikos.nikoleris@arm.com        const int numTrackedCaches;
36412665Snikos.nikoleris@arm.com        /** A mask for all cache being tracked. */
36512665Snikos.nikoleris@arm.com        const CachesMask inAllCachesMask;
36612665Snikos.nikoleris@arm.com        /** Array of pointers to blocks at the cache boundaries. */
36713163Sodanrc@yahoo.com.br        std::vector<FALRUBlk*> boundaries;
36812665Snikos.nikoleris@arm.com
36912665Snikos.nikoleris@arm.com      protected:
37012665Snikos.nikoleris@arm.com        /**
37112665Snikos.nikoleris@arm.com         * @defgroup FALRUStats Fully Associative LRU specific statistics
37212665Snikos.nikoleris@arm.com         * The FA lru stack lets us track multiple cache sizes at once. These
37312665Snikos.nikoleris@arm.com         * statistics track the hits and misses for different cache sizes.
37412665Snikos.nikoleris@arm.com         * @{
37512665Snikos.nikoleris@arm.com         */
37612665Snikos.nikoleris@arm.com
37712665Snikos.nikoleris@arm.com        /** Hits in each cache */
37812665Snikos.nikoleris@arm.com        Stats::Vector hits;
37912665Snikos.nikoleris@arm.com        /** Misses in each cache */
38012665Snikos.nikoleris@arm.com        Stats::Vector misses;
38112665Snikos.nikoleris@arm.com        /** Total number of accesses */
38212665Snikos.nikoleris@arm.com        Stats::Scalar accesses;
38312665Snikos.nikoleris@arm.com
38412665Snikos.nikoleris@arm.com        /**
38512665Snikos.nikoleris@arm.com         * @}
38612665Snikos.nikoleris@arm.com         */
38712665Snikos.nikoleris@arm.com    };
38812665Snikos.nikoleris@arm.com    CacheTracking cacheTracking;
3892810Srdreslin@umich.edu};
3902810Srdreslin@umich.edu
3916216Snate@binkert.org#endif // __MEM_CACHE_TAGS_FA_LRU_HH__
392