gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Friends | List of all members
Minor::Execute Class Reference

Execute stage. More...

#include <execute.hh>

Inheritance diagram for Minor::Execute:
Named

Classes

struct  ExecuteThreadInfo
 

Public Member Functions

 Execute (const std::string &name_, MinorCPU &cpu_, MinorCPUParams &params, Latch< ForwardInstData >::Output inp_, Latch< BranchData >::Input out_)
 
 ~Execute ()
 
MinorCPU::MinorCPUPortgetDcachePort ()
 Returns the DcachePort owned by this Execute to pass upwards. More...
 
LSQgetLSQ ()
 To allow ExecContext to find the LSQ. More...
 
bool instIsRightStream (MinorDynInstPtr inst)
 Does the given instruction have the right stream sequence number to be committed? More...
 
bool instIsHeadInst (MinorDynInstPtr inst)
 Returns true if the given instruction is at the head of the inFlightInsts instruction queue. More...
 
void evaluate ()
 Pass on input/buffer data to the output if you can. More...
 
void minorTrace () const
 
bool isDrained ()
 After thread suspension, has Execute been drained of in-flight instructions and memory accesses. More...
 
unsigned int drain ()
 Like the drain interface on SimObject. More...
 
void drainResume ()
 
- Public Member Functions inherited from Named
 Named (const std::string &name_)
 
const std::string & name () const
 

Public Attributes

std::vector< InputBuffer
< ForwardInstData > > 
inputBuffer
 

Protected Types

enum  DrainState { NotDraining, DrainCurrentInst, DrainHaltFetch, DrainAllInsts }
 Stage cycle-by-cycle state. More...
 

Protected Member Functions

const ForwardInstDatagetInput (ThreadID tid)
 Get a piece of data to work on from the inputBuffer, or 0 if there is no data. More...
 
void popInput (ThreadID tid)
 Pop an element off the input buffer, if there are any. More...
 
void tryToBranch (MinorDynInstPtr inst, Fault fault, BranchData &branch)
 Generate Branch data based (into branch) on an observed (or not) change in PC while executing an instruction. More...
 
void updateBranchData (ThreadID tid, BranchData::Reason reason, MinorDynInstPtr inst, const TheISA::PCState &target, BranchData &branch)
 Actually create a branch to communicate to Fetch1/Fetch2 and, if that is a stream-changing branch update the streamSeqNum. More...
 
void handleMemResponse (MinorDynInstPtr inst, LSQ::LSQRequestPtr response, BranchData &branch, Fault &fault)
 Handle extracting mem ref responses from the memory queues and completing the associated instructions. More...
 
bool executeMemRefInst (MinorDynInstPtr inst, BranchData &branch, bool &failed_predicate, Fault &fault)
 Execute a memory reference instruction. More...
 
bool isInterrupted (ThreadID thread_id) const
 Has an interrupt been raised. More...
 
bool isInbetweenInsts (ThreadID thread_id) const
 Are we between instructions? Can we be interrupted? More...
 
bool takeInterrupt (ThreadID thread_id, BranchData &branch)
 Act on an interrupt. More...
 
unsigned int issue (ThreadID thread_id)
 Try and issue instructions from the inputBuffer. More...
 
bool tryPCEvents (ThreadID thread_id)
 Try to act on PC-related events. More...
 
void doInstCommitAccounting (MinorDynInstPtr inst)
 Do the stats handling and instruction count and PC event events related to the new instruction/op counts. More...
 
ThreadID checkInterrupts (BranchData &branch, bool &interrupted)
 Check all threads for possible interrupts. More...
 
bool hasInterrupt (ThreadID thread_id)
 Checks if a specific thread has an interrupt. More...
 
bool commitInst (MinorDynInstPtr inst, bool early_memory_issue, BranchData &branch, Fault &fault, bool &committed, bool &completed_mem_issue)
 Commit a single instruction. More...
 
void commit (ThreadID thread_id, bool only_commit_microops, bool discard, BranchData &branch)
 Try and commit instructions from the ends of the functional unit pipelines. More...
 
