gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
DefaultDecode< Impl > Class Template Reference

DefaultDecode class handles both single threaded and SMT decode. More...

#include <decode.hh>

Classes

struct  Stalls
 Source of possible stalls. More...
 

Public Types

enum  DecodeStatus { Active, Inactive }
 Overall decode stage status. More...
 
enum  ThreadStatus {
  Running, Idle, StartSquash, Squashing,
  Blocked, Unblocking
}
 Individual thread status. More...
 

Public Member Functions

 DefaultDecode (O3CPU *_cpu, DerivO3CPUParams *params)
 DefaultDecode constructor. More...
 
void startupStage ()
 
void resetStage ()
 
std::string name () const
 Returns the name of decode. More...
 
void regStats ()
 Registers statistics. More...
 
void setTimeBuffer (TimeBuffer< TimeStruct > *tb_ptr)
 Sets the main backwards communication time buffer pointer. More...
 
void setDecodeQueue (TimeBuffer< DecodeStruct > *dq_ptr)
 Sets pointer to time buffer used to communicate to the next stage. More...
 
void setFetchQueue (TimeBuffer< FetchStruct > *fq_ptr)
 Sets pointer to time buffer coming from fetch. More...
 
void setActiveThreads (std::list< ThreadID > *at_ptr)
 Sets pointer to list of active threads. More...
 
void drainSanityCheck () const
 Perform sanity checks after a drain. More...
 
bool isDrained () const
 Has the stage drained? More...
 
void takeOverFrom ()
 Takes over from another CPU's thread. More...
 
void tick ()
 Ticks decode, processing all input signals and decoding as many instructions as possible. More...
 
void decode (bool &status_change, ThreadID tid)
 Determines what to do based on decode's current status. More...
 
void decodeInsts (ThreadID tid)
 Processes instructions from fetch and passes them on to rename. More...
 
unsigned squash (ThreadID tid)
 Squashes due to commit signalling a squash. More...
 

Private Types

typedef Impl::O3CPU O3CPU
 
typedef Impl::DynInstPtr DynInstPtr
 
typedef Impl::CPUPol CPUPol
 
typedef CPUPol::FetchStruct FetchStruct
 
typedef CPUPol::DecodeStruct DecodeStruct
 
typedef CPUPol::TimeStruct TimeStruct
 

Private Member Functions

void skidInsert (ThreadID tid)
 Inserts a thread's instructions into the skid buffer, to be decoded once decode unblocks. More...
 
bool skidsEmpty ()
 Returns if all of the skid buffers are empty. More...
 
void updateStatus ()
 Updates overall decode status based on all of the threads' statuses. More...
 
void sortInsts ()
 Separates instructions from fetch into individual lists of instructions sorted by thread. More...
 
void readStallSignals (ThreadID tid)
 Reads all stall signals from the backwards communication timebuffer. More...
 
bool checkSignalsAndUpdate (ThreadID tid)
 Checks all input signals and updates decode's status appropriately. More...
 
bool checkStall (ThreadID tid) const
 Checks all stall signals, and returns if any are true. More...
 
bool fetchInstsValid ()
 Returns if there any instructions from fetch on this cycle. More...
 
bool block (ThreadID tid)
 Switches decode to blocking, and signals back that decode has become blocked. More...
 
bool unblock (ThreadID tid)
 Switches decode to unblocking if the skid buffer is empty, and signals back that decode has unblocked. More...
 
void squash (DynInstPtr &inst, ThreadID tid)
 Squashes if there is a PC-relative branch that was predicted incorrectly. More...
 

Private Attributes

DecodeStatus _status
 Decode status. More...
 
ThreadStatus decodeStatus [Impl::MaxThreads]
 Per-thread status. More...
 
O3CPUcpu
 CPU interface. More...
 
TimeBuffer< TimeStruct > * timeBuffer
 Time buffer interface. More...
 
TimeBuffer< TimeStruct >::wire fromRename
 Wire to get rename's output from backwards time buffer. More...
 
TimeBuffer< TimeStruct >::wire fromIEW
 Wire to get iew's information from backwards time buffer. More...
 
TimeBuffer< TimeStruct >::wire fromCommit
 Wire to get commit's information from backwards time buffer. More...
 
TimeBuffer< TimeStruct >::wire toFetch
 Wire to write information heading to previous stages. More...
 
TimeBuffer< DecodeStruct > * decodeQueue
 Decode instruction queue. More...
 
TimeBuffer< DecodeStruct >::wire toRename
 Wire used to write any information heading to rename. More...
 
TimeBuffer< FetchStruct > * fetchQueue
 Fetch instruction queue interface. More...
 
