gem5  v20.1.0.0
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/timebuf.hh"
48 
49 struct DerivO3CPUParams;
50 
58 template<class Impl>
60 {
61  private:
62  // Typedefs from the Impl.
63  typedef typename Impl::O3CPU O3CPU;
64  typedef typename Impl::DynInstPtr DynInstPtr;
65  typedef typename Impl::CPUPol CPUPol;
66 
67  // Typedefs from the CPU policy.
68  typedef typename CPUPol::FetchStruct FetchStruct;
69  typedef typename CPUPol::DecodeStruct DecodeStruct;
70  typedef typename CPUPol::TimeStruct TimeStruct;
71 
72  public:
76  enum DecodeStatus {
79  };
80 
82  enum ThreadStatus {
89  };
90 
91  private:
94 
96  ThreadStatus decodeStatus[Impl::MaxThreads];
97 
98  public:
100  DefaultDecode(O3CPU *_cpu, DerivO3CPUParams *params);
101 
102  void startupStage();
103 
105  void clearStates(ThreadID tid);
106 
107  void resetStage();
108 
110  std::string name() const;
111 
114 
117 
120 
123 
125  void drainSanityCheck() const;
126 
128  bool isDrained() const;
129 
131  void takeOverFrom() { resetStage(); }
132 
136  void tick();
137 
143  void decode(bool &status_change, ThreadID tid);
144 
150  void decodeInsts(ThreadID tid);
151 
152  private:
156  void skidInsert(ThreadID tid);
157 
159  bool skidsEmpty();
160 
162  void updateStatus();
163 
167  void sortInsts();
168 
170  void readStallSignals(ThreadID tid);
171 
174 
176  bool checkStall(ThreadID tid) const;
177 
179  inline bool fetchInstsValid();
180 
185  bool block(ThreadID tid);
186 
191  bool unblock(ThreadID tid);
192 
196  void squash(const DynInstPtr &inst, ThreadID tid);
197 
198  public:
202  unsigned squash(ThreadID tid);
203 
204  private:
205  // Interfaces to objects outside of decode.
208 
211 
214 
217 
220 
222  // Might not be the best name as not only fetch will read it.
224 
227 
230 
233 
236 
238  std::queue<DynInstPtr> insts[Impl::MaxThreads];
239 
241  std::queue<DynInstPtr> skidBuffer[Impl::MaxThreads];
242 
247 
249  struct Stalls {
250  bool rename;
251  };
252 
254  Stalls stalls[Impl::MaxThreads];
255 
258 
261 
264 
267 
269  unsigned decodeWidth;
270 
272  unsigned toRenameIndex;
273 
276 
279 
281  unsigned skidBufferMax;
282 
284  Addr bdelayDoneSeqNum[Impl::MaxThreads];
285 
287  DynInstPtr squashInst[Impl::MaxThreads];
288 
293  bool squashAfterDelaySlot[Impl::MaxThreads];
294 
295  struct DecodeStats : public Stats::Group {
297 
320  } stats;
321 };
322 
323 #endif // __CPU_O3_DECODE_HH__
DefaultDecode::squash
void squash(const DynInstPtr &inst, ThreadID tid)
Squashes if there is a PC-relative branch that was predicted incorrectly.
Definition: decode_impl.hh:288
DefaultDecode::DecodeStats::squashCycles
Stats::Scalar squashCycles
Stat for total number of squashing cycles.
Definition: decode.hh:307
DefaultDecode::bdelayDoneSeqNum
Addr bdelayDoneSeqNum[Impl::MaxThreads]
SeqNum of Squashing Branch Delay Instruction (used for MIPS)
Definition: decode.hh:284
DefaultDecode::timeBuffer
TimeBuffer< TimeStruct > * timeBuffer
Time buffer interface.
Definition: decode.hh:210
DefaultDecode::renameToDecodeDelay
Cycles renameToDecodeDelay
Rename to decode delay.
Definition: decode.hh:257
DefaultDecode::checkStall
bool checkStall(ThreadID tid) const
Checks all stall signals, and returns if any are true.
Definition: decode_impl.hh:218
DefaultDecode::DecodeStats::decodedInsts
Stats::Scalar decodedInsts
Stat for total number of decoded instructions.
Definition: decode.hh:317
DefaultDecode::Squashing
@ Squashing
Definition: decode.hh:86
DefaultDecode::checkSignalsAndUpdate
bool checkSignalsAndUpdate(ThreadID tid)
Checks all input signals and updates decode's status appropriately.
Definition: decode_impl.hh:491
DefaultDecode::TimeStruct
CPUPol::TimeStruct TimeStruct
Definition: decode.hh:70
ThreadID
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:227
DefaultDecode::insts
std::queue< DynInstPtr > insts[Impl::MaxThreads]
Queue of all instructions coming from fetch this cycle.
Definition: decode.hh:238
DefaultDecode::setActiveThreads
void setActiveThreads(std::list< ThreadID > *at_ptr)
Sets pointer to list of active threads.
Definition: decode_impl.hh:189
DefaultDecode::decodeStatus
ThreadStatus decodeStatus[Impl::MaxThreads]
Per-thread status.
Definition: decode.hh:96
DefaultDecode::DecodeStats::runCycles
Stats::Scalar runCycles
Stat for total number of normal running cycles.
Definition: decode.hh:303
DefaultDecode::Stalls
Source of possible stalls.
Definition: decode.hh:249
DefaultDecode::O3CPU
Impl::O3CPU O3CPU
Definition: decode.hh:63
DefaultDecode::iewToDecodeDelay
Cycles iewToDecodeDelay
IEW to decode delay.
Definition: decode.hh:260
DefaultDecode::squashAfterDelaySlot
bool squashAfterDelaySlot[Impl::MaxThreads]
Tells when their is a pending delay slot inst.
Definition: decode.hh:293
DefaultDecode::fromRename
TimeBuffer< TimeStruct >::wire fromRename
Wire to get rename's output from backwards time buffer.
Definition: decode.hh:213
DefaultDecode::DynInstPtr
Impl::DynInstPtr DynInstPtr
Definition: decode.hh:64
TimeBuffer< TimeStruct >
DefaultDecode::name
std::string name() const
Returns the name of decode.
Definition: decode_impl.hh:117
DefaultDecode::drainSanityCheck
void drainSanityCheck() const
Perform sanity checks after a drain.
Definition: decode_impl.hh:196
DefaultDecode::FetchStruct
CPUPol::FetchStruct FetchStruct
Definition: decode.hh:68
DefaultDecode::takeOverFrom
void takeOverFrom()
Takes over from another CPU's thread.
Definition: decode.hh:131
DefaultDecode::toRenameIndex
unsigned toRenameIndex
Index of instructions being sent to rename.
Definition: decode.hh:272
timebuf.hh
Stats::Scalar
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2533
DefaultDecode::setTimeBuffer
void setTimeBuffer(TimeBuffer< TimeStruct > *tb_ptr)
Sets the main backwards communication time buffer pointer.
Definition: decode_impl.hh:154
DefaultDecode::DecodeStruct
CPUPol::DecodeStruct DecodeStruct
Definition: decode.hh:69
DefaultDecode::DecodeStats::unblockCycles
Stats::Scalar unblockCycles
Stat for total number of unblocking cycles.
Definition: decode.hh:305
DefaultDecode::DecodeStats::DecodeStats
DecodeStats(O3CPU *cpu)
Definition: decode_impl.hh:123
DefaultDecode::fromCommit
TimeBuffer< TimeStruct >::wire fromCommit
Wire to get commit's information from backwards time buffer.
Definition: decode.hh:219
DefaultDecode::Active
@ Active
Definition: decode.hh:77
DefaultDecode::skidInsert
void skidInsert(ThreadID tid)
Inserts a thread's instructions into the skid buffer, to be decoded once decode unblocks.
Definition: decode_impl.hh:388
DefaultDecode::resetStage
void resetStage()
Definition: decode_impl.hh:103
DefaultDecode::block
bool block(ThreadID tid)
Switches decode to blocking, and signals back that decode has become blocked.
Definition: decode_impl.hh:239
DefaultDecode::Idle
@ Idle
Definition: decode.hh:84
statistics.hh
DefaultDecode::CPUPol
Impl::CPUPol CPUPol
Definition: decode.hh:65
DefaultDecode::DecodeStats::blockedCycles
Stats::Scalar blockedCycles
Stat for total number of blocked cycles.
Definition: decode.hh:301
DefaultDecode::DecodeStats::controlMispred
Stats::Scalar controlMispred
Stat for number of times decode detected a non-control instruction incorrectly predicted as a branch.
Definition: decode.hh:315
DefaultDecode::activeThreads
std::list< ThreadID > * activeThreads
List of active thread ids.
Definition: decode.hh:278
DefaultDecode::StartSquash
@ StartSquash
Definition: decode.hh:85
DefaultDecode::skidBuffer
std::queue< DynInstPtr > skidBuffer[Impl::MaxThreads]
Skid buffer between fetch and decode.
Definition: decode.hh:241
DefaultDecode::Inactive
@ Inactive
Definition: decode.hh:78
DefaultDecode::ThreadStatus
ThreadStatus
Individual thread status.
Definition: decode.hh:82
DefaultDecode::DecodeStats::idleCycles
Stats::Scalar idleCycles
Stat for total number of idle cycles.
Definition: decode.hh:299
DefaultDecode::DecodeStatus
DecodeStatus
Overall decode stage status.
Definition: decode.hh:76
DefaultDecode::toFetch
TimeBuffer< TimeStruct >::wire toFetch
Wire to write information heading to previous stages.
Definition: decode.hh:223
DefaultDecode::DecodeStats::branchMispred
Stats::Scalar branchMispred
Stat for number of times a branch mispredict is detected.
Definition: decode.hh:311
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
DefaultDecode::cpu
O3CPU * cpu
CPU interface.
Definition: decode.hh:207
DefaultDecode::stalls
Stalls stalls[Impl::MaxThreads]
Tracks which stages are telling decode to stall.
Definition: decode.hh:254
DefaultDecode::_status
DecodeStatus _status
Decode status.
Definition: decode.hh:93
DefaultDecode::fromFetch
TimeBuffer< FetchStruct >::wire fromFetch
Wire to get fetch's output from fetch queue.
Definition: decode.hh:235
DefaultDecode::fetchInstsValid
bool fetchInstsValid()
Returns if there any instructions from fetch on this cycle.
Definition: decode_impl.hh:232
DefaultDecode::clearStates
void clearStates(ThreadID tid)
Clear all thread-specific states.
Definition: decode_impl.hh:95
DefaultDecode::Stalls::rename
bool rename
Definition: decode.hh:250
DefaultDecode::startupStage
void startupStage()
Definition: decode_impl.hh:88
DefaultDecode::toRename
TimeBuffer< DecodeStruct >::wire toRename
Wire used to write any information heading to rename.
Definition: decode.hh:229
DefaultDecode::updateStatus
void updateStatus()
Updates overall decode status based on all of the threads' statuses.
Definition: decode_impl.hh:428
DefaultDecode::sortInsts
void sortInsts()
Separates instructions from fetch into individual lists of instructions sorted by thread.
Definition: decode_impl.hh:467
DefaultDecode::decodeInsts
void decodeInsts(ThreadID tid)
Processes instructions from fetch and passes them on to rename.
Definition: decode_impl.hh:629
DefaultDecode::Unblocking
@ Unblocking
Definition: decode.hh:88
DefaultDecode::tick
void tick()
Ticks decode, processing all input signals and decoding as many instructions as possible.
Definition: decode_impl.hh:548
DefaultDecode::Running
@ Running
Definition: decode.hh:83
DefaultDecode::DecodeStats::squashedInsts
Stats::Scalar squashedInsts
Stat for total number of squashed instructions.
Definition: decode.hh:319
DefaultDecode::decodeWidth
unsigned decodeWidth
The width of decode, in instructions.
Definition: decode.hh:269
DefaultDecode::stats
DefaultDecode::DecodeStats stats
DefaultDecode::skidsEmpty
bool skidsEmpty()
Returns if all of the skid buffers are empty.
Definition: decode_impl.hh:412
DefaultDecode
DefaultDecode class handles both single threaded and SMT decode.
Definition: decode.hh:59
Stats::Group
Statistics container.
Definition: group.hh:83
DefaultDecode::decodeQueue
TimeBuffer< DecodeStruct > * decodeQueue
Decode instruction queue.
Definition: decode.hh:226
DefaultDecode::wroteToTimeBuffer
bool wroteToTimeBuffer
Variable that tracks if decode has written to the time buffer this cycle.
Definition: decode.hh:246
DefaultDecode::fetchQueue
TimeBuffer< FetchStruct > * fetchQueue
Fetch instruction queue interface.
Definition: decode.hh:232
DefaultDecode::squashInst
DynInstPtr squashInst[Impl::MaxThreads]
Instruction used for squashing branch (used for MIPS)
Definition: decode.hh:287
DefaultDecode::DecodeStats
Definition: decode.hh:295
Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
DefaultDecode::setFetchQueue
void setFetchQueue(TimeBuffer< FetchStruct > *fq_ptr)
Sets pointer to time buffer coming from fetch.
Definition: decode_impl.hh:179
DefaultDecode::setDecodeQueue
void setDecodeQueue(TimeBuffer< DecodeStruct > *dq_ptr)
Sets pointer to time buffer used to communicate to the next stage.
Definition: decode_impl.hh:169
DefaultDecode::Blocked
@ Blocked
Definition: decode.hh:87
DefaultDecode::isDrained
bool isDrained() const
Has the stage drained?
Definition: decode_impl.hh:206
DefaultDecode::DecodeStats::branchResolved
Stats::Scalar branchResolved
Stat for number of times a branch is resolved at decode.
Definition: decode.hh:309
DefaultDecode::decode
void decode(bool &status_change, ThreadID tid)
Determines what to do based on decode's current status.
Definition: decode_impl.hh:584
DefaultDecode::numThreads
ThreadID numThreads
number of Active Threads
Definition: decode.hh:275
std::list< ThreadID >
DefaultDecode::DefaultDecode
DefaultDecode(O3CPU *_cpu, DerivO3CPUParams *params)
DefaultDecode constructor.
Definition: decode_impl.hh:60
DefaultDecode::unblock
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:269
DefaultDecode::skidBufferMax
unsigned skidBufferMax
Maximum size of the skid buffer.
Definition: decode.hh:281
DefaultDecode::commitToDecodeDelay
Cycles commitToDecodeDelay
Commit to decode delay.
Definition: decode.hh:263
DefaultDecode::fromIEW
TimeBuffer< TimeStruct >::wire fromIEW
Wire to get iew's information from backwards time buffer.
Definition: decode.hh:216
DefaultDecode::fetchToDecodeDelay
Cycles fetchToDecodeDelay
Fetch to decode delay.
Definition: decode.hh:266
DefaultDecode::readStallSignals
void readStallSignals(ThreadID tid)
Reads all stall signals from the backwards communication timebuffer.
Definition: decode_impl.hh:477

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