1/* 2 * Copyright (c) 2018 Inria 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 78 unchanged lines hidden (view full) --- 87 SectorBlk*& sec_blk = sets[i][j]; 88 89 // Locate next cache sector 90 sec_blk = &secBlks[sec_blk_index]; 91 92 // Associate a replacement data entry to the sector 93 sec_blk->replacementData = replacementPolicy->instantiateEntry(); 94 |
95 // Set its index 96 sec_blk->setPosition(i, j); 97 |
98 // Initialize all blocks in this sector 99 sec_blk->blks.resize(numBlocksPerSector); 100 for (unsigned k = 0; k < numBlocksPerSector; ++k){ 101 // Select block within the set to be linked 102 SectorSubBlk*& blk = sec_blk->blks[k]; 103 104 // Locate next cache block 105 blk = &blks[blk_index]; 106 107 // Associate a data chunk to the block 108 blk->data = &dataBlks[blkSize*blk_index]; 109 110 // Associate sector block to this block 111 blk->setSectorBlock(sec_blk); 112 113 // Associate the sector replacement data to this block 114 blk->replacementData = sec_blk->replacementData; 115 |
116 // Set its index and sector offset 117 blk->setPosition(i, j); |
118 blk->setSectorOffset(k); 119 120 // Update block index 121 ++blk_index; 122 } 123 124 // Update sector block index 125 ++sec_blk_index; --- 179 unchanged lines hidden (view full) --- 305 assert(!victim->isValid()); 306 } else { 307 // The whole sector must be evicted to make room for the new sector 308 for (const auto& blk : victim_sector->blks){ 309 evict_blks.push_back(blk); 310 } 311 } 312 |
313 DPRINTF(CacheRepl, "set %x, way %x, sector offset %x: selecting blk " \ 314 "for replacement\n", victim->getSet(), victim->getWay(), |
315 victim->getSectorOffset()); 316 317 return victim; 318} 319 320Addr 321SectorTags::extractTag(Addr addr) const 322{ --- 11 unchanged lines hidden (view full) --- 334{ 335 return (addr >> sectorShift) & sectorMask; 336} 337 338Addr 339SectorTags::regenerateBlkAddr(const CacheBlk* blk) const 340{ 341 const SectorSubBlk* blk_cast = static_cast<const SectorSubBlk*>(blk); |
342 const Addr set = blk_cast->getSectorBlock()->getSet() << setShift; 343 return ((blk_cast->getTag() << tagShift) | set | |
344 ((Addr)blk_cast->getSectorOffset() << sectorShift)); 345} 346 347void 348SectorTags::forEachBlk(std::function<void(CacheBlk &)> visitor) 349{ 350 for (SectorSubBlk& blk : blks) { 351 visitor(blk); --- 19 unchanged lines hidden --- |