34#include "debug/Fetch.hh"
39namespace branch_prediction
44 localPredictorSize(params.localPredictorSize),
45 localCtrBits(params.localCtrBits),
46 localPredictorSets(localPredictorSize / localCtrBits),
47 localCtrs(localPredictorSets,
SatCounter8(localCtrBits)),
48 indexMask(localPredictorSets - 1)
51 fatal(
"Invalid local predictor size!\n");
55 fatal(
"Invalid number of local predictor sets! Check localCtrBits.\n");
60 DPRINTF(Fetch,
"local predictor size: %i\n",
65 DPRINTF(Fetch,
"instruction shift amount: %i\n",
83 DPRINTF(Fetch,
"Looking up index %#x\n",
86 uint8_t counter_val =
localCtrs[local_predictor_idx];
88 DPRINTF(Fetch,
"prediction is %i.\n",
100 assert(bp_history == NULL);
101 unsigned local_predictor_idx;
112 DPRINTF(Fetch,
"Looking up index %#x\n", local_predictor_idx);
115 DPRINTF(Fetch,
"Branch updated as taken.\n");
118 DPRINTF(Fetch,
"Branch updated as not taken.\n");
Basically a wrapper class to hold both the branch predictor and the BTB.
const unsigned instShiftAmt
Number of bits to shift instructions by for predictor addresses.
virtual void uncondBranch(ThreadID tid, Addr pc, void *&bp_history)
void update(ThreadID tid, Addr branch_addr, bool taken, void *bp_history, bool squashed, const StaticInstPtr &inst, Addr corrTarget)
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 localPredictorSize
Size of the local predictor.
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.
bool getPrediction(uint8_t &count)
Returns the taken/not taken prediction given the value of the counter.
const unsigned localCtrBits
Number of bits of the local predictor's counters.
const unsigned localPredictorSets
Number of sets.
LocalBP(const LocalBPParams ¶ms)
Default branch predictor constructor.
const unsigned indexMask
Mask to get index bits.
std::vector< SatCounter8 > localCtrs
Array of counters that make up the local predictor.
unsigned getLocalIndex(Addr &PC)
Calculates the local index based on the PC.
static constexpr bool isPowerOf2(const T &n)
#define fatal(...)
This implements a cprintf based fatal() function.
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
int16_t ThreadID
Thread index/ID type.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.