gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 
55 struct DerivO3CPUParams;
56 
60 template <class Impl>
61 class ROB
62 {
63  protected:
65  public:
66  //Typedefs from the Impl.
67  typedef typename Impl::O3CPU O3CPU;
68  typedef typename Impl::DynInstPtr DynInstPtr;
69 
72 
74  enum Status {
78  };
79 
81  enum ROBPolicy{
85  };
86 
87  private:
89  Status robStatus[Impl::MaxThreads];
90 
93 
94  public:
99  ROB(O3CPU *_cpu, DerivO3CPUParams *params);
100 
101  std::string name() const;
102 
107 
109  void drainSanityCheck() const;
110 
112  void takeOverFrom();
113 
119  void insertInst(DynInstPtr &inst);
120 
125 // DynInstPtr readHeadInst();
126 
132 
136  DynInstPtr findInst(ThreadID tid, InstSeqNum squash_inst);
137 
142 // DynInstPtr readTailInst();
143 
149 
151 // void retireHead();
152 
156  void retireHead(ThreadID tid);
157 
159 // bool isHeadReady();
160 
162  bool isHeadReady(ThreadID tid);
163 
165  bool canCommit();
166 
168  void resetEntries();
169 
171  int entryAmount(ThreadID num_threads);
172 
174  unsigned numFreeEntries();
175 
177  unsigned numFreeEntries(ThreadID tid);
178 
180  unsigned getMaxEntries(ThreadID tid)
181  { return maxEntries[tid]; }
182 
185  { return threadEntries[tid]; }
186 
188  bool isFull()
189  { return numInstsInROB == numEntries; }
190 
192  bool isFull(ThreadID tid)
193  { return threadEntries[tid] == numEntries; }
194 
196  bool isEmpty() const
197  { return numInstsInROB == 0; }
198 
200  bool isEmpty(ThreadID tid) const
201  { return threadEntries[tid] == 0; }
202 
204  void doSquash(ThreadID tid);
205 
209  void squash(InstSeqNum squash_num, ThreadID tid);
210 
212  void updateHead();
213 
215  void updateTail();
216 
218 // uint64_t readHeadPC();
219 
221 // uint64_t readHeadPC(ThreadID tid);
222 
224 // uint64_t readHeadNextPC();
225 
227 // uint64_t readHeadNextPC(ThreadID tid);
228 
230 // InstSeqNum readHeadSeqNum();
231 
234 // InstSeqNum readHeadSeqNum(ThreadID tid);
235 
237 // uint64_t readTailPC();
238 
240 // uint64_t readTailPC(ThreadID tid);
241 
243 // InstSeqNum readTailSeqNum();
244 
246 // InstSeqNum readTailSeqNum(ThreadID tid);
247 
251  bool isDoneSquashing(ThreadID tid) const
252  { return doneSquashing[tid]; }
253 
257  bool isDoneSquashing();
258 
263  int countInsts();
264 
269  int countInsts(ThreadID tid);
270 
272  void regStats();
273 
274  private:
276  void resetState();
277 
280 
283 
285  unsigned numEntries;
286 
288  unsigned threadEntries[Impl::MaxThreads];
289 
291  unsigned maxEntries[Impl::MaxThreads];
292 
294  std::list<DynInstPtr> instList[Impl::MaxThreads];
295 
297  unsigned squashWidth;
298 
299  public:
305 
309 
310  private:
318  InstIt squashIt[Impl::MaxThreads];
319 
320  public:
323 
326 
327  private:
329  InstSeqNum squashedSeqNum[Impl::MaxThreads];
330 
332  bool doneSquashing[Impl::MaxThreads];
333 
336 
337  // The number of rob_reads
339  // The number of rob_writes
341 };
342 
343 #endif //__CPU_O3_ROB_HH__
void takeOverFrom()
Takes over another CPU's thread.
Definition: rob_impl.hh:153
std::list< ThreadID > * activeThreads
Active Threads in CPU.
Definition: rob.hh:282
bool canCommit()
Is there any commitable head instruction across all threads ready.
Definition: rob_impl.hh:297
bool isFull()
Returns if the ROB is full.
Definition: rob.hh:188
unsigned threadEntries[Impl::MaxThreads]
Entries Per Thread.
Definition: rob.hh:288
void doSquash(ThreadID tid)
Executes the squash, marking squashed instructions.
Definition: rob_impl.hh:330
ROBPolicy
SMT ROB Sharing Policy.
Definition: rob.hh:81
void retireHead(ThreadID tid)
Retires the head instruction, removing it from the ROB.
Definition: rob_impl.hh:249
STL pair class.
Definition: stl.hh:61
bool isDoneSquashing(ThreadID tid) const
Reads the PC of the oldest head instruction.
Definition: rob.hh:251
void resetState()
Reset the ROB state.
Definition: rob_impl.hh:111
bool isEmpty(ThreadID tid) const
Returns if a specific thread's partition is empty.
Definition: rob.hh:200
int numInstsInROB
Number of instructions in the ROB.
Definition: rob.hh:322
void insertInst(DynInstPtr &inst)
Function to insert an instruction into the ROB.
Definition: rob_impl.hh:212
InstIt head
Iterator pointing to the instruction which is the first instruction in in the ROB.
Definition: rob.hh:308
Status robStatus[Impl::MaxThreads]
Per-thread ROB status.
Definition: rob.hh:89
bool isEmpty() const
Returns if the ROB is empty.
Definition: rob.hh:196
Status
Possible ROB statuses.
Definition: rob.hh:74
ROB(O3CPU *_cpu, DerivO3CPUParams *params)
ROB constructor.
Definition: rob_impl.hh:57
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:335
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:556
InstIt tail
Iterator pointing to the instruction which is the last instruction in the ROB.
Definition: rob.hh:304
void updateHead()
Updates the head instruction with the new oldest instruction.
Definition: rob_impl.hh:407
InstSeqNum squashedSeqNum[Impl::MaxThreads]
The sequence number of the squashed instruction.
Definition: rob.hh:329
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2475
DynInstPtr readTailInst(ThreadID tid)
Returns pointer to the tail instruction within the ROB.
Definition: rob_impl.hh:532
Impl::DynInstPtr DynInstPtr
Definition: rob.hh:68
std::pair< RegIndex, PhysRegIndex > UnmapInfo
Definition: rob.hh:70
std::list< DynInstPtr >::iterator InstIt
Definition: rob.hh:71
uint8_t RegIndex
Definition: registers.hh:46
TheISA::RegIndex RegIndex
Definition: rob.hh:64
unsigned numFreeEntries()
Returns the number of total free entries in the ROB.
Definition: rob_impl.hh:316
ROBPolicy robPolicy
ROB resource sharing policy for SMT mode.
Definition: rob.hh:92
std::list< DynInstPtr > instList[Impl::MaxThreads]
ROB List of Instructions.
Definition: rob.hh:294
unsigned getThreadEntries(ThreadID tid)
Returns the number of entries being used by a specific thread.
Definition: rob.hh:184
void setActiveThreads(std::list< ThreadID > *at_ptr)
Sets pointer to the list of active threads.
Definition: rob_impl.hh:136
void drainSanityCheck() const
Perform sanity checks after a drain.
Definition: rob_impl.hh:144
InstIt squashIt[Impl::MaxThreads]
Iterator used for walking through the list of instructions when squashing.
Definition: rob.hh:318
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:449
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
std::string name() const
Definition: rob_impl.hh:129
void squash(InstSeqNum squash_num, ThreadID tid)
Squashes all instructions younger than the given sequence number for the specific thread...
Definition: rob_impl.hh:487
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:171
void regStats()
Registers statistics.
Definition: rob_impl.hh:542
O3CPU * cpu
Pointer to the CPU.
Definition: rob.hh:279
Stats::Scalar robWrites
Definition: rob.hh:340
void resetEntries()
Re-adjust ROB partitioning.
Definition: rob_impl.hh:160
Impl::O3CPU O3CPU
Definition: rob.hh:67
bool isHeadReady(ThreadID tid)
Is the oldest instruction across all threads ready.
Definition: rob_impl.hh:285
bool doneSquashing[Impl::MaxThreads]
Is the ROB done squashing.
Definition: rob.hh:332
int countInsts()
This is more of a debugging function than anything.
Definition: rob_impl.hh:193
unsigned getMaxEntries(ThreadID tid)
Returns the maximum number of entries for a specific thread.
Definition: rob.hh:180
Stats::Scalar robReads
Definition: rob.hh:338
unsigned squashWidth
Number of instructions that can be squashed in a single cycle.
Definition: rob.hh:297
Definition: rob.hh:76
DynInstPtr readHeadInst(ThreadID tid)
Returns pointer to the head instruction within the ROB.
Definition: rob_impl.hh:517
DynInstPtr dummyInst
Dummy instruction returned if there are no insts left.
Definition: rob.hh:325
bool isFull(ThreadID tid)
Returns if a specific thread's partition is full.
Definition: rob.hh:192
unsigned numEntries
Number of instructions in the ROB.
Definition: rob.hh:285
ROB class.
Definition: rob.hh:61
int entryAmount(ThreadID num_threads)
Number of entries needed For 'num_threads' amount of threads.
Definition: rob_impl.hh:182
unsigned maxEntries[Impl::MaxThreads]
Max Insts a Thread Can Have in the ROB.
Definition: rob.hh:291

Generated on Fri Jun 9 2017 13:03:44 for gem5 by doxygen 1.8.6