forked from hanashalaby4/MemoryHierarchySimulator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cache.h
57 lines (40 loc) · 856 Bytes
/
cache.h
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
#include <vector>
#include "global.h"
using namespace std;
#ifndef CACHE_H
#define CACHE_H
class cache {
private:
vector<Byte> bytes;
vector<cacheLine> cacheLines;
int size;
int lineSize;
int accessTime;
int hits;
int misses;
int accesses;
public:
cache();
cache(int s, int l, int a);
//getters
int getSize() const;
int getLineSize() const;
int getAccessTime () const;
int getHits() const;
int getMisses() const;
int getAccesses() const;
//setters
void setSize(int s);
void setLineSize(int l);
void setAccessTime(int a);
//void setHits(int h);
//void setMisses(int m);
//cache operations
void initializeCache();
bool accessMemory(int address, int &index, int &tag, bool &hit);
void displayCacheContents() const;
//helper functions
int calculateIndex(int address) const;
int calculateTag(int address) const;
};
#endif //CACHE_H