fa_lru.cc (11189:4237221d3e31) fa_lru.cc (11484:08b33c52a16d)
1/*
2 * Copyright (c) 2013 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

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

74
75 warmupBound = size/blkSize;
76 numBlocks = size/blkSize;
77
78 blks = new FALRUBlk[numBlocks];
79 head = &(blks[0]);
80 tail = &(blks[numBlocks-1]);
81
1/*
2 * Copyright (c) 2013 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

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

74
75 warmupBound = size/blkSize;
76 numBlocks = size/blkSize;
77
78 blks = new FALRUBlk[numBlocks];
79 head = &(blks[0]);
80 tail = &(blks[numBlocks-1]);
81
82 head->prev = NULL;
82 head->prev = nullptr;
83 head->next = &(blks[1]);
84 head->inCache = cacheMask;
85
86 tail->prev = &(blks[numBlocks-2]);
83 head->next = &(blks[1]);
84 head->inCache = cacheMask;
85
86 tail->prev = &(blks[numBlocks-2]);
87 tail->next = NULL;
87 tail->next = nullptr;
88 tail->inCache = 0;
89
90 unsigned index = (1 << 17) / blkSize;
91 unsigned j = 0;
92 int flags = cacheMask;
93 for (unsigned i = 1; i < numBlocks - 1; i++) {
94 blks[i].inCache = flags;
95 if (i == index - 1){

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

154
155FALRUBlk *
156FALRU::hashLookup(Addr addr) const
157{
158 tagIterator iter = tagHash.find(addr);
159 if (iter != tagHash.end()) {
160 return (*iter).second;
161 }
88 tail->inCache = 0;
89
90 unsigned index = (1 << 17) / blkSize;
91 unsigned j = 0;
92 int flags = cacheMask;
93 for (unsigned i = 1; i < numBlocks - 1; i++) {
94 blks[i].inCache = flags;
95 if (i == index - 1){

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

154
155FALRUBlk *
156FALRU::hashLookup(Addr addr) const
157{
158 tagIterator iter = tagHash.find(addr);
159 if (iter != tagHash.end()) {
160 return (*iter).second;
161 }
162 return NULL;
162 return nullptr;
163}
164
165void
166FALRU::invalidate(CacheBlk *blk)
167{
168 assert(blk);
169 tagsInUse--;
170}

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

194 misses[i]++;
195 }
196 }
197 hits[numCaches]++;
198 if (blk != head){
199 moveToHead(blk);
200 }
201 } else {
163}
164
165void
166FALRU::invalidate(CacheBlk *blk)
167{
168 assert(blk);
169 tagsInUse--;
170}

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

194 misses[i]++;
195 }
196 }
197 hits[numCaches]++;
198 if (blk != head){
199 moveToHead(blk);
200 }
201 } else {
202 blk = NULL;
202 blk = nullptr;
203 for (unsigned i = 0; i <= numCaches; ++i) {
204 misses[i]++;
205 }
206 }
207 if (inCache) {
208 *inCache = tmp_in_cache;
209 }
210

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

218FALRU::findBlock(Addr addr, bool is_secure) const
219{
220 Addr blkAddr = blkAlign(addr);
221 FALRUBlk* blk = hashLookup(blkAddr);
222
223 if (blk && blk->isValid()) {
224 assert(blk->tag == blkAddr);
225 } else {
203 for (unsigned i = 0; i <= numCaches; ++i) {
204 misses[i]++;
205 }
206 }
207 if (inCache) {
208 *inCache = tmp_in_cache;
209 }
210

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

218FALRU::findBlock(Addr addr, bool is_secure) const
219{
220 Addr blkAddr = blkAlign(addr);
221 FALRUBlk* blk = hashLookup(blkAddr);
222
223 if (blk && blk->isValid()) {
224 assert(blk->tag == blkAddr);
225 } else {
226 blk = NULL;
226 blk = nullptr;
227 }
228 return blk;
229}
230
231CacheBlk*
232FALRU::findBlockBySetAndWay(int set, int way) const
233{
234 assert(set == 0);

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

272 cacheBoundaries[i] = cacheBoundaries[i]->prev;
273 } else if (cacheBoundaries[i] == blk) {
274 cacheBoundaries[i] = blk->prev;
275 }
276 }
277 blk->inCache = cacheMask;
278 if (blk != head) {
279 if (blk == tail){
227 }
228 return blk;
229}
230
231CacheBlk*
232FALRU::findBlockBySetAndWay(int set, int way) const
233{
234 assert(set == 0);

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

272 cacheBoundaries[i] = cacheBoundaries[i]->prev;
273 } else if (cacheBoundaries[i] == blk) {
274 cacheBoundaries[i] = blk->prev;
275 }
276 }
277 blk->inCache = cacheMask;
278 if (blk != head) {
279 if (blk == tail){
280 assert(blk->next == NULL);
280 assert(blk->next == nullptr);
281 tail = blk->prev;
281 tail = blk->prev;
282 tail->next = NULL;
282 tail->next = nullptr;
283 } else {
284 blk->prev->next = blk->next;
285 blk->next->prev = blk->prev;
286 }
287 blk->next = head;
283 } else {
284 blk->prev->next = blk->next;
285 blk->next->prev = blk->prev;
286 }
287 blk->next = head;
288 blk->prev = NULL;
288 blk->prev = nullptr;
289 head->prev = blk;
290 head = blk;
291 }
292}
293
294bool
295FALRU::check()
296{

--- 29 unchanged lines hidden ---
289 head->prev = blk;
290 head = blk;
291 }
292}
293
294bool
295FALRU::check()
296{

--- 29 unchanged lines hidden ---