67,74c67,69
< * The BaseSetAssoc tags provide a base, as well as the functionality
< * common to any set associative tags. Any derived class must implement
< * the methods related to the specifics of the actual replacment policy.
< * These are:
< *
< * BlkType* accessBlock();
< * BlkType* findVictim();
< * void insertBlock();
---
> * The BaseSetAssoc placement policy divides the cache into s sets of w
> * cache lines (ways). A cache line is mapped onto a set, and can be placed
> * into any of the ways of this set.
112c107,108
< public:
---
> /** Replacement policy */
> BaseReplacementPolicy *replacementPolicy;
113a110,111
> public:
>
172c170,172
< blk->refCount += 1;
---
>
> // Update replacement data of accessed block
> replacementPolicy->touch(blk);
192,196c192,195
< * Find an invalid block to evict for the address provided.
< * If there are no invalid blocks, this will return the block
< * in the least-recently-used position.
< * @param addr The addr to a find a replacement candidate for.
< * @return The candidate block.
---
> * Find replacement victim based on address.
> *
> * @param addr Address to find a victim for.
> * @return Cache block to be replaced.
200,201c199,201
< BlkType *blk = nullptr;
< int set = extractSet(addr);
---
> // Choose replacement victim from replacement candidates
> return replacementPolicy->getVictim(getPossibleLocations(addr));
> }
203,210c203,214
< // prefer to evict an invalid block
< for (int i = 0; i < allocAssoc; ++i) {
< blk = sets[set].blks[i];
< if (!blk->isValid())
< break;
< }
<
< return blk;
---
> /**
> * Find all possible block locations for insertion and replacement of
> * an address. Should be called immediately before ReplacementPolicy's
> * findVictim() not to break cache resizing.
> * Returns blocks in all ways belonging to the set of the address.
> *
> * @param addr The addr to a find possible locations for.
> * @return The possible locations.
> */
> const std::vector<CacheBlk*> getPossibleLocations(Addr addr)
> {
> return sets[extractSet(addr)].blks;
245c249
< // to insert the new one and mark it as touched
---
> // to insert the new one
247d250
< blk->isTouched = true;
257d259
< blk->tickInserted = curTick();
261a264,265
>
> replacementPolicy->reset(blk);