gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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  * Authors: Kevin Lim
41  * Korey Sewell
42  */
43 
44 #ifndef __CPU_O3_ROB_HH__
45 #define __CPU_O3_ROB_HH__
46 
47 #include <string>
48 #include <utility>
49 #include <vector>
50 
51 #include "arch/registers.hh"
52 #include "base/types.hh"
53 #include "config/the_isa.hh"
54 #include "enums/SMTQueuePolicy.hh"
55 
56 struct DerivO3CPUParams;
57 
61 template <class Impl>
62 class ROB
63 {
64  public:
65  //Typedefs from the Impl.
66  typedef typename Impl::O3CPU O3CPU;
67  typedef typename Impl::DynInstPtr DynInstPtr;
68 
71 
73  enum Status {
77  };
78 
79  private:
81  Status robStatus[Impl::MaxThreads];
82 
84  SMTQueuePolicy robPolicy;
85 
86  public:
91  ROB(O3CPU *_cpu, DerivO3CPUParams *params);
92 
93  std::string name() const;
94 
99 
101  void drainSanityCheck() const;
102 
104  void takeOverFrom();
105 
111  void insertInst(const DynInstPtr &inst);
112 
117 // DynInstPtr readHeadInst();
118 
123  const DynInstPtr &readHeadInst(ThreadID tid);
124 
128  DynInstPtr findInst(ThreadID tid, InstSeqNum squash_inst);
129 
134 // DynInstPtr readTailInst();
135 
140  DynInstPtr readTailInst(ThreadID tid);
141 
143 // void retireHead();
144 
148  void retireHead(ThreadID tid);
149 
151 // bool isHeadReady();
152 
154  bool isHeadReady(ThreadID tid);
155 
157  bool canCommit();
158 
160  void resetEntries();
161 
163  int entryAmount(ThreadID num_threads);
164 
166  unsigned numFreeEntries();
167 
169  unsigned numFreeEntries(ThreadID tid);
170 
172  unsigned getMaxEntries(ThreadID tid)
173  { return maxEntries[tid]; }
174 
177  { return threadEntries[tid]; }
178 
180  bool isFull()
181  { return numInstsInROB == numEntries; }
182 
184  bool isFull(ThreadID tid)
185  { return threadEntries[tid] == numEntries; }
186 
188  bool isEmpty() const
189  { return numInstsInROB == 0; }
190 
192  bool isEmpty(ThreadID tid) const
193  { return threadEntries[tid] == 0; }
194 
196  void doSquash(ThreadID tid);
197 
201  void squash(InstSeqNum squash_num, ThreadID tid);
202 
204  void updateHead();
205 
207  void updateTail();
208 
210 // uint64_t readHeadPC();
211 
213 // uint64_t readHeadPC(ThreadID tid);
214 
216 // uint64_t readHeadNextPC();
217 
219 // uint64_t readHeadNextPC(ThreadID tid);
220 
222 // InstSeqNum readHeadSeqNum();
223 
226 // InstSeqNum readHeadSeqNum(ThreadID tid);
227 
229 // uint64_t readTailPC();
230 
232 // uint64_t readTailPC(ThreadID tid);
233 
235 // InstSeqNum readTailSeqNum();
236 
238 // InstSeqNum readTailSeqNum(ThreadID tid);
239 
243  bool isDoneSquashing(ThreadID tid) const
244  { return doneSquashing[tid]; }
245 
249  bool isDoneSquashing();
250 
255  int countInsts();
256 
261  size_t countInsts(ThreadID tid);
262 
264  void regStats();
265 
266  private:
268  void resetState();
269 
271  O3CPU *cpu;
272 
275 
277  unsigned numEntries;
278 
280  unsigned threadEntries[Impl::MaxThreads];
281 
283  unsigned maxEntries[Impl::MaxThreads];
284 
286  std::list<DynInstPtr> instList[Impl::MaxThreads];
287 
289  unsigned squashWidth;
290 
291  public:
296  InstIt tail;
297 
300  InstIt head;
301 
302  private:
310  InstIt squashIt[Impl::MaxThreads];
311 
312  public:
315 
317  DynInstPtr dummyInst;
318 
319  private:
321  InstSeqNum squashedSeqNum[Impl::MaxThreads];
322 
324  bool doneSquashing[Impl::MaxThreads];
325 
328 
329  // The number of rob_reads
331  // The number of rob_writes
333 };
334 
335 #endif //__CPU_O3_ROB_HH__
void takeOverFrom()
Takes over another CPU&#39;s thread.
Definition: rob_impl.hh:146
void drainSanityCheck() const
Perform sanity checks after a drain.
Definition: rob_impl.hh:137
std::list< ThreadID > * activeThreads
Active Threads in CPU.
Definition: rob.hh:274
bool canCommit()
Is there any commitable head instruction across all threads ready.
Definition: rob_impl.hh:290
bool isFull()
Returns if the ROB is full.
Definition: rob.hh:180
unsigned threadEntries[Impl::MaxThreads]
Entries Per Thread.
Definition: rob.hh:280
void doSquash(ThreadID tid)
Executes the squash, marking squashed instructions.
Definition: rob_impl.hh:323
void retireHead(ThreadID tid)
Retires the head instruction, removing it from the ROB.
Definition: rob_impl.hh:243
SMTQueuePolicy robPolicy
ROB resource sharing policy for SMT mode.
Definition: rob.hh:84
STL pair class.
Definition: stl.hh:61
void resetState()
Reset the ROB state.
Definition: rob_impl.hh:104
int numInstsInROB
Number of instructions in the ROB.
Definition: rob.hh:314
InstIt head
Iterator pointing to the instruction which is the first instruction in in the ROB.
Definition: rob.hh:300
Status robStatus[Impl::MaxThreads]
Per-thread ROB status.
Definition: rob.hh:81
Status
Possible ROB statuses.
Definition: rob.hh:73
ROB(O3CPU *_cpu, DerivO3CPUParams *params)
ROB constructor.
Definition: rob_impl.hh:58
bool isDoneSquashing()
Checks if the ROB is still in the process of squashing instructions for any thread.
ThreadID numThreads
Number of active threads.
Definition: rob.hh:327
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_impl.hh:549
InstIt tail
Iterator pointing to the instruction which is the last instruction in the ROB.
Definition: rob.hh:296
void updateHead()
Updates the head instruction with the new oldest instruction.
Definition: rob_impl.hh:400
InstSeqNum squashedSeqNum[Impl::MaxThreads]
The sequence number of the squashed instruction.
Definition: rob.hh:321
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2508
bool isEmpty() const
Returns if the ROB is empty.
Definition: rob.hh:188
const DynInstPtr & readHeadInst(ThreadID tid)
Returns pointer to the head instruction within the ROB.
Definition: rob_impl.hh:510
std::string name() const
Definition: rob_impl.hh:122
DynInstPtr readTailInst(ThreadID tid)
Returns pointer to the tail instruction within the ROB.
Definition: rob_impl.hh:525
Impl::DynInstPtr DynInstPtr
Definition: rob.hh:67
std::pair< RegIndex, PhysRegIndex > UnmapInfo
Definition: rob.hh:69
std::list< DynInstPtr >::iterator InstIt
Definition: rob.hh:70
unsigned numFreeEntries()
Returns the number of total free entries in the ROB.
Definition: rob_impl.hh:309
std::list< DynInstPtr > instList[Impl::MaxThreads]
ROB List of Instructions.
Definition: rob.hh:286
unsigned getThreadEntries(ThreadID tid)
Returns the number of entries being used by a specific thread.
Definition: rob.hh:176
void setActiveThreads(std::list< ThreadID > *at_ptr)
Sets pointer to the list of active threads.
Definition: rob_impl.hh:129
InstIt squashIt[Impl::MaxThreads]
Iterator used for walking through the list of instructions when squashing.
Definition: rob.hh:310
uint64_t InstSeqNum
Definition: inst_seq.hh:40
STL list class.
Definition: stl.hh:54
void updateTail()
Updates the tail instruction with the new youngest instruction.
Definition: rob_impl.hh:442
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
bool isDoneSquashing(ThreadID tid) const
Reads the PC of the oldest head instruction.
Definition: rob.hh:243
void squash(InstSeqNum squash_num, ThreadID tid)
Squashes all instructions younger than the given sequence number for the specific thread...
Definition: rob_impl.hh:480
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:227
void regStats()
Registers statistics.
Definition: rob_impl.hh:535
bool isEmpty(ThreadID tid) const
Returns if a specific thread&#39;s partition is empty.
Definition: rob.hh:192
O3CPU * cpu
Pointer to the CPU.
Definition: rob.hh:271
Stats::Scalar robWrites
Definition: rob.hh:332
void resetEntries()
Re-adjust ROB partitioning.
Definition: rob_impl.hh:153
Impl::O3CPU O3CPU
Definition: rob.hh:66
bool isHeadReady(ThreadID tid)
Is the oldest instruction across all threads ready.
Definition: rob_impl.hh:278
bool doneSquashing[Impl::MaxThreads]
Is the ROB done squashing.
Definition: rob.hh:324
int countInsts()
This is more of a debugging function than anything.
Definition: rob_impl.hh:187
unsigned getMaxEntries(ThreadID tid)
Returns the maximum number of entries for a specific thread.
Definition: rob.hh:172
Stats::Scalar robReads
Definition: rob.hh:330
unsigned squashWidth
Number of instructions that can be squashed in a single cycle.
Definition: rob.hh:289
Definition: rob.hh:75
DynInstPtr dummyInst
Dummy instruction returned if there are no insts left.
Definition: rob.hh:317
bool isFull(ThreadID tid)
Returns if a specific thread&#39;s partition is full.
Definition: rob.hh:184
unsigned numEntries
Number of instructions in the ROB.
Definition: rob.hh:277
ROB class.
Definition: rob.hh:62
void insertInst(const DynInstPtr &inst)
Function to insert an instruction into the ROB.
Definition: rob_impl.hh:206
int entryAmount(ThreadID num_threads)
Number of entries needed For &#39;num_threads&#39; amount of threads.
Definition: rob_impl.hh:176
unsigned maxEntries[Impl::MaxThreads]
Max Insts a Thread Can Have in the ROB.
Definition: rob.hh:283

Generated on Fri Feb 28 2020 16:26:59 for gem5 by doxygen 1.8.13