gem5  v20.1.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 "arch/registers.hh"
49 #include "base/types.hh"
50 #include "config/the_isa.hh"
51 #include "enums/SMTQueuePolicy.hh"
52 
53 struct DerivO3CPUParams;
54 
58 template <class Impl>
59 class ROB
60 {
61  public:
62  //Typedefs from the Impl.
63  typedef typename Impl::O3CPU O3CPU;
64  typedef typename Impl::DynInstPtr DynInstPtr;
65 
68 
70  enum Status {
74  };
75 
76  private:
78  Status robStatus[Impl::MaxThreads];
79 
81  SMTQueuePolicy robPolicy;
82 
83  public:
88  ROB(O3CPU *_cpu, DerivO3CPUParams *params);
89 
90  std::string name() const;
91 
96 
98  void drainSanityCheck() const;
99 
101  void takeOverFrom();
102 
108  void insertInst(const DynInstPtr &inst);
109 
114 // DynInstPtr readHeadInst();
115 
120  const DynInstPtr &readHeadInst(ThreadID tid);
121 
125  DynInstPtr findInst(ThreadID tid, InstSeqNum squash_inst);
126 
131 // DynInstPtr readTailInst();
132 
138 
140 // void retireHead();
141 
145  void retireHead(ThreadID tid);
146 
148 // bool isHeadReady();
149 
151  bool isHeadReady(ThreadID tid);
152 
154  bool canCommit();
155 
157  void resetEntries();
158 
160  int entryAmount(ThreadID num_threads);
161 
163  unsigned numFreeEntries();
164 
166  unsigned numFreeEntries(ThreadID tid);
167 
169  unsigned getMaxEntries(ThreadID tid)
170  { return maxEntries[tid]; }
171 
174  { return threadEntries[tid]; }
175 
177  bool isFull()
178  { return numInstsInROB == numEntries; }
179 
181  bool isFull(ThreadID tid)
182  { return threadEntries[tid] == numEntries; }
183 
185  bool isEmpty() const
186  { return numInstsInROB == 0; }
187 
189  bool isEmpty(ThreadID tid) const
190  { return threadEntries[tid] == 0; }
191 
193  void doSquash(ThreadID tid);
194 
198  void squash(InstSeqNum squash_num, ThreadID tid);
199 
201  void updateHead();
202 
204  void updateTail();
205 
207 // uint64_t readHeadPC();
208 
210 // uint64_t readHeadPC(ThreadID tid);
211 
213 // uint64_t readHeadNextPC();
214 
216 // uint64_t readHeadNextPC(ThreadID tid);
217 
219 // InstSeqNum readHeadSeqNum();
220 
223 // InstSeqNum readHeadSeqNum(ThreadID tid);
224 
226 // uint64_t readTailPC();
227 
229 // uint64_t readTailPC(ThreadID tid);
230 
232 // InstSeqNum readTailSeqNum();
233 
235 // InstSeqNum readTailSeqNum(ThreadID tid);
236 
240  bool isDoneSquashing(ThreadID tid) const
241  { return doneSquashing[tid]; }
242 
246  bool isDoneSquashing();
247 
252  int countInsts();
253 
258  size_t countInsts(ThreadID tid);
259 
260  private:
262  void resetState();
263 
266 
269 
271  unsigned numEntries;
272 
274  unsigned threadEntries[Impl::MaxThreads];
275 
277  unsigned maxEntries[Impl::MaxThreads];
278 
280  std::list<DynInstPtr> instList[Impl::MaxThreads];
281 
283  unsigned squashWidth;
284 
285  public:
291 
295 
296  private:
304  InstIt squashIt[Impl::MaxThreads];
305 
306  public:
309 
312 
313  private:
315  InstSeqNum squashedSeqNum[Impl::MaxThreads];
316 
318  bool doneSquashing[Impl::MaxThreads];
319 
322 
323 
324  struct ROBStats : public Stats::Group {
325  ROBStats(Stats::Group *parent);
326 
327  // The number of rob_reads
329  // The number of rob_writes
331  } stats;
332 };
333 
334 #endif //__CPU_O3_ROB_HH__
ROB::squashIt
InstIt squashIt[Impl::MaxThreads]
Iterator used for walking through the list of instructions when squashing.
Definition: rob.hh:304
ROB::resetEntries
void resetEntries()
Re-adjust ROB partitioning.
Definition: rob_impl.hh:151
ROB::O3CPU
Impl::O3CPU O3CPU
Definition: rob.hh:63
ROB::head
InstIt head
Iterator pointing to the instruction which is the first instruction in in the ROB.
Definition: rob.hh:294
ROB::activeThreads
std::list< ThreadID > * activeThreads
Active Threads in CPU.
Definition: rob.hh:268
ROB::isDoneSquashing
bool isDoneSquashing(ThreadID tid) const
Reads the PC of the oldest head instruction.
Definition: rob.hh:240
ROB::Status
Status
Possible ROB statuses.
Definition: rob.hh:70
ThreadID
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:227
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_impl.hh:541
ROB::squash
void squash(InstSeqNum squash_num, ThreadID tid)
Squashes all instructions younger than the given sequence number for the specific thread.
Definition: rob_impl.hh:478
ROB::updateHead
void updateHead()
Updates the head instruction with the new oldest instruction.
Definition: rob_impl.hh:398
ROB::readTailInst
DynInstPtr readTailInst(ThreadID tid)
Returns pointer to the tail instruction within the ROB.
Definition: rob_impl.hh:523
ROB::getMaxEntries
unsigned getMaxEntries(ThreadID tid)
Returns the maximum number of entries for a specific thread.
Definition: rob.hh:169
ROB::readHeadInst
const DynInstPtr & readHeadInst(ThreadID tid)
Returns pointer to the head instruction within the ROB.
Definition: rob_impl.hh:508
ROB::name
std::string name() const
Definition: rob_impl.hh:120
ROB::updateTail
void updateTail()
Updates the tail instruction with the new youngest instruction.
Definition: rob_impl.hh:440
ROB::maxEntries
unsigned maxEntries[Impl::MaxThreads]
Max Insts a Thread Can Have in the ROB.
Definition: rob.hh:277
ROB::dummyInst
DynInstPtr dummyInst
Dummy instruction returned if there are no insts left.
Definition: rob.hh:311
ROB::numThreads
ThreadID numThreads
Number of active threads.
Definition: rob.hh:321
ROB::instList
std::list< DynInstPtr > instList[Impl::MaxThreads]
ROB List of Instructions.
Definition: rob.hh:280
ROB::Idle
@ Idle
Definition: rob.hh:72
ROB::ROB
ROB(O3CPU *_cpu, DerivO3CPUParams *params)
ROB constructor.
Definition: rob_impl.hh:55
Stats::Scalar
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2533
ROB::entryAmount
int entryAmount(ThreadID num_threads)
Number of entries needed For 'num_threads' amount of threads.
Definition: rob_impl.hh:174
ROB::Running
@ Running
Definition: rob.hh:71
ROB::numInstsInROB
int numInstsInROB
Number of instructions in the ROB.
Definition: rob.hh:308
ROB::UnmapInfo
std::pair< RegIndex, PhysRegIndex > UnmapInfo
Definition: rob.hh:66
ROB::takeOverFrom
void takeOverFrom()
Takes over another CPU's thread.
Definition: rob_impl.hh:144
ROB::drainSanityCheck
void drainSanityCheck() const
Perform sanity checks after a drain.
Definition: rob_impl.hh:135
ROB::canCommit
bool canCommit()
Is there any commitable head instruction across all threads ready.
Definition: rob_impl.hh:288
ROB::doSquash
void doSquash(ThreadID tid)
Executes the squash, marking squashed instructions.
Definition: rob_impl.hh:321
ROB::isEmpty
bool isEmpty(ThreadID tid) const
Returns if a specific thread's partition is empty.
Definition: rob.hh:189
ROB::ROBStats::ROBStats
ROBStats(Stats::Group *parent)
Definition: rob_impl.hh:532
ROB::tail
InstIt tail
Iterator pointing to the instruction which is the last instruction in the ROB.
Definition: rob.hh:290
ROB::getThreadEntries
unsigned getThreadEntries(ThreadID tid)
Returns the number of entries being used by a specific thread.
Definition: rob.hh:173
std::pair
STL pair class.
Definition: stl.hh:58
InstSeqNum
uint64_t InstSeqNum
Definition: inst_seq.hh:37
ROB::isHeadReady
bool isHeadReady(ThreadID tid)
Is the oldest instruction across all threads ready.
Definition: rob_impl.hh:276
ROB::ROBSquashing
@ ROBSquashing
Definition: rob.hh:73
ROB::resetState
void resetState()
Reset the ROB state.
Definition: rob_impl.hh:102
ROB::squashedSeqNum
InstSeqNum squashedSeqNum[Impl::MaxThreads]
The sequence number of the squashed instruction.
Definition: rob.hh:315
ROB::cpu
O3CPU * cpu
Pointer to the CPU.
Definition: rob.hh:265
ROB::DynInstPtr
Impl::DynInstPtr DynInstPtr
Definition: rob.hh:64
ROB::doneSquashing
bool doneSquashing[Impl::MaxThreads]
Is the ROB done squashing.
Definition: rob.hh:318
ROB::stats
ROB::ROBStats stats
ROB::InstIt
std::list< DynInstPtr >::iterator InstIt
Definition: rob.hh:67
ROB::squashWidth
unsigned squashWidth
Number of instructions that can be squashed in a single cycle.
Definition: rob.hh:283
ROB::ROBStats::writes
Stats::Scalar writes
Definition: rob.hh:330
ROB::robStatus
Status robStatus[Impl::MaxThreads]
Per-thread ROB status.
Definition: rob.hh:78
ROB::threadEntries
unsigned threadEntries[Impl::MaxThreads]
Entries Per Thread.
Definition: rob.hh:274
types.hh
ROB::retireHead
void retireHead(ThreadID tid)
Retires the head instruction, removing it from the ROB.
Definition: rob_impl.hh:241
ROB::isDoneSquashing
bool isDoneSquashing()
Checks if the ROB is still in the process of squashing instructions for any thread.
Stats::Group
Statistics container.
Definition: group.hh:83
ROB::numEntries
unsigned numEntries
Number of instructions in the ROB.
Definition: rob.hh:271
ROB::isFull
bool isFull(ThreadID tid)
Returns if a specific thread's partition is full.
Definition: rob.hh:181
ROB::countInsts
int countInsts()
This is more of a debugging function than anything.
Definition: rob_impl.hh:185
ROB::isEmpty
bool isEmpty() const
Returns if the ROB is empty.
Definition: rob.hh:185
std::list
STL list class.
Definition: stl.hh:51
ROB::ROBStats::reads
Stats::Scalar reads
Definition: rob.hh:328
ROB::numFreeEntries
unsigned numFreeEntries()
Returns the number of total free entries in the ROB.
Definition: rob_impl.hh:307
ROB
ROB class.
Definition: rob.hh:59
ROB::robPolicy
SMTQueuePolicy robPolicy
ROB resource sharing policy for SMT mode.
Definition: rob.hh:81
ROB::isFull
bool isFull()
Returns if the ROB is full.
Definition: rob.hh:177
ROB::insertInst
void insertInst(const DynInstPtr &inst)
Function to insert an instruction into the ROB.
Definition: rob_impl.hh:204
ROB::ROBStats
Definition: rob.hh:324
ROB::setActiveThreads
void setActiveThreads(std::list< ThreadID > *at_ptr)
Sets pointer to the list of active threads.
Definition: rob_impl.hh:127

Generated on Wed Sep 30 2020 14:02:09 for gem5 by doxygen 1.8.17