base_set_assoc.hh (12743:b5ccee582b40) base_set_assoc.hh (12744:d1ff0b42b747)
1/*
2 * Copyright (c) 2012-2014,2017 ARM Limited
3 * All rights reserved.
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 186 unchanged lines hidden (view full) ---

195 *
196 * @param set The set of the block.
197 * @param way The way of the block.
198 * @return The block.
199 */
200 ReplaceableEntry* findBlockBySetAndWay(int set, int way) const override;
201
202 /**
1/*
2 * Copyright (c) 2012-2014,2017 ARM Limited
3 * All rights reserved.
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 186 unchanged lines hidden (view full) ---

195 *
196 * @param set The set of the block.
197 * @param way The way of the block.
198 * @return The block.
199 */
200 ReplaceableEntry* findBlockBySetAndWay(int set, int way) const override;
201
202 /**
203 * Find replacement victim based on address.
203 * Find replacement victim based on address. The list of evicted blocks
204 * only contains the victim.
204 *
205 * @param addr Address to find a victim for.
205 *
206 * @param addr Address to find a victim for.
207 * @param evict_blks Cache blocks to be evicted.
206 * @return Cache block to be replaced.
207 */
208 * @return Cache block to be replaced.
209 */
208 CacheBlk* findVictim(Addr addr) override
210 CacheBlk* findVictim(Addr addr, std::vector<CacheBlk*>& evict_blks) const
211 override
209 {
210 // Get possible locations for the victim block
211 std::vector<CacheBlk*> locations = getPossibleLocations(addr);
212
213 // Choose replacement victim from replacement candidates
214 CacheBlk* victim = static_cast<CacheBlk*>(replacementPolicy->getVictim(
215 std::vector<ReplaceableEntry*>(
216 locations.begin(), locations.end())));
217
212 {
213 // Get possible locations for the victim block
214 std::vector<CacheBlk*> locations = getPossibleLocations(addr);
215
216 // Choose replacement victim from replacement candidates
217 CacheBlk* victim = static_cast<CacheBlk*>(replacementPolicy->getVictim(
218 std::vector<ReplaceableEntry*>(
219 locations.begin(), locations.end())));
220
221 // There is only one eviction for this replacement
222 evict_blks.push_back(victim);
223
218 DPRINTF(CacheRepl, "set %x, way %x: selecting blk for replacement\n",
219 victim->set, victim->way);
220
221 return victim;
222 }
223
224 /**
225 * Find all possible block locations for insertion and replacement of
226 * an address. Should be called immediately before ReplacementPolicy's
227 * findVictim() not to break cache resizing.
228 * Returns blocks in all ways belonging to the set of the address.
229 *
230 * @param addr The addr to a find possible locations for.
231 * @return The possible locations.
232 */
224 DPRINTF(CacheRepl, "set %x, way %x: selecting blk for replacement\n",
225 victim->set, victim->way);
226
227 return victim;
228 }
229
230 /**
231 * Find all possible block locations for insertion and replacement of
232 * an address. Should be called immediately before ReplacementPolicy's
233 * findVictim() not to break cache resizing.
234 * Returns blocks in all ways belonging to the set of the address.
235 *
236 * @param addr The addr to a find possible locations for.
237 * @return The possible locations.
238 */
233 const std::vector getPossibleLocations(Addr addr)
239 const std::vector<CacheBlk*> getPossibleLocations(Addr addr) const
234 {
235 return sets[extractSet(addr)].blks;
236 }
237
238 /**
239 * Insert the new block into the cache and update replacement data.
240 *
241 * @param pkt Packet holding the address to update

--- 80 unchanged lines hidden ---
240 {
241 return sets[extractSet(addr)].blks;
242 }
243
244 /**
245 * Insert the new block into the cache and update replacement data.
246 *
247 * @param pkt Packet holding the address to update

--- 80 unchanged lines hidden ---