35 #include "debug/Fetch.hh"
39 unsigned _instShiftAmt,
40 unsigned _num_threads)
41 : numEntries(_numEntries),
43 instShiftAmt(_instShiftAmt),
46 DPRINTF(Fetch,
"BTB: Creating BTB object.\n");
49 fatal(
"BTB entries is not a power of 2!");
93 unsigned btb_idx =
getIndex(instPC, tid);
100 && inst_tag ==
btb[btb_idx].tag
101 &&
btb[btb_idx].tid == tid) {
114 unsigned btb_idx =
getIndex(instPC, tid);
121 && inst_tag ==
btb[btb_idx].tag
122 &&
btb[btb_idx].tid == tid) {
123 return btb[btb_idx].target;
132 unsigned btb_idx =
getIndex(instPC, tid);
136 btb[btb_idx].tid = tid;
137 btb[btb_idx].valid =
true;
138 btb[btb_idx].target = target;
std::vector< BTBEntry > btb
The actual BTB.
unsigned numEntries
The number of entries in the BTB.
unsigned getIndex(Addr instPC, ThreadID tid)
Returns the index into the BTB, based on the branch's PC.
unsigned tagShiftAmt
Number of bits to shift PC when calculating tag.
unsigned tagMask
The tag mask.
DefaultBTB(unsigned numEntries, unsigned tagBits, unsigned instShiftAmt, unsigned numThreads)
Creates a BTB with the given number of entries, number of bits per tag, and instruction offset amount...
unsigned instShiftAmt
Number of bits to shift PC when calculating index.
bool isPowerOf2(const T &n)
void update(Addr instPC, const TheISA::PCState &targetPC, ThreadID tid)
Updates the BTB with the target of a branch.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
TheISA::PCState lookup(Addr instPC, ThreadID tid)
Looks up an address in the BTB.
unsigned log2NumThreads
Log2 NumThreads used for hashing threadid.
int16_t ThreadID
Thread index/ID type.
int floorLog2(unsigned x)
unsigned idxMask
The index mask.
Addr getTag(Addr instPC)
Returns the tag bits of a given address.
bool valid(Addr instPC, ThreadID tid)
Checks if a branch is in the BTB.
GenericISA::SimplePCState< MachInst > PCState
unsigned tagBits
The number of tag bits per entry.