void setDrainState (ThreadID thread_id, DrainState state)
 Set the drain state (with useful debugging messages) More...
 
ThreadID getCommittingThread ()
 Use the current threading policy to determine the next thread to decode from. More...
 
ThreadID getIssuingThread ()
 

Protected Attributes

Latch< ForwardInstData >::Output inp
 Input port carrying instructions from Decode. More...
 
Latch< BranchData >::Input out
 Input port carrying stream changes to Fetch1. More...
 
MinorCPUcpu
 Pointer back to the containing CPU. More...
 
unsigned int issueLimit
 Number of instructions that can be issued per cycle. More...
 
unsigned int memoryIssueLimit
 Number of memory ops that can be issued per cycle. More...
 
unsigned int commitLimit
 Number of instructions that can be committed per cycle. More...
 
unsigned int memoryCommitLimit
 Number of memory instructions that can be committed per cycle. More...
 
bool processMoreThanOneInput
 If true, more than one input line can be processed each cycle if there is room to execute more instructions than taken from the first line. More...
 
MinorFUPoolfuDescriptions
 Descriptions of the functional units we want to generate. More...
 
unsigned int numFuncUnits
 Number of functional units to produce. More...
 
Cycles longestFuLatency
 Longest latency of any FU, useful for setting up the activity recoder. More...
 
bool setTraceTimeOnCommit
 Modify instruction trace times on commit. More...
 
bool setTraceTimeOnIssue
 Modify instruction trace times on issue. More...
 
bool allowEarlyMemIssue
 Allow mem refs to leave their FUs before reaching the head of the in flight insts queue if their dependencies are met. More...
 
unsigned int noCostFUIndex
 The FU index of the non-existent costless FU for instructions which pass the MinorDynInst::isNoCostInst test. More...
 
LSQ lsq
 Dcache port to pass on to the CPU. More...
 
std::vector< Scoreboardscoreboard
 Scoreboard of instruction dependencies. More...
 
std::vector< FUPipeline * > funcUnits
 The execution functional units. More...
 
std::vector< ExecuteThreadInfoexecuteInfo
 
ThreadID interruptPriority
 
ThreadID issuePriority
 
ThreadID commitPriority
 
- Protected Attributes inherited from Named
const std::string _name
 

Friends

std::ostream & operator<< (std::ostream &os, DrainState state)
 

Detailed Description

Execute stage.

Everything apart from fetching and decoding instructions. The LSQ lives here too.

Definition at line 62 of file execute.hh.

Member Enumeration Documentation

Stage cycle-by-cycle state.

State that drain passes through (in order). On a drain request, Execute transitions into either DrainCurrentInst (if between microops) or DrainHaltFetch.

Note that Execute doesn't actually have * a 'Drained' state, only an indication that it's currently draining and isDrained that can't tell if there are insts still in the pipeline leading up to Execute

Enumerator
NotDraining 
DrainCurrentInst 
DrainHaltFetch 
DrainAllInsts 

Definition at line 138 of file execute.hh.

Constructor & Destructor Documentation

Minor::Execute::Execute ( const std::string &  name_,
MinorCPU cpu_,
MinorCPUParams &  params,
Latch< ForwardInstData >::Output  inp_,
Latch< BranchData >::Input  out_ 
)
Minor::Execute::~Execute ( )

Definition at line 1834 of file execute.cc.

References cpu, executeInfo, funcUnits, ArmISA::i, and numFuncUnits.

Member Function Documentation

ThreadID Minor::Execute::checkInterrupts ( BranchData branch,
bool &  interrupted 
)
protected

Check all threads for possible interrupts.

If interrupt is taken, returns the tid of the thread. interrupted is set if any thread has an interrupt, irrespective of if it is taken

Definition at line 1579 of file execute.cc.

References cpu, DPRINTF, executeInfo, FullSystem, interruptPriority, InvalidThreadID, isInbetweenInsts(), isInterrupted(), NotDraining, and takeInterrupt().

Referenced by evaluate().

void Minor::Execute::commit ( ThreadID  thread_id,
bool  only_commit_microops,
bool  discard,
BranchData branch 
)
protected

