45#include "debug/BTB.hh"
50namespace branch_prediction
55 numEntries(
p.numEntries),
57 instShiftAmt(
p.instShiftAmt),
60 DPRINTF(BTB,
"BTB: Creating BTB object.\n");
63 fatal(
"BTB entries is not a power of 2!");
107 unsigned btb_idx =
getIndex(instPC, tid);
113 && inst_tag ==
btb[btb_idx].tag
114 &&
btb[btb_idx].tid == tid) {
115 return &
btb[btb_idx];
126 return entry !=
nullptr;
140 return entry->
target.get();
162 unsigned btb_idx =
getIndex(instPC, tid);
168 btb[btb_idx].tid = tid;
169 btb[btb_idx].valid =
true;
170 set(
btb[btb_idx].target, target);
172 btb[btb_idx].inst = inst;
void update() const
Align cycle and tick to the next clock edge if not already done.
gem5::branch_prediction::BranchTargetBuffer::BranchTargetBufferStats stats
enums::BranchType BranchType
unsigned log2NumThreads
Log2 NumThreads used for hashing threadid.
bool valid(ThreadID tid, Addr instPC) override
Checks if a branch address is in the BTB.
const PCStateBase * lookup(ThreadID tid, Addr instPC, BranchType type=BranchType::NoBranch) override
Looks up an address in the BTB to get the target of the branch.
void memInvalidate() override
Invalidate the contents of memory buffers.
unsigned tagMask
The tag mask.
unsigned numEntries
The number of entries in the BTB.
Addr getTag(Addr instPC)
Returns the tag bits of a given address.
BTBEntry * findEntry(Addr instPC, ThreadID tid)
Internal call to find an address in the BTB.
unsigned instShiftAmt
Number of bits to shift PC when calculating index.
const StaticInstPtr getInst(ThreadID tid, Addr instPC) override
Looks up an address in the BTB and return the instruction information if existant.
unsigned tagShiftAmt
Number of bits to shift PC when calculating tag.
std::vector< BTBEntry > btb
The actual BTB.
SimpleBTB(const SimpleBTBParams ¶ms)
unsigned getIndex(Addr instPC, ThreadID tid)
Returns the index into the BTB, based on the branch's PC.
unsigned tagBits
The number of tag bits per entry.
unsigned idxMask
The index mask.
static constexpr std::enable_if_t< std::is_integral_v< T >, int > floorLog2(T x)
static constexpr bool isPowerOf2(const T &n)
#define fatal(...)
This implements a cprintf based fatal() function.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
int16_t ThreadID
Thread index/ID type.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
statistics::Vector misses
statistics::Vector lookups
statistics::Vector updates
std::unique_ptr< PCStateBase > target
The entry's target.
StaticInstPtr inst
Pointer to the static branch instruction at this address.