2 * Copyright (c) 2004-2005 The Regents of The University of Michigan
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #ifndef __CPU_BETA_CPU_SIMPLE_DECODE_HH__
30 #define __CPU_BETA_CPU_SIMPLE_DECODE_HH__
34 #include "base/statistics.hh"
35 #include "base/timebuf.hh"
41 // Typedefs from the Impl.
42 typedef typename Impl::ISA ISA;
43 typedef typename Impl::FullCPU FullCPU;
44 typedef typename Impl::DynInstPtr DynInstPtr;
45 typedef typename Impl::Params Params;
46 typedef typename Impl::CPUPol CPUPol;
48 // Typedefs from the CPU policy.
49 typedef typename CPUPol::FetchStruct FetchStruct;
50 typedef typename CPUPol::DecodeStruct DecodeStruct;
51 typedef typename CPUPol::TimeStruct TimeStruct;
53 // Typedefs from the ISA.
54 typedef typename ISA::Addr Addr;
57 // The only time decode will become blocked is if dispatch becomes
58 // blocked, which means IQ or ROB is probably full.
68 // May eventually need statuses on a per thread basis.
72 SimpleDecode(Params ¶ms);
76 void setCPU(FullCPU *cpu_ptr);
78 void setTimeBuffer(TimeBuffer<TimeStruct> *tb_ptr);
80 void setDecodeQueue(TimeBuffer<DecodeStruct> *dq_ptr);
82 void setFetchQueue(TimeBuffer<FetchStruct> *fq_ptr);
89 inline bool fetchInstsValid();
93 inline void unblock();
95 void squash(DynInstPtr &inst);
98 // Might want to make squash a friend function.
102 // Interfaces to objects outside of decode.
103 /** CPU interface. */
106 /** Time buffer interface. */
107 TimeBuffer<TimeStruct> *timeBuffer;
109 /** Wire to get rename's output from backwards time buffer. */
110 typename TimeBuffer<TimeStruct>::wire fromRename;
112 /** Wire to get iew's information from backwards time buffer. */
113 typename TimeBuffer<TimeStruct>::wire fromIEW;
115 /** Wire to get commit's information from backwards time buffer. */
116 typename TimeBuffer<TimeStruct>::wire fromCommit;
118 /** Wire to write information heading to previous stages. */
119 // Might not be the best name as not only fetch will read it.
120 typename TimeBuffer<TimeStruct>::wire toFetch;
122 /** Decode instruction queue. */
123 TimeBuffer<DecodeStruct> *decodeQueue;
125 /** Wire used to write any information heading to rename. */
126 typename TimeBuffer<DecodeStruct>::wire toRename;
128 /** Fetch instruction queue interface. */
129 TimeBuffer<FetchStruct> *fetchQueue;
131 /** Wire to get fetch's output from fetch queue. */
132 typename TimeBuffer<FetchStruct>::wire fromFetch;
134 /** Skid buffer between fetch and decode. */
135 std::queue<FetchStruct> skidBuffer;
137 //Consider making these unsigned to avoid any confusion.
138 /** Rename to decode delay, in ticks. */
139 unsigned renameToDecodeDelay;
141 /** IEW to decode delay, in ticks. */
142 unsigned iewToDecodeDelay;
144 /** Commit to decode delay, in ticks. */
145 unsigned commitToDecodeDelay;
147 /** Fetch to decode delay, in ticks. */
148 unsigned fetchToDecodeDelay;
150 /** The width of decode, in instructions. */
151 unsigned decodeWidth;
153 /** The instruction that decode is currently on. It needs to have
154 * persistent state so that when a stall occurs in the middle of a
155 * group of instructions, it can restart at the proper instruction.
159 Stats::Scalar<> decodeIdleCycles;
160 Stats::Scalar<> decodeBlockedCycles;
161 Stats::Scalar<> decodeUnblockCycles;
162 Stats::Scalar<> decodeSquashCycles;
163 Stats::Scalar<> decodeBranchMispred;
164 Stats::Scalar<> decodeControlMispred;
165 Stats::Scalar<> decodeDecodedInsts;
166 Stats::Scalar<> decodeSquashedInsts;
169 #endif // __CPU_BETA_CPU_SIMPLE_DECODE_HH__