gem5  [DEVELOP-FOR-23.0]
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
btb.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2004-2005 The Regents of The University of Michigan
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met: redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer;
9  * redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution;
12  * neither the name of the copyright holders nor the names of its
13  * contributors may be used to endorse or promote products derived from
14  * this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef __CPU_PRED_BTB_HH__
30 #define __CPU_PRED_BTB_HH__
31 
32 #include "arch/generic/pcstate.hh"
33 #include "base/logging.hh"
34 #include "base/types.hh"
35 
36 namespace gem5
37 {
38 
39 namespace branch_prediction
40 {
41 
43 {
44  private:
45  struct BTBEntry
46  {
48  Addr tag = 0;
49 
51  std::unique_ptr<PCStateBase> target;
52 
55 
57  bool valid = false;
58  };
59 
60  public:
67  DefaultBTB(unsigned numEntries, unsigned tagBits,
68  unsigned instShiftAmt, unsigned numThreads);
69 
70  void reset();
71 
77  const PCStateBase *lookup(Addr instPC, ThreadID tid);
78 
84  bool valid(Addr instPC, ThreadID tid);
85 
91  void update(Addr inst_pc, const PCStateBase &target_pc, ThreadID tid);
92 
93  private:
98  inline unsigned getIndex(Addr instPC, ThreadID tid);
99 
104  inline Addr getTag(Addr instPC);
105 
108 
110  unsigned numEntries;
111 
113  unsigned idxMask;
114 
116  unsigned tagBits;
117 
119  unsigned tagMask;
120 
122  unsigned instShiftAmt;
123 
125  unsigned tagShiftAmt;
126 
128  unsigned log2NumThreads;
129 };
130 
131 } // namespace branch_prediction
132 } // namespace gem5
133 
134 #endif // __CPU_PRED_BTB_HH__
gem5::branch_prediction::DefaultBTB
Definition: btb.hh:42
gem5::branch_prediction::DefaultBTB::lookup
const PCStateBase * lookup(Addr instPC, ThreadID tid)
Looks up an address in the BTB.
Definition: btb.cc:116
gem5::branch_prediction::DefaultBTB::BTBEntry::valid
bool valid
Whether or not the entry is valid.
Definition: btb.hh:57
gem5::branch_prediction::DefaultBTB::BTBEntry::tag
Addr tag
The entry's tag.
Definition: btb.hh:48
gem5::branch_prediction::DefaultBTB::BTBEntry::tid
ThreadID tid
The entry's thread id.
Definition: btb.hh:54
gem5::branch_prediction::DefaultBTB::tagBits
unsigned tagBits
The number of tag bits per entry.
Definition: btb.hh:116
std::vector
STL vector class.
Definition: stl.hh:37
gem5::branch_prediction::DefaultBTB::tagMask
unsigned tagMask
The tag mask.
Definition: btb.hh:119
gem5::branch_prediction::DefaultBTB::instShiftAmt
unsigned instShiftAmt
Number of bits to shift PC when calculating index.
Definition: btb.hh:122
gem5::branch_prediction::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...
Definition: btb.cc:41
gem5::branch_prediction::DefaultBTB::BTBEntry
Definition: btb.hh:45
gem5::branch_prediction::DefaultBTB::log2NumThreads
unsigned log2NumThreads
Log2 NumThreads used for hashing threadid.
Definition: btb.hh:128
gem5::branch_prediction::DefaultBTB::reset
void reset()
Definition: btb.cc:70
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::branch_prediction::DefaultBTB::getTag
Addr getTag(Addr instPC)
Returns the tag bits of a given address.
Definition: btb.cc:89
pcstate.hh
types.hh
gem5::branch_prediction::DefaultBTB::getIndex
unsigned getIndex(Addr instPC, ThreadID tid)
Returns the index into the BTB, based on the branch's PC.
Definition: btb.cc:79
gem5::branch_prediction::DefaultBTB::BTBEntry::target
std::unique_ptr< PCStateBase > target
The entry's target.
Definition: btb.hh:51
logging.hh
gem5::PCStateBase
Definition: pcstate.hh:57
gem5::branch_prediction::DefaultBTB::numEntries
unsigned numEntries
The number of entries in the BTB.
Definition: btb.hh:110
gem5::branch_prediction::DefaultBTB::btb
std::vector< BTBEntry > btb
The actual BTB.
Definition: btb.hh:107
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::branch_prediction::DefaultBTB::tagShiftAmt
unsigned tagShiftAmt
Number of bits to shift PC when calculating tag.
Definition: btb.hh:125
gem5::branch_prediction::DefaultBTB::valid
bool valid(Addr instPC, ThreadID tid)
Checks if a branch is in the BTB.
Definition: btb.cc:95
gem5::branch_prediction::DefaultBTB::update
void update(Addr inst_pc, const PCStateBase &target_pc, ThreadID tid)
Updates the BTB with the target of a branch.
Definition: btb.cc:134
gem5::ThreadID
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:235
gem5::branch_prediction::DefaultBTB::idxMask
unsigned idxMask
The index mask.
Definition: btb.hh:113

Generated on Sun Jul 30 2023 01:56:53 for gem5 by doxygen 1.8.17