// my_predictor.h // This file contains a sample my_predictor class. // It is a simple 32,768-entry gshare with a history length of 15. // Note that this predictor doesn't use the whole 32 kilobytes available // for the CBP-2 contest; it is just an example. // my update class my_update : public branch_update { public: unsigned int index; }; // Local Branch Predictor class my_predictor : public branch_predictor{ public: #define BHR_num 22 // (b.address & ((1<> 1) & 1; if (b.br_flags & BR_CONDITIONAL) { // Calculate index for the Pattern Table using XOR of history and part of the PC u.index = BHRTable[history ^ (b.address & ((1<> 1) & 1; // Decide the final prediction based on Pattern Table values if (PTable[u.index] == 3 || PTable[u.index] == 4) { // unclear u.direction_prediction(bimodal_prediction); } else { u.direction_prediction(local_prediction); } } else { u.direction_prediction(true); } u.target_prediction (0); return &u; } void update (branch_update *u, bool taken, unsigned int target, branch_info &b) { if (bi.br_flags & BR_CONDITIONAL) { unsigned char *c = &PTable[((my_update*)u)->index]; // Update Pattern Table based on branch outcome if (taken) { if (*c < 7) (*c)++; } else { if (*c > 0) (*c)--; } // Update Bimodal Table based on branch outcome unsigned int bimodal_index = b.address & ((1 << BMODAL_BITS) - 1); if (taken) { if (BimodalTable[bimodal_index] < 7) BimodalTable[bimodal_index]++; } else { if (BimodalTable[bimodal_index] > 0) BimodalTable[bimodal_index]--; } // Update the Branch History Register Table BHRTable[history ^ (b.address & ((1<