-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCache.java
More file actions
44 lines (36 loc) · 1.1 KB
/
Copy pathCache.java
File metadata and controls
44 lines (36 loc) · 1.1 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
public class Cache {
Set[] sets; //where Cache data will be held
//cache initialization
public Cache(int cacheSize, int asc, String type, int blockSize) {
int numBlocks = (cacheSize*1024)/blockSize; //amount of blocks in cache --
int numSets = numBlocks;
numSets = (numBlocks / asc);
//initalize sets
sets = new Set[numSets];
for(int i = 0; i < numSets; i++) {
sets[i] = new Set(asc, blockSize, i);
}
}
//LOAD
public void cacheLoad(int offset, int index, int access, int tag, Memory mem, int address, String hexAd) {
for(Set set : sets) {
if(set.index == index) {
//System.out.println(set.index);
set.load(set, tag, offset, access, mem, address, hexAd);
break;
}
}
}
//STORE
public void cacheWrite(String val, int offset, int index, int access, int tag, Memory mem, int address, String type, String hexAd) {
for(Set set: sets) {
if(set.index == index) {
// System.out.println("SET FOUND");
//System.out.println(val);
//System.out.println(access);
set.write(set, val, offset, access, tag, mem, address, type, hexAd);
break;
}
}
}
}