sector_tags.cc (13217:725b1701b4ee) | sector_tags.cc (13218:5e7df60c6cab) |
---|---|
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 | 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 |
|
95 // Initialize all blocks in this sector 96 sec_blk->blks.resize(numBlocksPerSector); 97 for (unsigned k = 0; k < numBlocksPerSector; ++k){ 98 // Select block within the set to be linked 99 SectorSubBlk*& blk = sec_blk->blks[k]; 100 101 // Locate next cache block 102 blk = &blks[blk_index]; 103 104 // Associate a data chunk to the block 105 blk->data = &dataBlks[blkSize*blk_index]; 106 107 // Associate sector block to this block 108 blk->setSectorBlock(sec_blk); 109 110 // Associate the sector replacement data to this block 111 blk->replacementData = sec_blk->replacementData; 112 | 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 |
113 // Set its set, way and sector offset 114 blk->set = i; 115 blk->way = j; | 116 // Set its index and sector offset 117 blk->setPosition(i, j); |
116 blk->setSectorOffset(k); 117 118 // Update block index 119 ++blk_index; 120 } 121 122 // Update sector block index 123 ++sec_blk_index; --- 179 unchanged lines hidden (view full) --- 303 assert(!victim->isValid()); 304 } else { 305 // The whole sector must be evicted to make room for the new sector 306 for (const auto& blk : victim_sector->blks){ 307 evict_blks.push_back(blk); 308 } 309 } 310 | 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 |
311 DPRINTF(CacheRepl, "set %x, way %x, sector offset %x: %s\n", 312 "selecting blk for replacement\n", victim->set, victim->way, | 313 DPRINTF(CacheRepl, "set %x, way %x, sector offset %x: selecting blk " \ 314 "for replacement\n", victim->getSet(), victim->getWay(), |
313 victim->getSectorOffset()); 314 315 return victim; 316} 317 318Addr 319SectorTags::extractTag(Addr addr) const 320{ --- 11 unchanged lines hidden (view full) --- 332{ 333 return (addr >> sectorShift) & sectorMask; 334} 335 336Addr 337SectorTags::regenerateBlkAddr(const CacheBlk* blk) const 338{ 339 const SectorSubBlk* blk_cast = static_cast<const SectorSubBlk*>(blk); | 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); |
340 return ((blk_cast->getTag() << tagShift) | ((Addr)blk->set << setShift) | | 342 const Addr set = blk_cast->getSectorBlock()->getSet() << setShift; 343 return ((blk_cast->getTag() << tagShift) | set | |
341 ((Addr)blk_cast->getSectorOffset() << sectorShift)); 342} 343 344void 345SectorTags::forEachBlk(std::function<void(CacheBlk &)> visitor) 346{ 347 for (SectorSubBlk& blk : blks) { 348 visitor(blk); --- 19 unchanged lines hidden --- | 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 --- |