gem5  v21.2.0.0
rob.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Copyright (c) 2004-2006 The Regents of The University of Michigan
15  * All rights reserved.
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions are
19  * met: redistributions of source code must retain the above copyright
20  * notice, this list of conditions and the following disclaimer;
21  * redistributions in binary form must reproduce the above copyright
22  * notice, this list of conditions and the following disclaimer in the
23  * documentation and/or other materials provided with the distribution;
24  * neither the name of the copyright holders nor the names of its
25  * contributors may be used to endorse or promote products derived from
26  * this software without specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39  */
40 
41 #ifndef __CPU_O3_ROB_HH__
42 #define __CPU_O3_ROB_HH__
43 
44 #include <string>
45 #include <utility>
46 #include <vector>
47 
48 #include "base/statistics.hh"
49 #include "base/types.hh"
50 #include "config/the_isa.hh"
51 #include "cpu/inst_seq.hh"
52 #include "cpu/o3/dyn_inst_ptr.hh"
53 #include "cpu/o3/limits.hh"
54 #include "cpu/reg_class.hh"
55 #include "enums/SMTQueuePolicy.hh"
56 
57 namespace gem5
58 {
59 
60 struct O3CPUParams;
61 
62 namespace o3
63 {
64 
65 class CPU;
66 
67 struct DerivO3CPUParams;
68 
72 class ROB
73 {
74  public:
77 
79  enum Status
80  {
84  };
85 
86  private:
89 
91  SMTQueuePolicy robPolicy;
92 
93  public:
98  ROB(CPU *_cpu, const O3CPUParams &params);
99 
100  std::string name() const;
101 
106 
108  void drainSanityCheck() const;
109 
111  void takeOverFrom();
112 
118  void insertInst(const DynInstPtr &inst);
119 
124 // DynInstPtr readHeadInst();
125 
130  const DynInstPtr &readHeadInst(ThreadID tid);
131 
135  DynInstPtr findInst(ThreadID tid, InstSeqNum squash_inst);
136 
141 // DynInstPtr readTailInst();
142 
148 
150 // void retireHead();
151 
155  void retireHead(ThreadID tid);
156 
158 // bool isHeadReady();
159 
161  bool isHeadReady(ThreadID tid);
162 
164  bool canCommit();
165 
167  void resetEntries();
168 
170  int entryAmount(ThreadID num_threads);
171 
173  unsigned numFreeEntries();
174 
176  unsigned numFreeEntries(ThreadID tid);
177 
179  unsigned getMaxEntries(ThreadID tid)
180  { return maxEntries[tid]; }
181 
184  { return threadEntries[tid]; }
185 
187  bool isFull()
188  { return numInstsInROB == numEntries; }
189 
191  bool isFull(ThreadID tid)
192  { return threadEntries[tid] == numEntries; }
193 
195  bool isEmpty() const
196  { return numInstsInROB == 0; }
197 
199  bool isEmpty(ThreadID tid) const
200  { return threadEntries[tid] == 0; }
201 
203  void doSquash(ThreadID tid);
204 
208  void squash(InstSeqNum squash_num, ThreadID tid);
209 
211  void updateHead();
212 
214  void updateTail();
215 
217 // uint64_t readHeadPC();
218 
220 // uint64_t readHeadPC(ThreadID tid);
221 
223 // uint64_t readHeadNextPC();
224 
226 // uint64_t readHeadNextPC(ThreadID tid);
227 
229 // InstSeqNum readHeadSeqNum();
230 
233 // InstSeqNum readHeadSeqNum(ThreadID tid);
234 
236 // uint64_t readTailPC();
237 
239 // uint64_t readTailPC(ThreadID tid);
240 
242 // InstSeqNum readTailSeqNum();
243 
245 // InstSeqNum readTailSeqNum(ThreadID tid);
246 
250  bool isDoneSquashing(ThreadID tid) const
251  { return doneSquashing[tid]; }
252 
256  bool isDoneSquashing();
257 
262  int countInsts();
263 
268  size_t countInsts(ThreadID tid);
269 
270  private:
272  void resetState();
273 
276 
279 
281  unsigned numEntries;
282 
285 
288 
291 
293  unsigned squashWidth;
294 
295  public:
301 
305 
306  private:
315 
316  public:
319 
322 
323  private:
326 
329 
332 
333 
334  struct ROBStats : public statistics::Group
335  {
336  ROBStats(statistics::Group *parent);
337 
338  // The number of rob_reads
340  // The number of rob_writes
342  } stats;
343 };
344 
345 } // namespace o3
346 } // namespace gem5
347 
348 #endif //__CPU_O3_ROB_HH__
gem5::o3::ROB::dummyInst
DynInstPtr dummyInst
Dummy instruction returned if there are no insts left.
Definition: rob.hh:321
gem5::statistics::Scalar
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:1930
gem5::o3::ROB::doSquash
void doSquash(ThreadID tid)
Executes the squash, marking squashed instructions.
Definition: rob.cc:309
gem5::o3::ROB::entryAmount
int entryAmount(ThreadID num_threads)
Number of entries needed For 'num_threads' amount of threads.
Definition: rob.cc:170
gem5::o3::ROB::squash
void squash(InstSeqNum squash_num, ThreadID tid)
Squashes all instructions younger than the given sequence number for the specific thread.
Definition: rob.cc:473
gem5::o3::ROB::readTailInst
DynInstPtr readTailInst(ThreadID tid)
Returns pointer to the tail instruction within the ROB.
Definition: rob.cc:516
gem5::o3::ROB::squashWidth
unsigned squashWidth
Number of instructions that can be squashed in a single cycle.
Definition: rob.hh:293
gem5::o3::ROB::squashIt
InstIt squashIt[MaxThreads]
Iterator used for walking through the list of instructions when squashing.
Definition: rob.hh:314
gem5::o3::ROB::updateHead
void updateHead()
Updates the head instruction with the new oldest instruction.
Definition: rob.cc:395
gem5::o3::ROB::isEmpty
bool isEmpty(ThreadID tid) const
Returns if a specific thread's partition is empty.
Definition: rob.hh:199
gem5::o3::ROB::ROBSquashing
@ ROBSquashing
Definition: rob.hh:83
gem5::o3::ROB::insertInst
void insertInst(const DynInstPtr &inst)
Function to insert an instruction into the ROB.
Definition: rob.cc:197
gem5::o3::ROB::drainSanityCheck
void drainSanityCheck() const
Perform sanity checks after a drain.
Definition: rob.cc:134
gem5::o3::ROB::numEntries
unsigned numEntries
Number of instructions in the ROB.
Definition: rob.hh:281
gem5::o3::ROB::threadEntries
unsigned threadEntries[MaxThreads]
Entries Per Thread.
Definition: rob.hh:284
gem5::o3::ROB::isDoneSquashing
bool isDoneSquashing(ThreadID tid) const
Reads the PC of the oldest head instruction.
Definition: rob.hh:250
gem5::o3::ROB::Running
@ Running
Definition: rob.hh:81
gem5::o3::ROB::robStatus
Status robStatus[MaxThreads]
Per-thread ROB status.
Definition: rob.hh:88
gem5::o3::ROB::UnmapInfo
std::pair< RegIndex, RegIndex > UnmapInfo
Definition: rob.hh:75
gem5::o3::ROB::stats
gem5::o3::ROB::ROBStats stats
gem5::o3::ROB::numFreeEntries
unsigned numFreeEntries()
Returns the number of total free entries in the ROB.
Definition: rob.cc:297
gem5::o3::ROB::isFull
bool isFull(ThreadID tid)
Returns if a specific thread's partition is full.
Definition: rob.hh:191
gem5::o3::ROB::resetEntries
void resetEntries()
Re-adjust ROB partitioning.
Definition: rob.cc:148
gem5::RefCountingPtr
If you want a reference counting pointer to a mutable object, create it like this:
Definition: refcnt.hh:126
gem5::o3::ROB::maxEntries
unsigned maxEntries[MaxThreads]
Max Insts a Thread Can Have in the ROB.
Definition: rob.hh:287
gem5::o3::ROB::getMaxEntries
unsigned getMaxEntries(ThreadID tid)
Returns the maximum number of entries for a specific thread.
Definition: rob.hh:179
gem5::o3::ROB::InstIt
std::list< DynInstPtr >::iterator InstIt
Definition: rob.hh:76
gem5::o3::ROB::canCommit
bool canCommit()
Is there any commitable head instruction across all threads ready.
Definition: rob.cc:279
gem5::o3::ROB::isFull
bool isFull()
Returns if the ROB is full.
Definition: rob.hh:187
gem5::o3::ROB::head
InstIt head
Iterator pointing to the instruction which is the first instruction in in the ROB.
Definition: rob.hh:304
inst_seq.hh
gem5::o3::CPU
O3CPU class, has each of the stages (fetch through commit) within it, as well as all of the time buff...
Definition: cpu.hh:94
gem5::o3::ROB::readHeadInst
const DynInstPtr & readHeadInst(ThreadID tid)
Returns pointer to the head instruction within the ROB.
Definition: rob.cc:502
statistics.hh
gem5::o3::ROB::tail
InstIt tail
Iterator pointing to the instruction which is the last instruction in the ROB.
Definition: rob.hh:300
gem5::o3::ROB::name
std::string name() const
Definition: rob.cc:121
gem5::o3::ROB::setActiveThreads
void setActiveThreads(std::list< ThreadID > *at_ptr)
Sets pointer to the list of active threads.
Definition: rob.cc:127
gem5::o3::ROB::cpu
CPU * cpu
Pointer to the CPU.
Definition: rob.hh:275
gem5::o3::ROB::isHeadReady
bool isHeadReady(ThreadID tid)
Is the oldest instruction across all threads ready.
Definition: rob.cc:268
std::pair
STL pair class.
Definition: stl.hh:58
gem5::o3::ROB::instList
std::list< DynInstPtr > instList[MaxThreads]
ROB List of Instructions.
Definition: rob.hh:290
gem5::o3::ROB::Status
Status
Possible ROB statuses.
Definition: rob.hh:79
dyn_inst_ptr.hh
gem5::o3::ROB::ROBStats
Definition: rob.hh:334
gem5::o3::ROB::numThreads
ThreadID numThreads
Number of active threads.
Definition: rob.hh:331
gem5::o3::ROB::robPolicy
SMTQueuePolicy robPolicy
ROB resource sharing policy for SMT mode.
Definition: rob.hh:91
gem5::o3::ROB::getThreadEntries
unsigned getThreadEntries(ThreadID tid)
Returns the number of entries being used by a specific thread.
Definition: rob.hh:183
gem5::o3::ROB::ROBStats::ROBStats
ROBStats(statistics::Group *parent)
Definition: rob.cc:524
gem5::o3::MaxThreads
static constexpr int MaxThreads
Definition: limits.hh:38
gem5::o3::ROB::squashedSeqNum
InstSeqNum squashedSeqNum[MaxThreads]
The sequence number of the squashed instruction.
Definition: rob.hh:325
gem5::o3::ROB::findInst
DynInstPtr findInst(ThreadID tid, InstSeqNum squash_inst)
Returns a pointer to the instruction with the given sequence if it is in the ROB.
Definition: rob.cc:534
gem5::o3::ROB::ROBStats::reads
statistics::Scalar reads
Definition: rob.hh:339
gem5::o3::ROB::Idle
@ Idle
Definition: rob.hh:82
types.hh
gem5::o3::ROB::resetState
void resetState()
Reset the ROB state.
Definition: rob.cc:104
gem5::o3::ROB::isEmpty
bool isEmpty() const
Returns if the ROB is empty.
Definition: rob.hh:195
reg_class.hh
gem5::statistics::Group
Statistics container.
Definition: group.hh:93
gem5::o3::ROB::ROB
ROB(CPU *_cpu, const O3CPUParams &params)
ROB constructor.
Definition: rob.cc:58
gem5::InstSeqNum
uint64_t InstSeqNum
Definition: inst_seq.hh:40
gem5::o3::ROB::retireHead
void retireHead(ThreadID tid)
Retires the head instruction, removing it from the ROB.
Definition: rob.cc:234
gem5::o3::ROB::doneSquashing
bool doneSquashing[MaxThreads]
Is the ROB done squashing.
Definition: rob.hh:328
gem5::o3::ROB::ROBStats::writes
statistics::Scalar writes
Definition: rob.hh:341
gem5::o3::ROB::activeThreads
std::list< ThreadID > * activeThreads
Active Threads in CPU.
Definition: rob.hh:278
std::list
STL list class.
Definition: stl.hh:51
gem5::o3::ROB::numInstsInROB
int numInstsInROB
Number of instructions in the ROB.
Definition: rob.hh:318
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: tlb.cc:60
gem5::o3::ROB::countInsts
int countInsts()
This is more of a debugging function than anything.
Definition: rob.cc:180
limits.hh
gem5::o3::ROB
ROB class.
Definition: rob.hh:72
gem5::o3::ROB::isDoneSquashing
bool isDoneSquashing()
Checks if the ROB is still in the process of squashing instructions for any thread.
gem5::o3::ROB::updateTail
void updateTail()
Updates the tail instruction with the new youngest instruction.
Definition: rob.cc:436
gem5::ThreadID
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:242
gem5::o3::ROB::takeOverFrom
void takeOverFrom()
Takes over another CPU's thread.
Definition: rob.cc:142

Generated on Tue Dec 21 2021 11:34:26 for gem5 by doxygen 1.8.17