base_set_assoc.hh revision 11722
110263Satgutier@umich.edu/*
210941Sdavid.guillen@arm.com * Copyright (c) 2012-2014 ARM Limited
310263Satgutier@umich.edu * All rights reserved.
410263Satgutier@umich.edu *
510263Satgutier@umich.edu * The license below extends only to copyright in the software and shall
610263Satgutier@umich.edu * not be construed as granting a license to any other intellectual
710263Satgutier@umich.edu * property including but not limited to intellectual property relating
810263Satgutier@umich.edu * to a hardware implementation of the functionality of the software
910263Satgutier@umich.edu * licensed hereunder.  You may use the software subject to the license
1010263Satgutier@umich.edu * terms below provided that you ensure that this notice is replicated
1110263Satgutier@umich.edu * unmodified and in its entirety in all distributions of the software,
1210263Satgutier@umich.edu * modified or unmodified, in source code or in binary form.
1310263Satgutier@umich.edu *
1410263Satgutier@umich.edu * Copyright (c) 2003-2005,2014 The Regents of The University of Michigan
1510263Satgutier@umich.edu * All rights reserved.
1610263Satgutier@umich.edu *
1710263Satgutier@umich.edu * Redistribution and use in source and binary forms, with or without
1810263Satgutier@umich.edu * modification, are permitted provided that the following conditions are
1910263Satgutier@umich.edu * met: redistributions of source code must retain the above copyright
2010263Satgutier@umich.edu * notice, this list of conditions and the following disclaimer;
2110263Satgutier@umich.edu * redistributions in binary form must reproduce the above copyright
2210263Satgutier@umich.edu * notice, this list of conditions and the following disclaimer in the
2310263Satgutier@umich.edu * documentation and/or other materials provided with the distribution;
2410263Satgutier@umich.edu * neither the name of the copyright holders nor the names of its
2510263Satgutier@umich.edu * contributors may be used to endorse or promote products derived from
2610263Satgutier@umich.edu * this software without specific prior written permission.
2710263Satgutier@umich.edu *
2810263Satgutier@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2910263Satgutier@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3010263Satgutier@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
3110263Satgutier@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3210263Satgutier@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3310263Satgutier@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3410263Satgutier@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3510263Satgutier@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3610263Satgutier@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3710263Satgutier@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3810263Satgutier@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3910263Satgutier@umich.edu *
4010263Satgutier@umich.edu * Authors: Erik Hallnor
4110263Satgutier@umich.edu */
4210263Satgutier@umich.edu
4310263Satgutier@umich.edu/**
4410263Satgutier@umich.edu * @file
4510263Satgutier@umich.edu * Declaration of a base set associative tag store.
4610263Satgutier@umich.edu */
4710263Satgutier@umich.edu
4810263Satgutier@umich.edu#ifndef __MEM_CACHE_TAGS_BASESETASSOC_HH__
4910263Satgutier@umich.edu#define __MEM_CACHE_TAGS_BASESETASSOC_HH__
5010263Satgutier@umich.edu
5110263Satgutier@umich.edu#include <cassert>
5210263Satgutier@umich.edu#include <cstring>
5310263Satgutier@umich.edu#include <list>
5410263Satgutier@umich.edu
5511486Snikos.nikoleris@arm.com#include "mem/cache/base.hh"
5611486Snikos.nikoleris@arm.com#include "mem/cache/blk.hh"
5710263Satgutier@umich.edu#include "mem/cache/tags/base.hh"
5810263Satgutier@umich.edu#include "mem/cache/tags/cacheset.hh"
5910263Satgutier@umich.edu#include "mem/packet.hh"
6010263Satgutier@umich.edu#include "params/BaseSetAssoc.hh"
6110263Satgutier@umich.edu
6210263Satgutier@umich.edu/**
6310263Satgutier@umich.edu * A BaseSetAssoc cache tag store.
6410263Satgutier@umich.edu * @sa  \ref gem5MemorySystem "gem5 Memory System"
6510263Satgutier@umich.edu *
6610263Satgutier@umich.edu * The BaseSetAssoc tags provide a base, as well as the functionality
6710263Satgutier@umich.edu * common to any set associative tags. Any derived class must implement
6810263Satgutier@umich.edu * the methods related to the specifics of the actual replacment policy.
6910263Satgutier@umich.edu * These are:
7010263Satgutier@umich.edu *
7110263Satgutier@umich.edu * BlkType* accessBlock();
7210263Satgutier@umich.edu * BlkType* findVictim();
7310263Satgutier@umich.edu * void insertBlock();
7410263Satgutier@umich.edu * void invalidate();
7510263Satgutier@umich.edu */
7610263Satgutier@umich.educlass BaseSetAssoc : public BaseTags
7710263Satgutier@umich.edu{
7810263Satgutier@umich.edu  public:
7910263Satgutier@umich.edu    /** Typedef the block type used in this tag store. */
8010263Satgutier@umich.edu    typedef CacheBlk BlkType;
8110263Satgutier@umich.edu    /** Typedef for a list of pointers to the local block class. */
8210263Satgutier@umich.edu    typedef std::list<BlkType*> BlkList;
8310263Satgutier@umich.edu    /** Typedef the set type used in this tag store. */
8410263Satgutier@umich.edu    typedef CacheSet<CacheBlk> SetType;
8510263Satgutier@umich.edu
8610263Satgutier@umich.edu
8710263Satgutier@umich.edu  protected:
8810263Satgutier@umich.edu    /** The associativity of the cache. */
8910263Satgutier@umich.edu    const unsigned assoc;
9010941Sdavid.guillen@arm.com    /** The allocatable associativity of the cache (alloc mask). */
9110941Sdavid.guillen@arm.com    unsigned allocAssoc;
9210263Satgutier@umich.edu    /** The number of sets in the cache. */
9310263Satgutier@umich.edu    const unsigned numSets;
9410263Satgutier@umich.edu    /** Whether tags and data are accessed sequentially. */
9510263Satgutier@umich.edu    const bool sequentialAccess;
9610263Satgutier@umich.edu
9710263Satgutier@umich.edu    /** The cache sets. */
9810263Satgutier@umich.edu    SetType *sets;
9910263Satgutier@umich.edu
10010263Satgutier@umich.edu    /** The cache blocks. */
10110263Satgutier@umich.edu    BlkType *blks;
10210263Satgutier@umich.edu    /** The data blocks, 1 per cache block. */
10310263Satgutier@umich.edu    uint8_t *dataBlks;
10410263Satgutier@umich.edu
10510263Satgutier@umich.edu    /** The amount to shift the address to get the set. */
10610263Satgutier@umich.edu    int setShift;
10710263Satgutier@umich.edu    /** The amount to shift the address to get the tag. */
10810263Satgutier@umich.edu    int tagShift;
10910263Satgutier@umich.edu    /** Mask out all bits that aren't part of the set index. */
11010263Satgutier@umich.edu    unsigned setMask;
11110263Satgutier@umich.edu    /** Mask out all bits that aren't part of the block offset. */
11210263Satgutier@umich.edu    unsigned blkMask;
11310263Satgutier@umich.edu
11410263Satgutier@umich.edupublic:
11510263Satgutier@umich.edu
11610263Satgutier@umich.edu    /** Convenience typedef. */
11710263Satgutier@umich.edu     typedef BaseSetAssocParams Params;
11810263Satgutier@umich.edu
11910263Satgutier@umich.edu    /**
12010263Satgutier@umich.edu     * Construct and initialize this tag store.
12110263Satgutier@umich.edu     */
12210263Satgutier@umich.edu    BaseSetAssoc(const Params *p);
12310263Satgutier@umich.edu
12410263Satgutier@umich.edu    /**
12510263Satgutier@umich.edu     * Destructor
12610263Satgutier@umich.edu     */
12710263Satgutier@umich.edu    virtual ~BaseSetAssoc();
12810263Satgutier@umich.edu
12910263Satgutier@umich.edu    /**
13010263Satgutier@umich.edu     * Return the block size.
13110263Satgutier@umich.edu     * @return the block size.
13210263Satgutier@umich.edu     */
13310263Satgutier@umich.edu    unsigned
13410263Satgutier@umich.edu    getBlockSize() const
13510263Satgutier@umich.edu    {
13610263Satgutier@umich.edu        return blkSize;
13710263Satgutier@umich.edu    }
13810263Satgutier@umich.edu
13910263Satgutier@umich.edu    /**
14010263Satgutier@umich.edu     * Return the subblock size. In the case of BaseSetAssoc it is always
14110263Satgutier@umich.edu     * the block size.
14210263Satgutier@umich.edu     * @return The block size.
14310263Satgutier@umich.edu     */
14410263Satgutier@umich.edu    unsigned
14510263Satgutier@umich.edu    getSubBlockSize() const
14610263Satgutier@umich.edu    {
14710263Satgutier@umich.edu        return blkSize;
14810263Satgutier@umich.edu    }
14910263Satgutier@umich.edu
15010263Satgutier@umich.edu    /**
15110941Sdavid.guillen@arm.com     * Return the number of sets this cache has
15210941Sdavid.guillen@arm.com     * @return The number of sets.
15310941Sdavid.guillen@arm.com     */
15410941Sdavid.guillen@arm.com    unsigned
15511169Sandreas.hansson@arm.com    getNumSets() const override
15610941Sdavid.guillen@arm.com    {
15710941Sdavid.guillen@arm.com        return numSets;
15810941Sdavid.guillen@arm.com    }
15910941Sdavid.guillen@arm.com
16010941Sdavid.guillen@arm.com    /**
16110941Sdavid.guillen@arm.com     * Return the number of ways this cache has
16210941Sdavid.guillen@arm.com     * @return The number of ways.
16310941Sdavid.guillen@arm.com     */
16410941Sdavid.guillen@arm.com    unsigned
16511169Sandreas.hansson@arm.com    getNumWays() const override
16610941Sdavid.guillen@arm.com    {
16710941Sdavid.guillen@arm.com        return assoc;
16810941Sdavid.guillen@arm.com    }
16910941Sdavid.guillen@arm.com
17010941Sdavid.guillen@arm.com    /**
17110941Sdavid.guillen@arm.com     * Find the cache block given set and way
17210941Sdavid.guillen@arm.com     * @param set The set of the block.
17310941Sdavid.guillen@arm.com     * @param way The way of the block.
17410941Sdavid.guillen@arm.com     * @return The cache block.
17510941Sdavid.guillen@arm.com     */
17611169Sandreas.hansson@arm.com    CacheBlk *findBlockBySetAndWay(int set, int way) const override;
17710941Sdavid.guillen@arm.com
17810941Sdavid.guillen@arm.com    /**
17910263Satgutier@umich.edu     * Invalidate the given block.
18010263Satgutier@umich.edu     * @param blk The block to invalidate.
18110263Satgutier@umich.edu     */
18211169Sandreas.hansson@arm.com    void invalidate(CacheBlk *blk) override
18310263Satgutier@umich.edu    {
18410263Satgutier@umich.edu        assert(blk);
18510263Satgutier@umich.edu        assert(blk->isValid());
18610263Satgutier@umich.edu        tagsInUse--;
18710263Satgutier@umich.edu        assert(blk->srcMasterId < cache->system->maxMasters());
18810263Satgutier@umich.edu        occupancies[blk->srcMasterId]--;
18910263Satgutier@umich.edu        blk->srcMasterId = Request::invldMasterId;
19010263Satgutier@umich.edu        blk->task_id = ContextSwitchTaskId::Unknown;
19110263Satgutier@umich.edu        blk->tickInserted = curTick();
19210263Satgutier@umich.edu    }
19310263Satgutier@umich.edu
19410263Satgutier@umich.edu    /**
19510263Satgutier@umich.edu     * Access block and update replacement data. May not succeed, in which case
19611484Snikos.nikoleris@arm.com     * nullptr is returned. This has all the implications of a cache
19710263Satgutier@umich.edu     * access and should only be used as such. Returns the access latency as a
19810263Satgutier@umich.edu     * side effect.
19910263Satgutier@umich.edu     * @param addr The address to find.
20010263Satgutier@umich.edu     * @param is_secure True if the target memory space is secure.
20110263Satgutier@umich.edu     * @param asid The address space ID.
20210263Satgutier@umich.edu     * @param lat The access latency.
20310263Satgutier@umich.edu     * @return Pointer to the cache block if found.
20410263Satgutier@umich.edu     */
20510815Sdavid.guillen@arm.com    CacheBlk* accessBlock(Addr addr, bool is_secure, Cycles &lat,
20611169Sandreas.hansson@arm.com                          int context_src) override
20710263Satgutier@umich.edu    {
20810263Satgutier@umich.edu        Addr tag = extractTag(addr);
20910263Satgutier@umich.edu        int set = extractSet(addr);
21010263Satgutier@umich.edu        BlkType *blk = sets[set].findBlk(tag, is_secure);
21110263Satgutier@umich.edu
21210263Satgutier@umich.edu        // Access all tags in parallel, hence one in each way.  The data side
21310263Satgutier@umich.edu        // either accesses all blocks in parallel, or one block sequentially on
21410263Satgutier@umich.edu        // a hit.  Sequential access with a miss doesn't access data.
21510941Sdavid.guillen@arm.com        tagAccesses += allocAssoc;
21610263Satgutier@umich.edu        if (sequentialAccess) {
21711484Snikos.nikoleris@arm.com            if (blk != nullptr) {
21810263Satgutier@umich.edu                dataAccesses += 1;
21910263Satgutier@umich.edu            }
22010263Satgutier@umich.edu        } else {
22110941Sdavid.guillen@arm.com            dataAccesses += allocAssoc;
22210263Satgutier@umich.edu        }
22310263Satgutier@umich.edu
22411484Snikos.nikoleris@arm.com        if (blk != nullptr) {
22511722Ssophiane.senni@gmail.com            // If a cache hit
22611722Ssophiane.senni@gmail.com            lat = accessLatency;
22711722Ssophiane.senni@gmail.com            // Check if the block to be accessed is available. If not,
22811722Ssophiane.senni@gmail.com            // apply the accessLatency on top of block->whenReady.
22911722Ssophiane.senni@gmail.com            if (blk->whenReady > curTick() &&
23011722Ssophiane.senni@gmail.com                cache->ticksToCycles(blk->whenReady - curTick()) >
23111722Ssophiane.senni@gmail.com                accessLatency) {
23211722Ssophiane.senni@gmail.com                lat = cache->ticksToCycles(blk->whenReady - curTick()) +
23311722Ssophiane.senni@gmail.com                accessLatency;
23410263Satgutier@umich.edu            }
23510263Satgutier@umich.edu            blk->refCount += 1;
23611722Ssophiane.senni@gmail.com        } else {
23711722Ssophiane.senni@gmail.com            // If a cache miss
23811722Ssophiane.senni@gmail.com            lat = lookupLatency;
23910263Satgutier@umich.edu        }
24010263Satgutier@umich.edu
24110263Satgutier@umich.edu        return blk;
24210263Satgutier@umich.edu    }
24310263Satgutier@umich.edu
24410263Satgutier@umich.edu    /**
24510263Satgutier@umich.edu     * Finds the given address in the cache, do not update replacement data.
24610263Satgutier@umich.edu     * i.e. This is a no-side-effect find of a block.
24710263Satgutier@umich.edu     * @param addr The address to find.
24810263Satgutier@umich.edu     * @param is_secure True if the target memory space is secure.
24910263Satgutier@umich.edu     * @param asid The address space ID.
25010263Satgutier@umich.edu     * @return Pointer to the cache block if found.
25110263Satgutier@umich.edu     */
25211169Sandreas.hansson@arm.com    CacheBlk* findBlock(Addr addr, bool is_secure) const override;
25310263Satgutier@umich.edu
25410263Satgutier@umich.edu    /**
25510263Satgutier@umich.edu     * Find an invalid block to evict for the address provided.
25610263Satgutier@umich.edu     * If there are no invalid blocks, this will return the block
25710263Satgutier@umich.edu     * in the least-recently-used position.
25810263Satgutier@umich.edu     * @param addr The addr to a find a replacement candidate for.
25910263Satgutier@umich.edu     * @return The candidate block.
26010263Satgutier@umich.edu     */
26111169Sandreas.hansson@arm.com    CacheBlk* findVictim(Addr addr) override
26210263Satgutier@umich.edu    {
26311484Snikos.nikoleris@arm.com        BlkType *blk = nullptr;
26410263Satgutier@umich.edu        int set = extractSet(addr);
26510263Satgutier@umich.edu
26610263Satgutier@umich.edu        // prefer to evict an invalid block
26710941Sdavid.guillen@arm.com        for (int i = 0; i < allocAssoc; ++i) {
26810263Satgutier@umich.edu            blk = sets[set].blks[i];
26910941Sdavid.guillen@arm.com            if (!blk->isValid())
27010263Satgutier@umich.edu                break;
27110263Satgutier@umich.edu        }
27210263Satgutier@umich.edu
27310263Satgutier@umich.edu        return blk;
27410263Satgutier@umich.edu    }
27510263Satgutier@umich.edu
27610263Satgutier@umich.edu    /**
27710263Satgutier@umich.edu     * Insert the new block into the cache.
27810263Satgutier@umich.edu     * @param pkt Packet holding the address to update
27910263Satgutier@umich.edu     * @param blk The block to update.
28010263Satgutier@umich.edu     */
28111169Sandreas.hansson@arm.com     void insertBlock(PacketPtr pkt, CacheBlk *blk) override
28210263Satgutier@umich.edu     {
28310263Satgutier@umich.edu         Addr addr = pkt->getAddr();
28410263Satgutier@umich.edu         MasterID master_id = pkt->req->masterId();
28510263Satgutier@umich.edu         uint32_t task_id = pkt->req->taskId();
28610274Smitch.hayenga@arm.com
28710263Satgutier@umich.edu         if (!blk->isTouched) {
28810263Satgutier@umich.edu             tagsInUse++;
28910263Satgutier@umich.edu             blk->isTouched = true;
29010263Satgutier@umich.edu             if (!warmedUp && tagsInUse.value() >= warmupBound) {
29110263Satgutier@umich.edu                 warmedUp = true;
29210263Satgutier@umich.edu                 warmupCycle = curTick();
29310263Satgutier@umich.edu             }
29410263Satgutier@umich.edu         }
29510263Satgutier@umich.edu
29610263Satgutier@umich.edu         // If we're replacing a block that was previously valid update
29710263Satgutier@umich.edu         // stats for it. This can't be done in findBlock() because a
29810263Satgutier@umich.edu         // found block might not actually be replaced there if the
29910263Satgutier@umich.edu         // coherence protocol says it can't be.
30010263Satgutier@umich.edu         if (blk->isValid()) {
30110263Satgutier@umich.edu             replacements[0]++;
30210263Satgutier@umich.edu             totalRefs += blk->refCount;
30310263Satgutier@umich.edu             ++sampledRefs;
30410263Satgutier@umich.edu             blk->refCount = 0;
30510263Satgutier@umich.edu
30610263Satgutier@umich.edu             // deal with evicted block
30710263Satgutier@umich.edu             assert(blk->srcMasterId < cache->system->maxMasters());
30810263Satgutier@umich.edu             occupancies[blk->srcMasterId]--;
30910263Satgutier@umich.edu
31010263Satgutier@umich.edu             blk->invalidate();
31110263Satgutier@umich.edu         }
31210263Satgutier@umich.edu
31310263Satgutier@umich.edu         blk->isTouched = true;
31410274Smitch.hayenga@arm.com
31510263Satgutier@umich.edu         // Set tag for new block.  Caller is responsible for setting status.
31610263Satgutier@umich.edu         blk->tag = extractTag(addr);
31710263Satgutier@umich.edu
31810263Satgutier@umich.edu         // deal with what we are bringing in
31910263Satgutier@umich.edu         assert(master_id < cache->system->maxMasters());
32010263Satgutier@umich.edu         occupancies[master_id]++;
32110263Satgutier@umich.edu         blk->srcMasterId = master_id;
32210263Satgutier@umich.edu         blk->task_id = task_id;
32310263Satgutier@umich.edu         blk->tickInserted = curTick();
32410263Satgutier@umich.edu
32510263Satgutier@umich.edu         // We only need to write into one tag and one data block.
32610263Satgutier@umich.edu         tagAccesses += 1;
32710263Satgutier@umich.edu         dataAccesses += 1;
32810263Satgutier@umich.edu     }
32910263Satgutier@umich.edu
33010263Satgutier@umich.edu    /**
33110941Sdavid.guillen@arm.com     * Limit the allocation for the cache ways.
33210941Sdavid.guillen@arm.com     * @param ways The maximum number of ways available for replacement.
33310941Sdavid.guillen@arm.com     */
33411169Sandreas.hansson@arm.com    virtual void setWayAllocationMax(int ways) override
33510941Sdavid.guillen@arm.com    {
33610941Sdavid.guillen@arm.com        fatal_if(ways < 1, "Allocation limit must be greater than zero");
33710941Sdavid.guillen@arm.com        allocAssoc = ways;
33810941Sdavid.guillen@arm.com    }
33910941Sdavid.guillen@arm.com
34010941Sdavid.guillen@arm.com    /**
34110941Sdavid.guillen@arm.com     * Get the way allocation mask limit.
34210941Sdavid.guillen@arm.com     * @return The maximum number of ways available for replacement.
34310941Sdavid.guillen@arm.com     */
34411169Sandreas.hansson@arm.com    virtual int getWayAllocationMax() const override
34510941Sdavid.guillen@arm.com    {
34610941Sdavid.guillen@arm.com        return allocAssoc;
34710941Sdavid.guillen@arm.com    }
34810941Sdavid.guillen@arm.com
34910941Sdavid.guillen@arm.com    /**
35010263Satgutier@umich.edu     * Generate the tag from the given address.
35110263Satgutier@umich.edu     * @param addr The address to get the tag from.
35210263Satgutier@umich.edu     * @return The tag of the address.
35310263Satgutier@umich.edu     */
35411169Sandreas.hansson@arm.com    Addr extractTag(Addr addr) const override
35510263Satgutier@umich.edu    {
35610263Satgutier@umich.edu        return (addr >> tagShift);
35710263Satgutier@umich.edu    }
35810263Satgutier@umich.edu
35910263Satgutier@umich.edu    /**
36010263Satgutier@umich.edu     * Calculate the set index from the address.
36110263Satgutier@umich.edu     * @param addr The address to get the set from.
36210263Satgutier@umich.edu     * @return The set index of the address.
36310263Satgutier@umich.edu     */
36411169Sandreas.hansson@arm.com    int extractSet(Addr addr) const override
36510263Satgutier@umich.edu    {
36610263Satgutier@umich.edu        return ((addr >> setShift) & setMask);
36710263Satgutier@umich.edu    }
36810263Satgutier@umich.edu
36910263Satgutier@umich.edu    /**
37010263Satgutier@umich.edu     * Align an address to the block size.
37110263Satgutier@umich.edu     * @param addr the address to align.
37210263Satgutier@umich.edu     * @return The block address.
37310263Satgutier@umich.edu     */
37410263Satgutier@umich.edu    Addr blkAlign(Addr addr) const
37510263Satgutier@umich.edu    {
37610263Satgutier@umich.edu        return (addr & ~(Addr)blkMask);
37710263Satgutier@umich.edu    }
37810263Satgutier@umich.edu
37910263Satgutier@umich.edu    /**
38010263Satgutier@umich.edu     * Regenerate the block address from the tag.
38110263Satgutier@umich.edu     * @param tag The tag of the block.
38210263Satgutier@umich.edu     * @param set The set of the block.
38310263Satgutier@umich.edu     * @return The block address.
38410263Satgutier@umich.edu     */
38511169Sandreas.hansson@arm.com    Addr regenerateBlkAddr(Addr tag, unsigned set) const override
38610263Satgutier@umich.edu    {
38710263Satgutier@umich.edu        return ((tag << tagShift) | ((Addr)set << setShift));
38810263Satgutier@umich.edu    }
38910263Satgutier@umich.edu
39010263Satgutier@umich.edu    /**
39110263Satgutier@umich.edu     * Called at end of simulation to complete average block reference stats.
39210263Satgutier@umich.edu     */
39311169Sandreas.hansson@arm.com    void cleanupRefs() override;
39410263Satgutier@umich.edu
39510263Satgutier@umich.edu    /**
39610263Satgutier@umich.edu     * Print all tags used
39710263Satgutier@umich.edu     */
39811169Sandreas.hansson@arm.com    std::string print() const override;
39910263Satgutier@umich.edu
40010263Satgutier@umich.edu    /**
40110263Satgutier@umich.edu     * Called prior to dumping stats to compute task occupancy
40210263Satgutier@umich.edu     */
40311169Sandreas.hansson@arm.com    void computeStats() override;
40410263Satgutier@umich.edu
40510263Satgutier@umich.edu    /**
40610263Satgutier@umich.edu     * Visit each block in the tag store and apply a visitor to the
40710263Satgutier@umich.edu     * block.
40810263Satgutier@umich.edu     *
40910263Satgutier@umich.edu     * The visitor should be a function (or object that behaves like a
41010263Satgutier@umich.edu     * function) that takes a cache block reference as its parameter
41110263Satgutier@umich.edu     * and returns a bool. A visitor can request the traversal to be
41210263Satgutier@umich.edu     * stopped by returning false, returning true causes it to be
41310263Satgutier@umich.edu     * called for the next block in the tag store.
41410263Satgutier@umich.edu     *
41510263Satgutier@umich.edu     * \param visitor Visitor to call on each block.
41610263Satgutier@umich.edu     */
41711168Sandreas.hansson@arm.com    void forEachBlk(CacheBlkVisitor &visitor) override {
41810263Satgutier@umich.edu        for (unsigned i = 0; i < numSets * assoc; ++i) {
41910263Satgutier@umich.edu            if (!visitor(blks[i]))
42010263Satgutier@umich.edu                return;
42110263Satgutier@umich.edu        }
42210263Satgutier@umich.edu    }
42310263Satgutier@umich.edu};
42410263Satgutier@umich.edu
42510263Satgutier@umich.edu#endif // __MEM_CACHE_TAGS_BASESETASSOC_HH__
426