Deleted Added
sdiff udiff text old ( 13216:6ae030076b29 ) new ( 13217:725b1701b4ee )
full compact
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
199{
200 return sets[extractSet(addr)];
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
241 const std::vector<SectorBlk*> locations = getPossibleLocations(addr);
242
243 // Search for block
244 for (const auto& sector : locations) {
245 auto blk = 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
267 const std::vector<SectorBlk*> 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 for (const auto& sector : sector_locations){
274 if ((tag == sector->getTag()) && sector->isValid() &&
275 (is_secure == sector->isSecure())){
276 victim_sector = sector;
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(
285 std::vector<ReplaceableEntry*>(
286 sector_locations.begin(), sector_locations.end())));
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 ---