Deleted Added
sdiff udiff text old ( 12637:bfc3cb9c7e6c ) new ( 12648:78941f188bb3 )
full compact
1/*
2 * Copyright (c) 2013,2016-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

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

59 if (!isPowerOf2(blkSize))
60 fatal("cache block size (in bytes) `%d' must be a power of two",
61 blkSize);
62 if (!isPowerOf2(size))
63 fatal("Cache Size must be power of 2 for now");
64
65 // Track all cache sizes from 128K up by powers of 2
66 numCaches = floorLog2(size) - 17;
67 if (numCaches >0){
68 cacheBoundaries = new FALRUBlk *[numCaches];
69 cacheMask = (ULL(1) << numCaches) - 1;
70 } else {
71 cacheMask = 0;
72 }
73
74 blks = new FALRUBlk[numBlocks];
75 head = &(blks[0]);

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

159 return (*iter).second;
160 }
161 return nullptr;
162}
163
164void
165FALRU::invalidate(CacheBlk *blk)
166{
167 // TODO: We need to move the block to the tail to make it the next victim
168 BaseTags::invalidate(blk);
169
170 // Erase block entry in the hash table
171 tagHash.erase(blk->tag);
172}
173
174CacheBlk*
175FALRU::accessBlock(Addr addr, bool is_secure, Cycles &lat)
176{
177 return accessBlock(addr, is_secure, lat, 0);

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

271 tagHash[falruBlk->tag] = falruBlk;
272
273 //assert(check());
274}
275
276void
277FALRU::moveToHead(FALRUBlk *blk)
278{
279 int updateMask = blk->inCache ^ cacheMask;
280 for (unsigned i = 0; i < numCaches; i++){
281 if ((1<<i) & updateMask) {
282 cacheBoundaries[i]->inCache &= ~(1<<i);
283 cacheBoundaries[i] = cacheBoundaries[i]->prev;
284 } else if (cacheBoundaries[i] == blk) {
285 cacheBoundaries[i] = blk->prev;
286 }
287 }
288 blk->inCache = cacheMask;
289 if (blk != head) {
290 if (blk == tail){
291 assert(blk->next == nullptr);
292 tail = blk->prev;
293 tail->next = nullptr;
294 } else {
295 blk->prev->next = blk->next;
296 blk->next->prev = blk->prev;
297 }
298 blk->next = head;
299 blk->prev = nullptr;
300 head->prev = blk;
301 head = blk;
302 }
303}
304
305bool
306FALRU::check()
307{
308 FALRUBlk* blk = head;
309 int tot_size = 0;
310 int boundary = 1<<17;
311 int j = 0;
312 int flags = cacheMask;

--- 24 unchanged lines hidden ---