commit.hh revision 2935:d1223a6c9156
111308Santhony.gutierrez@amd.com/*
211308Santhony.gutierrez@amd.com * Copyright (c) 2004-2006 The Regents of The University of Michigan
311308Santhony.gutierrez@amd.com * All rights reserved.
411308Santhony.gutierrez@amd.com *
511308Santhony.gutierrez@amd.com * Redistribution and use in source and binary forms, with or without
611308Santhony.gutierrez@amd.com * modification, are permitted provided that the following conditions are
711308Santhony.gutierrez@amd.com * met: redistributions of source code must retain the above copyright
811308Santhony.gutierrez@amd.com * notice, this list of conditions and the following disclaimer;
911308Santhony.gutierrez@amd.com * redistributions in binary form must reproduce the above copyright
1011308Santhony.gutierrez@amd.com * notice, this list of conditions and the following disclaimer in the
1111308Santhony.gutierrez@amd.com * documentation and/or other materials provided with the distribution;
1211308Santhony.gutierrez@amd.com * neither the name of the copyright holders nor the names of its
1311308Santhony.gutierrez@amd.com * contributors may be used to endorse or promote products derived from
1411308Santhony.gutierrez@amd.com * this software without specific prior written permission.
1511308Santhony.gutierrez@amd.com *
1611308Santhony.gutierrez@amd.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1711308Santhony.gutierrez@amd.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1811308Santhony.gutierrez@amd.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1911308Santhony.gutierrez@amd.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2011308Santhony.gutierrez@amd.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2111308Santhony.gutierrez@amd.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2211308Santhony.gutierrez@amd.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2311308Santhony.gutierrez@amd.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2411308Santhony.gutierrez@amd.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2511308Santhony.gutierrez@amd.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2611308Santhony.gutierrez@amd.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2711308Santhony.gutierrez@amd.com *
2811308Santhony.gutierrez@amd.com * Authors: Kevin Lim
2911308Santhony.gutierrez@amd.com *          Korey Sewell
3011308Santhony.gutierrez@amd.com */
3111308Santhony.gutierrez@amd.com
3211308Santhony.gutierrez@amd.com#ifndef __CPU_O3_COMMIT_HH__
3311308Santhony.gutierrez@amd.com#define __CPU_O3_COMMIT_HH__
3411308Santhony.gutierrez@amd.com
3511308Santhony.gutierrez@amd.com#include "arch/faults.hh"
3611308Santhony.gutierrez@amd.com#include "base/statistics.hh"
3711308Santhony.gutierrez@amd.com#include "base/timebuf.hh"
3811308Santhony.gutierrez@amd.com#include "cpu/exetrace.hh"
3911308Santhony.gutierrez@amd.com#include "cpu/inst_seq.hh"
4011308Santhony.gutierrez@amd.com
4111308Santhony.gutierrez@amd.comtemplate <class>
4211308Santhony.gutierrez@amd.comclass O3ThreadState;
4311308Santhony.gutierrez@amd.com
4411308Santhony.gutierrez@amd.com/**
4511308Santhony.gutierrez@amd.com * DefaultCommit handles single threaded and SMT commit. Its width is
4611308Santhony.gutierrez@amd.com * specified by the parameters; each cycle it tries to commit that
4711308Santhony.gutierrez@amd.com * many instructions. The SMT policy decides which thread it tries to
4811308Santhony.gutierrez@amd.com * commit instructions from. Non- speculative instructions must reach
4911308Santhony.gutierrez@amd.com * the head of the ROB before they are ready to execute; once they
5011308Santhony.gutierrez@amd.com * reach the head, commit will broadcast the instruction's sequence
5111308Santhony.gutierrez@amd.com * number to the previous stages so that they can issue/ execute the
5211308Santhony.gutierrez@amd.com * instruction. Only one non-speculative instruction is handled per
5311308Santhony.gutierrez@amd.com * cycle. Commit is responsible for handling all back-end initiated
5411308Santhony.gutierrez@amd.com * redirects.  It receives the redirect, and then broadcasts it to all
5511308Santhony.gutierrez@amd.com * stages, indicating the sequence number they should squash until,
5611308Santhony.gutierrez@amd.com * and any necessary branch misprediction information as well. It
5711308Santhony.gutierrez@amd.com * priortizes redirects by instruction's age, only broadcasting a
5811308Santhony.gutierrez@amd.com * redirect if it corresponds to an instruction that should currently
5911308Santhony.gutierrez@amd.com * be in the ROB. This is done by tracking the sequence number of the
6011308Santhony.gutierrez@amd.com * youngest instruction in the ROB, which gets updated to any
6111308Santhony.gutierrez@amd.com * squashing instruction's sequence number, and only broadcasting a
6211308Santhony.gutierrez@amd.com * redirect if it corresponds to an older instruction. Commit also
6311308Santhony.gutierrez@amd.com * supports multiple cycle squashing, to model a ROB that can only
6411308Santhony.gutierrez@amd.com * remove a certain number of instructions per cycle.
6511308Santhony.gutierrez@amd.com */
6611308Santhony.gutierrez@amd.comtemplate<class Impl>
6711308Santhony.gutierrez@amd.comclass DefaultCommit
6811308Santhony.gutierrez@amd.com{
6911308Santhony.gutierrez@amd.com  public:
7011308Santhony.gutierrez@amd.com    // Typedefs from the Impl.
7111308Santhony.gutierrez@amd.com    typedef typename Impl::O3CPU O3CPU;
7211308Santhony.gutierrez@amd.com    typedef typename Impl::DynInstPtr DynInstPtr;
7311308Santhony.gutierrez@amd.com    typedef typename Impl::Params Params;
7411308Santhony.gutierrez@amd.com    typedef typename Impl::CPUPol CPUPol;
7511308Santhony.gutierrez@amd.com
7611308Santhony.gutierrez@amd.com    typedef typename CPUPol::RenameMap RenameMap;
7711308Santhony.gutierrez@amd.com    typedef typename CPUPol::ROB ROB;
7811308Santhony.gutierrez@amd.com
7911308Santhony.gutierrez@amd.com    typedef typename CPUPol::TimeStruct TimeStruct;
8011308Santhony.gutierrez@amd.com    typedef typename CPUPol::FetchStruct FetchStruct;
8111308Santhony.gutierrez@amd.com    typedef typename CPUPol::IEWStruct IEWStruct;
8211308Santhony.gutierrez@amd.com    typedef typename CPUPol::RenameStruct RenameStruct;
8311308Santhony.gutierrez@amd.com
8411308Santhony.gutierrez@amd.com    typedef typename CPUPol::Fetch Fetch;
8511308Santhony.gutierrez@amd.com    typedef typename CPUPol::IEW IEW;
8611308Santhony.gutierrez@amd.com
8711308Santhony.gutierrez@amd.com    typedef O3ThreadState<Impl> Thread;
8811308Santhony.gutierrez@amd.com
8911308Santhony.gutierrez@amd.com    /** Event class used to schedule a squash due to a trap (fault or
9011308Santhony.gutierrez@amd.com     * interrupt) to happen on a specific cycle.
9111308Santhony.gutierrez@amd.com     */
9211308Santhony.gutierrez@amd.com    class TrapEvent : public Event {
9311308Santhony.gutierrez@amd.com      private:
9411308Santhony.gutierrez@amd.com        DefaultCommit<Impl> *commit;
9511308Santhony.gutierrez@amd.com        unsigned tid;
9611308Santhony.gutierrez@amd.com
9711308Santhony.gutierrez@amd.com      public:
9811308Santhony.gutierrez@amd.com        TrapEvent(DefaultCommit<Impl> *_commit, unsigned _tid);
9911308Santhony.gutierrez@amd.com
10011308Santhony.gutierrez@amd.com        void process();
10111308Santhony.gutierrez@amd.com        const char *description();
10211308Santhony.gutierrez@amd.com    };
10311308Santhony.gutierrez@amd.com
10411308Santhony.gutierrez@amd.com    /** Overall commit status. Used to determine if the CPU can deschedule
10511308Santhony.gutierrez@amd.com     * itself due to a lack of activity.
10611308Santhony.gutierrez@amd.com     */
10711308Santhony.gutierrez@amd.com    enum CommitStatus{
10811308Santhony.gutierrez@amd.com        Active,
10911308Santhony.gutierrez@amd.com        Inactive
11011308Santhony.gutierrez@amd.com    };
11111308Santhony.gutierrez@amd.com
11211308Santhony.gutierrez@amd.com    /** Individual thread status. */
11311308Santhony.gutierrez@amd.com    enum ThreadStatus {
11411308Santhony.gutierrez@amd.com        Running,
11511308Santhony.gutierrez@amd.com        Idle,
11611308Santhony.gutierrez@amd.com        ROBSquashing,
11711308Santhony.gutierrez@amd.com        TrapPending,
11811308Santhony.gutierrez@amd.com        FetchTrapPending
11911308Santhony.gutierrez@amd.com    };
12011308Santhony.gutierrez@amd.com
12111308Santhony.gutierrez@amd.com    /** Commit policy for SMT mode. */
12211308Santhony.gutierrez@amd.com    enum CommitPolicy {
12311308Santhony.gutierrez@amd.com        Aggressive,
12411308Santhony.gutierrez@amd.com        RoundRobin,
12511308Santhony.gutierrez@amd.com        OldestReady
12611308Santhony.gutierrez@amd.com    };
12711308Santhony.gutierrez@amd.com
12811308Santhony.gutierrez@amd.com  private:
12911308Santhony.gutierrez@amd.com    /** Overall commit status. */
13011308Santhony.gutierrez@amd.com    CommitStatus _status;
13111308Santhony.gutierrez@amd.com    /** Next commit status, to be set at the end of the cycle. */
13211308Santhony.gutierrez@amd.com    CommitStatus _nextStatus;
13311308Santhony.gutierrez@amd.com    /** Per-thread status. */
13411308Santhony.gutierrez@amd.com    ThreadStatus commitStatus[Impl::MaxThreads];
13511308Santhony.gutierrez@amd.com    /** Commit policy used in SMT mode. */
13611308Santhony.gutierrez@amd.com    CommitPolicy commitPolicy;
13711308Santhony.gutierrez@amd.com
13811308Santhony.gutierrez@amd.com  public:
13911308Santhony.gutierrez@amd.com    /** Construct a DefaultCommit with the given parameters. */
14011308Santhony.gutierrez@amd.com    DefaultCommit(Params *params);
14111308Santhony.gutierrez@amd.com
14211308Santhony.gutierrez@amd.com    /** Returns the name of the DefaultCommit. */
14311308Santhony.gutierrez@amd.com    std::string name() const;
14411308Santhony.gutierrez@amd.com
14511308Santhony.gutierrez@amd.com    /** Registers statistics. */
14611308Santhony.gutierrez@amd.com    void regStats();
14711308Santhony.gutierrez@amd.com
14811308Santhony.gutierrez@amd.com    /** Sets the CPU pointer. */
14911308Santhony.gutierrez@amd.com    void setCPU(O3CPU *cpu_ptr);
15011308Santhony.gutierrez@amd.com
15111308Santhony.gutierrez@amd.com    /** Sets the list of threads. */
15211308Santhony.gutierrez@amd.com    void setThreads(std::vector<Thread *> &threads);
15311308Santhony.gutierrez@amd.com
15411308Santhony.gutierrez@amd.com    /** Sets the main time buffer pointer, used for backwards communication. */
15511308Santhony.gutierrez@amd.com    void setTimeBuffer(TimeBuffer<TimeStruct> *tb_ptr);
15611308Santhony.gutierrez@amd.com
15711308Santhony.gutierrez@amd.com    void setFetchQueue(TimeBuffer<FetchStruct> *fq_ptr);
15811308Santhony.gutierrez@amd.com
15911308Santhony.gutierrez@amd.com    /** Sets the pointer to the queue coming from rename. */
16011308Santhony.gutierrez@amd.com    void setRenameQueue(TimeBuffer<RenameStruct> *rq_ptr);
16111308Santhony.gutierrez@amd.com
16211308Santhony.gutierrez@amd.com    /** Sets the pointer to the queue coming from IEW. */
16311308Santhony.gutierrez@amd.com    void setIEWQueue(TimeBuffer<IEWStruct> *iq_ptr);
16411308Santhony.gutierrez@amd.com
16511308Santhony.gutierrez@amd.com    /** Sets the pointer to the IEW stage. */
16611308Santhony.gutierrez@amd.com    void setIEWStage(IEW *iew_stage);
16711308Santhony.gutierrez@amd.com
16811308Santhony.gutierrez@amd.com    /** The pointer to the IEW stage. Used solely to ensure that
16911308Santhony.gutierrez@amd.com     * various events (traps, interrupts, syscalls) do not occur until
17011308Santhony.gutierrez@amd.com     * all stores have written back.
17111308Santhony.gutierrez@amd.com     */
17211308Santhony.gutierrez@amd.com    IEW *iewStage;
17311308Santhony.gutierrez@amd.com
17411308Santhony.gutierrez@amd.com    /** Sets pointer to list of active threads. */
17511308Santhony.gutierrez@amd.com    void setActiveThreads(std::list<unsigned> *at_ptr);
17611308Santhony.gutierrez@amd.com
17711308Santhony.gutierrez@amd.com    /** Sets pointer to the commited state rename map. */
17811308Santhony.gutierrez@amd.com    void setRenameMap(RenameMap rm_ptr[Impl::MaxThreads]);
17911308Santhony.gutierrez@amd.com
18011308Santhony.gutierrez@amd.com    /** Sets pointer to the ROB. */
18111308Santhony.gutierrez@amd.com    void setROB(ROB *rob_ptr);
18211308Santhony.gutierrez@amd.com
18311308Santhony.gutierrez@amd.com    /** Initializes stage by sending back the number of free entries. */
18411308Santhony.gutierrez@amd.com    void initStage();
18511308Santhony.gutierrez@amd.com
18611308Santhony.gutierrez@amd.com    /** Initializes the draining of commit. */
18711308Santhony.gutierrez@amd.com    bool drain();
18811308Santhony.gutierrez@amd.com
18911308Santhony.gutierrez@amd.com    /** Resumes execution after draining. */
19011308Santhony.gutierrez@amd.com    void resume();
19111308Santhony.gutierrez@amd.com
19211308Santhony.gutierrez@amd.com    /** Completes the switch out of commit. */
19311308Santhony.gutierrez@amd.com    void switchOut();
19411308Santhony.gutierrez@amd.com
19511308Santhony.gutierrez@amd.com    /** Takes over from another CPU's thread. */
19611308Santhony.gutierrez@amd.com    void takeOverFrom();
19711308Santhony.gutierrez@amd.com
19811308Santhony.gutierrez@amd.com    /** Ticks the commit stage, which tries to commit instructions. */
19911308Santhony.gutierrez@amd.com    void tick();
20011308Santhony.gutierrez@amd.com
20111308Santhony.gutierrez@amd.com    /** Handles any squashes that are sent from IEW, and adds instructions
20211308Santhony.gutierrez@amd.com     * to the ROB and tries to commit instructions.
20311308Santhony.gutierrez@amd.com     */
20411308Santhony.gutierrez@amd.com    void commit();
20511308Santhony.gutierrez@amd.com
20611308Santhony.gutierrez@amd.com    /** Returns the number of free ROB entries for a specific thread. */
20711308Santhony.gutierrez@amd.com    unsigned numROBFreeEntries(unsigned tid);
20811308Santhony.gutierrez@amd.com
20911308Santhony.gutierrez@amd.com    /** Generates an event to schedule a squash due to a trap. */
21011308Santhony.gutierrez@amd.com    void generateTrapEvent(unsigned tid);
21111308Santhony.gutierrez@amd.com
21211308Santhony.gutierrez@amd.com    /** Records that commit needs to initiate a squash due to an
21311308Santhony.gutierrez@amd.com     * external state update through the TC.
21411308Santhony.gutierrez@amd.com     */
21511308Santhony.gutierrez@amd.com    void generateTCEvent(unsigned tid);
21611308Santhony.gutierrez@amd.com
21711308Santhony.gutierrez@amd.com  private:
21811308Santhony.gutierrez@amd.com    /** Updates the overall status of commit with the nextStatus, and
21911308Santhony.gutierrez@amd.com     * tell the CPU if commit is active/inactive.
22011308Santhony.gutierrez@amd.com     */
22111308Santhony.gutierrez@amd.com    void updateStatus();
22211308Santhony.gutierrez@amd.com
22311308Santhony.gutierrez@amd.com    /** Sets the next status based on threads' statuses, which becomes the
22411308Santhony.gutierrez@amd.com     * current status at the end of the cycle.
22511308Santhony.gutierrez@amd.com     */
22611308Santhony.gutierrez@amd.com    void setNextStatus();
22711308Santhony.gutierrez@amd.com
22811308Santhony.gutierrez@amd.com    /** Checks if the ROB is completed with squashing. This is for the case
22911308Santhony.gutierrez@amd.com     * where the ROB can take multiple cycles to complete squashing.
23011308Santhony.gutierrez@amd.com     */
23111308Santhony.gutierrez@amd.com    bool robDoneSquashing();
23211308Santhony.gutierrez@amd.com
23311308Santhony.gutierrez@amd.com    /** Returns if any of the threads have the number of ROB entries changed
23411308Santhony.gutierrez@amd.com     * on this cycle. Used to determine if the number of free ROB entries needs
23511308Santhony.gutierrez@amd.com     * to be sent back to previous stages.
23611308Santhony.gutierrez@amd.com     */
23711308Santhony.gutierrez@amd.com    bool changedROBEntries();
23811308Santhony.gutierrez@amd.com
23911308Santhony.gutierrez@amd.com    /** Squashes all in flight instructions. */
24011308Santhony.gutierrez@amd.com    void squashAll(unsigned tid);
24111534Sjohn.kalamatianos@amd.com
24211308Santhony.gutierrez@amd.com    /** Handles squashing due to a trap. */
24311308Santhony.gutierrez@amd.com    void squashFromTrap(unsigned tid);
24411308Santhony.gutierrez@amd.com
24511308Santhony.gutierrez@amd.com    /** Handles squashing due to an TC write. */
24611308Santhony.gutierrez@amd.com    void squashFromTC(unsigned tid);
24711308Santhony.gutierrez@amd.com
24811308Santhony.gutierrez@amd.com    /** Commits as many instructions as possible. */
24911308Santhony.gutierrez@amd.com    void commitInsts();
25011308Santhony.gutierrez@amd.com
25111308Santhony.gutierrez@amd.com    /** Tries to commit the head ROB instruction passed in.
25211308Santhony.gutierrez@amd.com     * @param head_inst The instruction to be committed.
25311308Santhony.gutierrez@amd.com     */
25411308Santhony.gutierrez@amd.com    bool commitHead(DynInstPtr &head_inst, unsigned inst_num);
25511308Santhony.gutierrez@amd.com
25611308Santhony.gutierrez@amd.com    /** Gets instructions from rename and inserts them into the ROB. */
25711308Santhony.gutierrez@amd.com    void getInsts();
25811308Santhony.gutierrez@amd.com
25911308Santhony.gutierrez@amd.com    /** Marks completed instructions using information sent from IEW. */
26011308Santhony.gutierrez@amd.com    void markCompletedInsts();
26111308Santhony.gutierrez@amd.com
26211308Santhony.gutierrez@amd.com    /** Gets the thread to commit, based on the SMT policy. */
26311308Santhony.gutierrez@amd.com    int getCommittingThread();
26411308Santhony.gutierrez@amd.com
26511308Santhony.gutierrez@amd.com    /** Returns the thread ID to use based on a round robin policy. */
26611308Santhony.gutierrez@amd.com    int roundRobin();
26711308Santhony.gutierrez@amd.com
26811308Santhony.gutierrez@amd.com    /** Returns the thread ID to use based on an oldest instruction policy. */
26911308Santhony.gutierrez@amd.com    int oldestReady();
27011308Santhony.gutierrez@amd.com
27111308Santhony.gutierrez@amd.com  public:
27211308Santhony.gutierrez@amd.com    /** Returns the PC of the head instruction of the ROB.
273     * @todo: Probably remove this function as it returns only thread 0.
274     */
275    uint64_t readPC() { return PC[0]; }
276
277    /** Returns the PC of a specific thread. */
278    uint64_t readPC(unsigned tid) { return PC[tid]; }
279
280    /** Sets the PC of a specific thread. */
281    void setPC(uint64_t val, unsigned tid) { PC[tid] = val; }
282
283    /** Reads the next PC of a specific thread. */
284    uint64_t readNextPC(unsigned tid) { return nextPC[tid]; }
285
286    /** Sets the next PC of a specific thread. */
287    void setNextPC(uint64_t val, unsigned tid) { nextPC[tid] = val; }
288
289    /** Reads the next NPC of a specific thread. */
290    uint64_t readNextNPC(unsigned tid) { return nextNPC[tid]; }
291
292    /** Sets the next NPC of a specific thread. */
293    void setNextNPC(uint64_t val, unsigned tid) { nextNPC[tid] = val; }
294
295  private:
296    /** Time buffer interface. */
297    TimeBuffer<TimeStruct> *timeBuffer;
298
299    /** Wire to write information heading to previous stages. */
300    typename TimeBuffer<TimeStruct>::wire toIEW;
301
302    /** Wire to read information from IEW (for ROB). */
303    typename TimeBuffer<TimeStruct>::wire robInfoFromIEW;
304
305    TimeBuffer<FetchStruct> *fetchQueue;
306
307    typename TimeBuffer<FetchStruct>::wire fromFetch;
308
309    /** IEW instruction queue interface. */
310    TimeBuffer<IEWStruct> *iewQueue;
311
312    /** Wire to read information from IEW queue. */
313    typename TimeBuffer<IEWStruct>::wire fromIEW;
314
315    /** Rename instruction queue interface, for ROB. */
316    TimeBuffer<RenameStruct> *renameQueue;
317
318    /** Wire to read information from rename queue. */
319    typename TimeBuffer<RenameStruct>::wire fromRename;
320
321  public:
322    /** ROB interface. */
323    ROB *rob;
324
325  private:
326    /** Pointer to O3CPU. */
327    O3CPU *cpu;
328
329    /** Vector of all of the threads. */
330    std::vector<Thread *> thread;
331
332    /** Records that commit has written to the time buffer this cycle. Used for
333     * the CPU to determine if it can deschedule itself if there is no activity.
334     */
335    bool wroteToTimeBuffer;
336
337    /** Records if the number of ROB entries has changed this cycle. If it has,
338     * then the number of free entries must be re-broadcast.
339     */
340    bool changedROBNumEntries[Impl::MaxThreads];
341
342    /** A counter of how many threads are currently squashing. */
343    int squashCounter;
344
345    /** Records if a thread has to squash this cycle due to a trap. */
346    bool trapSquash[Impl::MaxThreads];
347
348    /** Records if a thread has to squash this cycle due to an XC write. */
349    bool tcSquash[Impl::MaxThreads];
350
351    /** Priority List used for Commit Policy */
352    std::list<unsigned> priority_list;
353
354    /** IEW to Commit delay, in ticks. */
355    unsigned iewToCommitDelay;
356
357    /** Commit to IEW delay, in ticks. */
358    unsigned commitToIEWDelay;
359
360    /** Rename to ROB delay, in ticks. */
361    unsigned renameToROBDelay;
362
363    unsigned fetchToCommitDelay;
364
365    /** Rename width, in instructions.  Used so ROB knows how many
366     *  instructions to get from the rename instruction queue.
367     */
368    unsigned renameWidth;
369
370    /** Commit width, in instructions. */
371    unsigned commitWidth;
372
373    /** Number of Reorder Buffers */
374    unsigned numRobs;
375
376    /** Number of Active Threads */
377    unsigned numThreads;
378
379    /** Is a drain pending. */
380    bool drainPending;
381
382    /** Is commit switched out. */
383    bool switchedOut;
384
385    /** The latency to handle a trap.  Used when scheduling trap
386     * squash event.
387     */
388    Tick trapLatency;
389
390    /** The commit PC of each thread.  Refers to the instruction that
391     * is currently being processed/committed.
392     */
393    Addr PC[Impl::MaxThreads];
394
395    /** The next PC of each thread. */
396    Addr nextPC[Impl::MaxThreads];
397
398    /** The next NPC of each thread. */
399    Addr nextNPC[Impl::MaxThreads];
400
401    /** The sequence number of the youngest valid instruction in the ROB. */
402    InstSeqNum youngestSeqNum[Impl::MaxThreads];
403
404    /** Pointer to the list of active threads. */
405    std::list<unsigned> *activeThreads;
406
407    /** Rename map interface. */
408    RenameMap *renameMap[Impl::MaxThreads];
409
410    /** Updates commit stats based on this instruction. */
411    void updateComInstStats(DynInstPtr &inst);
412
413    /** Stat for the total number of committed instructions. */
414    Stats::Scalar<> commitCommittedInsts;
415    /** Stat for the total number of squashed instructions discarded by commit.
416     */
417    Stats::Scalar<> commitSquashedInsts;
418    /** Stat for the total number of times commit is told to squash.
419     * @todo: Actually increment this stat.
420     */
421    Stats::Scalar<> commitSquashEvents;
422    /** Stat for the total number of times commit has had to stall due to a non-
423     * speculative instruction reaching the head of the ROB.
424     */
425    Stats::Scalar<> commitNonSpecStalls;
426    /** Stat for the total number of branch mispredicts that caused a squash. */
427    Stats::Scalar<> branchMispredicts;
428    /** Distribution of the number of committed instructions each cycle. */
429    Stats::Distribution<> numCommittedDist;
430
431    /** Total number of instructions committed. */
432    Stats::Vector<> statComInst;
433    /** Total number of software prefetches committed. */
434    Stats::Vector<> statComSwp;
435    /** Stat for the total number of committed memory references. */
436    Stats::Vector<> statComRefs;
437    /** Stat for the total number of committed loads. */
438    Stats::Vector<> statComLoads;
439    /** Total number of committed memory barriers. */
440    Stats::Vector<> statComMembars;
441    /** Total number of committed branches. */
442    Stats::Vector<> statComBranches;
443
444    /** Number of cycles where the commit bandwidth limit is reached. */
445    Stats::Scalar<> commitEligibleSamples;
446    /** Number of instructions not committed due to bandwidth limits. */
447    Stats::Vector<> commitEligible;
448};
449
450#endif // __CPU_O3_COMMIT_HH__
451