110259SAndrew.Bardsley@arm.com/*
210259SAndrew.Bardsley@arm.com * Copyright (c) 2013-2014 ARM Limited
310259SAndrew.Bardsley@arm.com * All rights reserved
410259SAndrew.Bardsley@arm.com *
510259SAndrew.Bardsley@arm.com * The license below extends only to copyright in the software and shall
610259SAndrew.Bardsley@arm.com * not be construed as granting a license to any other intellectual
710259SAndrew.Bardsley@arm.com * property including but not limited to intellectual property relating
810259SAndrew.Bardsley@arm.com * to a hardware implementation of the functionality of the software
910259SAndrew.Bardsley@arm.com * licensed hereunder.  You may use the software subject to the license
1010259SAndrew.Bardsley@arm.com * terms below provided that you ensure that this notice is replicated
1110259SAndrew.Bardsley@arm.com * unmodified and in its entirety in all distributions of the software,
1210259SAndrew.Bardsley@arm.com * modified or unmodified, in source code or in binary form.
1310259SAndrew.Bardsley@arm.com *
1410259SAndrew.Bardsley@arm.com * Redistribution and use in source and binary forms, with or without
1510259SAndrew.Bardsley@arm.com * modification, are permitted provided that the following conditions are
1610259SAndrew.Bardsley@arm.com * met: redistributions of source code must retain the above copyright
1710259SAndrew.Bardsley@arm.com * notice, this list of conditions and the following disclaimer;
1810259SAndrew.Bardsley@arm.com * redistributions in binary form must reproduce the above copyright
1910259SAndrew.Bardsley@arm.com * notice, this list of conditions and the following disclaimer in the
2010259SAndrew.Bardsley@arm.com * documentation and/or other materials provided with the distribution;
2110259SAndrew.Bardsley@arm.com * neither the name of the copyright holders nor the names of its
2210259SAndrew.Bardsley@arm.com * contributors may be used to endorse or promote products derived from
2310259SAndrew.Bardsley@arm.com * this software without specific prior written permission.
2410259SAndrew.Bardsley@arm.com *
2510259SAndrew.Bardsley@arm.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2610259SAndrew.Bardsley@arm.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2710259SAndrew.Bardsley@arm.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2810259SAndrew.Bardsley@arm.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2910259SAndrew.Bardsley@arm.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3010259SAndrew.Bardsley@arm.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3110259SAndrew.Bardsley@arm.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3210259SAndrew.Bardsley@arm.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3310259SAndrew.Bardsley@arm.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3410259SAndrew.Bardsley@arm.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3510259SAndrew.Bardsley@arm.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3610259SAndrew.Bardsley@arm.com *
3710259SAndrew.Bardsley@arm.com * Authors: Andrew Bardsley
3810259SAndrew.Bardsley@arm.com */
3910259SAndrew.Bardsley@arm.com
4010259SAndrew.Bardsley@arm.com/**
4110259SAndrew.Bardsley@arm.com * @file
4210259SAndrew.Bardsley@arm.com *
4310259SAndrew.Bardsley@arm.com *  All the fun of executing instructions from Decode and sending branch/new
4410259SAndrew.Bardsley@arm.com *  instruction stream info. to Fetch1.
4510259SAndrew.Bardsley@arm.com */
4610259SAndrew.Bardsley@arm.com
4710259SAndrew.Bardsley@arm.com#ifndef __CPU_MINOR_EXECUTE_HH__
4810259SAndrew.Bardsley@arm.com#define __CPU_MINOR_EXECUTE_HH__
4910259SAndrew.Bardsley@arm.com
5010259SAndrew.Bardsley@arm.com#include "cpu/minor/buffers.hh"
5110259SAndrew.Bardsley@arm.com#include "cpu/minor/cpu.hh"
5210259SAndrew.Bardsley@arm.com#include "cpu/minor/func_unit.hh"
5310259SAndrew.Bardsley@arm.com#include "cpu/minor/lsq.hh"
5410259SAndrew.Bardsley@arm.com#include "cpu/minor/pipe_data.hh"
5510259SAndrew.Bardsley@arm.com#include "cpu/minor/scoreboard.hh"
5610259SAndrew.Bardsley@arm.com
5710259SAndrew.Bardsley@arm.comnamespace Minor
5810259SAndrew.Bardsley@arm.com{
5910259SAndrew.Bardsley@arm.com
6010259SAndrew.Bardsley@arm.com/** Execute stage.  Everything apart from fetching and decoding instructions.
6110259SAndrew.Bardsley@arm.com *  The LSQ lives here too. */
6210259SAndrew.Bardsley@arm.comclass Execute : public Named
6310259SAndrew.Bardsley@arm.com{
6410259SAndrew.Bardsley@arm.com  protected:
6510259SAndrew.Bardsley@arm.com    /** Input port carrying instructions from Decode */
6610259SAndrew.Bardsley@arm.com    Latch<ForwardInstData>::Output inp;
6710259SAndrew.Bardsley@arm.com
6810259SAndrew.Bardsley@arm.com    /** Input port carrying stream changes to Fetch1 */
6910259SAndrew.Bardsley@arm.com    Latch<BranchData>::Input out;
7010259SAndrew.Bardsley@arm.com
7110259SAndrew.Bardsley@arm.com    /** Pointer back to the containing CPU */
7210259SAndrew.Bardsley@arm.com    MinorCPU &cpu;
7310259SAndrew.Bardsley@arm.com
7410259SAndrew.Bardsley@arm.com    /** Number of instructions that can be issued per cycle */
7510259SAndrew.Bardsley@arm.com    unsigned int issueLimit;
7610259SAndrew.Bardsley@arm.com
7710259SAndrew.Bardsley@arm.com    /** Number of memory ops that can be issued per cycle */
7810259SAndrew.Bardsley@arm.com    unsigned int memoryIssueLimit;
7910259SAndrew.Bardsley@arm.com
8010259SAndrew.Bardsley@arm.com    /** Number of instructions that can be committed per cycle */
8110259SAndrew.Bardsley@arm.com    unsigned int commitLimit;
8210259SAndrew.Bardsley@arm.com
8310259SAndrew.Bardsley@arm.com    /** Number of memory instructions that can be committed per cycle */
8410259SAndrew.Bardsley@arm.com    unsigned int memoryCommitLimit;
8510259SAndrew.Bardsley@arm.com
8610259SAndrew.Bardsley@arm.com    /** If true, more than one input line can be processed each cycle if
8710259SAndrew.Bardsley@arm.com     *  there is room to execute more instructions than taken from the first
8810259SAndrew.Bardsley@arm.com     *  line */
8910259SAndrew.Bardsley@arm.com    bool processMoreThanOneInput;
9010259SAndrew.Bardsley@arm.com
9110259SAndrew.Bardsley@arm.com    /** Descriptions of the functional units we want to generate */
9210259SAndrew.Bardsley@arm.com    MinorFUPool &fuDescriptions;
9310259SAndrew.Bardsley@arm.com
9410259SAndrew.Bardsley@arm.com    /** Number of functional units to produce */
9510259SAndrew.Bardsley@arm.com    unsigned int numFuncUnits;
9610259SAndrew.Bardsley@arm.com
9710259SAndrew.Bardsley@arm.com    /** Longest latency of any FU, useful for setting up the activity
9810259SAndrew.Bardsley@arm.com     *  recoder */
9910259SAndrew.Bardsley@arm.com    Cycles longestFuLatency;
10010259SAndrew.Bardsley@arm.com
10110259SAndrew.Bardsley@arm.com    /** Modify instruction trace times on commit */
10210259SAndrew.Bardsley@arm.com    bool setTraceTimeOnCommit;
10310259SAndrew.Bardsley@arm.com
10410259SAndrew.Bardsley@arm.com    /** Modify instruction trace times on issue */
10510259SAndrew.Bardsley@arm.com    bool setTraceTimeOnIssue;
10610259SAndrew.Bardsley@arm.com
10710259SAndrew.Bardsley@arm.com    /** Allow mem refs to leave their FUs before reaching the head
10810259SAndrew.Bardsley@arm.com     *  of the in flight insts queue if their dependencies are met */
10910259SAndrew.Bardsley@arm.com    bool allowEarlyMemIssue;
11010259SAndrew.Bardsley@arm.com
11110259SAndrew.Bardsley@arm.com    /** The FU index of the non-existent costless FU for instructions
11210259SAndrew.Bardsley@arm.com     *  which pass the MinorDynInst::isNoCostInst test */
11310259SAndrew.Bardsley@arm.com    unsigned int noCostFUIndex;
11410259SAndrew.Bardsley@arm.com
11510259SAndrew.Bardsley@arm.com    /** Dcache port to pass on to the CPU.  Execute owns this */
11610259SAndrew.Bardsley@arm.com    LSQ lsq;
11710259SAndrew.Bardsley@arm.com
11810259SAndrew.Bardsley@arm.com    /** Scoreboard of instruction dependencies */
11911567Smitch.hayenga@arm.com    std::vector<Scoreboard> scoreboard;
12010259SAndrew.Bardsley@arm.com
12110259SAndrew.Bardsley@arm.com    /** The execution functional units */
12210259SAndrew.Bardsley@arm.com    std::vector<FUPipeline *> funcUnits;
12310259SAndrew.Bardsley@arm.com
12410259SAndrew.Bardsley@arm.com  public: /* Public for Pipeline to be able to pass it to Decode */
12511567Smitch.hayenga@arm.com    std::vector<InputBuffer<ForwardInstData>> inputBuffer;
12610259SAndrew.Bardsley@arm.com
12710259SAndrew.Bardsley@arm.com  protected:
12810259SAndrew.Bardsley@arm.com    /** Stage cycle-by-cycle state */
12910259SAndrew.Bardsley@arm.com
13010259SAndrew.Bardsley@arm.com    /** State that drain passes through (in order).  On a drain request,
13110259SAndrew.Bardsley@arm.com     *  Execute transitions into either DrainCurrentInst (if between
13210259SAndrew.Bardsley@arm.com     *  microops) or DrainHaltFetch.
13310259SAndrew.Bardsley@arm.com     *
13410259SAndrew.Bardsley@arm.com     *  Note that Execute doesn't actually have *  a 'Drained' state, only
13510259SAndrew.Bardsley@arm.com     *  an indication that it's currently draining and isDrained that can't
13610259SAndrew.Bardsley@arm.com     *  tell if there are insts still in the pipeline leading up to
13710259SAndrew.Bardsley@arm.com     *  Execute */
13810259SAndrew.Bardsley@arm.com    enum DrainState
13910259SAndrew.Bardsley@arm.com    {
14010259SAndrew.Bardsley@arm.com        NotDraining, /* Not draining, possibly running */
14110259SAndrew.Bardsley@arm.com        DrainCurrentInst, /* Draining to end of inst/macroop */
14210259SAndrew.Bardsley@arm.com        DrainHaltFetch, /* Halting Fetch after completing current inst */
14310259SAndrew.Bardsley@arm.com        DrainAllInsts /* Discarding all remaining insts */
14410259SAndrew.Bardsley@arm.com    };
14510259SAndrew.Bardsley@arm.com
14611567Smitch.hayenga@arm.com    struct ExecuteThreadInfo {
14711567Smitch.hayenga@arm.com        /** Constructor */
14811567Smitch.hayenga@arm.com        ExecuteThreadInfo(unsigned int insts_committed) :
14911567Smitch.hayenga@arm.com            inputIndex(0),
15011567Smitch.hayenga@arm.com            lastCommitWasEndOfMacroop(true),
15111567Smitch.hayenga@arm.com            instsBeingCommitted(insts_committed),
15211567Smitch.hayenga@arm.com            streamSeqNum(InstId::firstStreamSeqNum),
15311567Smitch.hayenga@arm.com            lastPredictionSeqNum(InstId::firstPredictionSeqNum),
15411567Smitch.hayenga@arm.com            drainState(NotDraining)
15511567Smitch.hayenga@arm.com        { }
15610259SAndrew.Bardsley@arm.com
15711567Smitch.hayenga@arm.com        ExecuteThreadInfo(const ExecuteThreadInfo& other) :
15811567Smitch.hayenga@arm.com            inputIndex(other.inputIndex),
15911567Smitch.hayenga@arm.com            lastCommitWasEndOfMacroop(other.lastCommitWasEndOfMacroop),
16011567Smitch.hayenga@arm.com            instsBeingCommitted(other.instsBeingCommitted),
16111567Smitch.hayenga@arm.com            streamSeqNum(other.streamSeqNum),
16211567Smitch.hayenga@arm.com            lastPredictionSeqNum(other.lastPredictionSeqNum),
16311567Smitch.hayenga@arm.com            drainState(other.drainState)
16411567Smitch.hayenga@arm.com        { }
16510259SAndrew.Bardsley@arm.com
16611567Smitch.hayenga@arm.com        /** In-order instructions either in FUs or the LSQ */
16711567Smitch.hayenga@arm.com        Queue<QueuedInst, ReportTraitsAdaptor<QueuedInst> > *inFlightInsts;
16810259SAndrew.Bardsley@arm.com
16911567Smitch.hayenga@arm.com        /** Memory ref instructions still in the FUs */
17011567Smitch.hayenga@arm.com        Queue<QueuedInst, ReportTraitsAdaptor<QueuedInst> > *inFUMemInsts;
17110259SAndrew.Bardsley@arm.com
17211567Smitch.hayenga@arm.com        /** Index that we've completed upto in getInput data.  We can say we're
17311567Smitch.hayenga@arm.com         *  popInput when this equals getInput()->width() */
17411567Smitch.hayenga@arm.com        unsigned int inputIndex;
17510259SAndrew.Bardsley@arm.com
17611567Smitch.hayenga@arm.com        /** The last commit was the end of a full instruction so an interrupt
17711567Smitch.hayenga@arm.com         *  can safely happen */
17811567Smitch.hayenga@arm.com        bool lastCommitWasEndOfMacroop;
17910259SAndrew.Bardsley@arm.com
18011567Smitch.hayenga@arm.com        /** Structure for reporting insts currently being processed/retired
18111567Smitch.hayenga@arm.com         *  for MinorTrace */
18211567Smitch.hayenga@arm.com        ForwardInstData instsBeingCommitted;
18310259SAndrew.Bardsley@arm.com
18411567Smitch.hayenga@arm.com        /** Source of sequence number for instuction streams.  Increment this and
18511567Smitch.hayenga@arm.com         *  pass to fetch whenever an instruction stream needs to be changed.
18611567Smitch.hayenga@arm.com         *  For any more complicated behaviour (e.g. speculation) there'll need
18711567Smitch.hayenga@arm.com         *  to be another plan. */
18811567Smitch.hayenga@arm.com        InstSeqNum streamSeqNum;
18911567Smitch.hayenga@arm.com
19011567Smitch.hayenga@arm.com        /** A prediction number for use where one isn't available from an
19111567Smitch.hayenga@arm.com         *  instruction.  This is harvested from committed instructions.
19211567Smitch.hayenga@arm.com         *  This isn't really needed as the streamSeqNum will change on
19311567Smitch.hayenga@arm.com         *  a branch, but it minimises disruption in stream identification */
19411567Smitch.hayenga@arm.com        InstSeqNum lastPredictionSeqNum;
19511567Smitch.hayenga@arm.com
19611567Smitch.hayenga@arm.com        /** State progression for draining NotDraining -> ... -> DrainAllInsts */
19711567Smitch.hayenga@arm.com        DrainState drainState;
19811567Smitch.hayenga@arm.com    };
19911567Smitch.hayenga@arm.com
20011567Smitch.hayenga@arm.com    std::vector<ExecuteThreadInfo> executeInfo;
20111567Smitch.hayenga@arm.com
20211567Smitch.hayenga@arm.com    ThreadID interruptPriority;
20311567Smitch.hayenga@arm.com    ThreadID issuePriority;
20411567Smitch.hayenga@arm.com    ThreadID commitPriority;
20510259SAndrew.Bardsley@arm.com
20610259SAndrew.Bardsley@arm.com  protected:
20710259SAndrew.Bardsley@arm.com    friend std::ostream &operator <<(std::ostream &os, DrainState state);
20810259SAndrew.Bardsley@arm.com
20910259SAndrew.Bardsley@arm.com    /** Get a piece of data to work on from the inputBuffer, or 0 if there
21010259SAndrew.Bardsley@arm.com     *  is no data. */
21111567Smitch.hayenga@arm.com    const ForwardInstData *getInput(ThreadID tid);
21210259SAndrew.Bardsley@arm.com
21310259SAndrew.Bardsley@arm.com    /** Pop an element off the input buffer, if there are any */
21411567Smitch.hayenga@arm.com    void popInput(ThreadID tid);
21510259SAndrew.Bardsley@arm.com
21610259SAndrew.Bardsley@arm.com    /** Generate Branch data based (into branch) on an observed (or not)
21710259SAndrew.Bardsley@arm.com     *  change in PC while executing an instruction.
21810259SAndrew.Bardsley@arm.com     *  Also handles branch prediction information within the inst. */
21910259SAndrew.Bardsley@arm.com    void tryToBranch(MinorDynInstPtr inst, Fault fault, BranchData &branch);
22010259SAndrew.Bardsley@arm.com
22110259SAndrew.Bardsley@arm.com    /** Actually create a branch to communicate to Fetch1/Fetch2 and,
22210259SAndrew.Bardsley@arm.com     *  if that is a stream-changing branch update the streamSeqNum */
22311567Smitch.hayenga@arm.com    void updateBranchData(ThreadID tid, BranchData::Reason reason,
22410259SAndrew.Bardsley@arm.com        MinorDynInstPtr inst, const TheISA::PCState &target,
22510259SAndrew.Bardsley@arm.com        BranchData &branch);
22610259SAndrew.Bardsley@arm.com
22710259SAndrew.Bardsley@arm.com    /** Handle extracting mem ref responses from the memory queues and
22810259SAndrew.Bardsley@arm.com     *  completing the associated instructions.
22910259SAndrew.Bardsley@arm.com     *  Fault is an output and will contain any fault caused (and already
23010259SAndrew.Bardsley@arm.com     *  invoked by the function)
23110259SAndrew.Bardsley@arm.com     *  Sets branch to any branch generated by the instruction. */
23210259SAndrew.Bardsley@arm.com    void handleMemResponse(MinorDynInstPtr inst,
23310259SAndrew.Bardsley@arm.com        LSQ::LSQRequestPtr response, BranchData &branch,
23410259SAndrew.Bardsley@arm.com        Fault &fault);
23510259SAndrew.Bardsley@arm.com
23610259SAndrew.Bardsley@arm.com    /** Execute a memory reference instruction.  This calls initiateAcc on
23710259SAndrew.Bardsley@arm.com     *  the instruction which will then call writeMem or readMem to issue a
23810259SAndrew.Bardsley@arm.com     *  memory access to the LSQ.
23910259SAndrew.Bardsley@arm.com     *  Returns true if the instruction was executed rather than stalled
24010259SAndrew.Bardsley@arm.com     *  because of a lack of LSQ resources and false otherwise.
24110259SAndrew.Bardsley@arm.com     *  branch is set to any branch raised by the instruction.
24210259SAndrew.Bardsley@arm.com     *  failed_predicate is set to false if the instruction passed its
24310259SAndrew.Bardsley@arm.com     *  predicate and so will access memory or true if the instruction
24410259SAndrew.Bardsley@arm.com     *  *failed* its predicate and is now complete.
24510259SAndrew.Bardsley@arm.com     *  fault is set if any non-NoFault fault is raised.
24610259SAndrew.Bardsley@arm.com     *  Any faults raised are actually invoke-d by this function. */
24710259SAndrew.Bardsley@arm.com    bool executeMemRefInst(MinorDynInstPtr inst, BranchData &branch,
24810259SAndrew.Bardsley@arm.com        bool &failed_predicate, Fault &fault);
24910259SAndrew.Bardsley@arm.com
25010259SAndrew.Bardsley@arm.com    /** Has an interrupt been raised */
25110259SAndrew.Bardsley@arm.com    bool isInterrupted(ThreadID thread_id) const;
25210259SAndrew.Bardsley@arm.com
25310259SAndrew.Bardsley@arm.com    /** Are we between instructions?  Can we be interrupted? */
25411567Smitch.hayenga@arm.com    bool isInbetweenInsts(ThreadID thread_id) const;
25510259SAndrew.Bardsley@arm.com
25610259SAndrew.Bardsley@arm.com    /** Act on an interrupt.  Returns true if an interrupt was actually
25710259SAndrew.Bardsley@arm.com     *  signalled and invoked */
25810259SAndrew.Bardsley@arm.com    bool takeInterrupt(ThreadID thread_id, BranchData &branch);
25910259SAndrew.Bardsley@arm.com
26010259SAndrew.Bardsley@arm.com    /** Try and issue instructions from the inputBuffer */
26111567Smitch.hayenga@arm.com    unsigned int issue(ThreadID thread_id);
26210259SAndrew.Bardsley@arm.com
26310259SAndrew.Bardsley@arm.com    /** Try to act on PC-related events.  Returns true if any were
26410259SAndrew.Bardsley@arm.com     *  executed */
26511567Smitch.hayenga@arm.com    bool tryPCEvents(ThreadID thread_id);
26610259SAndrew.Bardsley@arm.com
26710259SAndrew.Bardsley@arm.com    /** Do the stats handling and instruction count and PC event events
26810259SAndrew.Bardsley@arm.com     *  related to the new instruction/op counts */
26910259SAndrew.Bardsley@arm.com    void doInstCommitAccounting(MinorDynInstPtr inst);
27010259SAndrew.Bardsley@arm.com
27111567Smitch.hayenga@arm.com    /** Check all threads for possible interrupts. If interrupt is taken,
27211567Smitch.hayenga@arm.com     *  returns the tid of the thread.  interrupted is set if any thread
27311567Smitch.hayenga@arm.com     *  has an interrupt, irrespective of if it is taken */
27411567Smitch.hayenga@arm.com    ThreadID checkInterrupts(BranchData& branch, bool& interrupted);
27511567Smitch.hayenga@arm.com
27611567Smitch.hayenga@arm.com    /** Checks if a specific thread has an interrupt.  No action is taken.
27711567Smitch.hayenga@arm.com     *  this is used for determining if a thread should only commit microops */
27811567Smitch.hayenga@arm.com    bool hasInterrupt(ThreadID thread_id);
27911567Smitch.hayenga@arm.com
28010259SAndrew.Bardsley@arm.com    /** Commit a single instruction.  Returns true if the instruction being
28110259SAndrew.Bardsley@arm.com     *  examined was completed (fully executed, discarded, or initiated a
28210259SAndrew.Bardsley@arm.com     *  memory access), false if there is still some processing to do.
28310259SAndrew.Bardsley@arm.com     *  fu_index is the index of the functional unit this instruction is
28410259SAndrew.Bardsley@arm.com     *  being executed in into for funcUnits
28510259SAndrew.Bardsley@arm.com     *  If early_memory_issue is true then this is an early execution
28610259SAndrew.Bardsley@arm.com     *  of a mem ref and so faults will not be processed.
28710259SAndrew.Bardsley@arm.com     *  If the return value is true:
28810259SAndrew.Bardsley@arm.com     *      fault is set if a fault happened,
28910259SAndrew.Bardsley@arm.com     *      branch is set to indicate any branch that occurs
29010259SAndrew.Bardsley@arm.com     *      committed is set to true if this instruction is committed
29110259SAndrew.Bardsley@arm.com     *          (and so needs to be traced and accounted for)
29210259SAndrew.Bardsley@arm.com     *      completed_mem_issue is set if the instruction was a
29310259SAndrew.Bardsley@arm.com     *          memory access that was issued */
29410259SAndrew.Bardsley@arm.com    bool commitInst(MinorDynInstPtr inst, bool early_memory_issue,
29510259SAndrew.Bardsley@arm.com        BranchData &branch, Fault &fault, bool &committed,
29610259SAndrew.Bardsley@arm.com        bool &completed_mem_issue);
29710259SAndrew.Bardsley@arm.com
29810259SAndrew.Bardsley@arm.com    /** Try and commit instructions from the ends of the functional unit
29910259SAndrew.Bardsley@arm.com     *  pipelines.
30010259SAndrew.Bardsley@arm.com     *  If only_commit_microops is true then only commit upto the
30110259SAndrew.Bardsley@arm.com     *  end of the currect full instruction.
30210259SAndrew.Bardsley@arm.com     *  If discard is true then discard all instructions rather than
30310259SAndrew.Bardsley@arm.com     *  committing.
30410259SAndrew.Bardsley@arm.com     *  branch is set to any branch raised during commit. */
30511567Smitch.hayenga@arm.com    void commit(ThreadID thread_id, bool only_commit_microops, bool discard,
30611567Smitch.hayenga@arm.com        BranchData &branch);
30710259SAndrew.Bardsley@arm.com
30810259SAndrew.Bardsley@arm.com    /** Set the drain state (with useful debugging messages) */
30911567Smitch.hayenga@arm.com    void setDrainState(ThreadID thread_id, DrainState state);
31011567Smitch.hayenga@arm.com
31111567Smitch.hayenga@arm.com    /** Use the current threading policy to determine the next thread to
31211567Smitch.hayenga@arm.com     *  decode from. */
31311567Smitch.hayenga@arm.com    ThreadID getCommittingThread();
31411567Smitch.hayenga@arm.com    ThreadID getIssuingThread();
31510259SAndrew.Bardsley@arm.com
31610259SAndrew.Bardsley@arm.com  public:
31710259SAndrew.Bardsley@arm.com    Execute(const std::string &name_,
31810259SAndrew.Bardsley@arm.com        MinorCPU &cpu_,
31910259SAndrew.Bardsley@arm.com        MinorCPUParams &params,
32010259SAndrew.Bardsley@arm.com        Latch<ForwardInstData>::Output inp_,
32110259SAndrew.Bardsley@arm.com        Latch<BranchData>::Input out_);
32210259SAndrew.Bardsley@arm.com
32310259SAndrew.Bardsley@arm.com    ~Execute();
32410259SAndrew.Bardsley@arm.com
32510259SAndrew.Bardsley@arm.com  public:
32610259SAndrew.Bardsley@arm.com
32710259SAndrew.Bardsley@arm.com    /** Returns the DcachePort owned by this Execute to pass upwards */
32810259SAndrew.Bardsley@arm.com    MinorCPU::MinorCPUPort &getDcachePort();
32910259SAndrew.Bardsley@arm.com
33010259SAndrew.Bardsley@arm.com    /** To allow ExecContext to find the LSQ */
33110259SAndrew.Bardsley@arm.com    LSQ &getLSQ() { return lsq; }
33210259SAndrew.Bardsley@arm.com
33310259SAndrew.Bardsley@arm.com    /** Does the given instruction have the right stream sequence number
33410259SAndrew.Bardsley@arm.com     *  to be committed? */
33510259SAndrew.Bardsley@arm.com    bool instIsRightStream(MinorDynInstPtr inst);
33610259SAndrew.Bardsley@arm.com
33710259SAndrew.Bardsley@arm.com    /** Returns true if the given instruction is at the head of the
33810259SAndrew.Bardsley@arm.com     *  inFlightInsts instruction queue */
33910259SAndrew.Bardsley@arm.com    bool instIsHeadInst(MinorDynInstPtr inst);
34010259SAndrew.Bardsley@arm.com
34110259SAndrew.Bardsley@arm.com    /** Pass on input/buffer data to the output if you can */
34210259SAndrew.Bardsley@arm.com    void evaluate();
34310259SAndrew.Bardsley@arm.com
34410259SAndrew.Bardsley@arm.com    void minorTrace() const;
34510259SAndrew.Bardsley@arm.com
34610259SAndrew.Bardsley@arm.com    /** After thread suspension, has Execute been drained of in-flight
34710259SAndrew.Bardsley@arm.com     *  instructions and memory accesses. */
34810259SAndrew.Bardsley@arm.com    bool isDrained();
34910259SAndrew.Bardsley@arm.com
35010259SAndrew.Bardsley@arm.com    /** Like the drain interface on SimObject */
35110259SAndrew.Bardsley@arm.com    unsigned int drain();
35210259SAndrew.Bardsley@arm.com    void drainResume();
35310259SAndrew.Bardsley@arm.com};
35410259SAndrew.Bardsley@arm.com
35510259SAndrew.Bardsley@arm.com}
35610259SAndrew.Bardsley@arm.com
35710259SAndrew.Bardsley@arm.com#endif /* __CPU_MINOR_EXECUTE_HH__ */
358