gem5  v22.1.0.0
iew.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2012, 2014, 2019 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_IEW_HH__
42 #define __CPU_O3_IEW_HH__
43 
44 #include <queue>
45 #include <set>
46 
47 #include "base/statistics.hh"
48 #include "cpu/o3/comm.hh"
49 #include "cpu/o3/dyn_inst_ptr.hh"
50 #include "cpu/o3/inst_queue.hh"
51 #include "cpu/o3/limits.hh"
52 #include "cpu/o3/lsq.hh"
53 #include "cpu/o3/scoreboard.hh"
54 #include "cpu/timebuf.hh"
55 #include "debug/IEW.hh"
56 #include "sim/probe/probe.hh"
57 
58 namespace gem5
59 {
60 
61 struct BaseO3CPUParams;
62 
63 namespace o3
64 {
65 
66 class FUPool;
67 
87 class IEW
88 {
89  public:
93  enum Status
94  {
96  Inactive
97  };
98 
101  {
107  Unblocking
108  };
109 
110  private:
119 
127 
128  public:
130  IEW(CPU *_cpu, const BaseO3CPUParams &params);
131 
133  std::string name() const;
134 
136  void regProbePoints();
137 
139  void startupStage();
140 
142  void clearStates(ThreadID tid);
143 
146 
149 
151  void setIEWQueue(TimeBuffer<IEWStruct> *iq_ptr);
152 
155 
157  void setScoreboard(Scoreboard *sb_ptr);
158 
160  void drainSanityCheck() const;
161 
163  bool isDrained() const;
164 
166  void takeOverFrom();
167 
169  void squash(ThreadID tid);
170 
172  void wakeDependents(const DynInstPtr &inst);
173 
177  void rescheduleMemInst(const DynInstPtr &inst);
178 
180  void replayMemInst(const DynInstPtr &inst);
181 
183  void blockMemInst(const DynInstPtr &inst);
184 
186  void cacheUnblocked();
187 
189  void instToCommit(const DynInstPtr &inst);
190 
192  void skidInsert(ThreadID tid);
193 
195  int skidCount();
196 
198  bool skidsEmpty();
199 
201  void updateStatus();
202 
204  void resetEntries();
205 
209  void wakeCPU();
210 
212  void activityThisCycle();
213 
215  void activateStage();
216 
218  void deactivateStage();
219 
221  bool hasStoresToWB() { return ldstQueue.hasStoresToWB(); }
222 
224  bool hasStoresToWB(ThreadID tid) { return ldstQueue.hasStoresToWB(tid); }
225 
227  void checkMisprediction(const DynInstPtr &inst);
228 
229  // hardware transactional memory
230  // For debugging purposes, it is useful to keep track of the most recent
231  // htmUid that has been committed (architecturally, not transactionally)
232  // to ensure that the core and the memory subsystem are observing
233  // correct ordering constraints.
234  void setLastRetiredHtmUid(ThreadID tid, uint64_t htmUid)
235  {
236  ldstQueue.setLastRetiredHtmUid(tid, htmUid);
237  }
238 
239  private:
243  void squashDueToBranch(const DynInstPtr &inst, ThreadID tid);
244 
248  void squashDueToMemOrder(const DynInstPtr &inst, ThreadID tid);
249 
251  void block(ThreadID tid);
252 
256  void unblock(ThreadID tid);
257 
259  void dispatch(ThreadID tid);
260 
262  void dispatchInsts(ThreadID tid);
263 
268  void executeInsts();
269 
275  void writebackInsts();
276 
278  bool checkStall(ThreadID tid);
279 
282 
284  void emptyRenameInsts(ThreadID tid);
285 
287  void sortInsts();
288 
289  public:
293  void tick();
294 
295  private:
297  void updateExeInstStats(const DynInstPtr &inst);
298 
301 
304 
307 
310 
313 
316 
319 
322 
328 
331 
333  std::queue<DynInstPtr> insts[MaxThreads];
334 
336  std::queue<DynInstPtr> skidBuffer[MaxThreads];
337 
340 
341  private:
344 
349 
351  void printAvailableInsts();
352 
353  public:
356 
359 
366 
367  private:
370 
375 
378 
381 
388 
390  unsigned dispatchWidth;
391 
393  unsigned issueWidth;
394 
396  unsigned wbNumInst;
397 
403  unsigned wbCycle;
404 
406  unsigned wbWidth;
407 
410 
413 
415  unsigned skidBufferMax;
416 
417 
418  struct IEWStats : public statistics::Group
419  {
420  IEWStats(CPU *cpu);
421 
453 
455  {
457 
478 
492 };
493 
494 } // namespace o3
495 } // namespace gem5
496 
497 #endif // __CPU_O3_IEW_HH__
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:79
ProbePointArg generates a point for the class of Arg.
Definition: probe.hh:264
O3CPU class, has each of the stages (fetch through commit) within it, as well as all of the time buff...
Definition: cpu.hh:94
Pool of FU's, specific to the new CPU model.
Definition: fu_pool.hh:76
IEW handles both single threaded and SMT IEW (issue/execute/writeback).
Definition: iew.hh:88
void printAvailableInsts()
Debug function to print instructions that are issued this cycle.
Definition: iew.cc:1113
Status
Overall IEW stage status.
Definition: iew.hh:94
@ Inactive
Definition: iew.hh:96
@ Active
Definition: iew.hh:95
void updateStatus()
Updates overall IEW status based on all of the stages' statuses.
Definition: iew.cc:650
void deactivateStage()
Tells CPU that the IEW stage is inactive and idle.
Definition: iew.cc:823
TimeBuffer< IEWStruct > * iewQueue
IEW stage time buffer.
Definition: iew.hh:327
void resetEntries()
Resets entries of the IQ and the LSQ.
TimeBuffer< TimeStruct >::wire fromCommit
Wire to get commit's output from backwards time buffer.
Definition: iew.hh:306
StageStatus dispatchStatus[MaxThreads]
Dispatch status.
Definition: iew.hh:114
std::list< ThreadID > * activeThreads
Pointer to list of active threads.
Definition: iew.hh:412
void takeOverFrom()
Takes over from another CPU's thread.
Definition: iew.cc:391
void setTimeBuffer(TimeBuffer< TimeStruct > *tb_ptr)
Sets main time buffer used for backwards communication.
Definition: iew.cc:304
int skidCount()
Returns the max of the number of entries in all of the skid buffers.
Definition: iew.cc:616
void instToCommit(const DynInstPtr &inst)
Sends an instruction to commit through the time buffer.
Definition: iew.cc:567
FUPool * fuPool
Pointer to the functional unit pool.
Definition: iew.hh:361
void squashDueToBranch(const DynInstPtr &inst, ThreadID tid)
Sends commit proper information for a squash due to a branch mispredict.
Definition: iew.cc:453
void squashDueToMemOrder(const DynInstPtr &inst, ThreadID tid)
Sends commit proper information for a squash due to a memory order violation.
Definition: iew.cc:477
unsigned wbWidth
Writeback width.
Definition: iew.hh:406
std::queue< DynInstPtr > insts[MaxThreads]
Queue of all instructions coming from rename this cycle.
Definition: iew.hh:333
void block(ThreadID tid)
Sets Dispatch to blocked, and signals back to other stages to block.
Definition: iew.cc:503
StageStatus exeStatus
Execute status.
Definition: iew.hh:116
void clearStates(ThreadID tid)
Clear all thread-specific states.
Definition: iew.cc:292
void dispatch(ThreadID tid)
Determines proper actions to take given Dispatch's status.
Definition: iew.cc:830
void startupStage()
Initializes stage; sends back the number of free IQ and LSQ entries.
Definition: iew.cc:269
void blockMemInst(const DynInstPtr &inst)
Moves memory instruction onto the list of cache blocked instructions.
Definition: iew.cc:555
void unblock(ThreadID tid)
Unblocks Dispatch if the skid buffer is empty, and signals back to other stages to unblock.
Definition: iew.cc:521
void sortInsts()
Sorts instructions coming from rename into lists separated by thread.
Definition: iew.cc:769
void wakeDependents(const DynInstPtr &inst)
Wakes all dependents of a completed instruction.
Definition: iew.cc:537
unsigned issueWidth
Width of issue, in instructions.
Definition: iew.hh:393
void updateExeInstStats(const DynInstPtr &inst)
Updates execution stats based on the instruction.
Definition: iew.cc:1560
void dispatchInsts(ThreadID tid)
Dispatches instructions to IQ and LSQ.
Definition: iew.cc:877
void drainSanityCheck() const
Perform sanity checks after a drain.
Definition: iew.cc:382
TimeBuffer< IssueStruct > issueToExecQueue
Issue stage queue.
Definition: iew.hh:318
void checkSignalsAndUpdate(ThreadID tid)
Processes inputs and changes state accordingly.
Definition: iew.cc:706
void activateStage()
Tells CPU that the IEW stage is active and running.
Definition: iew.cc:816
TimeBuffer< TimeStruct >::wire toRename
Wire to write information heading to previous stages.
Definition: iew.hh:309
bool wroteToTimeBuffer
Records if IEW has written to the time buffer this cycle, so that the CPU can deschedule itself if th...
Definition: iew.hh:348
CPU * cpu
CPU pointer.
Definition: iew.hh:343
void activityThisCycle()
Reports to the CPU that there is activity this cycle.
Definition: iew.cc:809
void setScoreboard(Scoreboard *sb_ptr)
Sets pointer to the scoreboard.
Definition: iew.cc:348
Scoreboard * scoreboard
Scoreboard pointer.
Definition: iew.hh:339
std::queue< DynInstPtr > skidBuffer[MaxThreads]
Skid buffer between rename and IEW.
Definition: iew.hh:336
TimeBuffer< IssueStruct >::wire fromIssue
Wire to read information from the issue stage time queue.
Definition: iew.hh:321
Cycles renameToIEWDelay
Rename to IEW delay.
Definition: iew.hh:380
TimeBuffer< TimeStruct > * timeBuffer
Pointer to main time buffer used for backwards communication.
Definition: iew.hh:300
void writebackInsts()
Writebacks instructions.
Definition: iew.cc:1381
void wakeCPU()
Tells the CPU to wakeup if it has descheduled itself due to no activity.
Definition: iew.cc:803
void squash(ThreadID tid)
Squashes instructions in IEW for a specific thread.
Definition: iew.cc:418
void setIEWQueue(TimeBuffer< IEWStruct > *iq_ptr)
Sets time buffer to pass on instructions to commit.
Definition: iew.cc:330
ProbePointArg< DynInstPtr > * ppExecute
To probe when instruction execution begins.
Definition: iew.hh:124
void rescheduleMemInst(const DynInstPtr &inst)
Tells memory dependence unit that a memory instruction needs to be rescheduled.
Definition: iew.cc:543
ThreadID numThreads
Number of active threads.
Definition: iew.hh:409
unsigned skidBufferMax
Maximum size of the skid buffer.
Definition: iew.hh:415
Status _status
Overall stage status.
Definition: iew.hh:112
TimeBuffer< RenameStruct >::wire fromRename
Wire to get rename's output from rename queue.
Definition: iew.hh:315
ProbePointArg< DynInstPtr > * ppMispredict
Probe points.
Definition: iew.hh:121
TimeBuffer< TimeStruct >::wire toFetch
Wire to write information heading to previous stages.
Definition: iew.hh:303
gem5::o3::IEW::IEWStats iewStats
void setLastRetiredHtmUid(ThreadID tid, uint64_t htmUid)
Definition: iew.hh:234
bool isDrained() const
Has the stage drained?
Definition: iew.cc:354
InstructionQueue instQueue
Instruction queue.
Definition: iew.hh:355
bool fetchRedirect[MaxThreads]
Records if there is a fetch redirect on this cycle for each thread.
Definition: iew.hh:369
TimeBuffer< RenameStruct > * renameQueue
Rename instruction queue interface.
Definition: iew.hh:312
IEW(CPU *_cpu, const BaseO3CPUParams &params)
Constructs a IEW with the given parameters.
Definition: iew.cc:67
unsigned dispatchWidth
Width of dispatch, in instructions.
Definition: iew.hh:390
ProbePointArg< DynInstPtr > * ppDispatch
Definition: iew.hh:122
std::string name() const
Returns the name of the IEW stage.
Definition: iew.cc:118
void tick()
Ticks IEW stage, causing Dispatch, the IQ, the LSQ, Execute, and Writeback to run for one cycle.
Definition: iew.cc:1431
bool hasStoresToWB(ThreadID tid)
Returns if the LSQ has any stores to writeback.
Definition: iew.hh:224
ProbePointArg< DynInstPtr > * ppToCommit
To probe when instruction execution is complete.
Definition: iew.hh:126
bool updatedQueues
Records if the queues have been changed (inserted or issued insts), so that IEW knows to broadcast th...
Definition: iew.hh:374
bool hasStoresToWB()
Returns if the LSQ has any stores to writeback.
Definition: iew.hh:221
void checkMisprediction(const DynInstPtr &inst)
Check misprediction
Definition: iew.cc:1591
LSQ ldstQueue
Load / store queue.
Definition: iew.hh:358
Cycles issueToExecuteDelay
Issue to execute delay.
Definition: iew.hh:387
void setActiveThreads(std::list< ThreadID > *at_ptr)
Sets pointer to list of active threads.
Definition: iew.cc:339
bool skidsEmpty()
Returns if all of the skid buffers are empty.
Definition: iew.cc:634
bool updateLSQNextCycle
Records if the LSQ needs to be updated on the next cycle, so that IEW knows if there will be activity...
Definition: iew.hh:365
void emptyRenameInsts(ThreadID tid)
Removes instructions from rename from a thread's instruction list.
Definition: iew.cc:782
void replayMemInst(const DynInstPtr &inst)
Re-executes all rescheduled memory instructions.
Definition: iew.cc:549
Cycles commitToIEWDelay
Commit to IEW delay.
Definition: iew.hh:377
unsigned wbCycle
Cycle number within the queue of instructions being written back.
Definition: iew.hh:403
void skidInsert(ThreadID tid)
Inserts unused instructions of a thread into the skid buffer.
Definition: iew.cc:595
void cacheUnblocked()
Notifies that the cache has become unblocked.
Definition: iew.cc:561
TimeBuffer< IEWStruct >::wire toCommit
Wire to write infromation heading to commit.
Definition: iew.hh:330
void regProbePoints()
Registers probes.
Definition: iew.cc:124
bool checkStall(ThreadID tid)
Checks if any of the stall conditions are currently true.
Definition: iew.cc:690
void executeInsts()
Executes instructions.
Definition: iew.cc:1135
unsigned wbNumInst
Index into queue of instructions being written back.
Definition: iew.hh:396
void setRenameQueue(TimeBuffer< RenameStruct > *rq_ptr)
Sets time buffer for getting instructions coming from rename.
Definition: iew.cc:321
StageStatus wbStatus
Writeback status.
Definition: iew.hh:118
StageStatus
Status for Issue, Execute, and Writeback stages.
Definition: iew.hh:101
@ Unblocking
Definition: iew.hh:107
@ StartSquash
Definition: iew.hh:105
@ Squashing
Definition: iew.hh:106
A standard instruction queue class.
Definition: inst_queue.hh:99
void setLastRetiredHtmUid(ThreadID tid, uint64_t htmUid)
Definition: lsq.cc:377
bool hasStoresToWB()
Returns whether or not there are any stores to write back to memory.
Definition: lsq.cc:714
Implements a simple scoreboard to track which registers are ready.
Definition: scoreboard.hh:55
A formula for statistics that is calculated when printed.
Definition: statistics.hh:2540
Statistics container.
Definition: group.hh:94
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:1931
A vector of scalar stats.
Definition: statistics.hh:2007
static constexpr int MaxThreads
Definition: limits.hh:38
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:235
Declaration of Statistics objects.
statistics::Formula numStoreInsts
Number of executed store instructions.
Definition: iew.hh:474
statistics::Vector numLoadInsts
Stat for total number of executed load instructions.
Definition: iew.hh:461
statistics::Vector numSwp
Number of executed software prefetches.
Definition: iew.hh:466
statistics::Vector numBranches
Number of executed branches.
Definition: iew.hh:472
statistics::Scalar numInsts
Stat for total number of executed instructions.
Definition: iew.hh:459
statistics::Vector numRefs
Number of executed meomory references.
Definition: iew.hh:470
statistics::Scalar numSquashedInsts
Stat for total number of squashed instructions skipped at execute.
Definition: iew.hh:464
statistics::Vector numNop
Number of executed nops.
Definition: iew.hh:468
statistics::Formula numRate
Number of instructions executed per cycle.
Definition: iew.hh:476
statistics::Scalar dispatchedInsts
Stat for total number of instructions dispatched.
Definition: iew.hh:431
statistics::Formula wbFanout
Average number of woken instructions per writeback.
Definition: iew.hh:490
statistics::Scalar squashCycles
Stat for total number of squashing cycles.
Definition: iew.hh:425
statistics::Vector consumerInst
Number of instructions that wake up from producers.
Definition: iew.hh:486
statistics::Scalar predictedNotTakenIncorrect
Stat for total number of incorrect predicted not taken branches.
Definition: iew.hh:449
statistics::Scalar dispLoadInsts
Stat for total number of dispatched load instructions.
Definition: iew.hh:435
statistics::Scalar dispNonSpecInsts
Stat for total number of dispatched non speculative insts.
Definition: iew.hh:439
statistics::Scalar idleCycles
Stat for total number of idle cycles.
Definition: iew.hh:423
statistics::Vector instsToCommit
Number of instructions sent to commit.
Definition: iew.hh:480
gem5::o3::IEW::IEWStats::ExecutedInstStats executedInstStats
statistics::Formula wbRate
Number of instructions per cycle written back.
Definition: iew.hh:488
statistics::Scalar dispSquashedInsts
Stat for total number of squashed instructions dispatch skips.
Definition: iew.hh:433
statistics::Scalar predictedTakenIncorrect
Stat for total number of incorrect predicted taken branches.
Definition: iew.hh:447
statistics::Scalar blockCycles
Stat for total number of blocking cycles.
Definition: iew.hh:427
statistics::Vector writebackCount
Number of instructions that writeback.
Definition: iew.hh:482
statistics::Scalar memOrderViolationEvents
Stat for total number of memory ordering violation events.
Definition: iew.hh:445
statistics::Vector producerInst
Number of instructions that wake consumers.
Definition: iew.hh:484
IEWStats(CPU *cpu)
Definition: iew.cc:144
statistics::Scalar iqFullEvents
Stat for number of times the IQ becomes full.
Definition: iew.hh:441
statistics::Scalar unblockCycles
Stat for total number of unblocking cycles.
Definition: iew.hh:429
statistics::Scalar lsqFullEvents
Stat for number of times the LSQ becomes full.
Definition: iew.hh:443
statistics::Formula branchMispredicts
Stat for total number of mispredicted branches detected at execute.
Definition: iew.hh:452
statistics::Scalar dispStoreInsts
Stat for total number of dispatched store instructions.
Definition: iew.hh:437

Generated on Wed Dec 21 2022 10:22:30 for gem5 by doxygen 1.9.1