iew.hh revision 1858
111901Sjason@lowepower.com/*
211901Sjason@lowepower.com * Copyright (c) 2004-2005 The Regents of The University of Michigan
311901Sjason@lowepower.com * All rights reserved.
411901Sjason@lowepower.com *
511901Sjason@lowepower.com * Redistribution and use in source and binary forms, with or without
611901Sjason@lowepower.com * modification, are permitted provided that the following conditions are
711901Sjason@lowepower.com * met: redistributions of source code must retain the above copyright
811901Sjason@lowepower.com * notice, this list of conditions and the following disclaimer;
911901Sjason@lowepower.com * redistributions in binary form must reproduce the above copyright
1011901Sjason@lowepower.com * notice, this list of conditions and the following disclaimer in the
1111901Sjason@lowepower.com * documentation and/or other materials provided with the distribution;
1211901Sjason@lowepower.com * neither the name of the copyright holders nor the names of its
1311901Sjason@lowepower.com * contributors may be used to endorse or promote products derived from
1411901Sjason@lowepower.com * this software without specific prior written permission.
1511901Sjason@lowepower.com *
1611901Sjason@lowepower.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1711901Sjason@lowepower.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1811901Sjason@lowepower.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1911901Sjason@lowepower.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2011901Sjason@lowepower.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2111901Sjason@lowepower.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2211901Sjason@lowepower.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2311901Sjason@lowepower.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2411901Sjason@lowepower.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2511901Sjason@lowepower.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2611901Sjason@lowepower.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2711901Sjason@lowepower.com */
2811901Sjason@lowepower.com
2911901Sjason@lowepower.com//Todo: Update with statuses.
3011901Sjason@lowepower.com//Need to handle delaying writes to the writeback bus if it's full at the
3111901Sjason@lowepower.com//given time.
3211901Sjason@lowepower.com
3311901Sjason@lowepower.com#ifndef __CPU_O3_CPU_SIMPLE_IEW_HH__
3411901Sjason@lowepower.com#define __CPU_O3_CPU_SIMPLE_IEW_HH__
3511901Sjason@lowepower.com
3611901Sjason@lowepower.com#include <queue>
3711901Sjason@lowepower.com
3811901Sjason@lowepower.com#include "config/full_system.hh"
3912883Sjason@lowepower.com#include "base/statistics.hh"
4012883Sjason@lowepower.com#include "base/timebuf.hh"
4112883Sjason@lowepower.com#include "cpu/o3/comm.hh"
4212883Sjason@lowepower.com
4312883Sjason@lowepower.comtemplate<class Impl>
4412883Sjason@lowepower.comclass SimpleIEW
4512883Sjason@lowepower.com{
4612883Sjason@lowepower.com  private:
4712883Sjason@lowepower.com    //Typedefs from Impl
4812883Sjason@lowepower.com    typedef typename Impl::ISA ISA;
4912883Sjason@lowepower.com    typedef typename Impl::CPUPol CPUPol;
5012883Sjason@lowepower.com    typedef typename Impl::DynInstPtr DynInstPtr;
5112883Sjason@lowepower.com    typedef typename Impl::FullCPU FullCPU;
5211901Sjason@lowepower.com    typedef typename Impl::Params Params;
5311901Sjason@lowepower.com
5411901Sjason@lowepower.com    typedef typename CPUPol::IQ IQ;
5511901Sjason@lowepower.com    typedef typename CPUPol::RenameMap RenameMap;
5611901Sjason@lowepower.com    typedef typename CPUPol::LDSTQ LDSTQ;
5711901Sjason@lowepower.com
5811901Sjason@lowepower.com    typedef typename CPUPol::TimeStruct TimeStruct;
5911901Sjason@lowepower.com    typedef typename CPUPol::IEWStruct IEWStruct;
6011901Sjason@lowepower.com    typedef typename CPUPol::RenameStruct RenameStruct;
6111901Sjason@lowepower.com    typedef typename CPUPol::IssueStruct IssueStruct;
6211901Sjason@lowepower.com
6311901Sjason@lowepower.com    friend class Impl::FullCPU;
6411901Sjason@lowepower.com  public:
6511901Sjason@lowepower.com    enum Status {
6611901Sjason@lowepower.com        Running,
6711901Sjason@lowepower.com        Blocked,
6811901Sjason@lowepower.com        Idle,
6911901Sjason@lowepower.com        Squashing,
7011901Sjason@lowepower.com        Unblocking
7111901Sjason@lowepower.com    };
7211901Sjason@lowepower.com
7311901Sjason@lowepower.com  private:
7411901Sjason@lowepower.com    Status _status;
7511901Sjason@lowepower.com    Status _issueStatus;
7611901Sjason@lowepower.com    Status _exeStatus;
7711901Sjason@lowepower.com    Status _wbStatus;
7811901Sjason@lowepower.com
7911901Sjason@lowepower.com  public:
8013398Santhony.gutierrez@amd.com    class WritebackEvent : public Event {
8113398Santhony.gutierrez@amd.com      private:
8213398Santhony.gutierrez@amd.com        DynInstPtr inst;
8313398Santhony.gutierrez@amd.com        SimpleIEW<Impl> *iewStage;
8413398Santhony.gutierrez@amd.com
8513398Santhony.gutierrez@amd.com      public:
8613398Santhony.gutierrez@amd.com        WritebackEvent(DynInstPtr &_inst, SimpleIEW<Impl> *_iew);
8713398Santhony.gutierrez@amd.com
8813398Santhony.gutierrez@amd.com        virtual void process();
8913398Santhony.gutierrez@amd.com        virtual const char *description();
9013398Santhony.gutierrez@amd.com    };
9113398Santhony.gutierrez@amd.com
9213398Santhony.gutierrez@amd.com  public:
9311901Sjason@lowepower.com    SimpleIEW(Params &params);
9411901Sjason@lowepower.com
9511901Sjason@lowepower.com    void regStats();
9611901Sjason@lowepower.com
9711901Sjason@lowepower.com    void setCPU(FullCPU *cpu_ptr);
9811901Sjason@lowepower.com
9911901Sjason@lowepower.com    void setTimeBuffer(TimeBuffer<TimeStruct> *tb_ptr);
10011901Sjason@lowepower.com
10112562Ssiddhesh.poyarekar@gmail.com    void setRenameQueue(TimeBuffer<RenameStruct> *rq_ptr);
10212562Ssiddhesh.poyarekar@gmail.com
10312562Ssiddhesh.poyarekar@gmail.com    void setIEWQueue(TimeBuffer<IEWStruct> *iq_ptr);
10411901Sjason@lowepower.com
10511901Sjason@lowepower.com    void setRenameMap(RenameMap *rm_ptr);
10611901Sjason@lowepower.com
10711901Sjason@lowepower.com    void squash();
10811901Sjason@lowepower.com
10911901Sjason@lowepower.com    void squashDueToBranch(DynInstPtr &inst);
11011901Sjason@lowepower.com
11111901Sjason@lowepower.com    void squashDueToMem(DynInstPtr &inst);
11211901Sjason@lowepower.com
11311901Sjason@lowepower.com    void block();
11411901Sjason@lowepower.com
11511901Sjason@lowepower.com    inline void unblock();
11611901Sjason@lowepower.com
11711901Sjason@lowepower.com    void wakeDependents(DynInstPtr &inst);
11811901Sjason@lowepower.com
11911901Sjason@lowepower.com    void instToCommit(DynInstPtr &inst);
12011901Sjason@lowepower.com
12111901Sjason@lowepower.com  private:
12211901Sjason@lowepower.com    void dispatchInsts();
12311901Sjason@lowepower.com
12411901Sjason@lowepower.com    void executeInsts();
12511901Sjason@lowepower.com
12611901Sjason@lowepower.com  public:
12711901Sjason@lowepower.com    void tick();
12811901Sjason@lowepower.com
12911901Sjason@lowepower.com    void iew();
13011901Sjason@lowepower.com
13111901Sjason@lowepower.com    //Interfaces to objects inside and outside of IEW.
13211901Sjason@lowepower.com    /** Time buffer interface. */
13311901Sjason@lowepower.com    TimeBuffer<TimeStruct> *timeBuffer;
13411901Sjason@lowepower.com
13511901Sjason@lowepower.com    /** Wire to get commit's output from backwards time buffer. */
13611901Sjason@lowepower.com    typename TimeBuffer<TimeStruct>::wire fromCommit;
13711977Sjason@lowepower.com
13811977Sjason@lowepower.com    /** Wire to write information heading to previous stages. */
13911977Sjason@lowepower.com    typename TimeBuffer<TimeStruct>::wire toRename;
14011977Sjason@lowepower.com
14111901Sjason@lowepower.com    /** Rename instruction queue interface. */
14211901Sjason@lowepower.com    TimeBuffer<RenameStruct> *renameQueue;
14311901Sjason@lowepower.com
14411901Sjason@lowepower.com    /** Wire to get rename's output from rename queue. */
14511901Sjason@lowepower.com    typename TimeBuffer<RenameStruct>::wire fromRename;
14611901Sjason@lowepower.com
14711901Sjason@lowepower.com    /** Issue stage queue. */
14811901Sjason@lowepower.com    TimeBuffer<IssueStruct> issueToExecQueue;
14911901Sjason@lowepower.com
15011901Sjason@lowepower.com    /** Wire to read information from the issue stage time queue. */
15111901Sjason@lowepower.com    typename TimeBuffer<IssueStruct>::wire fromIssue;
15211901Sjason@lowepower.com
15311901Sjason@lowepower.com    /**
15411901Sjason@lowepower.com     * IEW stage time buffer.  Holds ROB indices of instructions that
15511901Sjason@lowepower.com     * can be marked as completed.
15611901Sjason@lowepower.com     */
15711901Sjason@lowepower.com    TimeBuffer<IEWStruct> *iewQueue;
15811901Sjason@lowepower.com
15911901Sjason@lowepower.com    /** Wire to write infromation heading to commit. */
16011901Sjason@lowepower.com    typename TimeBuffer<IEWStruct>::wire toCommit;
16111901Sjason@lowepower.com
16211901Sjason@lowepower.com    //Will need internal queue to hold onto instructions coming from
16311901Sjason@lowepower.com    //the rename stage in case of a stall.
16411901Sjason@lowepower.com    /** Skid buffer between rename and IEW. */
16511901Sjason@lowepower.com    std::queue<RenameStruct> skidBuffer;
16611901Sjason@lowepower.com
16711901Sjason@lowepower.com  protected:
16811901Sjason@lowepower.com    /** Instruction queue. */
16911901Sjason@lowepower.com    IQ instQueue;
17011901Sjason@lowepower.com
17111901Sjason@lowepower.com    LDSTQ ldstQueue;
17211901Sjason@lowepower.com
17311901Sjason@lowepower.com#if !FULL_SYSTEM
17411901Sjason@lowepower.com  public:
17511901Sjason@lowepower.com    void lsqWriteback();
17611901Sjason@lowepower.com#endif
17711901Sjason@lowepower.com
17811901Sjason@lowepower.com  private:
17911901Sjason@lowepower.com    /** Pointer to rename map.  Might not want this stage to directly
18011901Sjason@lowepower.com     *  access this though...
18111901Sjason@lowepower.com     */
18211901Sjason@lowepower.com    RenameMap *renameMap;
18311901Sjason@lowepower.com
18411901Sjason@lowepower.com    /** CPU interface. */
18511921Spierre-yves.peneau@lirmm.fr    FullCPU *cpu;
18611921Spierre-yves.peneau@lirmm.fr
18711921Spierre-yves.peneau@lirmm.fr  private:
18811921Spierre-yves.peneau@lirmm.fr    /** Commit to IEW delay, in ticks. */
18911921Spierre-yves.peneau@lirmm.fr    unsigned commitToIEWDelay;
19011901Sjason@lowepower.com
19111901Sjason@lowepower.com    /** Rename to IEW delay, in ticks. */
19211901Sjason@lowepower.com    unsigned renameToIEWDelay;
19311901Sjason@lowepower.com
19411901Sjason@lowepower.com    /**
19511901Sjason@lowepower.com     * Issue to execute delay, in ticks.  What this actually represents is
19612562Ssiddhesh.poyarekar@gmail.com     * the amount of time it takes for an instruction to wake up, be
19712562Ssiddhesh.poyarekar@gmail.com     * scheduled, and sent to a FU for execution.
19812562Ssiddhesh.poyarekar@gmail.com     */
19911901Sjason@lowepower.com    unsigned issueToExecuteDelay;
20012883Sjason@lowepower.com
20112883Sjason@lowepower.com    /** Width of issue's read path, in instructions.  The read path is both
20212883Sjason@lowepower.com     *  the skid buffer and the rename instruction queue.
20312883Sjason@lowepower.com     *  Note to self: is this really different than issueWidth?
20412883Sjason@lowepower.com     */
20512883Sjason@lowepower.com    unsigned issueReadWidth;
20612883Sjason@lowepower.com
20711901Sjason@lowepower.com    /** Width of issue, in instructions. */
20811901Sjason@lowepower.com    unsigned issueWidth;
20911901Sjason@lowepower.com
21011901Sjason@lowepower.com    /** Width of execute, in instructions.  Might make more sense to break
21111901Sjason@lowepower.com     *  down into FP vs int.
21211901Sjason@lowepower.com     */
21311901Sjason@lowepower.com    unsigned executeWidth;
21411901Sjason@lowepower.com
21511901Sjason@lowepower.com    /** Number of cycles stage has been squashing.  Used so that the stage
21611901Sjason@lowepower.com     *  knows when it can start unblocking, which is when the previous stage
21711901Sjason@lowepower.com     *  has received the stall signal and clears up its outputs.
21811901Sjason@lowepower.com     */
21911901Sjason@lowepower.com    unsigned cyclesSquashing;
22011901Sjason@lowepower.com
22111901Sjason@lowepower.com    Stats::Scalar<> iewIdleCycles;
22211901Sjason@lowepower.com    Stats::Scalar<> iewSquashCycles;
22311901Sjason@lowepower.com    Stats::Scalar<> iewBlockCycles;
22411901Sjason@lowepower.com    Stats::Scalar<> iewUnblockCycles;
22511901Sjason@lowepower.com//    Stats::Scalar<> iewWBInsts;
22611901Sjason@lowepower.com    Stats::Scalar<> iewDispatchedInsts;
22711901Sjason@lowepower.com    Stats::Scalar<> iewDispSquashedInsts;
22811901Sjason@lowepower.com    Stats::Scalar<> iewDispLoadInsts;
22911901Sjason@lowepower.com    Stats::Scalar<> iewDispStoreInsts;
23011901Sjason@lowepower.com    Stats::Scalar<> iewDispNonSpecInsts;
23111901Sjason@lowepower.com    Stats::Scalar<> iewIQFullEvents;
23212562Ssiddhesh.poyarekar@gmail.com    Stats::Scalar<> iewExecutedInsts;
23312562Ssiddhesh.poyarekar@gmail.com    Stats::Scalar<> iewExecLoadInsts;
23412562Ssiddhesh.poyarekar@gmail.com    Stats::Scalar<> iewExecStoreInsts;
23511901Sjason@lowepower.com    Stats::Scalar<> iewExecSquashedInsts;
23611901Sjason@lowepower.com    Stats::Scalar<> memOrderViolationEvents;
23711901Sjason@lowepower.com    Stats::Scalar<> predictedTakenIncorrect;
23811901Sjason@lowepower.com};
23911901Sjason@lowepower.com
24012562Ssiddhesh.poyarekar@gmail.com#endif // __CPU_O3_CPU_IEW_HH__
24112562Ssiddhesh.poyarekar@gmail.com