gem5  v20.1.0.0
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
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 ()
 
TheISA::PCState lookup (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 instPC, const TheISA::PCState &targetPC, 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 37 of file btb.hh.

Constructor & Destructor Documentation

◆ DefaultBTB()

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 35 of file btb.cc.

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

Member Function Documentation

◆ getIndex()

unsigned 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 73 of file btb.cc.

References idxMask, instShiftAmt, log2NumThreads, and tagShiftAmt.

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

◆ getTag()

Addr 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 83 of file btb.cc.

References tagMask, and tagShiftAmt.

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

◆ lookup()

TheISA::PCState 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 110 of file btb.cc.

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

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

◆ reset()

void DefaultBTB::reset ( )

Definition at line 64 of file btb.cc.

References btb, ArmISA::i, and numEntries.

◆ update()

void DefaultBTB::update ( Addr  instPC,
const TheISA::PCState &  targetPC,
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 128 of file btb.cc.

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

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

◆ valid()

bool 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 89 of file btb.cc.

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

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

Member Data Documentation

◆ btb

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

The actual BTB.

Definition at line 107 of file btb.hh.

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

◆ idxMask

unsigned DefaultBTB::idxMask
private

The index mask.

Definition at line 113 of file btb.hh.

Referenced by DefaultBTB(), and getIndex().

◆ instShiftAmt

unsigned DefaultBTB::instShiftAmt
private

Number of bits to shift PC when calculating index.

Definition at line 122 of file btb.hh.

Referenced by DefaultBTB(), and getIndex().

◆ log2NumThreads

unsigned DefaultBTB::log2NumThreads
private

Log2 NumThreads used for hashing threadid.

Definition at line 128 of file btb.hh.

Referenced by getIndex().

◆ numEntries

unsigned DefaultBTB::numEntries
private

The number of entries in the BTB.

Definition at line 110 of file btb.hh.

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

◆ tagBits

unsigned DefaultBTB::tagBits
private

The number of tag bits per entry.

Definition at line 116 of file btb.hh.

Referenced by DefaultBTB().

◆ tagMask

unsigned DefaultBTB::tagMask
private

The tag mask.

Definition at line 119 of file btb.hh.

Referenced by DefaultBTB(), and getTag().

◆ tagShiftAmt

unsigned DefaultBTB::tagShiftAmt
private

Number of bits to shift PC when calculating tag.

Definition at line 125 of file btb.hh.

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


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

Generated on Wed Sep 30 2020 14:02:23 for gem5 by doxygen 1.8.17