gem5  v22.0.0.1
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__
gem5::branch_prediction::ReturnAddrStack::addrStack
std::vector< std::unique_ptr< PCStateBase > > addrStack
The RAS itself.
Definition: ras.hh:98
gem5::branch_prediction::ReturnAddrStack::init
void init(unsigned numEntries)
Initializes RAS with a specified number of entries.
Definition: ras.cc:38
gem5::branch_prediction::ReturnAddrStack::empty
bool empty()
Definition: ras.hh:78
gem5::branch_prediction::ReturnAddrStack
Return address stack class, implements a simple RAS.
Definition: ras.hh:44
std::vector
STL vector class.
Definition: stl.hh:37
gem5::branch_prediction::ReturnAddrStack::pop
void pop()
Pops the top address from the RAS.
Definition: ras.cc:65
gem5::branch_prediction::ReturnAddrStack::top
const PCStateBase * top()
Returns the top address on the RAS.
Definition: ras.hh:60
gem5::branch_prediction::ReturnAddrStack::numEntries
unsigned numEntries
The number of entries in the RAS.
Definition: ras.hh:101
gem5::branch_prediction::ReturnAddrStack::restore
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
gem5::branch_prediction::ReturnAddrStack::ReturnAddrStack
ReturnAddrStack()
Creates a return address stack, but init() must be called prior to use.
Definition: ras.hh:50
gem5::branch_prediction::ReturnAddrStack::topIdx
unsigned topIdx()
Returns the index of the top of the RAS.
Definition: ras.hh:63
pcstate.hh
gem5::branch_prediction::ReturnAddrStack::reset
void reset()
Definition: ras.cc:46
gem5::branch_prediction::ReturnAddrStack::full
bool full()
Definition: ras.hh:80
gem5::branch_prediction::ReturnAddrStack::tos
unsigned tos
The top of stack index.
Definition: ras.hh:107
types.hh
gem5::branch_prediction::ReturnAddrStack::usedEntries
unsigned usedEntries
The number of used entries in the RAS.
Definition: ras.hh:104
gem5::PCStateBase
Definition: pcstate.hh:57
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::branch_prediction::ReturnAddrStack::incrTos
void incrTos()
Increments the top of stack index.
Definition: ras.hh:84
gem5::branch_prediction::ReturnAddrStack::decrTos
void decrTos()
Decrements the top of stack index.
Definition: ras.hh:92
gem5::branch_prediction::ReturnAddrStack::push
void push(const PCStateBase &return_addr)
Pushes an address onto the RAS.
Definition: ras.cc:53

Generated on Sat Jun 18 2022 08:12:21 for gem5 by doxygen 1.8.17