gem5  v21.1.0.2
decode.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_DECODE_HH__
42 #define __CPU_O3_DECODE_HH__
43 
44 #include <queue>
45 
46 #include "base/statistics.hh"
47 #include "cpu/o3/comm.hh"
48 #include "cpu/o3/dyn_inst_ptr.hh"
49 #include "cpu/o3/limits.hh"
50 #include "cpu/timebuf.hh"
51 
52 namespace gem5
53 {
54 
55 struct O3CPUParams;
56 
57 namespace o3
58 {
59 
60 class CPU;
61 
69 class Decode
70 {
71  public:
76  {
79  };
80 
83  {
90  };
91 
92  private:
95 
98 
99  public:
101  Decode(CPU *_cpu, const O3CPUParams &params);
102 
103  void startupStage();
104 
106  void clearStates(ThreadID tid);
107 
108  void resetStage();
109 
111  std::string name() const;
112 
115 
118 
121 
124 
126  void drainSanityCheck() const;
127 
129  bool isDrained() const;
130 
132  void takeOverFrom() { resetStage(); }
133 
137  void tick();
138 
144  void decode(bool &status_change, ThreadID tid);
145 
151  void decodeInsts(ThreadID tid);
152 
153  private:
157  void skidInsert(ThreadID tid);
158 
160  bool skidsEmpty();
161 
163  void updateStatus();
164 
168  void sortInsts();
169 
171  void readStallSignals(ThreadID tid);
172 
175 
177  bool checkStall(ThreadID tid) const;
178 
180  bool fetchInstsValid();
181 
186  bool block(ThreadID tid);
187 
192  bool unblock(ThreadID tid);
193 
197  void squash(const DynInstPtr &inst, ThreadID tid);
198 
199  public:
203  unsigned squash(ThreadID tid);
204 
205  private:
206  // Interfaces to objects outside of decode.
209 
212 
215 
218 
221 
223  // Might not be the best name as not only fetch will read it.
225 
228 
231 
234 
237 
239  std::queue<DynInstPtr> insts[MaxThreads];
240 
242  std::queue<DynInstPtr> skidBuffer[MaxThreads];
243 
248 
250  struct Stalls
251  {
252  bool rename;
253  };
254 
257 
260 
263 
266 
269 
271  unsigned decodeWidth;
272 
274  unsigned toRenameIndex;
275 
278 
281 
283  unsigned skidBufferMax;
284 
287 
290 
296 
298  {
299  DecodeStats(CPU *cpu);
300 
323  } stats;
324 };
325 
326 } // namespace o3
327 } // namespace gem5
328 
329 #endif // __CPU_O3_DECODE_HH__
gem5::statistics::Scalar
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:1927
gem5::o3::Decode::skidBufferMax
unsigned skidBufferMax
Maximum size of the skid buffer.
Definition: decode.hh:283
gem5::o3::Decode::updateStatus
void updateStatus()
Updates overall decode status based on all of the threads' statuses.
Definition: decode.cc:428
gem5::o3::Decode::Inactive
@ Inactive
Definition: decode.hh:78
gem5::o3::Decode::sortInsts
void sortInsts()
Separates instructions from fetch into individual lists of instructions sorted by thread.
Definition: decode.cc:466
gem5::o3::Decode::commitToDecodeDelay
Cycles commitToDecodeDelay
Commit to decode delay.
Definition: decode.hh:265
gem5::o3::Decode::setActiveThreads
void setActiveThreads(std::list< ThreadID > *at_ptr)
Sets pointer to list of active threads.
Definition: decode.cc:192
gem5::o3::Decode::block
bool block(ThreadID tid)
Switches decode to blocking, and signals back that decode has become blocked.
Definition: decode.cc:237
gem5::o3::Decode::activeThreads
std::list< ThreadID > * activeThreads
List of active thread ids.
Definition: decode.hh:280
gem5::o3::Decode::squashAfterDelaySlot
bool squashAfterDelaySlot[MaxThreads]
Tells when their is a pending delay slot inst.
Definition: decode.hh:295
gem5::o3::Decode::DecodeStats::branchResolved
statistics::Scalar branchResolved
Stat for number of times a branch is resolved at decode.
Definition: decode.hh:312
gem5::o3::Decode::clearStates
void clearStates(ThreadID tid)
Clear all thread-specific states.
Definition: decode.cc:98
gem5::o3::Decode::skidBuffer
std::queue< DynInstPtr > skidBuffer[MaxThreads]
Skid buffer between fetch and decode.
Definition: decode.hh:242
gem5::o3::Decode::fetchInstsValid
bool fetchInstsValid()
Returns if there any instructions from fetch on this cycle.
Definition: decode.cc:231
gem5::o3::Decode::Blocked
@ Blocked
Definition: decode.hh:88
gem5::o3::Decode::DecodeStats::runCycles
statistics::Scalar runCycles
Stat for total number of normal running cycles.
Definition: decode.hh:306
gem5::o3::Decode::cpu
CPU * cpu
CPU interface.
Definition: decode.hh:208
gem5::o3::Decode::stats
gem5::o3::Decode::DecodeStats stats
gem5::o3::Decode::DecodeStats::controlMispred
statistics::Scalar controlMispred
Stat for number of times decode detected a non-control instruction incorrectly predicted as a branch.
Definition: decode.hh:318
gem5::o3::Decode::StartSquash
@ StartSquash
Definition: decode.hh:86
gem5::o3::Decode::fromRename
TimeBuffer< TimeStruct >::wire fromRename
Wire to get rename's output from backwards time buffer.
Definition: decode.hh:214
gem5::o3::Decode::DecodeStats::branchMispred
statistics::Scalar branchMispred
Stat for number of times a branch mispredict is detected.
Definition: decode.hh:314
gem5::o3::Decode::timeBuffer
TimeBuffer< TimeStruct > * timeBuffer
Time buffer interface.
Definition: decode.hh:211
gem5::RefCountingPtr< DynInst >
gem5::TimeBuffer
Definition: timebuf.hh:40
gem5::o3::Decode::wroteToTimeBuffer
bool wroteToTimeBuffer
Variable that tracks if decode has written to the time buffer this cycle.
Definition: decode.hh:247
gem5::o3::Decode::decode
void decode(bool &status_change, ThreadID tid)
Determines what to do based on decode's current status.
Definition: decode.cc:579
gem5::Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:78
gem5::o3::Decode::DecodeStats
Definition: decode.hh:297
gem5::o3::Decode::DecodeStats::DecodeStats
DecodeStats(CPU *cpu)
Definition: decode.cc:123
gem5::o3::Decode::numThreads
ThreadID numThreads
number of Active Threads
Definition: decode.hh:277
timebuf.hh
gem5::o3::Decode::Decode
Decode(CPU *_cpu, const O3CPUParams &params)
Decode constructor.
Definition: decode.cc:65
gem5::o3::Decode::skidsEmpty
bool skidsEmpty()
Returns if all of the skid buffers are empty.
Definition: decode.cc:413
comm.hh
gem5::o3::Decode::Unblocking
@ Unblocking
Definition: decode.hh:89
gem5::o3::Decode::resetStage
void resetStage()
Definition: decode.cc:105
gem5::o3::Decode::takeOverFrom
void takeOverFrom()
Takes over from another CPU's thread.
Definition: decode.hh:132
gem5::o3::Decode::tick
void tick()
Ticks decode, processing all input signals and decoding as many instructions as possible.
Definition: decode.cc:544
gem5::o3::Decode::fromCommit
TimeBuffer< TimeStruct >::wire fromCommit
Wire to get commit's information from backwards time buffer.
Definition: decode.hh:220
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:95
gem5::o3::Decode::Active
@ Active
Definition: decode.hh:77
gem5::o3::Decode::checkSignalsAndUpdate
bool checkSignalsAndUpdate(ThreadID tid)
Checks all input signals and updates decode's status appropriately.
Definition: decode.cc:488
gem5::o3::Decode::DecodeStats::unblockCycles
statistics::Scalar unblockCycles
Stat for total number of unblocking cycles.
Definition: decode.hh:308
gem5::o3::Decode::DecodeStatus
DecodeStatus
Overall decode stage status.
Definition: decode.hh:75
gem5::o3::Decode::squash
void squash(const DynInstPtr &inst, ThreadID tid)
Squashes if there is a PC-relative branch that was predicted incorrectly.
Definition: decode.cc:284
gem5::o3::Decode::DecodeStats::decodedInsts
statistics::Scalar decodedInsts
Stat for total number of decoded instructions.
Definition: decode.hh:320
gem5::o3::Decode::DecodeStats::blockedCycles
statistics::Scalar blockedCycles
Stat for total number of blocked cycles.
Definition: decode.hh:304
statistics.hh
gem5::o3::Decode::isDrained
bool isDrained() const
Has the stage drained?
Definition: decode.cc:207
gem5::o3::Decode::DecodeStats::idleCycles
statistics::Scalar idleCycles
Stat for total number of idle cycles.
Definition: decode.hh:302
gem5::o3::Decode::Stalls::rename
bool rename
Definition: decode.hh:252
gem5::o3::Decode::toRenameIndex
unsigned toRenameIndex
Index of instructions being sent to rename.
Definition: decode.hh:274
gem5::o3::Decode::toRename
TimeBuffer< DecodeStruct >::wire toRename
Wire used to write any information heading to rename.
Definition: decode.hh:230
gem5::o3::Decode::fromIEW
TimeBuffer< TimeStruct >::wire fromIEW
Wire to get iew's information from backwards time buffer.
Definition: decode.hh:217
gem5::o3::Decode::stalls
Stalls stalls[MaxThreads]
Tracks which stages are telling decode to stall.
Definition: decode.hh:256
gem5::o3::Decode::insts
std::queue< DynInstPtr > insts[MaxThreads]
Queue of all instructions coming from fetch this cycle.
Definition: decode.hh:239
gem5::o3::Decode::bdelayDoneSeqNum
Addr bdelayDoneSeqNum[MaxThreads]
SeqNum of Squashing Branch Delay Instruction (used for MIPS)
Definition: decode.hh:286
gem5::o3::Decode::Running
@ Running
Definition: decode.hh:84
gem5::o3::Decode::skidInsert
void skidInsert(ThreadID tid)
Inserts a thread's instructions into the skid buffer, to be decoded once decode unblocks.
Definition: decode.cc:389
gem5::o3::Decode::unblock
bool unblock(ThreadID tid)
Switches decode to unblocking if the skid buffer is empty, and signals back that decode has unblocked...
Definition: decode.cc:266
gem5::o3::Decode::DecodeStats::squashCycles
statistics::Scalar squashCycles
Stat for total number of squashing cycles.
Definition: decode.hh:310
gem5::o3::Decode::checkStall
bool checkStall(ThreadID tid) const
Checks all stall signals, and returns if any are true.
Definition: decode.cc:218
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::o3::Decode::DecodeStats::squashedInsts
statistics::Scalar squashedInsts
Stat for total number of squashed instructions.
Definition: decode.hh:322
dyn_inst_ptr.hh
gem5::o3::Decode::toFetch
TimeBuffer< TimeStruct >::wire toFetch
Wire to write information heading to previous stages.
Definition: decode.hh:224
gem5::o3::Decode::decodeQueue
TimeBuffer< DecodeStruct > * decodeQueue
Decode instruction queue.
Definition: decode.hh:227
gem5::o3::MaxThreads
static constexpr int MaxThreads
Definition: limits.hh:38
gem5::o3::Decode::setTimeBuffer
void setTimeBuffer(TimeBuffer< TimeStruct > *tb_ptr)
Sets the main backwards communication time buffer pointer.
Definition: decode.cc:160
gem5::o3::Decode::_status
DecodeStatus _status
Decode status.
Definition: decode.hh:94
gem5::o3::Decode::decodeStatus
ThreadStatus decodeStatus[MaxThreads]
Per-thread status.
Definition: decode.hh:97
gem5::o3::Decode
Decode class handles both single threaded and SMT decode.
Definition: decode.hh:69
gem5::o3::Decode::fetchQueue
TimeBuffer< FetchStruct > * fetchQueue
Fetch instruction queue interface.
Definition: decode.hh:233
gem5::o3::Decode::setDecodeQueue
void setDecodeQueue(TimeBuffer< DecodeStruct > *dq_ptr)
Sets pointer to time buffer used to communicate to the next stage.
Definition: decode.cc:174
gem5::o3::Decode::fromFetch
TimeBuffer< FetchStruct >::wire fromFetch
Wire to get fetch's output from fetch queue.
Definition: decode.hh:236
gem5::o3::Decode::drainSanityCheck
void drainSanityCheck() const
Perform sanity checks after a drain.
Definition: decode.cc:198
gem5::o3::Decode::Squashing
@ Squashing
Definition: decode.hh:87
gem5::statistics::Group
Statistics container.
Definition: group.hh:93
gem5::o3::Decode::Stalls
Source of possible stalls.
Definition: decode.hh:250
gem5::o3::Decode::readStallSignals
void readStallSignals(ThreadID tid)
Reads all stall signals from the backwards communication timebuffer.
Definition: decode.cc:475
gem5::o3::Decode::decodeInsts
void decodeInsts(ThreadID tid)
Processes instructions from fetch and passes them on to rename.
Definition: decode.cc:623
gem5::o3::Decode::renameToDecodeDelay
Cycles renameToDecodeDelay
Rename to decode delay.
Definition: decode.hh:259
gem5::o3::Decode::squashInst
DynInstPtr squashInst[MaxThreads]
Instruction used for squashing branch (used for MIPS)
Definition: decode.hh:289
gem5::o3::Decode::decodeWidth
unsigned decodeWidth
The width of decode, in instructions.
Definition: decode.hh:271
gem5::o3::Decode::setFetchQueue
void setFetchQueue(TimeBuffer< FetchStruct > *fq_ptr)
Sets pointer to time buffer coming from fetch.
Definition: decode.cc:183
gem5::o3::Decode::fetchToDecodeDelay
Cycles fetchToDecodeDelay
Fetch to decode delay.
Definition: decode.hh:268
std::list< ThreadID >
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::o3::Decode::startupStage
void startupStage()
Definition: decode.cc:92
limits.hh
gem5::o3::Decode::Idle
@ Idle
Definition: decode.hh:85
gem5::o3::Decode::name
std::string name() const
Returns the name of decode.
Definition: decode.cc:118
gem5::o3::Decode::ThreadStatus
ThreadStatus
Individual thread status.
Definition: decode.hh:82
gem5::o3::Decode::iewToDecodeDelay
Cycles iewToDecodeDelay
IEW to decode delay.
Definition: decode.hh:262
gem5::ThreadID
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:242
gem5::TimeBuffer::wire
Definition: timebuf.hh:59

Generated on Tue Sep 21 2021 12:25:01 for gem5 by doxygen 1.8.17