TimeBuffer< FetchStruct >::wire fromFetch
 Wire to get fetch's output from fetch queue. More...
 
std::queue< DynInstPtrinsts [Impl::MaxThreads]
 Queue of all instructions coming from fetch this cycle. More...
 
std::queue< DynInstPtrskidBuffer [Impl::MaxThreads]
 Skid buffer between fetch and decode. More...
 
bool wroteToTimeBuffer
 Variable that tracks if decode has written to the time buffer this cycle. More...
 
Stalls stalls [Impl::MaxThreads]
 Tracks which stages are telling decode to stall. More...
 
Cycles renameToDecodeDelay
 Rename to decode delay. More...
 
Cycles iewToDecodeDelay
 IEW to decode delay. More...
 
Cycles commitToDecodeDelay
 Commit to decode delay. More...
 
Cycles fetchToDecodeDelay
 Fetch to decode delay. More...
 
unsigned decodeWidth
 The width of decode, in instructions. More...
 
unsigned toRenameIndex
 Index of instructions being sent to rename. More...
 
ThreadID numThreads
 number of Active Threads More...
 
std::list< ThreadID > * activeThreads
 List of active thread ids. More...
 
unsigned skidBufferMax
 Maximum size of the skid buffer. More...
 
Addr bdelayDoneSeqNum [Impl::MaxThreads]
 SeqNum of Squashing Branch Delay Instruction (used for MIPS) More...
 
DynInstPtr squashInst [Impl::MaxThreads]
 Instruction used for squashing branch (used for MIPS) More...
 
bool squashAfterDelaySlot [Impl::MaxThreads]
 Tells when their is a pending delay slot inst. More...
 
Stats::Scalar decodeIdleCycles
 Stat for total number of idle cycles. More...
 
Stats::Scalar decodeBlockedCycles
 Stat for total number of blocked cycles. More...
 
Stats::Scalar decodeRunCycles
 Stat for total number of normal running cycles. More...
 
Stats::Scalar decodeUnblockCycles
 Stat for total number of unblocking cycles. More...
 
Stats::Scalar decodeSquashCycles
 Stat for total number of squashing cycles. More...
 
Stats::Scalar decodeBranchResolved
 Stat for number of times a branch is resolved at decode. More...
 
Stats::Scalar decodeBranchMispred
 Stat for number of times a branch mispredict is detected. More...
 
Stats::Scalar decodeControlMispred
 Stat for number of times decode detected a non-control instruction incorrectly predicted as a branch. More...
 
Stats::Scalar decodeDecodedInsts
 Stat for total number of decoded instructions. More...
 
Stats::Scalar decodeSquashedInsts
 Stat for total number of squashed instructions. More...
 

Detailed Description

template<class Impl>
class DefaultDecode< Impl >

DefaultDecode class handles both single threaded and SMT decode.

Its width is specified by the parameters; each cycles it tries to decode that many instructions. Because instructions are actually decoded when the StaticInst is created, this stage does not do much other than check any PC-relative branches.

Definition at line 61 of file decode.hh.

Member Typedef Documentation

template<class Impl >
typedef Impl::CPUPol DefaultDecode< Impl >::CPUPol
private

Definition at line 67 of file decode.hh.

template<class Impl >
typedef CPUPol::DecodeStruct DefaultDecode< Impl >::DecodeStruct
private

Definition at line 71 of file decode.hh.

template<class Impl >
typedef Impl::DynInstPtr DefaultDecode< Impl >::DynInstPtr
private

Definition at line 66 of file decode.hh.

template<class Impl >
typedef CPUPol::FetchStruct DefaultDecode< Impl >::FetchStruct
private

Definition at line 70 of file decode.hh.

template<class Impl >
typedef Impl::O3CPU DefaultDecode< Impl >::O3CPU
private

Definition at line 65 of file decode.hh.

template<class Impl >
typedef CPUPol::TimeStruct DefaultDecode< Impl >::TimeStruct
private

Definition at line 72 of file decode.hh.

Member Enumeration Documentation

template<class Impl >
enum DefaultDecode::DecodeStatus

Overall decode stage status.

Used to determine if the CPU can deschedule itself due to a lack of activity.

Enumerator
Active 
Inactive 

Definition at line 78 of file decode.hh.

template<class Impl >
enum DefaultDecode::ThreadStatus

Individual thread status.

Enumerator
Running 
Idle 
StartSquash 
Squashing 
Blocked 
Unblocking 

Definition at line 84 of file decode.hh.

Constructor & Destructor Documentation

