decode.hh revision 1060
1// Todo:
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.
7
8#ifndef __SIMPLE_DECODE_HH__
9#define __SIMPLE_DECODE_HH__
10
11#include <queue>
12
13//Will want to include: time buffer, structs,
14#include "base/timebuf.hh"
15#include "cpu/beta_cpu/comm.hh"
16
17using namespace std;
18
19template<class Impl>
20class SimpleDecode
21{
22  private:
23    // Typedefs from the Impl.
24    typedef typename Impl::ISA ISA;
25    typedef typename Impl::DynInst DynInst;
26    typedef typename Impl::FullCPU FullCPU;
27    typedef typename Impl::Params Params;
28
29    typedef typename Impl::FetchStruct FetchStruct;
30    typedef typename Impl::DecodeStruct DecodeStruct;
31    typedef typename Impl::TimeStruct TimeStruct;
32
33    // Typedefs from the ISA.
34    typedef typename ISA::Addr Addr;
35
36  public:
37    // The only time decode will become blocked is if dispatch becomes
38    // blocked, which means IQ or ROB is probably full.
39    enum Status {
40        Running,
41        Idle,
42        Squashing,
43        Blocked,
44        Unblocking
45    };
46
47  private:
48    // May eventually need statuses on a per thread basis.
49    Status _status;
50
51  public:
52    SimpleDecode(Params &params);
53
54    void setCPU(FullCPU *cpu_ptr);
55
56    void setTimeBuffer(TimeBuffer<TimeStruct> *tb_ptr);
57
58    void setDecodeQueue(TimeBuffer<DecodeStruct> *dq_ptr);
59
60    void setFetchQueue(TimeBuffer<FetchStruct> *fq_ptr);
61
62    void tick();
63
64    void decode();
65
66    // Might want to make squash a friend function.
67    void squash();
68
69  private:
70    void block();
71
72    inline void unblock();
73
74    void squash(DynInst *inst);
75
76    // Interfaces to objects outside of decode.
77    /** CPU interface. */
78    FullCPU *cpu;
79
80    /** Time buffer interface. */
81    TimeBuffer<TimeStruct> *timeBuffer;
82
83    /** Wire to get rename's output from backwards time buffer. */
84    typename TimeBuffer<TimeStruct>::wire fromRename;
85
86    /** Wire to get iew's information from backwards time buffer. */
87    typename TimeBuffer<TimeStruct>::wire fromIEW;
88
89    /** Wire to get commit's information from backwards time buffer. */
90    typename TimeBuffer<TimeStruct>::wire fromCommit;
91
92    /** Wire to write information heading to previous stages. */
93    // Might not be the best name as not only fetch will read it.
94    typename TimeBuffer<TimeStruct>::wire toFetch;
95
96    /** Decode instruction queue. */
97    TimeBuffer<DecodeStruct> *decodeQueue;
98
99    /** Wire used to write any information heading to rename. */
100    typename TimeBuffer<DecodeStruct>::wire toRename;
101
102    /** Fetch instruction queue interface. */
103    TimeBuffer<FetchStruct> *fetchQueue;
104
105    /** Wire to get fetch's output from fetch queue. */
106    typename TimeBuffer<FetchStruct>::wire fromFetch;
107
108    /** Skid buffer between fetch and decode. */
109    queue<FetchStruct> skidBuffer;
110
111  private:
112    //Consider making these unsigned to avoid any confusion.
113    /** Rename to decode delay, in ticks. */
114    unsigned renameToDecodeDelay;
115
116    /** IEW to decode delay, in ticks. */
117    unsigned iewToDecodeDelay;
118
119    /** Commit to decode delay, in ticks. */
120    unsigned commitToDecodeDelay;
121
122    /** Fetch to decode delay, in ticks. */
123    unsigned fetchToDecodeDelay;
124
125    /** The width of decode, in instructions. */
126    unsigned decodeWidth;
127};
128
129#endif // __SIMPLE_DECODE_HH__
130