gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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  * Authors: Kevin Lim
29  */
30 
31 #ifndef __CPU_PRED_BTB_HH__
32 #define __CPU_PRED_BTB_HH__
33 
34 #include "arch/types.hh"
35 #include "base/misc.hh"
36 #include "base/types.hh"
37 #include "config/the_isa.hh"
38 
40 {
41  private:
42  struct BTBEntry
43  {
45  : tag(0), target(0), valid(false)
46  {}
47 
50 
53 
56 
58  bool valid;
59  };
60 
61  public:
68  DefaultBTB(unsigned numEntries, unsigned tagBits,
69  unsigned instShiftAmt, unsigned numThreads);
70 
71  void reset();
72 
78  TheISA::PCState lookup(Addr instPC, ThreadID tid);
79 
85  bool valid(Addr instPC, ThreadID tid);
86 
92  void update(Addr instPC, const TheISA::PCState &targetPC,
93  ThreadID tid);
94 
95  private:
100  inline unsigned getIndex(Addr instPC, ThreadID tid);
101 
106  inline Addr getTag(Addr instPC);
107 
110 
112  unsigned numEntries;
113 
115  unsigned idxMask;
116 
118  unsigned tagBits;
119 
121  unsigned tagMask;
122 
124  unsigned instShiftAmt;
125 
127  unsigned tagShiftAmt;
128 
130  unsigned log2NumThreads;
131 };
132 
133 #endif // __CPU_PRED_BTB_HH__
Addr tag
The entry's tag.
Definition: btb.hh:49
std::vector< BTBEntry > btb
The actual BTB.
Definition: btb.hh:109
unsigned numEntries
The number of entries in the BTB.
Definition: btb.hh:112
TheISA::PCState target
The entry's target.
Definition: btb.hh:52
unsigned getIndex(Addr instPC, ThreadID tid)
Returns the index into the BTB, based on the branch's PC.
Definition: btb.cc:75
unsigned tagShiftAmt
Number of bits to shift PC when calculating tag.
Definition: btb.hh:127
unsigned tagMask
The tag mask.
Definition: btb.hh:121
STL vector class.
Definition: stl.hh:40
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:37
unsigned instShiftAmt
Number of bits to shift PC when calculating index.
Definition: btb.hh:124
void update(Addr instPC, const TheISA::PCState &targetPC, ThreadID tid)
Updates the BTB with the target of a branch.
Definition: btb.cc:130
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
TheISA::PCState lookup(Addr instPC, ThreadID tid)
Looks up an address in the BTB.
Definition: btb.cc:112
ThreadID tid
The entry's thread id.
Definition: btb.hh:55
unsigned log2NumThreads
Log2 NumThreads used for hashing threadid.
Definition: btb.hh:130
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:171
unsigned idxMask
The index mask.
Definition: btb.hh:115
Addr getTag(Addr instPC)
Returns the tag bits of a given address.
Definition: btb.cc:85
bool valid(Addr instPC, ThreadID tid)
Checks if a branch is in the BTB.
Definition: btb.cc:91
GenericISA::SimplePCState< MachInst > PCState
Definition: types.hh:43
bool valid
Whether or not the entry is valid.
Definition: btb.hh:58
void reset()
Definition: btb.cc:66
unsigned tagBits
The number of tag bits per entry.
Definition: btb.hh:118

Generated on Fri Jun 9 2017 13:03:44 for gem5 by doxygen 1.8.6