2c2
< * Copyright (c) 2004-2005 The Regents of The University of Michigan
---
> * Copyright (c) 2004-2006 The Regents of The University of Michigan
29,30c29,30
< #ifndef __CPU_O3_CPU_SIMPLE_DECODE_HH__
< #define __CPU_O3_CPU_SIMPLE_DECODE_HH__
---
> #ifndef __CPU_O3_DECODE_HH__
> #define __CPU_O3_DECODE_HH__
36a37,43
> /**
> * 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.
> */
38c45
< class SimpleDecode
---
> class DefaultDecode
53,55c60,69
< // The only time decode will become blocked is if dispatch becomes
< // blocked, which means IQ or ROB is probably full.
< enum Status {
---
> /** 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 {
57a72
> StartSquash,
64,65c79,80
< // May eventually need statuses on a per thread basis.
< Status _status;
---
> /** Decode status. */
> DecodeStatus _status;
66a82,84
> /** Per-thread status. */
> ThreadStatus decodeStatus[Impl::MaxThreads];
>
68c86,87
< SimpleDecode(Params &params);
---
> /** DefaultDecode constructor. */
> DefaultDecode(Params *params);
69a89,92
> /** Returns the name of decode. */
> std::string name() const;
>
> /** Registers statistics. */
71a95
> /** Sets CPU pointer. */
73a98
> /** Sets the main backwards communication time buffer pointer. */
75a101
> /** Sets pointer to time buffer used to communicate to the next stage. */
77a104
> /** Sets pointer to time buffer coming from fetch. */
79a107,115
> /** 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.
> */
82c118,123
< void decode();
---
> /** 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);
83a125,131
> /** 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);
>
84a133,158
> /** 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. */
87c161,165
< void block();
---
> /** 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);
89c167,171
< inline void unblock();
---
> /** 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);
91c173,176
< void squash(DynInstPtr &inst);
---
> /** Squashes if there is a PC-relative branch that was predicted
> * incorrectly. Sends squash information back to fetch.
> */
> void squash(DynInstPtr &inst, unsigned tid);
94,95c179,182
< // Might want to make squash a friend function.
< void squash();
---
> /** Squashes due to commit signalling a squash. Changes status to
> * squashing and clears block/unblock signals as needed.
> */
> unsigned squash(unsigned tid);
129a217,219
> /** Queue of all instructions coming from fetch this cycle. */
> std::queue<DynInstPtr> insts[Impl::MaxThreads];
>
131c221
< std::queue<FetchStruct> skidBuffer;
---
> std::queue<DynInstPtr> skidBuffer[Impl::MaxThreads];
133c223,237
< //Consider making these unsigned to avoid any confusion.
---
> /** 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];
>
149,153c253,254
< /** 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;
---
> /** Index of instructions being sent to rename. */
> unsigned toRenameIndex;
154a256,268
> /** 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. */
155a270
> /** Stat for total number of blocked cycles. */
156a272,274
> /** Stat for total number of normal running cycles. */
> Stats::Scalar<> decodeRunCycles;
> /** Stat for total number of unblocking cycles. */
157a276
> /** Stat for total number of squashing cycles. */
158a278,280
> /** Stat for number of times a branch is resolved at decode. */
> Stats::Scalar<> decodeBranchResolved;
> /** Stat for number of times a branch mispredict is detected. */
159a282,284
> /** Stat for number of times decode detected a non-control instruction
> * incorrectly predicted as a branch.
> */
160a286
> /** Stat for total number of decoded instructions. */
161a288
> /** Stat for total number of squashed instructions. */
165c292
< #endif // __CPU_O3_CPU_SIMPLE_DECODE_HH__
---
> #endif // __CPU_O3_DECODE_HH__