template<class Impl >
DefaultDecode< Impl >::DefaultDecode ( O3CPU _cpu,
DerivO3CPUParams *  params 
)

Member Function Documentation

template<class Impl >
bool DefaultDecode< Impl >::block ( ThreadID  tid)
private

Switches decode to blocking, and signals back that decode has become blocked.

Returns
Returns true if there is a status change.

Definition at line 242 of file decode_impl.hh.

References DPRINTF.

template<class Impl >
bool DefaultDecode< Impl >::checkSignalsAndUpdate ( ThreadID  tid)
private

Checks all input signals and updates decode's status appropriately.

Definition at line 494 of file decode_impl.hh.

References DPRINTF, and Running.

template<class Impl >
bool DefaultDecode< Impl >::checkStall ( ThreadID  tid) const
private

Checks all stall signals, and returns if any are true.

Definition at line 221 of file decode_impl.hh.

References DPRINTF.

template<class Impl >
void DefaultDecode< Impl >::decode ( bool &  status_change,
ThreadID  tid 
)

Determines what to do based on decode's current status.

Parameters
status_changedecode() sets this variable if there was a status change (ie switching from from blocking to unblocking).
tidThread id to decode instructions from.

Definition at line 587 of file decode_impl.hh.

References DPRINTF, and Running.

template<class Impl >
void DefaultDecode< Impl >::decodeInsts ( ThreadID  tid)

Processes instructions from fetch and passes them on to rename.

Decoding of instructions actually happens when they are created in fetch, so this function mostly checks if PC-relative branches are correct.

Definition at line 632 of file decode_impl.hh.

References curTick(), DPRINTF, DTRACE, panic, and Running.

template<class Impl >
void DefaultDecode< Impl >::drainSanityCheck ( ) const

Perform sanity checks after a drain.

Definition at line 199 of file decode_impl.hh.

template<class Impl >
bool DefaultDecode< Impl >::fetchInstsValid ( )
inlineprivate

Returns if there any instructions from fetch on this cycle.

Definition at line 235 of file decode_impl.hh.

template<class Impl >
bool DefaultDecode< Impl >::isDrained ( ) const

Has the stage drained?

Definition at line 209 of file decode_impl.hh.

References Running.

template<class Impl >
std::string DefaultDecode< Impl >::name ( ) const

Returns the name of decode.

Definition at line 103 of file decode_impl.hh.

template<class Impl >
void DefaultDecode< Impl >::readStallSignals ( ThreadID  tid)
private

Reads all stall signals from the backwards communication timebuffer.

Definition at line 480 of file decode_impl.hh.

template<class Impl >
void DefaultDecode< Impl >::regStats ( )

Registers statistics.

Definition at line 110 of file decode_impl.hh.

References name().

template<class Impl >
void DefaultDecode< Impl >::resetStage ( )

Definition at line 89 of file decode_impl.hh.

Referenced by DefaultDecode< Impl >::takeOverFrom().

template<class Impl >
void DefaultDecode< Impl >::setActiveThreads ( std::list< ThreadID > *  at_ptr)

Sets pointer to list of active threads.

Definition at line 192 of file decode_impl.hh.

template<class Impl >
void DefaultDecode< Impl >::setDecodeQueue ( TimeBuffer< DecodeStruct > *  dq_ptr)

Sets pointer to time buffer used to communicate to the next stage.

Definition at line 172 of file decode_impl.hh.

References TimeBuffer< T >::getWire().

template<class Impl >
void DefaultDecode< Impl >::setFetchQueue ( TimeBuffer< FetchStruct > *  fq_ptr)

Sets pointer to time buffer coming from fetch.

Definition at line 182 of file decode_impl.hh.

References TimeBuffer< T >::getWire().

template<class Impl >
void DefaultDecode< Impl >::setTimeBuffer ( TimeBuffer< TimeStruct > *  tb_ptr)

Sets the main backwards communication time buffer pointer.

Definition at line 157 of file decode_impl.hh.

References TimeBuffer< T >::getWire().

template<class Impl >
void DefaultDecode< Impl >::skidInsert ( ThreadID  tid)
private

Inserts a thread's instructions into the skid buffer, to be decoded once decode unblocks.

Definition at line 391 of file decode_impl.hh.

References DPRINTF, and X86ISA::size().

template<class Impl >
bool DefaultDecode< Impl >::skidsEmpty ( )
private

Returns if all of the skid buffers are empty.

Definition at line 415 of file decode_impl.hh.

template<class Impl >
void DefaultDecode< Impl >::sortInsts ( )
private

Separates instructions from fetch into individual lists of instructions sorted by thread.

Definition at line 470 of file decode_impl.hh.

