-
Notifications
You must be signed in to change notification settings - Fork 0
/
cache_impl.h
43 lines (35 loc) · 1.17 KB
/
cache_impl.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
/*
* cache_impl.h
*
* 20493-01 Computer Architecture
* Term Project on Implementation of Cache Mechanism
*
* Skeleton Code Prepared by Prof. HyungJune Lee
* Nov 16, 2022
*
*/
/* DO NOT CHANGE THE FOLLOWING DEFINITIONS EXCEPT 'DEFAULT_CACHE_ASSOC */
#ifndef _CACHE_IMPL_H_
#define _CACHE_IMPL_H_
#define WORD_SIZE_BYTE 4
#define DEFAULT_CACHE_SIZE_BYTE 32
#define DEFAULT_CACHE_BLOCK_SIZE_BYTE 8
#define DEFAULT_CACHE_ASSOC 4 /* This can be changed to 1(for direct mapped cache) or 4(for fully assoc cache) */
#define DEFAULT_MEMORY_SIZE_WORD 128
#define CACHE_ACCESS_CYCLE 1
#define MEMORY_ACCESS_CYCLE 100
#define CACHE_SET_SIZE ((DEFAULT_CACHE_SIZE_BYTE)/(DEFAULT_CACHE_BLOCK_SIZE_BYTE*DEFAULT_CACHE_ASSOC))
/* Function Prototypes */
void init_memory_content();
void init_cache_content();
void print_cache_entries();
int check_cache_data_hit(void* addr, char type);
int access_memory(void *addr, char type);
/* Cache Entry Structure */
typedef struct cache_entry {
int valid;
int tag;
int timestamp;
char data[DEFAULT_CACHE_BLOCK_SIZE_BYTE];
} cache_entry_t;
#endif