Try and commit instructions from the ends of the functional unit pipelines.

If only_commit_microops is true then only commit upto the end of the currect full instruction. If discard is true then discard all instructions rather than committing. branch is set to any branch raised during commit.

Try and execute as many instructions from the end of FU pipelines as possible. This doesn't include actually advancing the pipelines.

We do this by looping on the front of the inFlightInsts queue for as long as we can find the desired instruction at the end of the functional unit it was issued to without seeing a branch or a fault. In this function, these terms are used: complete – The instruction has finished its passage through its functional unit and its fate has been decided (committed, discarded, issued to the memory system) commit – The instruction is complete(d), not discarded and has its effects applied to the CPU state discard(ed) – The instruction is complete but not committed as its streamSeqNum disagrees with the current Execute::streamSeqNum

Commits are also possible from two other places:

1) Responses returning from the LSQ 2) Mem ops issued to the LSQ ('committed' from the FUs) earlier than their position in the inFlightInsts queue, but after all their dependencies are resolved.

Definition at line 1003 of file execute.cc.

References Minor::MinorDynInst::bubble(), Minor::LSQ::canRequest(), commitInst(), commitLimit, Minor::LSQ::completeMemBarrierInst(), cpu, curTick(), DPRINTF, DTRACE, executeInfo, Minor::LSQ::findResponse(), Minor::SelfStallingPipeline< ElemType, ReportTraits, BubbleTraits >::front(), PowerISA::fu, funcUnits, Minor::LSQ::getLastMemBarrier(), handleMemResponse(), Minor::Execute::ExecuteThreadInfo::inFlightInsts, Minor::Execute::ExecuteThreadInfo::inFUMemInsts, Minor::QueuedInst::inst, Minor::ForwardInstData::insts, Minor::Execute::ExecuteThreadInfo::instsBeingCommitted, isInbetweenInsts(), Minor::BranchData::isStreamChange(), Minor::Execute::ExecuteThreadInfo::lastCommitWasEndOfMacroop, Minor::Execute::ExecuteThreadInfo::lastPredictionSeqNum, lsq, memoryCommitLimit, noCostFUIndex, NoFault, Minor::MinorStats::numDiscardedOps, ThreadContext::pcState(), Minor::LSQ::popResponse(), scoreboard, setTraceTimeOnCommit, MinorCPU::stats, Minor::Execute::ExecuteThreadInfo::streamSeqNum, tryPCEvents(), Minor::BranchData::UnpredictedBranch, and updateBranchData().

Referenced by evaluate().

bool Minor::Execute::commitInst ( MinorDynInstPtr  inst,
bool  early_memory_issue,
BranchData branch,
Fault fault,
bool &  committed,
bool &  completed_mem_issue 
)
protected

Commit a single instruction.

Returns true if the instruction being examined was completed (fully executed, discarded, or initiated a memory access), false if there is still some processing to do. fu_index is the index of the functional unit this instruction is being executed in into for funcUnits If early_memory_issue is true then this is an early execution of a mem ref and so faults will not be processed. If the return value is true: fault is set if a fault happened, branch is set to indicate any branch that occurs committed is set to true if this instruction is committed (and so needs to be traced and accounted for) completed_mem_issue is set if the instruction was a memory access that was issued

Definition at line 870 of file execute.cc.

References Minor::LSQ::canPushIntoStoreBuffer(), cpu, doInstCommitAccounting(), DPRINTF, executeInfo, executeMemRefInst(), Minor::BranchData::isBubble(), isInterrupted(), lsq, NoFault, Minor::MinorStats::numFetchSuspends, panic, Minor::ExecContext::readPredicate(), MinorCPU::stats, ThreadContext::status(), ThreadContext::Suspended, Minor::BranchData::SuspendThread, MinorCPU::threads, tryToBranch(), and updateBranchData().

Referenced by commit().

void Minor::Execute::doInstCommitAccounting ( MinorDynInstPtr  inst)
protected

Do the stats handling and instruction count and PC event events related to the new instruction/op counts.

Definition at line 837 of file execute.cc.

