2 // Add a couple of the branch fields to DynInst. Figure out where DynInst
3 // should try to compute the target of a PC-relative branch. Try to avoid
4 // having so many returns within the code.
5 // Fix up squashing too, as it's too
6 // dependent upon the iew stage continually telling it to squash.
8 #ifndef __CPU_BETA_CPU_SIMPLE_DECODE_HH__
9 #define __CPU_BETA_CPU_SIMPLE_DECODE_HH__
13 #include "base/statistics.hh"
14 #include "base/timebuf.hh"
20 // Typedefs from the Impl.
21 typedef typename Impl::ISA ISA;
22 typedef typename Impl::FullCPU FullCPU;
23 typedef typename Impl::DynInstPtr DynInstPtr;
24 typedef typename Impl::Params Params;
25 typedef typename Impl::CPUPol CPUPol;
27 // Typedefs from the CPU policy.
28 typedef typename CPUPol::FetchStruct FetchStruct;
29 typedef typename CPUPol::DecodeStruct DecodeStruct;
30 typedef typename CPUPol::TimeStruct TimeStruct;
32 // Typedefs from the ISA.
33 typedef typename ISA::Addr Addr;
36 // The only time decode will become blocked is if dispatch becomes
37 // blocked, which means IQ or ROB is probably full.
47 // May eventually need statuses on a per thread basis.
51 SimpleDecode(Params ¶ms);
55 void setCPU(FullCPU *cpu_ptr);
57 void setTimeBuffer(TimeBuffer<TimeStruct> *tb_ptr);
59 void setDecodeQueue(TimeBuffer<DecodeStruct> *dq_ptr);
61 void setFetchQueue(TimeBuffer<FetchStruct> *fq_ptr);
67 // Might want to make squash a friend function.
73 inline void unblock();
75 void squash(DynInstPtr &inst);
77 // Interfaces to objects outside of decode.
81 /** Time buffer interface. */
82 TimeBuffer<TimeStruct> *timeBuffer;
84 /** Wire to get rename's output from backwards time buffer. */
85 typename TimeBuffer<TimeStruct>::wire fromRename;
87 /** Wire to get iew's information from backwards time buffer. */
88 typename TimeBuffer<TimeStruct>::wire fromIEW;
90 /** Wire to get commit's information from backwards time buffer. */
91 typename TimeBuffer<TimeStruct>::wire fromCommit;
93 /** Wire to write information heading to previous stages. */
94 // Might not be the best name as not only fetch will read it.
95 typename TimeBuffer<TimeStruct>::wire toFetch;
97 /** Decode instruction queue. */
98 TimeBuffer<DecodeStruct> *decodeQueue;
100 /** Wire used to write any information heading to rename. */
101 typename TimeBuffer<DecodeStruct>::wire toRename;
103 /** Fetch instruction queue interface. */
104 TimeBuffer<FetchStruct> *fetchQueue;
106 /** Wire to get fetch's output from fetch queue. */
107 typename TimeBuffer<FetchStruct>::wire fromFetch;
109 /** Skid buffer between fetch and decode. */
110 std::queue<FetchStruct> skidBuffer;
113 //Consider making these unsigned to avoid any confusion.
114 /** Rename to decode delay, in ticks. */
115 unsigned renameToDecodeDelay;
117 /** IEW to decode delay, in ticks. */
118 unsigned iewToDecodeDelay;
120 /** Commit to decode delay, in ticks. */
121 unsigned commitToDecodeDelay;
123 /** Fetch to decode delay, in ticks. */
124 unsigned fetchToDecodeDelay;
126 /** The width of decode, in instructions. */
127 unsigned decodeWidth;
129 /** The instruction that decode is currently on. It needs to have
130 * persistent state so that when a stall occurs in the middle of a
131 * group of instructions, it can restart at the proper instruction.
135 Stats::Scalar<> decodeIdleCycles;
136 Stats::Scalar<> decodeBlockedCycles;
137 Stats::Scalar<> decodeUnblockCycles;
138 Stats::Scalar<> decodeSquashCycles;
139 Stats::Scalar<> decodeBranchMispred;
140 Stats::Scalar<> decodeControlMispred;
141 Stats::Scalar<> decodeDecodedInsts;
142 Stats::Scalar<> decodeSquashedInsts;
145 #endif // __CPU_BETA_CPU_SIMPLE_DECODE_HH__