gem5  v20.1.0.0
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/types.hh"
33 #include "base/logging.hh"
34 #include "base/types.hh"
35 #include "config/the_isa.hh"
36 
38 {
39  private:
40  struct BTBEntry
41  {
43  : tag(0), target(0), valid(false)
44  {}
45 
48 
51 
54 
56  bool valid;
57  };
58 
59  public:
66  DefaultBTB(unsigned numEntries, unsigned tagBits,
67  unsigned instShiftAmt, unsigned numThreads);
68 
69  void reset();
70 
76  TheISA::PCState lookup(Addr instPC, ThreadID tid);
77 
83  bool valid(Addr instPC, ThreadID tid);
84 
90  void update(Addr instPC, const TheISA::PCState &targetPC,
91  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 #endif // __CPU_PRED_BTB_HH__
DefaultBTB::BTBEntry::BTBEntry
BTBEntry()
Definition: btb.hh:42
ThreadID
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:227
DefaultBTB
Definition: btb.hh:37
DefaultBTB::log2NumThreads
unsigned log2NumThreads
Log2 NumThreads used for hashing threadid.
Definition: btb.hh:128
DefaultBTB::BTBEntry::tag
Addr tag
The entry's tag.
Definition: btb.hh:47
DefaultBTB::tagBits
unsigned tagBits
The number of tag bits per entry.
Definition: btb.hh:116
std::vector
STL vector class.
Definition: stl.hh:37
DefaultBTB::instShiftAmt
unsigned instShiftAmt
Number of bits to shift PC when calculating index.
Definition: btb.hh:122
DefaultBTB::BTBEntry
Definition: btb.hh:40
DefaultBTB::btb
std::vector< BTBEntry > btb
The actual BTB.
Definition: btb.hh:107
DefaultBTB::update
void update(Addr instPC, const TheISA::PCState &targetPC, ThreadID tid)
Updates the BTB with the target of a branch.
Definition: btb.cc:128
DefaultBTB::valid
bool valid(Addr instPC, ThreadID tid)
Checks if a branch is in the BTB.
Definition: btb.cc:89
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:35
DefaultBTB::numEntries
unsigned numEntries
The number of entries in the BTB.
Definition: btb.hh:110
DefaultBTB::tagShiftAmt
unsigned tagShiftAmt
Number of bits to shift PC when calculating tag.
Definition: btb.hh:125
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
DefaultBTB::tagMask
unsigned tagMask
The tag mask.
Definition: btb.hh:119
DefaultBTB::getTag
Addr getTag(Addr instPC)
Returns the tag bits of a given address.
Definition: btb.cc:83
DefaultBTB::getIndex
unsigned getIndex(Addr instPC, ThreadID tid)
Returns the index into the BTB, based on the branch's PC.
Definition: btb.cc:73
DefaultBTB::reset
void reset()
Definition: btb.cc:64
MipsISA::PCState
GenericISA::DelaySlotPCState< MachInst > PCState
Definition: types.hh:41
types.hh
DefaultBTB::BTBEntry::tid
ThreadID tid
The entry's thread id.
Definition: btb.hh:53
logging.hh
DefaultBTB::BTBEntry::target
TheISA::PCState target
The entry's target.
Definition: btb.hh:50
DefaultBTB::lookup
TheISA::PCState lookup(Addr instPC, ThreadID tid)
Looks up an address in the BTB.
Definition: btb.cc:110
DefaultBTB::idxMask
unsigned idxMask
The index mask.
Definition: btb.hh:113
DefaultBTB::BTBEntry::valid
bool valid
Whether or not the entry is valid.
Definition: btb.hh:56

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