References Minor::MinorStats::committedInstType, cpu, Minor::MinorStats::numInsts, Minor::MinorStats::numOps, MinorCPU::stats, and MinorCPU::threads.

Referenced by commitInst(), and handleMemResponse().

unsigned int Minor::Execute::drain ( )
void Minor::Execute::drainResume ( )
void Minor::Execute::evaluate ( )
bool Minor::Execute::executeMemRefInst ( MinorDynInstPtr  inst,
BranchData branch,
bool &  failed_predicate,
Fault fault 
)
protected

Execute a memory reference instruction.

This calls initiateAcc on the instruction which will then call writeMem or readMem to issue a memory access to the LSQ. Returns true if the instruction was executed rather than stalled because of a lack of LSQ resources and false otherwise. branch is set to any branch raised by the instruction. failed_predicate is set to false if the instruction passed its predicate and so will access memory or true if the instruction failed its predicate and is now complete. fault is set if any non-NoFault fault is raised. Any faults raised are actually invoke-d by this function.

Definition at line 444 of file execute.cc.

References Minor::LSQ::canRequest(), cpu, DPRINTF, lsq, NoFault, ThreadContext::pcState(), Minor::LSQ::pushFailedRequest(), Minor::ExecContext::readPredicate(), and MinorCPU::threads.

Referenced by commitInst().

ThreadID Minor::Execute::getCommittingThread ( )
inlineprotected
MinorCPU::MinorCPUPort & Minor::Execute::getDcachePort ( )

Returns the DcachePort owned by this Execute to pass upwards.

Definition at line 1861 of file execute.cc.

References Minor::LSQ::getDcachePort(), and lsq.

Referenced by Minor::Pipeline::getDataPort().

const ForwardInstData * Minor::Execute::getInput ( ThreadID  tid)
protected

Get a piece of data to work on from the inputBuffer, or 0 if there is no data.

Definition at line 194 of file execute.cc.

References inputBuffer, and Minor::ForwardInstData::isBubble().

Referenced by evaluate(), getIssuingThread(), and issue().

ThreadID Minor::Execute::getIssuingThread ( )
inlineprotected
LSQ& Minor::Execute::getLSQ ( )
inline

To allow ExecContext to find the LSQ.

Definition at line 331 of file execute.hh.

References lsq.

Referenced by Minor::ExecContext::initiateMemRead(), and Minor::ExecContext::writeMem().

void Minor::Execute::handleMemResponse ( MinorDynInstPtr  inst,
LSQ::LSQRequestPtr  response,
BranchData branch,
Fault fault 
)
protected

Handle extracting mem ref responses from the memory queues and completing the associated instructions.

Fault is an output and will contain any fault caused (and already invoked by the function) Sets branch to any branch generated by the instruction.

Definition at line 320 of file execute.cc.

References cpu, doInstCommitAccounting(), DPRINTF, fatal, Minor::LSQ::LSQRequest::fault, Packet::getAddr(), Packet::getConstPtr(), Packet::getSize(), Packet::isError(), lsq, Minor::LSQ::LSQRequest::needsToBeSentToStoreBuffer(), NoFault, Minor::LSQ::LSQRequest::packet, Minor::LSQ::popResponse(), Minor::ExecContext::readPredicate(), Minor::LSQ::sendStoreToStoreBuffer(), MinorCPU::threads, and tryToBranch().

Referenced by commit().

bool Minor::Execute::hasInterrupt ( ThreadID  thread_id)
protected

Checks if a specific thread has an interrupt.

No action is taken. this is used for determining if a thread should only commit microops

Definition at line 1614 of file execute.cc.

References cpu, executeInfo, FullSystem, isInterrupted(), and NotDraining.

Referenced by evaluate().

bool Minor::Execute::instIsHeadInst ( MinorDynInstPtr  inst)

Returns true if the given instruction is at the head of the inFlightInsts instruction queue.

Definition at line 1850 of file execute.cc.

References executeInfo.

Referenced by Minor::LSQ::tryToSendToTransfers().

bool Minor::Execute::instIsRightStream ( MinorDynInstPtr  inst)

Does the given instruction have the right stream sequence number to be committed?

