sector_tags.cc revision 13215
112752Sodanrc@yahoo.com.br/* 212752Sodanrc@yahoo.com.br * Copyright (c) 2018 Inria 312752Sodanrc@yahoo.com.br * All rights reserved. 412752Sodanrc@yahoo.com.br * 512752Sodanrc@yahoo.com.br * Redistribution and use in source and binary forms, with or without 612752Sodanrc@yahoo.com.br * modification, are permitted provided that the following conditions are 712752Sodanrc@yahoo.com.br * met: redistributions of source code must retain the above copyright 812752Sodanrc@yahoo.com.br * notice, this list of conditions and the following disclaimer; 912752Sodanrc@yahoo.com.br * redistributions in binary form must reproduce the above copyright 1012752Sodanrc@yahoo.com.br * notice, this list of conditions and the following disclaimer in the 1112752Sodanrc@yahoo.com.br * documentation and/or other materials provided with the distribution; 1212752Sodanrc@yahoo.com.br * neither the name of the copyright holders nor the names of its 1312752Sodanrc@yahoo.com.br * contributors may be used to endorse or promote products derived from 1412752Sodanrc@yahoo.com.br * this software without specific prior written permission. 1512752Sodanrc@yahoo.com.br * 1612752Sodanrc@yahoo.com.br * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1712752Sodanrc@yahoo.com.br * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1812752Sodanrc@yahoo.com.br * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1912752Sodanrc@yahoo.com.br * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2012752Sodanrc@yahoo.com.br * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2112752Sodanrc@yahoo.com.br * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2212752Sodanrc@yahoo.com.br * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2312752Sodanrc@yahoo.com.br * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2412752Sodanrc@yahoo.com.br * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2512752Sodanrc@yahoo.com.br * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2612752Sodanrc@yahoo.com.br * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2712752Sodanrc@yahoo.com.br * 2812752Sodanrc@yahoo.com.br * Authors: Daniel Carvalho 2912752Sodanrc@yahoo.com.br */ 3012752Sodanrc@yahoo.com.br 3112752Sodanrc@yahoo.com.br/** 3212752Sodanrc@yahoo.com.br * @file 3312752Sodanrc@yahoo.com.br * Definitions of a base set associative sector tag store. 3412752Sodanrc@yahoo.com.br */ 3512752Sodanrc@yahoo.com.br 3612752Sodanrc@yahoo.com.br#include "mem/cache/tags/sector_tags.hh" 3712752Sodanrc@yahoo.com.br 3812752Sodanrc@yahoo.com.br#include <cassert> 3912752Sodanrc@yahoo.com.br#include <memory> 4012752Sodanrc@yahoo.com.br#include <string> 4112752Sodanrc@yahoo.com.br 4212752Sodanrc@yahoo.com.br#include "base/intmath.hh" 4312752Sodanrc@yahoo.com.br#include "base/logging.hh" 4412752Sodanrc@yahoo.com.br#include "base/types.hh" 4512752Sodanrc@yahoo.com.br#include "debug/CacheRepl.hh" 4612752Sodanrc@yahoo.com.br#include "mem/cache/base.hh" 4712752Sodanrc@yahoo.com.br#include "mem/cache/replacement_policies/base.hh" 4812752Sodanrc@yahoo.com.br 4912752Sodanrc@yahoo.com.brSectorTags::SectorTags(const SectorTagsParams *p) 5012752Sodanrc@yahoo.com.br : BaseTags(p), assoc(p->assoc), allocAssoc(p->assoc), 5112752Sodanrc@yahoo.com.br sequentialAccess(p->sequential_access), 5212752Sodanrc@yahoo.com.br replacementPolicy(p->replacement_policy), 5312752Sodanrc@yahoo.com.br numBlocksPerSector(p->num_blocks_per_sector), 5412752Sodanrc@yahoo.com.br numSectors(numBlocks / p->num_blocks_per_sector), 5512752Sodanrc@yahoo.com.br numSets(numSectors / p->assoc), 5612752Sodanrc@yahoo.com.br blks(numBlocks), secBlks(numSectors), sets(numSets), 5712752Sodanrc@yahoo.com.br sectorShift(floorLog2(blkSize)), 5812752Sodanrc@yahoo.com.br setShift(sectorShift + floorLog2(numBlocksPerSector)), 5912752Sodanrc@yahoo.com.br tagShift(setShift + floorLog2(numSets)), 6012752Sodanrc@yahoo.com.br sectorMask(numBlocksPerSector - 1), setMask(numSets - 1) 6112752Sodanrc@yahoo.com.br{ 6212752Sodanrc@yahoo.com.br // Check parameters 6312752Sodanrc@yahoo.com.br fatal_if(blkSize < 4 || !isPowerOf2(blkSize), 6412752Sodanrc@yahoo.com.br "Block size must be at least 4 and a power of 2"); 6512752Sodanrc@yahoo.com.br fatal_if(!isPowerOf2(numSets), 6612752Sodanrc@yahoo.com.br "# of sets must be non-zero and a power of 2"); 6712752Sodanrc@yahoo.com.br fatal_if(!isPowerOf2(numBlocksPerSector), 6812752Sodanrc@yahoo.com.br "# of blocks per sector must be non-zero and a power of 2"); 6912752Sodanrc@yahoo.com.br fatal_if(assoc <= 0, "associativity must be greater than zero"); 7012752Sodanrc@yahoo.com.br 7112752Sodanrc@yahoo.com.br // Initialize all sets 7212752Sodanrc@yahoo.com.br unsigned sec_blk_index = 0; // index into sector blks array 7312752Sodanrc@yahoo.com.br unsigned blk_index = 0; // index into blks array 7412752Sodanrc@yahoo.com.br for (unsigned i = 0; i < numSets; ++i) { 7512752Sodanrc@yahoo.com.br sets[i].resize(assoc); 7612752Sodanrc@yahoo.com.br 7712752Sodanrc@yahoo.com.br // Initialize all sectors in this set 7812752Sodanrc@yahoo.com.br for (unsigned j = 0; j < assoc; ++j) { 7912752Sodanrc@yahoo.com.br // Select block within the set to be linked 8012752Sodanrc@yahoo.com.br SectorBlk*& sec_blk = sets[i][j]; 8112752Sodanrc@yahoo.com.br 8212752Sodanrc@yahoo.com.br // Locate next cache sector 8312752Sodanrc@yahoo.com.br sec_blk = &secBlks[sec_blk_index]; 8412752Sodanrc@yahoo.com.br 8512752Sodanrc@yahoo.com.br // Associate a replacement data entry to the sector 8612752Sodanrc@yahoo.com.br sec_blk->replacementData = replacementPolicy->instantiateEntry(); 8712752Sodanrc@yahoo.com.br 8812752Sodanrc@yahoo.com.br // Initialize all blocks in this sector 8912752Sodanrc@yahoo.com.br sec_blk->blks.resize(numBlocksPerSector); 9012752Sodanrc@yahoo.com.br for (unsigned k = 0; k < numBlocksPerSector; ++k){ 9112752Sodanrc@yahoo.com.br // Select block within the set to be linked 9212752Sodanrc@yahoo.com.br SectorSubBlk*& blk = sec_blk->blks[k]; 9312752Sodanrc@yahoo.com.br 9412752Sodanrc@yahoo.com.br // Locate next cache block 9512752Sodanrc@yahoo.com.br blk = &blks[blk_index]; 9612752Sodanrc@yahoo.com.br 9712752Sodanrc@yahoo.com.br // Associate a data chunk to the block 9812752Sodanrc@yahoo.com.br blk->data = &dataBlks[blkSize*blk_index]; 9912752Sodanrc@yahoo.com.br 10012752Sodanrc@yahoo.com.br // Associate sector block to this block 10112752Sodanrc@yahoo.com.br blk->setSectorBlock(sec_blk); 10212752Sodanrc@yahoo.com.br 10312752Sodanrc@yahoo.com.br // Associate the sector replacement data to this block 10412752Sodanrc@yahoo.com.br blk->replacementData = sec_blk->replacementData; 10512752Sodanrc@yahoo.com.br 10612752Sodanrc@yahoo.com.br // Set its set, way and sector offset 10712752Sodanrc@yahoo.com.br blk->set = i; 10812752Sodanrc@yahoo.com.br blk->way = j; 10912752Sodanrc@yahoo.com.br blk->setSectorOffset(k); 11012752Sodanrc@yahoo.com.br 11112752Sodanrc@yahoo.com.br // Update block index 11212752Sodanrc@yahoo.com.br ++blk_index; 11312752Sodanrc@yahoo.com.br } 11412752Sodanrc@yahoo.com.br 11512752Sodanrc@yahoo.com.br // Update sector block index 11612752Sodanrc@yahoo.com.br ++sec_blk_index; 11712752Sodanrc@yahoo.com.br } 11812752Sodanrc@yahoo.com.br } 11912752Sodanrc@yahoo.com.br} 12012752Sodanrc@yahoo.com.br 12112752Sodanrc@yahoo.com.brvoid 12212752Sodanrc@yahoo.com.brSectorTags::invalidate(CacheBlk *blk) 12312752Sodanrc@yahoo.com.br{ 12412752Sodanrc@yahoo.com.br BaseTags::invalidate(blk); 12512752Sodanrc@yahoo.com.br 12612752Sodanrc@yahoo.com.br // Get block's sector 12712752Sodanrc@yahoo.com.br SectorSubBlk* sub_blk = static_cast<SectorSubBlk*>(blk); 12812752Sodanrc@yahoo.com.br const SectorBlk* sector_blk = sub_blk->getSectorBlock(); 12912752Sodanrc@yahoo.com.br 13012752Sodanrc@yahoo.com.br // When a block in a sector is invalidated, it does not make the tag 13112752Sodanrc@yahoo.com.br // invalid automatically, as there might be other blocks in the sector 13212752Sodanrc@yahoo.com.br // using it. The tag is invalidated only when there is a single block 13312752Sodanrc@yahoo.com.br // in the sector. 13412752Sodanrc@yahoo.com.br if (!sector_blk->isValid()) { 13512752Sodanrc@yahoo.com.br // Decrease the number of tags in use 13612752Sodanrc@yahoo.com.br tagsInUse--; 13712752Sodanrc@yahoo.com.br 13812752Sodanrc@yahoo.com.br // Invalidate replacement data, as we're invalidating the sector 13912752Sodanrc@yahoo.com.br replacementPolicy->invalidate(sector_blk->replacementData); 14012752Sodanrc@yahoo.com.br } 14112752Sodanrc@yahoo.com.br} 14212752Sodanrc@yahoo.com.br 14312752Sodanrc@yahoo.com.brCacheBlk* 14412752Sodanrc@yahoo.com.brSectorTags::accessBlock(Addr addr, bool is_secure, Cycles &lat) 14512752Sodanrc@yahoo.com.br{ 14612752Sodanrc@yahoo.com.br CacheBlk *blk = findBlock(addr, is_secure); 14712752Sodanrc@yahoo.com.br 14812752Sodanrc@yahoo.com.br // Access all tags in parallel, hence one in each way. The data side 14912752Sodanrc@yahoo.com.br // either accesses all blocks in parallel, or one block sequentially on 15012752Sodanrc@yahoo.com.br // a hit. Sequential access with a miss doesn't access data. 15112752Sodanrc@yahoo.com.br tagAccesses += allocAssoc; 15212752Sodanrc@yahoo.com.br if (sequentialAccess) { 15312752Sodanrc@yahoo.com.br if (blk != nullptr) { 15412752Sodanrc@yahoo.com.br dataAccesses += 1; 15512752Sodanrc@yahoo.com.br } 15612752Sodanrc@yahoo.com.br } else { 15712752Sodanrc@yahoo.com.br dataAccesses += allocAssoc*numBlocksPerSector; 15812752Sodanrc@yahoo.com.br } 15912752Sodanrc@yahoo.com.br 16012752Sodanrc@yahoo.com.br if (blk != nullptr) { 16112752Sodanrc@yahoo.com.br // If a cache hit 16212752Sodanrc@yahoo.com.br lat = accessLatency; 16312752Sodanrc@yahoo.com.br // Check if the block to be accessed is available. If not, 16412752Sodanrc@yahoo.com.br // apply the accessLatency on top of block->whenReady. 16512752Sodanrc@yahoo.com.br if (blk->whenReady > curTick() && 16612752Sodanrc@yahoo.com.br cache->ticksToCycles(blk->whenReady - curTick()) > 16712752Sodanrc@yahoo.com.br accessLatency) { 16812752Sodanrc@yahoo.com.br lat = cache->ticksToCycles(blk->whenReady - curTick()) + 16912752Sodanrc@yahoo.com.br accessLatency; 17012752Sodanrc@yahoo.com.br } 17112752Sodanrc@yahoo.com.br 17212752Sodanrc@yahoo.com.br // Update number of references to accessed block 17312752Sodanrc@yahoo.com.br blk->refCount++; 17412752Sodanrc@yahoo.com.br 17512752Sodanrc@yahoo.com.br // Get block's sector 17612752Sodanrc@yahoo.com.br SectorSubBlk* sub_blk = static_cast<SectorSubBlk*>(blk); 17712752Sodanrc@yahoo.com.br const SectorBlk* sector_blk = sub_blk->getSectorBlock(); 17812752Sodanrc@yahoo.com.br 17912752Sodanrc@yahoo.com.br // Update replacement data of accessed block, which is shared with 18012752Sodanrc@yahoo.com.br // the whole sector it belongs to 18112752Sodanrc@yahoo.com.br replacementPolicy->touch(sector_blk->replacementData); 18212752Sodanrc@yahoo.com.br } else { 18312752Sodanrc@yahoo.com.br // If a cache miss 18412752Sodanrc@yahoo.com.br lat = lookupLatency; 18512752Sodanrc@yahoo.com.br } 18612752Sodanrc@yahoo.com.br 18712752Sodanrc@yahoo.com.br return blk; 18812752Sodanrc@yahoo.com.br} 18912752Sodanrc@yahoo.com.br 19012752Sodanrc@yahoo.com.brconst std::vector<SectorBlk*> 19112752Sodanrc@yahoo.com.brSectorTags::getPossibleLocations(Addr addr) const 19212752Sodanrc@yahoo.com.br{ 19312752Sodanrc@yahoo.com.br return sets[extractSet(addr)]; 19412752Sodanrc@yahoo.com.br} 19512752Sodanrc@yahoo.com.br 19612752Sodanrc@yahoo.com.brvoid 19713215Sodanrc@yahoo.com.brSectorTags::insertBlock(const Addr addr, const bool is_secure, 19813215Sodanrc@yahoo.com.br const int src_master_ID, const uint32_t task_ID, 19913215Sodanrc@yahoo.com.br CacheBlk *blk) 20012752Sodanrc@yahoo.com.br{ 20113215Sodanrc@yahoo.com.br // Do common block insertion functionality 20213215Sodanrc@yahoo.com.br BaseTags::insertBlock(addr, is_secure, src_master_ID, task_ID, blk); 20312752Sodanrc@yahoo.com.br 20412752Sodanrc@yahoo.com.br // Get block's sector 20512752Sodanrc@yahoo.com.br SectorSubBlk* sub_blk = static_cast<SectorSubBlk*>(blk); 20612752Sodanrc@yahoo.com.br const SectorBlk* sector_blk = sub_blk->getSectorBlock(); 20712752Sodanrc@yahoo.com.br 20812752Sodanrc@yahoo.com.br // When a block is inserted, the tag is only a newly used tag if the 20912752Sodanrc@yahoo.com.br // sector was not previously present in the cache. 21012752Sodanrc@yahoo.com.br // This assumes BaseTags::insertBlock does not set the valid bit. 21112752Sodanrc@yahoo.com.br if (sector_blk->isValid()) { 21212752Sodanrc@yahoo.com.br // An existing entry's replacement data is just updated 21312752Sodanrc@yahoo.com.br replacementPolicy->touch(sector_blk->replacementData); 21412752Sodanrc@yahoo.com.br } else { 21512752Sodanrc@yahoo.com.br // Increment tag counter 21612752Sodanrc@yahoo.com.br tagsInUse++; 21712752Sodanrc@yahoo.com.br 21812752Sodanrc@yahoo.com.br // A new entry resets the replacement data 21912752Sodanrc@yahoo.com.br replacementPolicy->reset(sector_blk->replacementData); 22012752Sodanrc@yahoo.com.br } 22112752Sodanrc@yahoo.com.br} 22212752Sodanrc@yahoo.com.br 22312752Sodanrc@yahoo.com.brCacheBlk* 22412752Sodanrc@yahoo.com.brSectorTags::findBlock(Addr addr, bool is_secure) const 22512752Sodanrc@yahoo.com.br{ 22612752Sodanrc@yahoo.com.br // Extract sector tag 22712752Sodanrc@yahoo.com.br const Addr tag = extractTag(addr); 22812752Sodanrc@yahoo.com.br 22912752Sodanrc@yahoo.com.br // The address can only be mapped to a specific location of a sector 23012752Sodanrc@yahoo.com.br // due to sectors being composed of contiguous-address entries 23112752Sodanrc@yahoo.com.br const Addr offset = extractSectorOffset(addr); 23212752Sodanrc@yahoo.com.br 23312752Sodanrc@yahoo.com.br // Find all possible sector locations for the given address 23412752Sodanrc@yahoo.com.br const std::vector<SectorBlk*> locations = getPossibleLocations(addr); 23512752Sodanrc@yahoo.com.br 23612752Sodanrc@yahoo.com.br // Search for block 23712752Sodanrc@yahoo.com.br for (const auto& sector : locations) { 23812752Sodanrc@yahoo.com.br auto blk = sector->blks[offset]; 23912752Sodanrc@yahoo.com.br if (blk->getTag() == tag && blk->isValid() && 24012752Sodanrc@yahoo.com.br blk->isSecure() == is_secure) { 24112752Sodanrc@yahoo.com.br return blk; 24212752Sodanrc@yahoo.com.br } 24312752Sodanrc@yahoo.com.br } 24412752Sodanrc@yahoo.com.br 24512752Sodanrc@yahoo.com.br // Did not find block 24612752Sodanrc@yahoo.com.br return nullptr; 24712752Sodanrc@yahoo.com.br} 24812752Sodanrc@yahoo.com.br 24912752Sodanrc@yahoo.com.brReplaceableEntry* 25012752Sodanrc@yahoo.com.brSectorTags::findBlockBySetAndWay(int set, int way) const 25112752Sodanrc@yahoo.com.br{ 25212752Sodanrc@yahoo.com.br return sets[set][way]; 25312752Sodanrc@yahoo.com.br} 25412752Sodanrc@yahoo.com.br 25512752Sodanrc@yahoo.com.brCacheBlk* 25612752Sodanrc@yahoo.com.brSectorTags::findVictim(Addr addr, const bool is_secure, 25712752Sodanrc@yahoo.com.br std::vector<CacheBlk*>& evict_blks) const 25812752Sodanrc@yahoo.com.br{ 25912752Sodanrc@yahoo.com.br // Get all possible locations of this sector 26012752Sodanrc@yahoo.com.br const std::vector<SectorBlk*> sector_locations = 26112752Sodanrc@yahoo.com.br getPossibleLocations(addr); 26212752Sodanrc@yahoo.com.br 26312752Sodanrc@yahoo.com.br // Check if the sector this address belongs to has been allocated 26412752Sodanrc@yahoo.com.br Addr tag = extractTag(addr); 26512752Sodanrc@yahoo.com.br SectorBlk* victim_sector = nullptr; 26612752Sodanrc@yahoo.com.br for (const auto& sector : sector_locations){ 26712752Sodanrc@yahoo.com.br if ((tag == sector->getTag()) && sector->isValid() && 26812752Sodanrc@yahoo.com.br (is_secure == sector->isSecure())){ 26912752Sodanrc@yahoo.com.br victim_sector = sector; 27012752Sodanrc@yahoo.com.br break; 27112752Sodanrc@yahoo.com.br } 27212752Sodanrc@yahoo.com.br } 27312752Sodanrc@yahoo.com.br 27412752Sodanrc@yahoo.com.br // If the sector is not present 27512752Sodanrc@yahoo.com.br if (victim_sector == nullptr){ 27612752Sodanrc@yahoo.com.br // Choose replacement victim from replacement candidates 27712752Sodanrc@yahoo.com.br victim_sector = static_cast<SectorBlk*>(replacementPolicy->getVictim( 27812752Sodanrc@yahoo.com.br std::vector<ReplaceableEntry*>( 27912752Sodanrc@yahoo.com.br sector_locations.begin(), sector_locations.end()))); 28012752Sodanrc@yahoo.com.br } 28112752Sodanrc@yahoo.com.br 28212752Sodanrc@yahoo.com.br // Get the location of the victim block within the sector 28312756Snikos.nikoleris@arm.com SectorSubBlk* victim = victim_sector->blks[extractSectorOffset(addr)]; 28412752Sodanrc@yahoo.com.br 28512752Sodanrc@yahoo.com.br // Get evicted blocks. Blocks are only evicted if the sectors mismatch and 28612752Sodanrc@yahoo.com.br // the currently existing sector is valid. 28712752Sodanrc@yahoo.com.br if ((tag == victim_sector->getTag()) && 28812752Sodanrc@yahoo.com.br (is_secure == victim_sector->isSecure())){ 28912752Sodanrc@yahoo.com.br // It would be a hit if victim was valid, and upgrades do not call 29012752Sodanrc@yahoo.com.br // findVictim, so it cannot happen 29112752Sodanrc@yahoo.com.br assert(!victim->isValid()); 29212752Sodanrc@yahoo.com.br } else { 29312752Sodanrc@yahoo.com.br // The whole sector must be evicted to make room for the new sector 29412752Sodanrc@yahoo.com.br for (const auto& blk : victim_sector->blks){ 29512752Sodanrc@yahoo.com.br evict_blks.push_back(blk); 29612752Sodanrc@yahoo.com.br } 29712752Sodanrc@yahoo.com.br } 29812752Sodanrc@yahoo.com.br 29912752Sodanrc@yahoo.com.br DPRINTF(CacheRepl, "set %x, way %x, sector offset %x: %s\n", 30012752Sodanrc@yahoo.com.br "selecting blk for replacement\n", victim->set, victim->way, 30112756Snikos.nikoleris@arm.com victim->getSectorOffset()); 30212752Sodanrc@yahoo.com.br 30312752Sodanrc@yahoo.com.br return victim; 30412752Sodanrc@yahoo.com.br} 30512752Sodanrc@yahoo.com.br 30612752Sodanrc@yahoo.com.brAddr 30712752Sodanrc@yahoo.com.brSectorTags::extractTag(Addr addr) const 30812752Sodanrc@yahoo.com.br{ 30912752Sodanrc@yahoo.com.br return addr >> tagShift; 31012752Sodanrc@yahoo.com.br} 31112752Sodanrc@yahoo.com.br 31212752Sodanrc@yahoo.com.brint 31312752Sodanrc@yahoo.com.brSectorTags::extractSet(Addr addr) const 31412752Sodanrc@yahoo.com.br{ 31512752Sodanrc@yahoo.com.br return (addr >> setShift) & setMask; 31612752Sodanrc@yahoo.com.br} 31712752Sodanrc@yahoo.com.br 31812752Sodanrc@yahoo.com.brint 31912752Sodanrc@yahoo.com.brSectorTags::extractSectorOffset(Addr addr) const 32012752Sodanrc@yahoo.com.br{ 32112752Sodanrc@yahoo.com.br return (addr >> sectorShift) & sectorMask; 32212752Sodanrc@yahoo.com.br} 32312752Sodanrc@yahoo.com.br 32412752Sodanrc@yahoo.com.brAddr 32512752Sodanrc@yahoo.com.brSectorTags::regenerateBlkAddr(const CacheBlk* blk) const 32612752Sodanrc@yahoo.com.br{ 32712752Sodanrc@yahoo.com.br const SectorSubBlk* blk_cast = static_cast<const SectorSubBlk*>(blk); 32812752Sodanrc@yahoo.com.br return ((blk_cast->getTag() << tagShift) | ((Addr)blk->set << setShift) | 32912752Sodanrc@yahoo.com.br ((Addr)blk_cast->getSectorOffset() << sectorShift)); 33012752Sodanrc@yahoo.com.br} 33112752Sodanrc@yahoo.com.br 33212752Sodanrc@yahoo.com.brvoid 33312752Sodanrc@yahoo.com.brSectorTags::forEachBlk(std::function<void(CacheBlk &)> visitor) 33412752Sodanrc@yahoo.com.br{ 33512752Sodanrc@yahoo.com.br for (SectorSubBlk& blk : blks) { 33612752Sodanrc@yahoo.com.br visitor(blk); 33712752Sodanrc@yahoo.com.br } 33812752Sodanrc@yahoo.com.br} 33912752Sodanrc@yahoo.com.br 34012752Sodanrc@yahoo.com.brbool 34112752Sodanrc@yahoo.com.brSectorTags::anyBlk(std::function<bool(CacheBlk &)> visitor) 34212752Sodanrc@yahoo.com.br{ 34312752Sodanrc@yahoo.com.br for (SectorSubBlk& blk : blks) { 34412752Sodanrc@yahoo.com.br if (visitor(blk)) { 34512752Sodanrc@yahoo.com.br return true; 34612752Sodanrc@yahoo.com.br } 34712752Sodanrc@yahoo.com.br } 34812752Sodanrc@yahoo.com.br return false; 34912752Sodanrc@yahoo.com.br} 35012752Sodanrc@yahoo.com.br 35112752Sodanrc@yahoo.com.brSectorTags * 35212752Sodanrc@yahoo.com.brSectorTagsParams::create() 35312752Sodanrc@yahoo.com.br{ 35412752Sodanrc@yahoo.com.br return new SectorTags(this); 35512752Sodanrc@yahoo.com.br} 356