2c2
< * Copyright (c) 2004-2006 The Regents of The University of Michigan
---
> * Copyright (c) 2004-2005 The Regents of The University of Michigan
26a27,28
> *
> * Authors: Kevin Lim
29,30c31,32
< #ifndef __CPU_O3_DECODE_HH__
< #define __CPU_O3_DECODE_HH__
---
> #ifndef __CPU_O3_CPU_SIMPLE_DECODE_HH__
> #define __CPU_O3_CPU_SIMPLE_DECODE_HH__
37,43d38
< /**
< * DefaultDecode class handles both single threaded and SMT
< * decode. Its width is specified by the parameters; each cycles it
< * tries to decode that many instructions. Because instructions are
< * actually decoded when the StaticInst is created, this stage does
< * not do much other than check any PC-relative branches.
< */
45c40
< class DefaultDecode
---
> class SimpleDecode
60,69c55,57
< /** Overall decode stage status. Used to determine if the CPU can
< * deschedule itself due to a lack of activity.
< */
< enum DecodeStatus {
< Active,
< Inactive
< };
<
< /** Individual thread status. */
< enum ThreadStatus {
---
> // The only time decode will become blocked is if dispatch becomes
> // blocked, which means IQ or ROB is probably full.
> enum Status {
72d59
< StartSquash,
79,80c66,67
< /** Decode status. */
< DecodeStatus _status;
---
> // May eventually need statuses on a per thread basis.
> Status _status;
82,84d68
< /** Per-thread status. */
< ThreadStatus decodeStatus[Impl::MaxThreads];
<
86,87c70
< /** DefaultDecode constructor. */
< DefaultDecode(Params *params);
---
> SimpleDecode(Params &params);
89,92d71
< /** Returns the name of decode. */
< std::string name() const;
<
< /** Registers statistics. */
95d73
< /** Sets CPU pointer. */
98d75
< /** Sets the main backwards communication time buffer pointer. */
101d77
< /** Sets pointer to time buffer used to communicate to the next stage. */
104d79
< /** Sets pointer to time buffer coming from fetch. */
107,115d81
< /** Sets pointer to list of active threads. */
< void setActiveThreads(std::list<unsigned> *at_ptr);
<
< void switchOut();
<
< void takeOverFrom();
< /** Ticks decode, processing all input signals and decoding as many
< * instructions as possible.
< */
118,123c84
< /** Determines what to do based on decode's current status.
< * @param status_change decode() sets this variable if there was a status
< * change (ie switching from from blocking to unblocking).
< * @param tid Thread id to decode instructions from.
< */
< void decode(bool &status_change, unsigned tid);
---
> void decode();
125,131d85
< /** Processes instructions from fetch and passes them on to rename.
< * Decoding of instructions actually happens when they are created in
< * fetch, so this function mostly checks if PC-relative branches are
< * correct.
< */
< void decodeInsts(unsigned tid);
<
133,158d86
< /** Inserts a thread's instructions into the skid buffer, to be decoded
< * once decode unblocks.
< */
< void skidInsert(unsigned tid);
<
< /** Returns if all of the skid buffers are empty. */
< bool skidsEmpty();
<
< /** Updates overall decode status based on all of the threads' statuses. */
< void updateStatus();
<
< /** Separates instructions from fetch into individual lists of instructions
< * sorted by thread.
< */
< void sortInsts();
<
< /** Reads all stall signals from the backwards communication timebuffer. */
< void readStallSignals(unsigned tid);
<
< /** Checks all input signals and updates decode's status appropriately. */
< bool checkSignalsAndUpdate(unsigned tid);
<
< /** Checks all stall signals, and returns if any are true. */
< bool checkStall(unsigned tid) const;
<
< /** Returns if there any instructions from fetch on this cycle. */
161,165c89
< /** Switches decode to blocking, and signals back that decode has
< * become blocked.
< * @return Returns true if there is a status change.
< */
< bool block(unsigned tid);
---
> void block();
167,171c91
< /** Switches decode to unblocking if the skid buffer is empty, and
< * signals back that decode has unblocked.
< * @return Returns true if there is a status change.
< */
< bool unblock(unsigned tid);
---
> inline void unblock();
173,176c93
< /** Squashes if there is a PC-relative branch that was predicted
< * incorrectly. Sends squash information back to fetch.
< */
< void squash(DynInstPtr &inst, unsigned tid);
---
> void squash(DynInstPtr &inst);
179,182c96,97
< /** Squashes due to commit signalling a squash. Changes status to
< * squashing and clears block/unblock signals as needed.
< */
< unsigned squash(unsigned tid);
---
> // Might want to make squash a friend function.
> void squash();
217,219d131
< /** Queue of all instructions coming from fetch this cycle. */
< std::queue<DynInstPtr> insts[Impl::MaxThreads];
<
221c133
< std::queue<DynInstPtr> skidBuffer[Impl::MaxThreads];
---
> std::queue<FetchStruct> skidBuffer;
223,237c135
< /** Variable that tracks if decode has written to the time buffer this
< * cycle. Used to tell CPU if there is activity this cycle.
< */
< bool wroteToTimeBuffer;
<
< /** Source of possible stalls. */
< struct Stalls {
< bool rename;
< bool iew;
< bool commit;
< };
<
< /** Tracks which stages are telling decode to stall. */
< Stalls stalls[Impl::MaxThreads];
<
---
> //Consider making these unsigned to avoid any confusion.
253,254c151,155
< /** Index of instructions being sent to rename. */
< unsigned toRenameIndex;
---
> /** The instruction that decode is currently on. It needs to have
> * persistent state so that when a stall occurs in the middle of a
> * group of instructions, it can restart at the proper instruction.
> */
> unsigned numInst;
256,268d156
< /** number of Active Threads*/
< unsigned numThreads;
<
< /** List of active thread ids */
< std::list<unsigned> *activeThreads;
<
< /** Number of branches in flight. */
< unsigned branchCount[Impl::MaxThreads];
<
< /** Maximum size of the skid buffer. */
< unsigned skidBufferMax;
<
< /** Stat for total number of idle cycles. */
270d157
< /** Stat for total number of blocked cycles. */
272,274d158
< /** Stat for total number of normal running cycles. */
< Stats::Scalar<> decodeRunCycles;
< /** Stat for total number of unblocking cycles. */
276d159
< /** Stat for total number of squashing cycles. */
278,280d160
< /** Stat for number of times a branch is resolved at decode. */
< Stats::Scalar<> decodeBranchResolved;
< /** Stat for number of times a branch mispredict is detected. */
282,284d161
< /** Stat for number of times decode detected a non-control instruction
< * incorrectly predicted as a branch.
< */
286d162
< /** Stat for total number of decoded instructions. */
288d163
< /** Stat for total number of squashed instructions. */
292c167
< #endif // __CPU_O3_DECODE_HH__
---
> #endif // __CPU_O3_CPU_SIMPLE_DECODE_HH__