gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 39 of file btb.hh.

Constructor & Destructor Documentation

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

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

Member Function Documentation

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

References idxMask, instShiftAmt, log2NumThreads, and tagShiftAmt.

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

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

References tagMask, and tagShiftAmt.

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

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

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

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

void DefaultBTB::reset ( )

Definition at line 66 of file btb.cc.

References btb, ArmISA::i, and numEntries.

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

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

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

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

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

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

Member Data Documentation

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

The actual BTB.

Definition at line 109 of file btb.hh.

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

unsigned DefaultBTB::idxMask
private

The index mask.

Definition at line 115 of file btb.hh.

Referenced by DefaultBTB(), and getIndex().

unsigned DefaultBTB::instShiftAmt
private

Number of bits to shift PC when calculating index.

Definition at line 124 of file btb.hh.

Referenced by DefaultBTB(), and getIndex().

unsigned DefaultBTB::log2NumThreads
private

Log2 NumThreads used for hashing threadid.

Definition at line 130 of file btb.hh.

Referenced by getIndex().

unsigned DefaultBTB::numEntries
private

The number of entries in the BTB.

Definition at line 112 of file btb.hh.

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

unsigned DefaultBTB::tagBits
private

The number of tag bits per entry.

Definition at line 118 of file btb.hh.

Referenced by DefaultBTB().

unsigned DefaultBTB::tagMask
private

The tag mask.

Definition at line 121 of file btb.hh.

Referenced by DefaultBTB(), and getTag().

unsigned DefaultBTB::tagShiftAmt
private

Number of bits to shift PC when calculating tag.

Definition at line 127 of file btb.hh.

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


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

Generated on Fri Jun 9 2017 13:04:06 for gem5 by doxygen 1.8.6