33c33
< * Definitions of a base set associative sector tag store.
---
> * Definitions of a sector tag store.
47a48
> #include "mem/cache/tags/indexing_policies/base.hh"
50c51
< : BaseTags(p), assoc(p->assoc), allocAssoc(p->assoc),
---
> : BaseTags(p), allocAssoc(p->assoc),
54,60c55,57
< numSectors(numBlocks / p->num_blocks_per_sector),
< numSets(numSectors / p->assoc),
< blks(numBlocks), secBlks(numSectors), sets(numSets),
< sectorShift(floorLog2(blkSize)),
< setShift(sectorShift + floorLog2(numBlocksPerSector)),
< tagShift(setShift + floorLog2(numSets)),
< sectorMask(numBlocksPerSector - 1), setMask(numSets - 1)
---
> numSectors(numBlocks / p->num_blocks_per_sector), blks(numBlocks),
> secBlks(numSectors), sectorShift(floorLog2(blkSize)),
> sectorMask(numBlocksPerSector - 1)
65,66d61
< fatal_if(!isPowerOf2(numSets),
< "# of sets must be non-zero and a power of 2");
69d63
< fatal_if(assoc <= 0, "associativity must be greater than zero");
78,79c72
< // Initialize all sets
< unsigned sec_blk_index = 0; // index into sector blks array
---
> // Initialize all blocks
81,82c74,78
< for (unsigned i = 0; i < numSets; ++i) {
< sets[i].resize(assoc);
---
> for (unsigned sec_blk_index = 0; sec_blk_index < numSectors;
> sec_blk_index++)
> {
> // Locate next cache sector
> SectorBlk* sec_blk = &secBlks[sec_blk_index];
84,87c80,81
< // Initialize all sectors in this set
< for (unsigned j = 0; j < assoc; ++j) {
< // Select block within the set to be linked
< SectorBlk*& sec_blk = sets[i][j];
---
> // Link block to indexing policy
> indexingPolicy->setEntry(sec_blk, sec_blk_index);
89,90c83,84
< // Locate next cache sector
< sec_blk = &secBlks[sec_blk_index];
---
> // Associate a replacement data entry to the sector
> sec_blk->replacementData = replacementPolicy->instantiateEntry();
92,93c86,90
< // Associate a replacement data entry to the sector
< sec_blk->replacementData = replacementPolicy->instantiateEntry();
---
> // Initialize all blocks in this sector
> sec_blk->blks.resize(numBlocksPerSector);
> for (unsigned k = 0; k < numBlocksPerSector; ++k){
> // Select block within the set to be linked
> SectorSubBlk*& blk = sec_blk->blks[k];
95,96c92,93
< // Set its index
< sec_blk->setPosition(i, j);
---
> // Locate next cache block
> blk = &blks[blk_index];
98,102c95,96
< // Initialize all blocks in this sector
< sec_blk->blks.resize(numBlocksPerSector);
< for (unsigned k = 0; k < numBlocksPerSector; ++k){
< // Select block within the set to be linked
< SectorSubBlk*& blk = sec_blk->blks[k];
---
> // Associate a data chunk to the block
> blk->data = &dataBlks[blkSize*blk_index];
104,105c98,99
< // Locate next cache block
< blk = &blks[blk_index];
---
> // Associate sector block to this block
> blk->setSectorBlock(sec_blk);
107,108c101,102
< // Associate a data chunk to the block
< blk->data = &dataBlks[blkSize*blk_index];
---
> // Associate the sector replacement data to this block
> blk->replacementData = sec_blk->replacementData;
110,111c104,105
< // Associate sector block to this block
< blk->setSectorBlock(sec_blk);
---
> // Set its index and sector offset
> blk->setSectorOffset(k);
113,125c107,108
< // Associate the sector replacement data to this block
< blk->replacementData = sec_blk->replacementData;
<
< // Set its index and sector offset
< blk->setPosition(i, j);
< blk->setSectorOffset(k);
<
< // Update block index
< ++blk_index;
< }
<
< // Update sector block index
< ++sec_blk_index;
---
> // Update block index
> ++blk_index;
199,208d181
< std::vector<ReplaceableEntry*>
< SectorTags::getPossibleLocations(const Addr addr) const
< {
< std::vector<ReplaceableEntry*> locations;
< for (const auto& blk : sets[extractSet(addr)]) {
< locations.push_back(static_cast<ReplaceableEntry*>(blk));
< }
< return locations;
< }
<
246,248c219,221
< // Find all possible sector locations for the given address
< const std::vector<ReplaceableEntry*> locations =
< getPossibleLocations(addr);
---
> // Find all possible sector entries that may contain the given address
> const std::vector<ReplaceableEntry*> entries =
> indexingPolicy->getPossibleEntries(addr);
251c224
< for (const auto& sector : locations) {
---
> for (const auto& sector : entries) {
263,268d235
< ReplaceableEntry*
< SectorTags::findBlockBySetAndWay(int set, int way) const
< {
< return sets[set][way];
< }
<
273,275c240,242
< // Get all possible locations of this sector
< const std::vector<ReplaceableEntry*> sector_locations =
< getPossibleLocations(addr);
---
> // Get possible entries to be victimized
> const std::vector<ReplaceableEntry*> sector_entries =
> indexingPolicy->getPossibleEntries(addr);
280c247
< for (const auto& sector : sector_locations) {
---
> for (const auto& sector : sector_entries) {
293c260
< sector_locations));
---
> sector_entries));
296c263
< // Get the location of the victim block within the sector
---
> // Get the entry of the victim block within the sector
320,325d286
< Addr
< SectorTags::extractTag(Addr addr) const
< {
< return addr >> tagShift;
< }
<
327,332d287
< SectorTags::extractSet(Addr addr) const
< {
< return (addr >> setShift) & setMask;
< }
<
< int
342,344c297,299
< const Addr set = blk_cast->getSectorBlock()->getSet() << setShift;
< return ((blk_cast->getTag() << tagShift) | set |
< ((Addr)blk_cast->getSectorOffset() << sectorShift));
---
> const SectorBlk* sec_blk = blk_cast->getSectorBlock();
> const Addr sec_addr = indexingPolicy->regenerateAddr(blk->tag, sec_blk);
> return sec_addr | ((Addr)blk_cast->getSectorOffset() << sectorShift);
368a324,326
> // There must be a indexing policy
> fatal_if(!indexing_policy, "An indexing policy is required");
>