Go to the documentation of this file.
33 #include "debug/Fetch.hh"
37 unsigned _instShiftAmt,
38 unsigned _num_threads)
39 : numEntries(_numEntries),
41 instShiftAmt(_instShiftAmt),
44 DPRINTF(Fetch,
"BTB: Creating BTB object.\n");
47 fatal(
"BTB entries is not a power of 2!");
91 unsigned btb_idx =
getIndex(instPC, tid);
98 && inst_tag ==
btb[btb_idx].tag
99 &&
btb[btb_idx].tid == tid) {
112 unsigned btb_idx =
getIndex(instPC, tid);
119 && inst_tag ==
btb[btb_idx].tag
120 &&
btb[btb_idx].tid == tid) {
121 return btb[btb_idx].target;
130 unsigned btb_idx =
getIndex(instPC, tid);
134 btb[btb_idx].tid = tid;
135 btb[btb_idx].valid =
true;
136 btb[btb_idx].target = target;
#define fatal(...)
This implements a cprintf based fatal() function.
int16_t ThreadID
Thread index/ID type.
unsigned log2NumThreads
Log2 NumThreads used for hashing threadid.
unsigned tagBits
The number of tag bits per entry.
std::enable_if< std::is_integral< T >::value, int >::type floorLog2(T x)
unsigned instShiftAmt
Number of bits to shift PC when calculating index.
std::vector< BTBEntry > btb
The actual BTB.
void update(Addr instPC, const TheISA::PCState &targetPC, ThreadID tid)
Updates the BTB with the target of a branch.
bool valid(Addr instPC, ThreadID tid)
Checks if a branch is in the BTB.
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 numEntries
The number of entries in the BTB.
unsigned tagShiftAmt
Number of bits to shift PC when calculating tag.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
unsigned tagMask
The tag mask.
Addr getTag(Addr instPC)
Returns the tag bits of a given address.
unsigned getIndex(Addr instPC, ThreadID tid)
Returns the index into the BTB, based on the branch's PC.
GenericISA::DelaySlotPCState< MachInst > PCState
TheISA::PCState lookup(Addr instPC, ThreadID tid)
Looks up an address in the BTB.
unsigned idxMask
The index mask.
bool isPowerOf2(const T &n)
Generated on Wed Sep 30 2020 14:02:09 for gem5 by doxygen 1.8.17