rename.hh

来自「M5,一个功能强大的多处理器系统模拟器.很多针对处理器架构,性能的研究都使用它作」· HH 代码 · 共 484 行 · 第 1/2 页

HH
484
字号
/* * Copyright (c) 2004, 2005, 2006 * The Regents of The University of Michigan * All Rights Reserved * * This code is part of the M5 simulator. * * Permission is granted to use, copy, create derivative works and * redistribute this software and such derivative works for any * purpose, so long as the copyright notice above, this grant of * permission, and the disclaimer below appear in all copies made; and * so long as the name of The University of Michigan is not used in * any advertising or publicity pertaining to the use or distribution * of this software without specific, written prior authorization. * * THIS SOFTWARE IS PROVIDED AS IS, WITHOUT REPRESENTATION FROM THE * UNIVERSITY OF MICHIGAN AS TO ITS FITNESS FOR ANY PURPOSE, AND * WITHOUT WARRANTY BY THE UNIVERSITY OF MICHIGAN OF ANY KIND, EITHER * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE. THE REGENTS OF THE UNIVERSITY OF MICHIGAN SHALL NOT BE * LIABLE FOR ANY DAMAGES, INCLUDING DIRECT, SPECIAL, INDIRECT, * INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WITH RESPECT TO ANY CLAIM * ARISING OUT OF OR IN CONNECTION WITH THE USE OF THE SOFTWARE, EVEN * IF IT HAS BEEN OR IS HEREAFTER ADVISED OF THE POSSIBILITY OF SUCH * DAMAGES. * * Authors: Kevin T. Lim */#ifndef __CPU_O3_RENAME_HH__#define __CPU_O3_RENAME_HH__#include <list>#include "base/statistics.hh"#include "base/timebuf.hh"/** * DefaultRename handles both single threaded and SMT rename. Its * width is specified by the parameters; each cycle it tries to rename * that many instructions. It holds onto the rename history of all * instructions with destination registers, storing the * arch. register, the new physical register, and the old physical * register, to allow for undoing of mappings if squashing happens, or * freeing up registers upon commit. Rename handles blocking if the * ROB, IQ, or LSQ is going to be full. Rename also handles barriers, * and does so by stalling on the instruction until the ROB is empty * and there are no instructions in flight to the ROB. */template<class Impl>class DefaultRename{  public:    // Typedefs from the Impl.    typedef typename Impl::CPUPol CPUPol;    typedef typename Impl::DynInstPtr DynInstPtr;    typedef typename Impl::O3CPU O3CPU;    typedef typename Impl::Params Params;    // Typedefs from the CPUPol    typedef typename CPUPol::DecodeStruct DecodeStruct;    typedef typename CPUPol::RenameStruct RenameStruct;    typedef typename CPUPol::TimeStruct TimeStruct;    typedef typename CPUPol::FreeList FreeList;    typedef typename CPUPol::RenameMap RenameMap;    // These are used only for initialization.    typedef typename CPUPol::IEW IEW;    typedef typename CPUPol::Commit Commit;    // Typedefs from the ISA.    typedef TheISA::RegIndex RegIndex;    // A list is used to queue the instructions.  Barrier insts must    // be added to the front of the list, which is the only reason for    // using a list instead of a queue. (Most other stages use a    // queue)    typedef std::list<DynInstPtr> InstQueue;    typedef typename std::list<DynInstPtr>::iterator ListIt;  public:    /** Overall rename status. Used to determine if the CPU can     * deschedule itself due to a lack of activity.     */    enum RenameStatus {        Active,        Inactive    };    /** Individual thread status. */    enum ThreadStatus {        Running,        Idle,        StartSquash,        Squashing,        Blocked,        Unblocking,        SerializeStall    };  private:    /** Rename status. */    RenameStatus _status;    /** Per-thread status. */    ThreadStatus renameStatus[Impl::MaxThreads];  public:    /** DefaultRename constructor. */    DefaultRename(O3CPU *_cpu, Params *params);    /** Returns the name of rename. */    std::string name() const;    /** Registers statistics. */    void regStats();    /** Sets the main backwards communication time buffer pointer. */    void setTimeBuffer(TimeBuffer<TimeStruct> *tb_ptr);    /** Sets pointer to time buffer used to communicate to the next stage. */    void setRenameQueue(TimeBuffer<RenameStruct> *rq_ptr);    /** Sets pointer to time buffer coming from decode. */    void setDecodeQueue(TimeBuffer<DecodeStruct> *dq_ptr);    /** Sets pointer to IEW stage. Used only for initialization. */    void setIEWStage(IEW *iew_stage)    { iew_ptr = iew_stage; }    /** Sets pointer to commit stage. Used only for initialization. */    void setCommitStage(Commit *commit_stage)    { commit_ptr = commit_stage; }  private:    /** Pointer to IEW stage. Used only for initialization. */    IEW *iew_ptr;    /** Pointer to commit stage. Used only for initialization. */    Commit *commit_ptr;  public:    /** Initializes variables for the stage. */    void initStage();    /** Sets pointer to list of active threads. */    void setActiveThreads(std::list<unsigned> *at_ptr);    /** Sets pointer to rename maps (per-thread structures). */    void setRenameMap(RenameMap rm_ptr[Impl::MaxThreads]);    /** Sets pointer to the free list. */    void setFreeList(FreeList *fl_ptr);    /** Sets pointer to the scoreboard. */    void setScoreboard(Scoreboard *_scoreboard);    /** Drains the rename stage. */    bool drain();    /** Resumes execution after a drain. */    void resume() { }    /** Switches out the rename stage. */    void switchOut();    /** Takes over from another CPU's thread. */    void takeOverFrom();    /** Squashes all instructions in a thread. */    void squash(const InstSeqNum &squash_seq_num, unsigned tid);    /** Ticks rename, which processes all input signals and attempts to rename     * as many instructions as possible.     */    void tick();    /** Debugging function used to dump history buffer of renamings. */    void dumpHistory();  private:    /** Determines what to do based on rename's current status.     * @param status_change rename() sets this variable if there was a status     * change (ie switching from blocking to unblocking).     * @param tid Thread id to rename instructions from.     */    void rename(bool &status_change, unsigned tid);    /** Renames instructions for the given thread. Also handles serializing     * instructions.     */    void renameInsts(unsigned tid);    /** Inserts unused instructions from a given thread into the skid buffer,     * to be renamed once rename unblocks.     */    void skidInsert(unsigned tid);    /** Separates instructions from decode into individual lists of instructions     * sorted by thread.     */    void sortInsts();    /** Returns if all of the skid buffers are empty. */    bool skidsEmpty();    /** Updates overall rename status based on all of the threads' statuses. */    void updateStatus();    /** Switches rename to blocking, and signals back that rename has become     * blocked.     * @return Returns true if there is a status change.     */    bool block(unsigned tid);    /** Switches rename to unblocking if the skid buffer is empty, and signals     * back that rename has unblocked.     * @return Returns true if there is a status change.     */    bool unblock(unsigned tid);    /** Executes actual squash, removing squashed instructions. */    void doSquash(const InstSeqNum &squash_seq_num, unsigned tid);    /** Removes a committed instruction's rename history. */    void removeFromHistory(InstSeqNum inst_seq_num, unsigned tid);    /** Renames the source registers of an instruction. */    inline void renameSrcRegs(DynInstPtr &inst, unsigned tid);    /** Renames the destination registers of an instruction. */    inline void renameDestRegs(DynInstPtr &inst, unsigned tid);    /** Calculates the number of free ROB entries for a specific thread. */    inline int calcFreeROBEntries(unsigned tid);    /** Calculates the number of free IQ entries for a specific thread. */    inline int calcFreeIQEntries(unsigned tid);    /** Calculates the number of free LSQ entries for a specific thread. */    inline int calcFreeLSQEntries(unsigned tid);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?