gem5  v21.2.0.0
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
gem5::branch_prediction::DefaultBTB Class Reference

#include <btb.hh>

Classes

struct  BTBEntry
 

Public Member Functions

 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. More...
 
void reset ()
 
const PCStateBaselookup (Addr instPC, ThreadID tid)
 Looks up an address in the BTB. More...
 
bool valid (Addr instPC, ThreadID tid)
 Checks if a branch is in the BTB. More...
 
void update (Addr inst_pc, const PCStateBase &target_pc, ThreadID tid)
 Updates the BTB with the target of a branch. More...
 

Private Member Functions

unsigned getIndex (Addr instPC, ThreadID tid)
 Returns the index into the BTB, based on the branch's PC. More...
 
Addr getTag (Addr instPC)
 Returns the tag bits of a given address. More...
 

Private Attributes

std::vector< BTBEntrybtb
 The actual BTB. More...
 
unsigned numEntries
 The number of entries in the BTB. More...
 
unsigned idxMask
 The index mask. More...
 
unsigned tagBits
 The number of tag bits per entry. More...
 
unsigned tagMask
 The tag mask. More...
 
unsigned instShiftAmt
 Number of bits to shift PC when calculating index. More...
 
unsigned tagShiftAmt
 Number of bits to shift PC when calculating tag. More...
 
unsigned log2NumThreads
 Log2 NumThreads used for hashing threadid. More...
 

Detailed Description

Definition at line 43 of file btb.hh.

Constructor & Destructor Documentation

◆ DefaultBTB()

gem5::branch_prediction::DefaultBTB::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.

Parameters
numEntriesNumber of entries for the BTB.
tagBitsNumber of bits for each tag in the BTB.
instShiftAmtOffset amount for instructions to ignore alignment.

Definition at line 41 of file btb.cc.

References btb, DPRINTF, fatal, gem5::floorLog2(), gem5::ArmISA::i, idxMask, instShiftAmt, gem5::isPowerOf2(), numEntries, tagBits, tagMask, and tagShiftAmt.

Member Function Documentation

◆ getIndex()

unsigned gem5::branch_prediction::DefaultBTB::getIndex ( Addr  instPC,
ThreadID  tid 
)
inlineprivate

Returns the index into the BTB, based on the branch's PC.

Parameters
inst_PCThe branch to look up.
Returns
Returns the index into the BTB.

Definition at line 79 of file btb.cc.

References idxMask, instShiftAmt, log2NumThreads, and tagShiftAmt.

Referenced by lookup(), update(), and valid().

◆ getTag()

Addr gem5::branch_prediction::DefaultBTB::getTag ( Addr  instPC)
inlineprivate

Returns the tag bits of a given address.

Parameters
inst_PCThe branch's address.
Returns
Returns the tag bits.

Definition at line 89 of file btb.cc.

References tagMask, and tagShiftAmt.

Referenced by lookup(), update(), and valid().

◆ lookup()

const PCStateBase * gem5::branch_prediction::DefaultBTB::lookup ( Addr  instPC,
ThreadID  tid 
)

Looks up an address in the BTB.

Must call valid() first on the address.

Parameters
inst_PCThe address of the branch to look up.
tidThe thread id.
Returns
Returns the target of the branch.

Definition at line 116 of file btb.cc.

References btb, getIndex(), getTag(), numEntries, and valid().

Referenced by gem5::branch_prediction::BPredUnit::BTBLookup(), and gem5::branch_prediction::BPredUnit::predict().

◆ reset()

void gem5::branch_prediction::DefaultBTB::reset ( )

Definition at line 70 of file btb.cc.

References btb, gem5::ArmISA::i, and numEntries.

◆ update()

void gem5::branch_prediction::DefaultBTB::update ( Addr  inst_pc,
const PCStateBase target_pc,
ThreadID  tid 
)

Updates the BTB with the target of a branch.

Parameters
inst_pcThe address of the branch being updated.
target_pcThe target address of the branch.
tidThe thread id.

Definition at line 134 of file btb.cc.

References btb, getIndex(), getTag(), and numEntries.

Referenced by gem5::branch_prediction::BPredUnit::BTBUpdate(), and gem5::branch_prediction::BPredUnit::squash().

◆ valid()

bool gem5::branch_prediction::DefaultBTB::valid ( Addr  instPC,
ThreadID  tid 
)

Checks if a branch is in the BTB.

Parameters
inst_PCThe address of the branch to look up.
tidThe thread id.
Returns
Whether or not the branch exists in the BTB.

Definition at line 95 of file btb.cc.

References btb, getIndex(), getTag(), and numEntries.

Referenced by gem5::branch_prediction::BPredUnit::BTBValid(), lookup(), and gem5::branch_prediction::BPredUnit::predict().

Member Data Documentation

◆ btb

std::vector<BTBEntry> gem5::branch_prediction::DefaultBTB::btb
private

The actual BTB.

Definition at line 108 of file btb.hh.

Referenced by DefaultBTB(), lookup(), reset(), update(), and valid().

◆ idxMask

unsigned gem5::branch_prediction::DefaultBTB::idxMask
private

The index mask.

Definition at line 114 of file btb.hh.

Referenced by DefaultBTB(), and getIndex().

◆ instShiftAmt

unsigned gem5::branch_prediction::DefaultBTB::instShiftAmt
private

Number of bits to shift PC when calculating index.

Definition at line 123 of file btb.hh.

Referenced by DefaultBTB(), and getIndex().

◆ log2NumThreads

unsigned gem5::branch_prediction::DefaultBTB::log2NumThreads
private

Log2 NumThreads used for hashing threadid.

Definition at line 129 of file btb.hh.

Referenced by getIndex().

◆ numEntries

unsigned gem5::branch_prediction::DefaultBTB::numEntries
private

The number of entries in the BTB.

Definition at line 111 of file btb.hh.

Referenced by DefaultBTB(), lookup(), reset(), update(), and valid().

◆ tagBits

unsigned gem5::branch_prediction::DefaultBTB::tagBits
private

The number of tag bits per entry.

Definition at line 117 of file btb.hh.

Referenced by DefaultBTB().

◆ tagMask

unsigned gem5::branch_prediction::DefaultBTB::tagMask
private

The tag mask.

Definition at line 120 of file btb.hh.

Referenced by DefaultBTB(), and getTag().

◆ tagShiftAmt

unsigned gem5::branch_prediction::DefaultBTB::tagShiftAmt
private

Number of bits to shift PC when calculating tag.

Definition at line 126 of file btb.hh.

Referenced by DefaultBTB(), getIndex(), and getTag().


The documentation for this class was generated from the following files:

Generated on Tue Dec 21 2021 11:35:24 for gem5 by doxygen 1.8.17