-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTAGEPredictor.h
89 lines (66 loc) · 2.56 KB
/
TAGEPredictor.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#ifndef _PREDICTOR_H_
#define _PREDICTOR_H_
#include "utils.h"
#include "tracer.h"
#include <bitset>
#define NUM_TAGE_TABLES 4
#define UINT16 unsigned short int
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
//Circular Shift Register for folding purposes
typedef struct csr {
UINT32 val;
UINT32 origLen;
UINT32 newLen;
} csr_t;
typedef struct bimodVal{
UINT32 pred; //prediction (2 bits)
//bool m; //metapredictor (1 bit) (eliminated)
} bimodVal_t;
typedef struct tagVal {
UINT32 pred;
UINT32 tag;
UINT32 u;
} tagVal_t;
typedef struct prediction{
bool pred;
bool altPred;
int table;
int altTable;
UINT32 index;
UINT32 altIndex;
} prediction_t;
class PREDICTOR{
// The state is defined for Gshare, change for your design
private:
bitset<131> GHR; // global history register
UINT16 PHR; //path history
// Bimodal
bimodVal_t *bimodal; //bimodal table
UINT32 numBimodalEntries; //number of entries in bimodal table
tagVal_t *tagTables[NUM_TAGE_TABLES]; //TAGE table
UINT32 tageTableSize; //number of entries in TAGE table
UINT32 tageHistory[NUM_TAGE_TABLES]; //number ofGHR bits examined by CSR to index a given table
csr_t *csrIndex; //circular shift register for indices
csr_t *csrTag[2]; //2 circular shift registers for tags
prediction_t pred; //global prediction
UINT32 tageIndex[NUM_TAGE_TABLES]; //index calculated for a given table
UINT32 tageTag[NUM_TAGE_TABLES]; //tag calculated for a given table
UINT32 clock; //global clock
bool clockState; //clocl flip it
INT32 altBetterCount; //number of times altpred is better than prd
public:
// The interface to the four functions below CAN NOT be changed
PREDICTOR(void);
bool GetPrediction(UINT32 PC);
void UpdatePredictor(UINT32 PC, bool resolveDir, bool predDir, UINT32 branchTarget);
void TrackOtherInst(UINT32 PC, OpType opType, UINT32 branchTarget);
//void steal(UINT32 PC, UINT32 table, UINT32 index, UINT32 bimodalIndex, bool predDir);
UINT32 getTag(UINT32 PC, int table, UINT32 tagSize);
UINT32 getIndex(UINT32 PC, int table, UINT32 tagSize, UINT32 phrOffset);
void initFold(csr_t *shift, UINT32 origLen, UINT32 newLen);
void fold(csr_t *shift);
// Contestants can define their own functions below
};
/***********************************************************/
#endif