gem5  v22.1.0.0
ras.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_RAS_HH__
30 #define __CPU_PRED_RAS_HH__
31 
32 #include <vector>
33 
34 #include "arch/generic/pcstate.hh"
35 #include "base/types.hh"
36 
37 namespace gem5
38 {
39 
40 namespace branch_prediction
41 {
42 
45 {
46  public:
51 
55  void init(unsigned numEntries);
56 
57  void reset();
58 
60  const PCStateBase *top() { return addrStack[tos].get(); }
61 
63  unsigned topIdx() { return tos; }
64 
66  void push(const PCStateBase &return_addr);
67 
69  void pop();
70 
76  void restore(unsigned top_entry_idx, const PCStateBase *restored);
77 
78  bool empty() { return usedEntries == 0; }
79 
80  bool full() { return usedEntries == numEntries; }
81  private:
83  inline void
85  {
86  if (++tos == numEntries)
87  tos = 0;
88  }
89 
91  inline void
93  {
94  tos = (tos == 0 ? numEntries - 1 : tos - 1);
95  }
96 
99 
101  unsigned numEntries;
102 
104  unsigned usedEntries;
105 
107  unsigned tos;
108 };
109 
110 } // namespace branch_prediction
111 } // namespace gem5
112 
113 #endif // __CPU_PRED_RAS_HH__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
Return address stack class, implements a simple RAS.
Definition: ras.hh:45
const PCStateBase * top()
Returns the top address on the RAS.
Definition: ras.hh:60
void push(const PCStateBase &return_addr)
Pushes an address onto the RAS.
Definition: ras.cc:53
std::vector< std::unique_ptr< PCStateBase > > addrStack
The RAS itself.
Definition: ras.hh:98
void restore(unsigned top_entry_idx, const PCStateBase *restored)
Changes index to the top of the RAS, and replaces the top address with a new target.
Definition: ras.cc:75
ReturnAddrStack()
Creates a return address stack, but init() must be called prior to use.
Definition: ras.hh:50
unsigned usedEntries
The number of used entries in the RAS.
Definition: ras.hh:104
void decrTos()
Decrements the top of stack index.
Definition: ras.hh:92
unsigned tos
The top of stack index.
Definition: ras.hh:107
void init(unsigned numEntries)
Initializes RAS with a specified number of entries.
Definition: ras.cc:38
void pop()
Pops the top address from the RAS.
Definition: ras.cc:65
unsigned topIdx()
Returns the index of the top of the RAS.
Definition: ras.hh:63
unsigned numEntries
The number of entries in the RAS.
Definition: ras.hh:101
void incrTos()
Increments the top of stack index.
Definition: ras.hh:84
STL vector class.
Definition: stl.hh:37
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....

Generated on Wed Dec 21 2022 10:22:31 for gem5 by doxygen 1.9.1