-
Notifications
You must be signed in to change notification settings - Fork 0
/
cache.h
63 lines (46 loc) · 1.44 KB
/
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
58
59
60
61
62
63
/* Header da cache do simulador MIPS32 */
/* Autor Bruno Cesar, bcesar.g6@gmail.com */
#ifndef __CACHE_H
#define __CACHE_H
#define C_TEXTO_SIZE 8192 //8192 * sizeof(word) = 32K
#define C_DADOS_SIZE 8192 //8192 * sizeof(word) = 32K
#define CACHE_TEXTO 1
#define CACHE_DADOS 0
#define FLAG_WRITE 1
#define FLAG_READ 2
#define FLAG_BLANK -1
#define NUM_LINHA 2048 //4 //2048
#define TAM_LINHA 4 //Numero de palavras
#include "simulador.h"
#include "memoria.h"
#include "utils.h"
typedef union endereco_t endereco;
// NUMERO DE BLOCOS = TOTAL_MEM / TAM_BLOCO
// NUM_TAG = NUMERO_DE_BLOCOS / NUMERO_DE_LINHA
// NUMERO_DE_LINHA = DEFINIDO
// 1 linha = 4 word ( 16 Bytes)
// 32K / 16 = 2k Linhas //testando com 4 linhas para 64Bytes
//ENDEREÇO DO BLOCO = Linha * (tam_byte) + tag * (tam_byte + tam_linha)
extern word barr_mem_dados;
extern word barr_mem_texto;
typedef struct{
unsigned int byte : 4; //4; //4
unsigned int linha : 11; //2; //11
unsigned int tag : 14; //19; //14
} c_access;
typedef struct{
word dados;
int tag : 14;
unsigned int v : 1; //Booleano verificador de ativação do Write_back
} c_linha;
union endereco_t{
unsigned int i;
c_access end;
};
c_linha* cache_texto;
c_linha* cache_dados;
void cWrite(unsigned int cache_id, endereco addr, unsigned int dado);
unsigned int cRead(unsigned int cache_id, endereco end);
void cacheInit();
void flushCache(unsigned int cache_id);
#endif /* __CACHE_H */