src/cpu/pred/bi_mode.cc
/*
 * Here we lookup the actual branch prediction. We use the PC to
 * identify the bias of a particular branch, which is based on the
 * prediction in the choice array. A hash of the global history
 * register and a branch's PC is used to index into both the taken
 * and not-taken predictors, which both present a prediction. The
 * choice array's prediction is used to select between the two
 * direction predictors for the final branch prediction.
 */
Here we lookup the actual branch prediction. We use the PC to
identify the bias of a particular branch, which is based on the
prediction in the choice array. A hash of the global history
register and a branch's PC is used to index into both the taken
and not-taken predictors, which both present a prediction. The
choice array's prediction is used to select between the two
direction predictors for the final branch prediction.
Here we lookup the actual branch prediction . We use the PC to identify the bias of a particular branch which is based on the prediction in the choice array . A hash of the global history register and a branch ' s PC is used to index into both the taken and not - taken predictors which both present a prediction . The choice array ' s prediction is used to select between the two direction predictors for the final branch prediction .
bool
BiModeBP::lookup(ThreadID tid, Addr branchAddr, void * &bpHistory)
{
    unsigned choiceHistoryIdx = ((branchAddr >> instShiftAmt)
                                & choiceHistoryMask);
    unsigned globalHistoryIdx = (((branchAddr >> instShiftAmt)
                                ^ globalHistoryReg[tid])
                                & globalHistoryMask);
    assert(choiceHistoryIdx < choicePredictorSize);
    assert(globalHistoryIdx < globalPredictorSize);
    bool choicePrediction = choiceCounters[choiceHistoryIdx]
                            > choiceThreshold;
    bool takenGHBPrediction = takenCounters[globalHistoryIdx]
                              > takenThreshold;
    bool notTakenGHBPrediction = notTakenCounters[globalHistoryIdx]
                                 > notTakenThreshold;
    bool finalPrediction;
    BPHistory *history = new BPHistory;
    history->globalHistoryReg = globalHistoryReg[tid];
    history->takenUsed = choicePrediction;
    history->takenPred = takenGHBPrediction;
    history->notTakenPred = notTakenGHBPrediction;
    if (choicePrediction) {
        finalPrediction = takenGHBPrediction;
    } else {
        finalPrediction = notTakenGHBPrediction;
    }
    history->finalPred = finalPrediction;
    bpHistory = static_cast<void*>(history);
    updateGlobalHistReg(tid, finalPrediction);
    return finalPrediction;
}
bool BiModeBP :: lookup ( ThreadID tid , Addr branchAddr , void * & bpHistory ) { unsigned choiceHistoryIdx = ( ( branchAddr >> instShiftAmt ) & choiceHistoryMask ) ; unsigned globalHistoryIdx = ( ( ( branchAddr >> instShiftAmt ) ^ globalHistoryReg [ tid ] ) & globalHistoryMask ) ; assert ( choiceHistoryIdx < choicePredictorSize ) ; assert ( globalHistoryIdx < globalPredictorSize ) ; bool choicePrediction = choiceCounters [ choiceHistoryIdx ] > choiceThreshold ; bool takenGHBPrediction = takenCounters [ globalHistoryIdx ] > takenThreshold ; bool notTakenGHBPrediction = notTakenCounters [ globalHistoryIdx ] > notTakenThreshold ; bool finalPrediction ; BPHistory * history = new BPHistory ; history -> globalHistoryReg = globalHistoryReg [ tid ] ; history -> takenUsed = choicePrediction ; history -> takenPred = takenGHBPrediction ; history -> notTakenPred = notTakenGHBPrediction ; if ( choicePrediction ) { finalPrediction = takenGHBPrediction ; } else { finalPrediction = notTakenGHBPrediction ; } history -> finalPred = finalPrediction ; bpHistory = static_cast < void * > ( history ) ; updateGlobalHistReg ( tid , finalPrediction ) ; return finalPrediction ; }
Here we lookup the actual branch prediction.
Here we lookup the actual branch prediction .