-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCache.h
More file actions
82 lines (58 loc) · 1.44 KB
/
Cache.h
File metadata and controls
82 lines (58 loc) · 1.44 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
77
78
79
80
81
#ifndef _CACHE_H
#define _CACHE_H
#include "stdafx.h"
#define ASSOCIATIVITY 2
typedef struct _BlockState {
int wordStartedOn;
int wordsGotten;
} BlockState;
typedef struct _DirectMappedCacheEntry {
int valid;
int tag;
int isLoading;
int* block;
BlockState blockState;
} DirectMappedCacheEntry;
typedef struct _MultiWayCacheEntry {
int valid;
int dirty;
int lru;
int tag;
int isLoading;
int* block;
BlockState blockState;
} MultiWayCacheEntry;
typedef struct _L1Cache {
DirectMappedCacheEntry* cache;
int cacheLength;
int blockSize;
int hits;
int misses;
} L1Cache;
typedef struct _L2Cache {
MultiWayCacheEntry** cache;
int cacheLength;
int blockSize;
int hits;
int misses;
} L2Cache;
void InitCaches(ConfigurationStruct* cs);
void DestroyCaches();
double GetL1HitRate();
double GetL2HitRate();
/* Loads a word from memory
returns number of cycles till word arrvied and the word loaded
*/
int LoadWord(int address,int* word);
int StoreWord(int address,int* word);
//note: should take care of BlockStatus Struct
void DoWork();
int PCtoAddress(int pc);
int GetCacheEntryNumber(int address,int blockSize, int cacheLength);
int GetOffset(int address,int blockSize, int cacheLength);
int GetAddressTag(int address,int blockSize, int cacheLength);
void SetLRU(int blockNum,MultiWayCacheEntry* line);
void WriteL1CacheToFile(char* filename);
void WriteL2CacheToFile(char* filename);
void WriteHitRatioAndAMAT(char* filename);
#endif