References ArmISA::i.

template<class Impl >
void DefaultDecode< Impl >::squash ( DynInstPtr inst,
ThreadID  tid 
)
private

Squashes if there is a PC-relative branch that was predicted incorrectly.

Sends squash information back to fetch.

Definition at line 291 of file decode_impl.hh.

References DPRINTF, and ArmISA::i.

template<class Impl >
unsigned DefaultDecode< Impl >::squash ( ThreadID  tid)

Squashes due to commit signalling a squash.

Changes status to squashing and clears block/unblock signals as needed.

Definition at line 343 of file decode_impl.hh.

References DPRINTF, FullSystem, and ArmISA::i.

template<class Impl >
void DefaultDecode< Impl >::startupStage ( )

Definition at line 82 of file decode_impl.hh.

template<class Impl >
void DefaultDecode< Impl >::takeOverFrom ( )
inline

Takes over from another CPU's thread.

Definition at line 132 of file decode.hh.

References DefaultDecode< Impl >::resetStage().

template<class Impl >
void DefaultDecode< Impl >::tick ( )

Ticks decode, processing all input signals and decoding as many instructions as possible.

Definition at line 551 of file decode_impl.hh.

References DPRINTF.

template<class Impl >
bool DefaultDecode< Impl >::unblock ( ThreadID  tid)
private

Switches decode to unblocking if the skid buffer is empty, and signals back that decode has unblocked.

Returns
Returns true if there is a status change.

Definition at line 272 of file decode_impl.hh.

References DPRINTF, and Running.

template<class Impl >
void DefaultDecode< Impl >::updateStatus ( )
private

Updates overall decode status based on all of the threads' statuses.

Definition at line 431 of file decode_impl.hh.

References DPRINTF.

Member Data Documentation

template<class Impl >
DecodeStatus DefaultDecode< Impl >::_status
private

Decode status.

Definition at line 95 of file decode.hh.

template<class Impl >
std::list<ThreadID>* DefaultDecode< Impl >::activeThreads
private

List of active thread ids.

Definition at line 279 of file decode.hh.

template<class Impl >
Addr DefaultDecode< Impl >::bdelayDoneSeqNum[Impl::MaxThreads]
private

SeqNum of Squashing Branch Delay Instruction (used for MIPS)

Definition at line 285 of file decode.hh.

template<class Impl >
Cycles DefaultDecode< Impl >::commitToDecodeDelay
private

Commit to decode delay.

Definition at line 264 of file decode.hh.

template<class Impl >
O3CPU* DefaultDecode< Impl >::cpu
private

CPU interface.

Definition at line 208 of file decode.hh.

template<class Impl >
Stats::Scalar DefaultDecode< Impl >::decodeBlockedCycles
private

Stat for total number of blocked cycles.

Definition at line 300 of file decode.hh.

template<class Impl >
Stats::Scalar DefaultDecode< Impl >::decodeBranchMispred
private

Stat for number of times a branch mispredict is detected.

Definition at line 310 of file decode.hh.

template<class Impl >
Stats::Scalar DefaultDecode< Impl >::decodeBranchResolved
private

Stat for number of times a branch is resolved at decode.

Definition at line 308 of file decode.hh.

template<class Impl >
Stats::Scalar DefaultDecode< Impl >::decodeControlMispred
private

Stat for number of times decode detected a non-control instruction incorrectly predicted as a branch.

Definition at line 314 of file decode.hh.

template<class Impl >
Stats::Scalar DefaultDecode< Impl >::decodeDecodedInsts
private

Stat for total number of decoded instructions.

Definition at line 316 of file decode.hh.

template<class Impl >
Stats::Scalar DefaultDecode< Impl >::decodeIdleCycles
private

Stat for total number of idle cycles.

Definition at line 298 of file decode.hh.

template<class Impl >
TimeBuffer<DecodeStruct>* DefaultDecode< Impl >::decodeQueue
private

Decode instruction queue.

Definition at line 227 of file decode.hh.

template<class Impl >
Stats::Scalar DefaultDecode< Impl >::decodeRunCycles
private

Stat for total number of normal running cycles.

Definition at line 302 of file decode.hh.

template<class Impl >
Stats::Scalar DefaultDecode< Impl >::decodeSquashCycles
private

Stat for total number of squashing cycles.

Definition at line 306 of file decode.hh.

template<class Impl >
Stats::Scalar DefaultDecode< Impl >::decodeSquashedInsts
private

Stat for total number of squashed instructions.

Definition at line 318 of file decode.hh.

template<class Impl >
ThreadStatus DefaultDecode< Impl >::decodeStatus[Impl::MaxThreads]
private

