50 localPredictorSize(params->localPredictorSize),
51 localCtrBits(params->localCtrBits),
52 localHistoryTableSize(params->localHistoryTableSize),
53 localHistoryBits(
ceilLog2(params->localPredictorSize)),
54 globalPredictorSize(params->globalPredictorSize),
55 globalCtrBits(params->globalCtrBits),
56 globalHistory(params->numThreads, 0),
58 ceilLog2(params->globalPredictorSize) >
59 ceilLog2(params->choicePredictorSize) ?
60 ceilLog2(params->globalPredictorSize) :
61 ceilLog2(params->choicePredictorSize)),
62 choicePredictorSize(params->choicePredictorSize),
63 choiceCtrBits(params->choiceCtrBits)
66 fatal(
"Invalid local predictor size!\n");
70 fatal(
"Invalid global predictor size!\n");
82 fatal(
"Invalid local history table size!\n");
102 fatal(
"Invalid choice predictor size!\n");
120 fatal(
"Global predictor too large for global history bits!\n");
123 fatal(
"Choice predictor too large for global history bits!\n");
128 inform(
"More global history bits than required by predictors\n");
193 bool local_prediction;
194 unsigned local_history_idx;
195 unsigned local_predictor_idx;
197 bool global_prediction;
198 bool choice_prediction;
222 bp_history = (
void *)history;
228 if (choice_prediction) {
229 if (global_prediction) {
239 if (local_prediction) {
262 bp_history =
static_cast<void *
>(history);
269 void *bp_history,
bool squashed)
292 if (old_local_pred_valid) {
308 old_local_pred_valid)
313 unsigned choice_predictor_idx =
327 unsigned global_predictor_idx =
331 if (old_local_pred_valid) {
332 localCtrs[old_local_pred_index].increment();
336 if (old_local_pred_valid) {
337 localCtrs[old_local_pred_index].decrement();
363 TournamentBPParams::create()
376 TournamentBP::BPHistory::newCount = 0;
std::vector< SatCounter > localCtrs
Local counters.
void uncondBranch(ThreadID tid, Addr pc, void *&bp_history)
Records that there was an unconditional branch, and modifies the bp history to point to an object tha...
Implements a tournament branch predictor, hopefully identical to the one used in the 21264...
void squash(ThreadID tid, void *bp_history)
Restores the global branch history on a squash.
unsigned globalPredictorSize
Number of entries in the global predictor.
unsigned localCtrBits
Number of bits of the local predictor's counters.
void updateGlobalHistTaken(ThreadID tid)
Updates global history as taken.
unsigned choicePredictorSize
Number of entries in the choice predictor.
unsigned calcLocHistIdx(Addr &branch_addr)
Returns the local history index, given a branch address.
unsigned localThreshold
Thresholds for the counter value; above the threshold is taken, equal to or below the threshold is no...
void updateGlobalHistNotTaken(ThreadID tid)
Updates global history as not taken.
unsigned globalHistoryMask
Mask to apply to globalHistory to access global history table.
unsigned globalCtrBits
Number of bits of the global predictor's counters.
unsigned globalHistoryBits
Number of bits for the global history.
unsigned localHistoryTableSize
Number of entries in the local history table.
unsigned localPredictorSize
Number of counters in the local predictor.
bool isPowerOf2(const T &n)
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
#define ULL(N)
uint64_t constant
void btbUpdate(ThreadID tid, Addr branch_addr, void *&bp_history)
Updates the branch predictor to Not Taken if a BTB entry is invalid or not found. ...
unsigned historyRegisterMask
Mask to control how much history is stored.
Basically a wrapper class to hold both the branch predictor and the BTB.
void updateLocalHistNotTaken(unsigned local_history_idx)
Updates local histories as not taken.
int16_t ThreadID
Thread index/ID type.
unsigned getGHR(ThreadID tid, void *bp_history) const
std::vector< unsigned > localHistoryTable
Array of local history table entries.
unsigned localPredictorMask
Mask to truncate values stored in the local history table.
std::vector< SatCounter > choiceCtrs
Array of counters that make up the choice predictor.
std::vector< unsigned > globalHistory
Global history register.
The branch history information that is created upon predicting a branch.
void update(ThreadID tid, Addr branch_addr, bool taken, void *bp_history, bool squashed)
Updates the branch predictor with the actual result of a branch.
bool lookup(ThreadID tid, Addr branch_addr, void *&bp_history)
Looks up the given address in the branch predictor and returns a true/false value as to whether it is...
const unsigned instShiftAmt
Number of bits to shift instructions by for predictor addresses.
static const int invalidPredictorIndex
Flag for invalid predictor index.
TournamentBP(const TournamentBPParams *params)
Default branch predictor constructor.
std::vector< SatCounter > globalCtrs
Array of counters that make up the global predictor.
unsigned choiceCtrBits
Number of bits in the choice predictor's counters.
unsigned choiceHistoryMask
Mask to apply to globalHistory to access choice history table.
unsigned localHistoryBits
Number of bits for each entry of the local history table.
void updateLocalHistTaken(unsigned local_history_idx)
Updates local histories as taken.