gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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  * Authors: Kevin Lim
41  */
42 
43 #ifndef __CPU_O3_DECODE_HH__
44 #define __CPU_O3_DECODE_HH__
45 
46 #include <queue>
47 
48 #include "base/statistics.hh"
49 #include "cpu/timebuf.hh"
50 
51 struct DerivO3CPUParams;
52 
60 template<class Impl>
62 {
63  private:
64  // Typedefs from the Impl.
65  typedef typename Impl::O3CPU O3CPU;
66  typedef typename Impl::DynInstPtr DynInstPtr;
67  typedef typename Impl::CPUPol CPUPol;
68 
69  // Typedefs from the CPU policy.
70  typedef typename CPUPol::FetchStruct FetchStruct;
71  typedef typename CPUPol::DecodeStruct DecodeStruct;
72  typedef typename CPUPol::TimeStruct TimeStruct;
73 
74  public:
78  enum DecodeStatus {
81  };
82 
84  enum ThreadStatus {
91  };
92 
93  private:
96 
98  ThreadStatus decodeStatus[Impl::MaxThreads];
99 
100  public:
102  DefaultDecode(O3CPU *_cpu, DerivO3CPUParams *params);
103 
104  void startupStage();
105 
107  void clearStates(ThreadID tid);
108 
109  void resetStage();
110 
112  std::string name() const;
113 
115  void regStats();
116 
119 
122 
125 
128 
130  void drainSanityCheck() const;
131 
133  bool isDrained() const;
134 
136  void takeOverFrom() { resetStage(); }
137 
141  void tick();
142 
148  void decode(bool &status_change, ThreadID tid);
149 
155  void decodeInsts(ThreadID tid);
156 
157  private:
161  void skidInsert(ThreadID tid);
162 
164  bool skidsEmpty();
165 
167  void updateStatus();
168 
172  void sortInsts();
173 
175  void readStallSignals(ThreadID tid);
176 
179 
181  bool checkStall(ThreadID tid) const;
182 
184  inline bool fetchInstsValid();
185 
190  bool block(ThreadID tid);
191 
196  bool unblock(ThreadID tid);
197 
201  void squash(const DynInstPtr &inst, ThreadID tid);
202 
203  public:
207  unsigned squash(ThreadID tid);
208 
209  private:
210  // Interfaces to objects outside of decode.
212  O3CPU *cpu;
213 
216 
219 
222 
225 
227  // Might not be the best name as not only fetch will read it.
229 
232 
235 
238 
241 
243  std::queue<DynInstPtr> insts[Impl::MaxThreads];
244 
246  std::queue<DynInstPtr> skidBuffer[Impl::MaxThreads];
247 
252 
254  struct Stalls {
255  bool rename;
256  };
257 
259  Stalls stalls[Impl::MaxThreads];
260 
263 
266 
269 
272 
274  unsigned decodeWidth;
275 
277  unsigned toRenameIndex;
278 
281 
284 
286  unsigned skidBufferMax;
287 
289  Addr bdelayDoneSeqNum[Impl::MaxThreads];
290 
292  DynInstPtr squashInst[Impl::MaxThreads];
293 
298  bool squashAfterDelaySlot[Impl::MaxThreads];
299 
300 
323 };
324 
325 #endif // __CPU_O3_DECODE_HH__
TimeBuffer< TimeStruct > * timeBuffer
Time buffer interface.
Definition: decode.hh:215
void resetStage()
Definition: decode_impl.hh:104
Cycles fetchToDecodeDelay
Fetch to decode delay.
Definition: decode.hh:271
void decode(bool &status_change, ThreadID tid)
Determines what to do based on decode&#39;s current status.
Definition: decode_impl.hh:602
ThreadID numThreads
number of Active Threads
Definition: decode.hh:280
unsigned toRenameIndex
Index of instructions being sent to rename.
Definition: decode.hh:277
void setDecodeQueue(TimeBuffer< DecodeStruct > *dq_ptr)
Sets pointer to time buffer used to communicate to the next stage.
Definition: decode_impl.hh:187
bool wroteToTimeBuffer
Variable that tracks if decode has written to the time buffer this cycle.
Definition: decode.hh:251
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
void sortInsts()
Separates instructions from fetch into individual lists of instructions sorted by thread...
Definition: decode_impl.hh:485
DynInstPtr squashInst[Impl::MaxThreads]
Instruction used for squashing branch (used for MIPS)
Definition: decode.hh:292
Stalls stalls[Impl::MaxThreads]
Tracks which stages are telling decode to stall.
Definition: decode.hh:259
bool squashAfterDelaySlot[Impl::MaxThreads]
Tells when their is a pending delay slot inst.
Definition: decode.hh:298
Cycles iewToDecodeDelay
IEW to decode delay.
Definition: decode.hh:265
Stats::Scalar decodeBlockedCycles
Stat for total number of blocked cycles.
Definition: decode.hh:304
void takeOverFrom()
Takes over from another CPU&#39;s thread.
Definition: decode.hh:136
DecodeStatus
Overall decode stage status.
Definition: decode.hh:78
TimeBuffer< DecodeStruct >::wire toRename
Wire used to write any information heading to rename.
Definition: decode.hh:234
void tick()
Ticks decode, processing all input signals and decoding as many instructions as possible.
Definition: decode_impl.hh:566
void startupStage()
Definition: decode_impl.hh:89
DefaultDecode(O3CPU *_cpu, DerivO3CPUParams *params)
DefaultDecode constructor.
Definition: decode_impl.hh:62
DefaultDecode class handles both single threaded and SMT decode.
Definition: decode.hh:61
bool isDrained() const
Has the stage drained?
Definition: decode_impl.hh:224
bool skidsEmpty()
Returns if all of the skid buffers are empty.
Definition: decode_impl.hh:430
void skidInsert(ThreadID tid)
Inserts a thread&#39;s instructions into the skid buffer, to be decoded once decode unblocks.
Definition: decode_impl.hh:406
unsigned decodeWidth
The width of decode, in instructions.
Definition: decode.hh:274
Declaration of Statistics objects.
TimeBuffer< TimeStruct >::wire fromIEW
Wire to get iew&#39;s information from backwards time buffer.
Definition: decode.hh:221
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2508
Stats::Scalar decodeUnblockCycles
Stat for total number of unblocking cycles.
Definition: decode.hh:308
void regStats()
Registers statistics.
Definition: decode_impl.hh:125
CPUPol::FetchStruct FetchStruct
Definition: decode.hh:70
ThreadStatus decodeStatus[Impl::MaxThreads]
Per-thread status.
Definition: decode.hh:98
unsigned skidBufferMax
Maximum size of the skid buffer.
Definition: decode.hh:286
TimeBuffer< TimeStruct >::wire fromRename
Wire to get rename&#39;s output from backwards time buffer.
Definition: decode.hh:218
std::list< ThreadID > * activeThreads
List of active thread ids.
Definition: decode.hh:283
Stats::Scalar decodeSquashCycles
Stat for total number of squashing cycles.
Definition: decode.hh:310
Impl::CPUPol CPUPol
Definition: decode.hh:67
void clearStates(ThreadID tid)
Clear all thread-specific states.
Definition: decode_impl.hh:96
Stats::Scalar decodeControlMispred
Stat for number of times decode detected a non-control instruction incorrectly predicted as a branch...
Definition: decode.hh:318
CPUPol::DecodeStruct DecodeStruct
Definition: decode.hh:71
void squash(const DynInstPtr &inst, ThreadID tid)
Squashes if there is a PC-relative branch that was predicted incorrectly.
Definition: decode_impl.hh:306
TimeBuffer< DecodeStruct > * decodeQueue
Decode instruction queue.
Definition: decode.hh:231
void drainSanityCheck() const
Perform sanity checks after a drain.
Definition: decode_impl.hh:214
Addr bdelayDoneSeqNum[Impl::MaxThreads]
SeqNum of Squashing Branch Delay Instruction (used for MIPS)
Definition: decode.hh:289
Stats::Scalar decodeBranchResolved
Stat for number of times a branch is resolved at decode.
Definition: decode.hh:312
void readStallSignals(ThreadID tid)
Reads all stall signals from the backwards communication timebuffer.
Definition: decode_impl.hh:495
TimeBuffer< TimeStruct >::wire fromCommit
Wire to get commit&#39;s information from backwards time buffer.
Definition: decode.hh:224
Impl::DynInstPtr DynInstPtr
Definition: decode.hh:66
Stats::Scalar decodeIdleCycles
Stat for total number of idle cycles.
Definition: decode.hh:302
O3CPU * cpu
CPU interface.
Definition: decode.hh:212
bool checkStall(ThreadID tid) const
Checks all stall signals, and returns if any are true.
Definition: decode_impl.hh:236
Stats::Scalar decodeSquashedInsts
Stat for total number of squashed instructions.
Definition: decode.hh:322
bool block(ThreadID tid)
Switches decode to blocking, and signals back that decode has become blocked.
Definition: decode_impl.hh:257
void setActiveThreads(std::list< ThreadID > *at_ptr)
Sets pointer to list of active threads.
Definition: decode_impl.hh:207
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
Source of possible stalls.
Definition: decode.hh:254
void decodeInsts(ThreadID tid)
Processes instructions from fetch and passes them on to rename.
Definition: decode_impl.hh:647
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:227
TimeBuffer< TimeStruct >::wire toFetch
Wire to write information heading to previous stages.
Definition: decode.hh:228
std::queue< DynInstPtr > insts[Impl::MaxThreads]
Queue of all instructions coming from fetch this cycle.
Definition: decode.hh:243
std::queue< DynInstPtr > skidBuffer[Impl::MaxThreads]
Skid buffer between fetch and decode.
Definition: decode.hh:246
Stats::Scalar decodeBranchMispred
Stat for number of times a branch mispredict is detected.
Definition: decode.hh:314
bool checkSignalsAndUpdate(ThreadID tid)
Checks all input signals and updates decode&#39;s status appropriately.
Definition: decode_impl.hh:509
DecodeStatus _status
Decode status.
Definition: decode.hh:95
CPUPol::TimeStruct TimeStruct
Definition: decode.hh:72
Cycles commitToDecodeDelay
Commit to decode delay.
Definition: decode.hh:268
Stats::Scalar decodeRunCycles
Stat for total number of normal running cycles.
Definition: decode.hh:306
void setFetchQueue(TimeBuffer< FetchStruct > *fq_ptr)
Sets pointer to time buffer coming from fetch.
Definition: decode_impl.hh:197
bool unblock(ThreadID tid)
Switches decode to unblocking if the skid buffer is empty, and signals back that decode has unblocked...
Definition: decode_impl.hh:287
Impl::O3CPU O3CPU
Definition: decode.hh:65
ThreadStatus
Individual thread status.
Definition: decode.hh:84
TimeBuffer< FetchStruct >::wire fromFetch
Wire to get fetch&#39;s output from fetch queue.
Definition: decode.hh:240
Stats::Scalar decodeDecodedInsts
Stat for total number of decoded instructions.
Definition: decode.hh:320
void updateStatus()
Updates overall decode status based on all of the threads&#39; statuses.
Definition: decode_impl.hh:446
TimeBuffer< FetchStruct > * fetchQueue
Fetch instruction queue interface.
Definition: decode.hh:237
std::string name() const
Returns the name of decode.
Definition: decode_impl.hh:118
Cycles renameToDecodeDelay
Rename to decode delay.
Definition: decode.hh:262
void setTimeBuffer(TimeBuffer< TimeStruct > *tb_ptr)
Sets the main backwards communication time buffer pointer.
Definition: decode_impl.hh:172
bool fetchInstsValid()
Returns if there any instructions from fetch on this cycle.
Definition: decode_impl.hh:250

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