Per-thread status.

Definition at line 98 of file decode.hh.

template<class Impl >
Stats::Scalar DefaultDecode< Impl >::decodeUnblockCycles
private

Stat for total number of unblocking cycles.

Definition at line 304 of file decode.hh.

template<class Impl >
unsigned DefaultDecode< Impl >::decodeWidth
private

The width of decode, in instructions.

Definition at line 270 of file decode.hh.

Referenced by DefaultDecode< Impl >::DefaultDecode().

template<class Impl >
TimeBuffer<FetchStruct>* DefaultDecode< Impl >::fetchQueue
private

Fetch instruction queue interface.

Definition at line 233 of file decode.hh.

template<class Impl >
Cycles DefaultDecode< Impl >::fetchToDecodeDelay
private

Fetch to decode delay.

Definition at line 267 of file decode.hh.

Referenced by DefaultDecode< Impl >::DefaultDecode().

template<class Impl >
TimeBuffer<TimeStruct>::wire DefaultDecode< Impl >::fromCommit
private

Wire to get commit's information from backwards time buffer.

Definition at line 220 of file decode.hh.

template<class Impl >
TimeBuffer<FetchStruct>::wire DefaultDecode< Impl >::fromFetch
private

Wire to get fetch's output from fetch queue.

Definition at line 236 of file decode.hh.

template<class Impl >
TimeBuffer<TimeStruct>::wire DefaultDecode< Impl >::fromIEW
private

Wire to get iew's information from backwards time buffer.

Definition at line 217 of file decode.hh.

template<class Impl >
TimeBuffer<TimeStruct>::wire DefaultDecode< Impl >::fromRename
private

Wire to get rename's output from backwards time buffer.

Definition at line 214 of file decode.hh.

template<class Impl >
Cycles DefaultDecode< Impl >::iewToDecodeDelay
private

IEW to decode delay.

Definition at line 261 of file decode.hh.

template<class Impl >
std::queue<DynInstPtr> DefaultDecode< Impl >::insts[Impl::MaxThreads]
private

Queue of all instructions coming from fetch this cycle.

Definition at line 239 of file decode.hh.

template<class Impl >
ThreadID DefaultDecode< Impl >::numThreads
private

number of Active Threads

Definition at line 276 of file decode.hh.

template<class Impl >
Cycles DefaultDecode< Impl >::renameToDecodeDelay
private

Rename to decode delay.

Definition at line 258 of file decode.hh.

template<class Impl >
std::queue<DynInstPtr> DefaultDecode< Impl >::skidBuffer[Impl::MaxThreads]
private

Skid buffer between fetch and decode.

Definition at line 242 of file decode.hh.

template<class Impl >
unsigned DefaultDecode< Impl >::skidBufferMax
private

Maximum size of the skid buffer.

Definition at line 282 of file decode.hh.

Referenced by DefaultDecode< Impl >::DefaultDecode().

template<class Impl >
bool DefaultDecode< Impl >::squashAfterDelaySlot[Impl::MaxThreads]
private

Tells when their is a pending delay slot inst.

to send to rename. If there is, then wait squash after the next instruction (used for MIPS).

Definition at line 294 of file decode.hh.

template<class Impl >
DynInstPtr DefaultDecode< Impl >::squashInst[Impl::MaxThreads]
private

Instruction used for squashing branch (used for MIPS)

Definition at line 288 of file decode.hh.

template<class Impl >
Stalls DefaultDecode< Impl >::stalls[Impl::MaxThreads]
private

Tracks which stages are telling decode to stall.

Definition at line 255 of file decode.hh.

template<class Impl >
TimeBuffer<TimeStruct>* DefaultDecode< Impl >::timeBuffer
private

Time buffer interface.

Definition at line 211 of file decode.hh.

template<class Impl >
TimeBuffer<TimeStruct>::wire DefaultDecode< Impl >::toFetch
private

Wire to write information heading to previous stages.

Definition at line 224 of file decode.hh.

template<class Impl >
TimeBuffer<DecodeStruct>::wire DefaultDecode< Impl >::toRename
private

Wire used to write any information heading to rename.

Definition at line 230 of file decode.hh.

template<class Impl >
unsigned DefaultDecode< Impl >::toRenameIndex
private

Index of instructions being sent to rename.

Definition at line 273 of file decode.hh.

template<class Impl >
bool DefaultDecode< Impl >::wroteToTimeBuffer
private

Variable that tracks if decode has written to the time buffer this cycle.

Used to tell CPU if there is activity this cycle.

Definition at line 247 of file decode.hh.


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

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