iew.hh revision 8230
11689SN/A/*
27782Sminkyu.jeong@arm.com * Copyright (c) 2010 ARM Limited
37782Sminkyu.jeong@arm.com * All rights reserved
47782Sminkyu.jeong@arm.com *
57782Sminkyu.jeong@arm.com * The license below extends only to copyright in the software and shall
67782Sminkyu.jeong@arm.com * not be construed as granting a license to any other intellectual
77782Sminkyu.jeong@arm.com * property including but not limited to intellectual property relating
87782Sminkyu.jeong@arm.com * to a hardware implementation of the functionality of the software
97782Sminkyu.jeong@arm.com * licensed hereunder.  You may use the software subject to the license
107782Sminkyu.jeong@arm.com * terms below provided that you ensure that this notice is replicated
117782Sminkyu.jeong@arm.com * unmodified and in its entirety in all distributions of the software,
127782Sminkyu.jeong@arm.com * modified or unmodified, in source code or in binary form.
137782Sminkyu.jeong@arm.com *
142326SN/A * Copyright (c) 2004-2006 The Regents of The University of Michigan
151689SN/A * All rights reserved.
161689SN/A *
171689SN/A * Redistribution and use in source and binary forms, with or without
181689SN/A * modification, are permitted provided that the following conditions are
191689SN/A * met: redistributions of source code must retain the above copyright
201689SN/A * notice, this list of conditions and the following disclaimer;
211689SN/A * redistributions in binary form must reproduce the above copyright
221689SN/A * notice, this list of conditions and the following disclaimer in the
231689SN/A * documentation and/or other materials provided with the distribution;
241689SN/A * neither the name of the copyright holders nor the names of its
251689SN/A * contributors may be used to endorse or promote products derived from
261689SN/A * this software without specific prior written permission.
271689SN/A *
281689SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
291689SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
301689SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
311689SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
321689SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
331689SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
341689SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
351689SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
361689SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
371689SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
381689SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
392665Ssaidi@eecs.umich.edu *
402665Ssaidi@eecs.umich.edu * Authors: Kevin Lim
411689SN/A */
421689SN/A
432292SN/A#ifndef __CPU_O3_IEW_HH__
442292SN/A#define __CPU_O3_IEW_HH__
451060SN/A
461060SN/A#include <queue>
478230Snate@binkert.org#include <set>
481060SN/A
491461SN/A#include "base/statistics.hh"
506221Snate@binkert.org#include "config/full_system.hh"
511717SN/A#include "cpu/o3/comm.hh"
528229Snate@binkert.org#include "cpu/o3/lsq.hh"
532292SN/A#include "cpu/o3/scoreboard.hh"
548229Snate@binkert.org#include "cpu/timebuf.hh"
551060SN/A
565529Snate@binkert.orgclass DerivO3CPUParams;
572292SN/Aclass FUPool;
582292SN/A
592292SN/A/**
602326SN/A * DefaultIEW handles both single threaded and SMT IEW
612326SN/A * (issue/execute/writeback).  It handles the dispatching of
622326SN/A * instructions to the LSQ/IQ as part of the issue stage, and has the
632326SN/A * IQ try to issue instructions each cycle. The execute latency is
642326SN/A * actually tied into the issue latency to allow the IQ to be able to
652292SN/A * do back-to-back scheduling without having to speculatively schedule
662326SN/A * instructions. This happens by having the IQ have access to the
672326SN/A * functional units, and the IQ gets the execution latencies from the
682326SN/A * FUs when it issues instructions. Instructions reach the execute
692326SN/A * stage on the last cycle of their execution, which is when the IQ
702326SN/A * knows to wake up any dependent instructions, allowing back to back
712326SN/A * scheduling. The execute portion of IEW separates memory
722326SN/A * instructions from non-memory instructions, either telling the LSQ
732326SN/A * to execute the instruction, or executing the instruction directly.
742326SN/A * The writeback portion of IEW completes the instructions by waking
752326SN/A * up any dependents, and marking the register ready on the
762326SN/A * scoreboard.
772292SN/A */
781681SN/Atemplate<class Impl>
792292SN/Aclass DefaultIEW
801060SN/A{
811060SN/A  private:
821060SN/A    //Typedefs from Impl
831061SN/A    typedef typename Impl::CPUPol CPUPol;
841061SN/A    typedef typename Impl::DynInstPtr DynInstPtr;
852733Sktlim@umich.edu    typedef typename Impl::O3CPU O3CPU;
861060SN/A
871681SN/A    typedef typename CPUPol::IQ IQ;
881061SN/A    typedef typename CPUPol::RenameMap RenameMap;
892292SN/A    typedef typename CPUPol::LSQ LSQ;
901060SN/A
911061SN/A    typedef typename CPUPol::TimeStruct TimeStruct;
921061SN/A    typedef typename CPUPol::IEWStruct IEWStruct;
931061SN/A    typedef typename CPUPol::RenameStruct RenameStruct;
941061SN/A    typedef typename CPUPol::IssueStruct IssueStruct;
951060SN/A
962733Sktlim@umich.edu    friend class Impl::O3CPU;
972292SN/A    friend class CPUPol::IQ;
982292SN/A
991060SN/A  public:
1002292SN/A    /** Overall IEW stage status. Used to determine if the CPU can
1012292SN/A     * deschedule itself due to a lack of activity.
1022292SN/A     */
1031060SN/A    enum Status {
1042292SN/A        Active,
1052292SN/A        Inactive
1062292SN/A    };
1072292SN/A
1082292SN/A    /** Status for Issue, Execute, and Writeback stages. */
1092292SN/A    enum StageStatus {
1101060SN/A        Running,
1111060SN/A        Blocked,
1121060SN/A        Idle,
1132292SN/A        StartSquash,
1141060SN/A        Squashing,
1151060SN/A        Unblocking
1161060SN/A    };
1171060SN/A
1181060SN/A  private:
1192292SN/A    /** Overall stage status. */
1201060SN/A    Status _status;
1212292SN/A    /** Dispatch status. */
1222292SN/A    StageStatus dispatchStatus[Impl::MaxThreads];
1232292SN/A    /** Execute status. */
1242292SN/A    StageStatus exeStatus;
1252292SN/A    /** Writeback status. */
1262292SN/A    StageStatus wbStatus;
1271060SN/A
1281060SN/A  public:
1292292SN/A    /** Constructs a DefaultIEW with the given parameters. */
1305529Snate@binkert.org    DefaultIEW(O3CPU *_cpu, DerivO3CPUParams *params);
1311060SN/A
1322292SN/A    /** Returns the name of the DefaultIEW stage. */
1332292SN/A    std::string name() const;
1341062SN/A
1352292SN/A    /** Registers statistics. */
1362632Sstever@eecs.umich.edu    void regStats();
1372632Sstever@eecs.umich.edu
1382292SN/A    /** Initializes stage; sends back the number of free IQ and LSQ entries. */
1392292SN/A    void initStage();
1402292SN/A
1412871Sktlim@umich.edu    /** Returns the dcache port. */
1422871Sktlim@umich.edu    Port *getDcachePort() { return ldstQueue.getDcachePort(); }
1432871Sktlim@umich.edu
1442292SN/A    /** Sets main time buffer used for backwards communication. */
1452632Sstever@eecs.umich.edu    void setTimeBuffer(TimeBuffer<TimeStruct> *tb_ptr);
1462632Sstever@eecs.umich.edu
1472292SN/A    /** Sets time buffer for getting instructions coming from rename. */
1482632Sstever@eecs.umich.edu    void setRenameQueue(TimeBuffer<RenameStruct> *rq_ptr);
1492632Sstever@eecs.umich.edu
1502292SN/A    /** Sets time buffer to pass on instructions to commit. */
1512632Sstever@eecs.umich.edu    void setIEWQueue(TimeBuffer<IEWStruct> *iq_ptr);
1522632Sstever@eecs.umich.edu
1532292SN/A    /** Sets pointer to list of active threads. */
1546221Snate@binkert.org    void setActiveThreads(std::list<ThreadID> *at_ptr);
1552632Sstever@eecs.umich.edu
1562292SN/A    /** Sets pointer to the scoreboard. */
1572292SN/A    void setScoreboard(Scoreboard *sb_ptr);
1582632Sstever@eecs.umich.edu
1592843Sktlim@umich.edu    /** Drains IEW stage. */
1602863Sktlim@umich.edu    bool drain();
1612843Sktlim@umich.edu
1622843Sktlim@umich.edu    /** Resumes execution after a drain. */
1632843Sktlim@umich.edu    void resume();
1642632Sstever@eecs.umich.edu
1652348SN/A    /** Completes switch out of IEW stage. */
1662843Sktlim@umich.edu    void switchOut();
1672632Sstever@eecs.umich.edu
1682348SN/A    /** Takes over from another CPU's thread. */
1692307SN/A    void takeOverFrom();
1702632Sstever@eecs.umich.edu
1712348SN/A    /** Returns if IEW is switched out. */
1722307SN/A    bool isSwitchedOut() { return switchedOut; }
1732632Sstever@eecs.umich.edu
1742292SN/A    /** Squashes instructions in IEW for a specific thread. */
1756221Snate@binkert.org    void squash(ThreadID tid);
1762107SN/A
1772292SN/A    /** Wakes all dependents of a completed instruction. */
1782632Sstever@eecs.umich.edu    void wakeDependents(DynInstPtr &inst);
1792632Sstever@eecs.umich.edu
1802292SN/A    /** Tells memory dependence unit that a memory instruction needs to be
1812292SN/A     * rescheduled. It will re-execute once replayMemInst() is called.
1822292SN/A     */
1832292SN/A    void rescheduleMemInst(DynInstPtr &inst);
1842292SN/A
1852292SN/A    /** Re-executes all rescheduled memory instructions. */
1862292SN/A    void replayMemInst(DynInstPtr &inst);
1872292SN/A
1882292SN/A    /** Sends an instruction to commit through the time buffer. */
1892632Sstever@eecs.umich.edu    void instToCommit(DynInstPtr &inst);
1902632Sstever@eecs.umich.edu
1912292SN/A    /** Inserts unused instructions of a thread into the skid buffer. */
1926221Snate@binkert.org    void skidInsert(ThreadID tid);
1932292SN/A
1942292SN/A    /** Returns the max of the number of entries in all of the skid buffers. */
1952292SN/A    int skidCount();
1962292SN/A
1972292SN/A    /** Returns if all of the skid buffers are empty. */
1982292SN/A    bool skidsEmpty();
1992292SN/A
2002292SN/A    /** Updates overall IEW status based on all of the stages' statuses. */
2012292SN/A    void updateStatus();
2022292SN/A
2032292SN/A    /** Resets entries of the IQ and the LSQ. */
2042292SN/A    void resetEntries();
2052292SN/A
2062292SN/A    /** Tells the CPU to wakeup if it has descheduled itself due to no
2072292SN/A     * activity. Used mainly by the LdWritebackEvent.
2082292SN/A     */
2092292SN/A    void wakeCPU();
2102292SN/A
2112292SN/A    /** Reports to the CPU that there is activity this cycle. */
2122292SN/A    void activityThisCycle();
2132292SN/A
2142292SN/A    /** Tells CPU that the IEW stage is active and running. */
2152292SN/A    inline void activateStage();
2162292SN/A
2172292SN/A    /** Tells CPU that the IEW stage is inactive and idle. */
2182292SN/A    inline void deactivateStage();
2192292SN/A
2202292SN/A    /** Returns if the LSQ has any stores to writeback. */
2212292SN/A    bool hasStoresToWB() { return ldstQueue.hasStoresToWB(); }
2222292SN/A
2235557Sktlim@umich.edu    /** Returns if the LSQ has any stores to writeback. */
2246221Snate@binkert.org    bool hasStoresToWB(ThreadID tid) { return ldstQueue.hasStoresToWB(tid); }
2255557Sktlim@umich.edu
2262820Sktlim@umich.edu    void incrWb(InstSeqNum &sn)
2272820Sktlim@umich.edu    {
2282820Sktlim@umich.edu        if (++wbOutstanding == wbMax)
2292820Sktlim@umich.edu            ableToIssue = false;
2302820Sktlim@umich.edu        DPRINTF(IEW, "wbOutstanding: %i\n", wbOutstanding);
2312353SN/A        assert(wbOutstanding <= wbMax);
2322926Sktlim@umich.edu#ifdef DEBUG
2332820Sktlim@umich.edu        wbList.insert(sn);
2342820Sktlim@umich.edu#endif
2352820Sktlim@umich.edu    }
2362820Sktlim@umich.edu
2372820Sktlim@umich.edu    void decrWb(InstSeqNum &sn)
2382820Sktlim@umich.edu    {
2392820Sktlim@umich.edu        if (wbOutstanding-- == wbMax)
2402820Sktlim@umich.edu            ableToIssue = true;
2417782Sminkyu.jeong@arm.com        DPRINTF(IEW, "wbOutstanding: %i [sn:%lli]\n", wbOutstanding, sn);
2422353SN/A        assert(wbOutstanding >= 0);
2432926Sktlim@umich.edu#ifdef DEBUG
2442820Sktlim@umich.edu        assert(wbList.find(sn) != wbList.end());
2452820Sktlim@umich.edu        wbList.erase(sn);
2462820Sktlim@umich.edu#endif
2472820Sktlim@umich.edu    }
2482820Sktlim@umich.edu
2492926Sktlim@umich.edu#ifdef DEBUG
2502820Sktlim@umich.edu    std::set<InstSeqNum> wbList;
2512820Sktlim@umich.edu
2522820Sktlim@umich.edu    void dumpWb()
2532820Sktlim@umich.edu    {
2542820Sktlim@umich.edu        std::set<InstSeqNum>::iterator wb_it = wbList.begin();
2552820Sktlim@umich.edu        while (wb_it != wbList.end()) {
2562820Sktlim@umich.edu            cprintf("[sn:%lli]\n",
2572820Sktlim@umich.edu                    (*wb_it));
2582820Sktlim@umich.edu            wb_it++;
2592820Sktlim@umich.edu        }
2602820Sktlim@umich.edu    }
2612820Sktlim@umich.edu#endif
2622820Sktlim@umich.edu
2632820Sktlim@umich.edu    bool canIssue() { return ableToIssue; }
2642820Sktlim@umich.edu
2652820Sktlim@umich.edu    bool ableToIssue;
2662820Sktlim@umich.edu
2677598Sminkyu.jeong@arm.com    /** Check misprediction  */
2687598Sminkyu.jeong@arm.com    void checkMisprediction(DynInstPtr &inst);
2697598Sminkyu.jeong@arm.com
2702632Sstever@eecs.umich.edu  private:
2712292SN/A    /** Sends commit proper information for a squash due to a branch
2722292SN/A     * mispredict.
2732292SN/A     */
2746221Snate@binkert.org    void squashDueToBranch(DynInstPtr &inst, ThreadID tid);
2752632Sstever@eecs.umich.edu
2762292SN/A    /** Sends commit proper information for a squash due to a memory order
2772292SN/A     * violation.
2782292SN/A     */
2796221Snate@binkert.org    void squashDueToMemOrder(DynInstPtr &inst, ThreadID tid);
2802292SN/A
2812292SN/A    /** Sends commit proper information for a squash due to memory becoming
2822292SN/A     * blocked (younger issued instructions must be retried).
2832292SN/A     */
2846221Snate@binkert.org    void squashDueToMemBlocked(DynInstPtr &inst, ThreadID tid);
2852292SN/A
2862292SN/A    /** Sets Dispatch to blocked, and signals back to other stages to block. */
2876221Snate@binkert.org    void block(ThreadID tid);
2882292SN/A
2892292SN/A    /** Unblocks Dispatch if the skid buffer is empty, and signals back to
2902292SN/A     * other stages to unblock.
2912292SN/A     */
2926221Snate@binkert.org    void unblock(ThreadID tid);
2932292SN/A
2942292SN/A    /** Determines proper actions to take given Dispatch's status. */
2956221Snate@binkert.org    void dispatch(ThreadID tid);
2962292SN/A
2972292SN/A    /** Dispatches instructions to IQ and LSQ. */
2986221Snate@binkert.org    void dispatchInsts(ThreadID tid);
2992292SN/A
3002292SN/A    /** Executes instructions. In the case of memory operations, it informs the
3012292SN/A     * LSQ to execute the instructions. Also handles any redirects that occur
3022292SN/A     * due to the executed instructions.
3032292SN/A     */
3042632Sstever@eecs.umich.edu    void executeInsts();
3052632Sstever@eecs.umich.edu
3062292SN/A    /** Writebacks instructions. In our model, the instruction's execute()
3072292SN/A     * function atomically reads registers, executes, and writes registers.
3082292SN/A     * Thus this writeback only wakes up dependent instructions, and informs
3092292SN/A     * the scoreboard of registers becoming ready.
3102292SN/A     */
3112292SN/A    void writebackInsts();
3122292SN/A
3132292SN/A    /** Returns the number of valid, non-squashed instructions coming from
3142292SN/A     * rename to dispatch.
3152292SN/A     */
3162292SN/A    unsigned validInstsFromRename();
3172292SN/A
3182292SN/A    /** Reads the stall signals. */
3196221Snate@binkert.org    void readStallSignals(ThreadID tid);
3202292SN/A
3212292SN/A    /** Checks if any of the stall conditions are currently true. */
3226221Snate@binkert.org    bool checkStall(ThreadID tid);
3232292SN/A
3242292SN/A    /** Processes inputs and changes state accordingly. */
3256221Snate@binkert.org    void checkSignalsAndUpdate(ThreadID tid);
3262292SN/A
3272702Sktlim@umich.edu    /** Removes instructions from rename from a thread's instruction list. */
3286221Snate@binkert.org    void emptyRenameInsts(ThreadID tid);
3292702Sktlim@umich.edu
3302292SN/A    /** Sorts instructions coming from rename into lists separated by thread. */
3312292SN/A    void sortInsts();
3321060SN/A
3331060SN/A  public:
3342292SN/A    /** Ticks IEW stage, causing Dispatch, the IQ, the LSQ, Execute, and
3352292SN/A     * Writeback to run for one cycle.
3362292SN/A     */
3372632Sstever@eecs.umich.edu    void tick();
3381060SN/A
3391060SN/A  private:
3402348SN/A    /** Updates execution stats based on the instruction. */
3412301SN/A    void updateExeInstStats(DynInstPtr &inst);
3421062SN/A
3432292SN/A    /** Pointer to main time buffer used for backwards communication. */
3442632Sstever@eecs.umich.edu    TimeBuffer<TimeStruct> *timeBuffer;
3451062SN/A
3462292SN/A    /** Wire to write information heading to previous stages. */
3472292SN/A    typename TimeBuffer<TimeStruct>::wire toFetch;
3481060SN/A
3491060SN/A    /** Wire to get commit's output from backwards time buffer. */
3501060SN/A    typename TimeBuffer<TimeStruct>::wire fromCommit;
3511060SN/A
3521060SN/A    /** Wire to write information heading to previous stages. */
3531060SN/A    typename TimeBuffer<TimeStruct>::wire toRename;
3541060SN/A
3551060SN/A    /** Rename instruction queue interface. */
3561060SN/A    TimeBuffer<RenameStruct> *renameQueue;
3571060SN/A
3581060SN/A    /** Wire to get rename's output from rename queue. */
3591060SN/A    typename TimeBuffer<RenameStruct>::wire fromRename;
3601060SN/A
3611060SN/A    /** Issue stage queue. */
3621060SN/A    TimeBuffer<IssueStruct> issueToExecQueue;
3631060SN/A
3641060SN/A    /** Wire to read information from the issue stage time queue. */
3651060SN/A    typename TimeBuffer<IssueStruct>::wire fromIssue;
3661060SN/A
3671060SN/A    /**
3681060SN/A     * IEW stage time buffer.  Holds ROB indices of instructions that
3691060SN/A     * can be marked as completed.
3701060SN/A     */
3711060SN/A    TimeBuffer<IEWStruct> *iewQueue;
3721060SN/A
3731060SN/A    /** Wire to write infromation heading to commit. */
3741060SN/A    typename TimeBuffer<IEWStruct>::wire toCommit;
3751060SN/A
3762292SN/A    /** Queue of all instructions coming from rename this cycle. */
3772292SN/A    std::queue<DynInstPtr> insts[Impl::MaxThreads];
3782292SN/A
3791060SN/A    /** Skid buffer between rename and IEW. */
3802292SN/A    std::queue<DynInstPtr> skidBuffer[Impl::MaxThreads];
3811060SN/A
3822292SN/A    /** Scoreboard pointer. */
3832292SN/A    Scoreboard* scoreboard;
3842292SN/A
3851681SN/A  private:
3862292SN/A    /** CPU pointer. */
3872733Sktlim@umich.edu    O3CPU *cpu;
3881060SN/A
3892292SN/A    /** Records if IEW has written to the time buffer this cycle, so that the
3902292SN/A     * CPU can deschedule itself if there is no activity.
3912292SN/A     */
3922292SN/A    bool wroteToTimeBuffer;
3932292SN/A
3942292SN/A    /** Source of possible stalls. */
3952292SN/A    struct Stalls {
3962292SN/A        bool commit;
3972292SN/A    };
3982292SN/A
3992292SN/A    /** Stages that are telling IEW to stall. */
4002292SN/A    Stalls stalls[Impl::MaxThreads];
4012292SN/A
4022292SN/A    /** Debug function to print instructions that are issued this cycle. */
4032292SN/A    void printAvailableInsts();
4042292SN/A
4052292SN/A  public:
4064329Sktlim@umich.edu    /** Instruction queue. */
4074329Sktlim@umich.edu    IQ instQueue;
4084329Sktlim@umich.edu
4094329Sktlim@umich.edu    /** Load / store queue. */
4104329Sktlim@umich.edu    LSQ ldstQueue;
4114329Sktlim@umich.edu
4124329Sktlim@umich.edu    /** Pointer to the functional unit pool. */
4134329Sktlim@umich.edu    FUPool *fuPool;
4142292SN/A    /** Records if the LSQ needs to be updated on the next cycle, so that
4152292SN/A     * IEW knows if there will be activity on the next cycle.
4162292SN/A     */
4172292SN/A    bool updateLSQNextCycle;
4182292SN/A
4191060SN/A  private:
4202292SN/A    /** Records if there is a fetch redirect on this cycle for each thread. */
4212292SN/A    bool fetchRedirect[Impl::MaxThreads];
4222292SN/A
4232292SN/A    /** Records if the queues have been changed (inserted or issued insts),
4242292SN/A     * so that IEW knows to broadcast the updated amount of free entries.
4252292SN/A     */
4262292SN/A    bool updatedQueues;
4272292SN/A
4281060SN/A    /** Commit to IEW delay, in ticks. */
4291060SN/A    unsigned commitToIEWDelay;
4301060SN/A
4311060SN/A    /** Rename to IEW delay, in ticks. */
4321060SN/A    unsigned renameToIEWDelay;
4331060SN/A
4341060SN/A    /**
4351060SN/A     * Issue to execute delay, in ticks.  What this actually represents is
4361060SN/A     * the amount of time it takes for an instruction to wake up, be
4371060SN/A     * scheduled, and sent to a FU for execution.
4381060SN/A     */
4391060SN/A    unsigned issueToExecuteDelay;
4401060SN/A
4412820Sktlim@umich.edu    /** Width of dispatch, in instructions. */
4422820Sktlim@umich.edu    unsigned dispatchWidth;
4431060SN/A
4441060SN/A    /** Width of issue, in instructions. */
4451060SN/A    unsigned issueWidth;
4461060SN/A
4472292SN/A    /** Index into queue of instructions being written back. */
4482292SN/A    unsigned wbNumInst;
4492292SN/A
4502292SN/A    /** Cycle number within the queue of instructions being written back.
4512292SN/A     * Used in case there are too many instructions writing back at the current
4522292SN/A     * cycle and writesbacks need to be scheduled for the future. See comments
4532292SN/A     * in instToCommit().
4541060SN/A     */
4552292SN/A    unsigned wbCycle;
4561060SN/A
4572820Sktlim@umich.edu    /** Number of instructions in flight that will writeback. */
4583125Sktlim@umich.edu
4593125Sktlim@umich.edu    /** Number of instructions in flight that will writeback. */
4602353SN/A    int wbOutstanding;
4612820Sktlim@umich.edu
4622820Sktlim@umich.edu    /** Writeback width. */
4632820Sktlim@umich.edu    unsigned wbWidth;
4642820Sktlim@umich.edu
4652820Sktlim@umich.edu    /** Writeback width * writeback depth, where writeback depth is
4662820Sktlim@umich.edu     * the number of cycles of writing back instructions that can be
4672820Sktlim@umich.edu     * buffered. */
4682820Sktlim@umich.edu    unsigned wbMax;
4692820Sktlim@umich.edu
4702292SN/A    /** Number of active threads. */
4716221Snate@binkert.org    ThreadID numThreads;
4722292SN/A
4732292SN/A    /** Pointer to list of active threads. */
4746221Snate@binkert.org    std::list<ThreadID> *activeThreads;
4752292SN/A
4762292SN/A    /** Maximum size of the skid buffer. */
4772292SN/A    unsigned skidBufferMax;
4782292SN/A
4792348SN/A    /** Is this stage switched out. */
4802307SN/A    bool switchedOut;
4812307SN/A
4822292SN/A    /** Stat for total number of idle cycles. */
4835999Snate@binkert.org    Stats::Scalar iewIdleCycles;
4842292SN/A    /** Stat for total number of squashing cycles. */
4855999Snate@binkert.org    Stats::Scalar iewSquashCycles;
4862292SN/A    /** Stat for total number of blocking cycles. */
4875999Snate@binkert.org    Stats::Scalar iewBlockCycles;
4882292SN/A    /** Stat for total number of unblocking cycles. */
4895999Snate@binkert.org    Stats::Scalar iewUnblockCycles;
4902292SN/A    /** Stat for total number of instructions dispatched. */
4915999Snate@binkert.org    Stats::Scalar iewDispatchedInsts;
4922292SN/A    /** Stat for total number of squashed instructions dispatch skips. */
4935999Snate@binkert.org    Stats::Scalar iewDispSquashedInsts;
4942292SN/A    /** Stat for total number of dispatched load instructions. */
4955999Snate@binkert.org    Stats::Scalar iewDispLoadInsts;
4962292SN/A    /** Stat for total number of dispatched store instructions. */
4975999Snate@binkert.org    Stats::Scalar iewDispStoreInsts;
4982292SN/A    /** Stat for total number of dispatched non speculative instructions. */
4995999Snate@binkert.org    Stats::Scalar iewDispNonSpecInsts;
5002292SN/A    /** Stat for number of times the IQ becomes full. */
5015999Snate@binkert.org    Stats::Scalar iewIQFullEvents;
5022292SN/A    /** Stat for number of times the LSQ becomes full. */
5035999Snate@binkert.org    Stats::Scalar iewLSQFullEvents;
5042292SN/A    /** Stat for total number of memory ordering violation events. */
5055999Snate@binkert.org    Stats::Scalar memOrderViolationEvents;
5062292SN/A    /** Stat for total number of incorrect predicted taken branches. */
5075999Snate@binkert.org    Stats::Scalar predictedTakenIncorrect;
5082292SN/A    /** Stat for total number of incorrect predicted not taken branches. */
5095999Snate@binkert.org    Stats::Scalar predictedNotTakenIncorrect;
5102292SN/A    /** Stat for total number of mispredicted branches detected at execute. */
5112292SN/A    Stats::Formula branchMispredicts;
5122301SN/A
5132727Sktlim@umich.edu    /** Stat for total number of executed instructions. */
5145999Snate@binkert.org    Stats::Scalar iewExecutedInsts;
5152727Sktlim@umich.edu    /** Stat for total number of executed load instructions. */
5165999Snate@binkert.org    Stats::Vector iewExecLoadInsts;
5172353SN/A    /** Stat for total number of executed store instructions. */
5185999Snate@binkert.org//    Stats::Scalar iewExecStoreInsts;
5192727Sktlim@umich.edu    /** Stat for total number of squashed instructions skipped at execute. */
5205999Snate@binkert.org    Stats::Scalar iewExecSquashedInsts;
5212348SN/A    /** Number of executed software prefetches. */
5225999Snate@binkert.org    Stats::Vector iewExecutedSwp;
5232348SN/A    /** Number of executed nops. */
5245999Snate@binkert.org    Stats::Vector iewExecutedNop;
5252348SN/A    /** Number of executed meomory references. */
5265999Snate@binkert.org    Stats::Vector iewExecutedRefs;
5272348SN/A    /** Number of executed branches. */
5285999Snate@binkert.org    Stats::Vector iewExecutedBranches;
5292348SN/A    /** Number of executed store instructions. */
5302301SN/A    Stats::Formula iewExecStoreInsts;
5312727Sktlim@umich.edu    /** Number of instructions executed per cycle. */
5322727Sktlim@umich.edu    Stats::Formula iewExecRate;
5332727Sktlim@umich.edu
5342348SN/A    /** Number of instructions sent to commit. */
5355999Snate@binkert.org    Stats::Vector iewInstsToCommit;
5362348SN/A    /** Number of instructions that writeback. */
5375999Snate@binkert.org    Stats::Vector writebackCount;
5382348SN/A    /** Number of instructions that wake consumers. */
5395999Snate@binkert.org    Stats::Vector producerInst;
5402348SN/A    /** Number of instructions that wake up from producers. */
5415999Snate@binkert.org    Stats::Vector consumerInst;
5422348SN/A    /** Number of instructions that were delayed in writing back due
5432348SN/A     * to resource contention.
5442348SN/A     */
5455999Snate@binkert.org    Stats::Vector wbPenalized;
5462348SN/A    /** Number of instructions per cycle written back. */
5472326SN/A    Stats::Formula wbRate;
5482348SN/A    /** Average number of woken instructions per writeback. */
5492326SN/A    Stats::Formula wbFanout;
5502348SN/A    /** Number of instructions per cycle delayed in writing back . */
5512326SN/A    Stats::Formula wbPenalizedRate;
5521060SN/A};
5531060SN/A
5542292SN/A#endif // __CPU_O3_IEW_HH__
555