Definition at line 1844 of file execute.cc.

References executeInfo.

Referenced by Minor::LSQ::tryToSendToTransfers().

bool Minor::Execute::isDrained ( )

After thread suspension, has Execute been drained of in-flight instructions and memory accesses.

Definition at line 1818 of file execute.cc.

References cpu, executeInfo, inputBuffer, Minor::LSQ::isDrained(), and lsq.

Referenced by drain(), and Minor::Pipeline::isDrained().

bool Minor::Execute::isInbetweenInsts ( ThreadID  thread_id) const
protected

Are we between instructions? Can we be interrupted?

Definition at line 1386 of file execute.cc.

References Minor::LSQ::accessesInFlight(), executeInfo, and lsq.

Referenced by checkInterrupts(), commit(), drain(), evaluate(), and minorTrace().

bool Minor::Execute::isInterrupted ( ThreadID  thread_id) const
protected

Has an interrupt been raised.

Definition at line 408 of file execute.cc.

References cpu.

Referenced by checkInterrupts(), commitInst(), and hasInterrupt().

unsigned int Minor::Execute::issue ( ThreadID  thread_id)
protected
void Minor::Execute::minorTrace ( ) const
void Minor::Execute::popInput ( ThreadID  tid)
protected

Pop an element off the input buffer, if there are any.

Definition at line 207 of file execute.cc.

References executeInfo, and inputBuffer.

Referenced by evaluate(), and issue().

void Minor::Execute::setDrainState ( ThreadID  thread_id,
DrainState  state 
)
protected

Set the drain state (with useful debugging messages)

Definition at line 1789 of file execute.cc.

References DPRINTF, and executeInfo.

Referenced by drain(), drainResume(), and evaluate().

bool Minor::Execute::takeInterrupt ( ThreadID  thread_id,
BranchData branch 
)
protected

Act on an interrupt.

Returns true if an interrupt was actually signalled and invoked

Definition at line 414 of file execute.cc.

References Minor::LSQ::accessesInFlight(), Minor::MinorDynInst::bubble(), cpu, DPRINTF, interrupt, Minor::BranchData::Interrupt, lsq, NoFault, and updateBranchData().

Referenced by checkInterrupts().

bool Minor::Execute::tryPCEvents ( ThreadID  thread_id)
protected

Try to act on PC-related events.

Returns true if any were executed

Definition at line 815 of file execute.cc.

References cpu, DPRINTF, ThreadContext::instAddr(), and ThreadContext::pcState().

Referenced by commit().

void Minor::Execute::tryToBranch ( MinorDynInstPtr  inst,
Fault  fault,
BranchData branch 
)
protected

Generate Branch data based (into branch) on an observed (or not) change in PC while executing an instruction.

Also handles branch prediction information within the inst.

Definition at line 216 of file execute.cc.

References AlphaISA::advancePC(), Minor::BranchData::BadlyPredictedBranch, Minor::BranchData::BadlyPredictedBranchTarget, Minor::BranchData::CorrectlyPredictedBranch, cpu, DPRINTF, Minor::BranchData::NoBranch, NoFault, ThreadContext::pcState(), ThreadContext::status(), ThreadContext::Suspended, Minor::BranchData::UnpredictedBranch, and updateBranchData().

Referenced by commitInst(), and handleMemResponse().

void Minor::Execute::updateBranchData ( ThreadID  tid,
BranchData::Reason  reason,
MinorDynInstPtr  inst,
const TheISA::PCState &  target,
BranchData branch 
)
protected

Actually create a branch to communicate to Fetch1/Fetch2 and, if that is a stream-changing branch update the streamSeqNum.

Definition at line 294 of file execute.cc.

References DPRINTF, executeInfo, Minor::BranchData::isStreamChange(), and Minor::BranchData::NoBranch.

Referenced by commit(), commitInst(), evaluate(), takeInterrupt(), and tryToBranch().

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
Execute::DrainState  state 
)
friend

Definition at line 1764 of file execute.cc.

Member Data Documentation

bool Minor::Execute::allowEarlyMemIssue
protected

