-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_fourWayCache.cc
More file actions
76 lines (58 loc) · 1.48 KB
/
test_fourWayCache.cc
File metadata and controls
76 lines (58 loc) · 1.48 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "src/fourWayCache/fourWayCache.hh"
#define TOTAL_TRANSACTION_COUNT 20
void test();
void test_random();
int main(){
//test();
test_random();
return 0;
}
void test(){
FourWayCache cache;
cache.setAddr(0x23, READ);
cache.printAddr();
cache.run();
cache.incrementCycleTime();
cache.setAddr(0x1023, READ);
cache.printAddr();
cache.run();
cache.incrementCycleTime();
cache.setAddr(0x2023,READ);
cache.printAddr();
cache.run();
cache.incrementCycleTime();
cache.setAddr(0x3023,READ);
cache.printAddr();
cache.run();
cache.incrementCycleTime();
cache.setAddr(0x4023,READ);
cache.printAddr();
cache.run();
cache.incrementCycleTime();
cache.setAddr(0x4024, READ);
cache.printAddr();
cache.run();
cache.incrementCycleTime();
cache.printStats();
cache.printValidCache();
}
void test_random(){
//Test function to generate random address
FourWayCache cache;
unsigned int addr;
addr = rand() % 0xffff;
TransactionType t;
for (int i = 0; i < TOTAL_TRANSACTION_COUNT; ++i){
//Generating random address
addr = rand() % 0xffff;
// For even value of i: Request type is Write
// For odd value of i: Request type is Read
t = (i%2) ? READ : WRITE;
cache.setAddr(addr,t);
cache.printAddr();
cache.run();
cache.incrementCycleTime();
}
cache.printStats();
cache.printValidCache();
}