1/* 2 * Copyright (c) 2014 The University of Wisconsin 3 * 4 * Copyright (c) 2006 INRIA (Institut National de Recherche en 5 * Informatique et en Automatique / French National Research Institute 6 * for Computer Science and Applied Mathematics) 7 * 8 * All rights reserved. --- 36 unchanged lines hidden (view full) --- 45#include "base/random.hh" 46#include "base/trace.hh" 47#include "debug/Fetch.hh" 48#include "debug/LTage.hh" 49 50LTAGE::LTAGE(const LTAGEParams *params) 51 : BPredUnit(params), 52 logSizeBiMP(params->logSizeBiMP), |
53 logRatioBiModalHystEntries(params->logRatioBiModalHystEntries), |
54 logSizeTagTables(params->logSizeTagTables), 55 logSizeLoopPred(params->logSizeLoopPred), 56 nHistoryTables(params->nHistoryTables), 57 tagTableCounterBits(params->tagTableCounterBits), 58 histBufferSize(params->histBufferSize), 59 minHist(params->minHist), 60 maxHist(params->maxHist), 61 minTagWidth(params->minTagWidth), --- 56 unchanged lines hidden (view full) --- 118 history.computeIndices[i].origLength, tagWidths[i]); 119 history.computeTags[1][i].init( 120 history.computeIndices[i].origLength, tagWidths[i] - 1); 121 DPRINTF(LTage, "HistLength:%d, TTSize:%d, TTTWidth:%d\n", 122 histLengths[i], tagTableSizes[i], tagWidths[i]); 123 } 124 } 125 |
126 const uint64_t bimodalTableSize = ULL(1) << logSizeBiMP; 127 btablePrediction.resize(bimodalTableSize, false); 128 btableHysteresis.resize(bimodalTableSize >> logRatioBiModalHystEntries, 129 true); 130 |
131 ltable = new LoopEntry[ULL(1) << logSizeLoopPred]; 132 gtable = new TageEntry*[nHistoryTables + 1]; 133 for (int i = 1; i <= nHistoryTables; i++) { 134 gtable[i] = new TageEntry[1<<(tagTableSizes[i])]; 135 } 136 137 tableIndices = new int [nHistoryTables+1]; 138 tableTags = new int [nHistoryTables+1]; --- 72 unchanged lines hidden (view full) --- 211 ctr--; 212 } 213} 214 215// Bimodal prediction 216bool 217LTAGE::getBimodePred(Addr pc, BranchInfo* bi) const 218{ |
219 return btablePrediction[bi->bimodalIndex]; |
220} 221 222 |
223// Update the bimodal predictor: a hysteresis bit is shared among N prediction 224// bits (N = 2 ^ logRatioBiModalHystEntries) |
225void 226LTAGE::baseUpdate(Addr pc, bool taken, BranchInfo* bi) 227{ |
228 int inter = (btablePrediction[bi->bimodalIndex] << 1) 229 + btableHysteresis[bi->bimodalIndex >> logRatioBiModalHystEntries]; |
230 if (taken) { 231 if (inter < 3) 232 inter++; 233 } else if (inter > 0) { 234 inter--; 235 } |
236 const bool pred = inter >> 1; 237 const bool hyst = inter & 1; 238 btablePrediction[bi->bimodalIndex] = pred; 239 btableHysteresis[bi->bimodalIndex >> logRatioBiModalHystEntries] = hyst; 240 DPRINTF(LTage, "Updating branch %lx, pred:%d, hyst:%d\n", pc, pred, hyst); |
241} 242 243 244//loop prediction: only used if high confidence 245bool 246LTAGE::getLoop(Addr pc, BranchInfo* bi) const 247{ 248 bi->loopHit = -1; --- 507 unchanged lines hidden --- |