Allow mem refs to leave their FUs before reaching the head of the in flight insts queue if their dependencies are met.

Definition at line 109 of file execute.hh.

Referenced by issue().

unsigned int Minor::Execute::commitLimit
protected

Number of instructions that can be committed per cycle.

Definition at line 81 of file execute.hh.

Referenced by commit(), and Execute().

ThreadID Minor::Execute::commitPriority
protected

Definition at line 204 of file execute.hh.

Referenced by getCommittingThread().

MinorCPU& Minor::Execute::cpu
protected
std::vector<ExecuteThreadInfo> Minor::Execute::executeInfo
protected
MinorFUPool& Minor::Execute::fuDescriptions
protected

Descriptions of the functional units we want to generate.

Definition at line 92 of file execute.hh.

Referenced by Execute().

std::vector<FUPipeline *> Minor::Execute::funcUnits
protected

The execution functional units.

Definition at line 122 of file execute.hh.

Referenced by commit(), evaluate(), Execute(), getCommittingThread(), issue(), minorTrace(), and ~Execute().

Latch<ForwardInstData>::Output Minor::Execute::inp
protected

Input port carrying instructions from Decode.

Definition at line 66 of file execute.hh.

Referenced by evaluate().

std::vector<InputBuffer<ForwardInstData> > Minor::Execute::inputBuffer

Definition at line 125 of file execute.hh.

Referenced by evaluate(), Execute(), getInput(), isDrained(), minorTrace(), and popInput().

ThreadID Minor::Execute::interruptPriority
protected

Definition at line 202 of file execute.hh.

Referenced by checkInterrupts().

unsigned int Minor::Execute::issueLimit
protected

Number of instructions that can be issued per cycle.

Definition at line 75 of file execute.hh.

Referenced by Execute(), and issue().

ThreadID Minor::Execute::issuePriority
protected

Definition at line 203 of file execute.hh.

Referenced by getIssuingThread().

Cycles Minor::Execute::longestFuLatency
protected

Longest latency of any FU, useful for setting up the activity recoder.

Definition at line 99 of file execute.hh.

LSQ Minor::Execute::lsq
protected
unsigned int Minor::Execute::memoryCommitLimit
protected

Number of memory instructions that can be committed per cycle.

Definition at line 84 of file execute.hh.

Referenced by commit(), and Execute().

unsigned int Minor::Execute::memoryIssueLimit
protected

Number of memory ops that can be issued per cycle.

Definition at line 78 of file execute.hh.

Referenced by Execute(), and issue().

unsigned int Minor::Execute::noCostFUIndex
protected

The FU index of the non-existent costless FU for instructions which pass the MinorDynInst::isNoCostInst test.

Definition at line 113 of file execute.hh.

Referenced by commit(), getCommittingThread(), and issue().

unsigned int Minor::Execute::numFuncUnits
protected

Number of functional units to produce.

Definition at line 95 of file execute.hh.

Referenced by evaluate(), Execute(), issue(), minorTrace(), and ~Execute().

Latch<BranchData>::Input Minor::Execute::out
protected

Input port carrying stream changes to Fetch1.

Definition at line 69 of file execute.hh.

Referenced by evaluate().

bool Minor::Execute::processMoreThanOneInput
protected

If true, more than one input line can be processed each cycle if there is room to execute more instructions than taken from the first line.

Definition at line 89 of file execute.hh.

Referenced by issue().

std::vector<Scoreboard> Minor::Execute::scoreboard
protected

Scoreboard of instruction dependencies.

Definition at line 119 of file execute.hh.

Referenced by commit(), evaluate(), Execute(), issue(), and minorTrace().

bool Minor::Execute::setTraceTimeOnCommit
protected

Modify instruction trace times on commit.

Definition at line 102 of file execute.hh.

Referenced by commit().

bool Minor::Execute::setTraceTimeOnIssue
protected

Modify instruction trace times on issue.

Definition at line 105 of file execute.hh.

Referenced by issue().


The documentation for this class was generated from the following files:

Generated on Fri Jun 9 2017 13:04:33 for gem5 by doxygen 1.8.6