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. The list of evicted blocks 204 * only contains the victim. |
205 * 206 * @param addr Address to find a victim for. |
207 * @param evict_blks Cache blocks to be evicted. |
208 * @return Cache block to be replaced. 209 */ |
210 CacheBlk* findVictim(Addr addr, std::vector<CacheBlk*>& evict_blks) const 211 override |
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 |
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 */ |
239 const std::vector<CacheBlk*> getPossibleLocations(Addr addr) const |
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 --- |