-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathevict_block.cpp
More file actions
44 lines (37 loc) · 795 Bytes
/
evict_block.cpp
File metadata and controls
44 lines (37 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "structures.h"
int evict_block(unsigned long long int tagg,unsigned long long int index,int level){
int i,dirty;
if(level==1){
for(i=0;i<L1_ASSOC;i++){
if(L1->s[index]->b[i]->tag==tagg){
L1->s[index]->b[i]->valid=0;
dirty=L1->s[index]->b[i]->dirty;
//reset dirty bit
L1->s[index]->b[i]->lru=0;
L1->s[index]->b[i]->fifo=0;
L1->s[index]->b[i]->dirty=0;
if(dirty==1){
L1_writebacks++;
L2_writebacks++;
return 1;
}
return 0;
}
}
}
else if(level==2){
for(i=0;i<L2_ASSOC;i++){
if(L2->s[index]->b[i]->tag==tagg){
L2->s[index]->b[i]->valid=0;
dirty=L2->s[index]->b[i]->dirty;
//reset dirty bit
L2->s[index]->b[i]->dirty=0;
if(dirty==1){
return 1;
}
return 0;
}
}
}
return 0;
}