sector_tags.cc (13216:6ae030076b29) | sector_tags.cc (13217:725b1701b4ee) |
---|---|
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; --- 180 unchanged lines hidden (view full) --- 189 } else { 190 // If a cache miss 191 lat = lookupLatency; 192 } 193 194 return blk; 195} 196 | 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; --- 180 unchanged lines hidden (view full) --- 189 } else { 190 // If a cache miss 191 lat = lookupLatency; 192 } 193 194 return blk; 195} 196 |
197const std::vector<SectorBlk*> 198SectorTags::getPossibleLocations(Addr addr) const | 197std::vector<ReplaceableEntry*> 198SectorTags::getPossibleLocations(const Addr addr) const |
199{ | 199{ |
200 return sets[extractSet(addr)]; | 200 std::vector<ReplaceableEntry*> locations; 201 for (const auto& blk : sets[extractSet(addr)]) { 202 locations.push_back(static_cast<ReplaceableEntry*>(blk)); 203 } 204 return locations; |
201} 202 203void 204SectorTags::insertBlock(const Addr addr, const bool is_secure, 205 const int src_master_ID, const uint32_t task_ID, 206 CacheBlk *blk) 207{ 208 // Do common block insertion functionality --- 24 unchanged lines hidden (view full) --- 233 // Extract sector tag 234 const Addr tag = extractTag(addr); 235 236 // The address can only be mapped to a specific location of a sector 237 // due to sectors being composed of contiguous-address entries 238 const Addr offset = extractSectorOffset(addr); 239 240 // Find all possible sector locations for the given address | 205} 206 207void 208SectorTags::insertBlock(const Addr addr, const bool is_secure, 209 const int src_master_ID, const uint32_t task_ID, 210 CacheBlk *blk) 211{ 212 // Do common block insertion functionality --- 24 unchanged lines hidden (view full) --- 237 // Extract sector tag 238 const Addr tag = extractTag(addr); 239 240 // The address can only be mapped to a specific location of a sector 241 // due to sectors being composed of contiguous-address entries 242 const Addr offset = extractSectorOffset(addr); 243 244 // Find all possible sector locations for the given address |
241 const std::vector<SectorBlk*> locations = getPossibleLocations(addr); | 245 const std::vector<ReplaceableEntry*> locations = 246 getPossibleLocations(addr); |
242 243 // Search for block 244 for (const auto& sector : locations) { | 247 248 // Search for block 249 for (const auto& sector : locations) { |
245 auto blk = sector->blks[offset]; | 250 auto blk = static_cast<SectorBlk*>(sector)->blks[offset]; |
246 if (blk->getTag() == tag && blk->isValid() && 247 blk->isSecure() == is_secure) { 248 return blk; 249 } 250 } 251 252 // Did not find block 253 return nullptr; --- 5 unchanged lines hidden (view full) --- 259 return sets[set][way]; 260} 261 262CacheBlk* 263SectorTags::findVictim(Addr addr, const bool is_secure, 264 std::vector<CacheBlk*>& evict_blks) const 265{ 266 // Get all possible locations of this sector | 251 if (blk->getTag() == tag && blk->isValid() && 252 blk->isSecure() == is_secure) { 253 return blk; 254 } 255 } 256 257 // Did not find block 258 return nullptr; --- 5 unchanged lines hidden (view full) --- 264 return sets[set][way]; 265} 266 267CacheBlk* 268SectorTags::findVictim(Addr addr, const bool is_secure, 269 std::vector<CacheBlk*>& evict_blks) const 270{ 271 // Get all possible locations of this sector |
267 const std::vector<SectorBlk*> sector_locations = | 272 const std::vector<ReplaceableEntry*> sector_locations = |
268 getPossibleLocations(addr); 269 270 // Check if the sector this address belongs to has been allocated 271 Addr tag = extractTag(addr); 272 SectorBlk* victim_sector = nullptr; | 273 getPossibleLocations(addr); 274 275 // Check if the sector this address belongs to has been allocated 276 Addr tag = extractTag(addr); 277 SectorBlk* victim_sector = nullptr; |
273 for (const auto& sector : sector_locations){ 274 if ((tag == sector->getTag()) && sector->isValid() && 275 (is_secure == sector->isSecure())){ 276 victim_sector = sector; | 278 for (const auto& sector : sector_locations) { 279 SectorBlk* sector_blk = static_cast<SectorBlk*>(sector); 280 if ((tag == sector_blk->getTag()) && sector_blk->isValid() && 281 (is_secure == sector_blk->isSecure())){ 282 victim_sector = sector_blk; |
277 break; 278 } 279 } 280 281 // If the sector is not present 282 if (victim_sector == nullptr){ 283 // Choose replacement victim from replacement candidates 284 victim_sector = static_cast<SectorBlk*>(replacementPolicy->getVictim( | 283 break; 284 } 285 } 286 287 // If the sector is not present 288 if (victim_sector == nullptr){ 289 // Choose replacement victim from replacement candidates 290 victim_sector = static_cast<SectorBlk*>(replacementPolicy->getVictim( |
285 std::vector<ReplaceableEntry*>( 286 sector_locations.begin(), sector_locations.end()))); | 291 sector_locations)); |
287 } 288 289 // Get the location of the victim block within the sector 290 SectorSubBlk* victim = victim_sector->blks[extractSectorOffset(addr)]; 291 292 // Get evicted blocks. Blocks are only evicted if the sectors mismatch and 293 // the currently existing sector is valid. 294 if ((tag == victim_sector->getTag()) && --- 68 unchanged lines hidden --- | 292 } 293 294 // Get the location of the victim block within the sector 295 SectorSubBlk* victim = victim_sector->blks[extractSectorOffset(addr)]; 296 297 // Get evicted blocks. Blocks are only evicted if the sectors mismatch and 298 // the currently existing sector is valid. 299 if ((tag == victim_sector->getTag()) && --- 68 unchanged lines hidden --- |