gem5  v20.1.0.0
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  DecodeStats
 
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 clearStates (ThreadID tid)
 Clear all thread-specific states. More...
 
void resetStage ()
 
std::string name () const
 Returns the name of decode. 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 (const 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...
 
DefaultDecode::DecodeStats stats
 

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 59 of file decode.hh.

Member Typedef Documentation

◆ CPUPol

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

Definition at line 65 of file decode.hh.

◆ DecodeStruct

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

Definition at line 69 of file decode.hh.

◆ DynInstPtr

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

Definition at line 64 of file decode.hh.

◆ FetchStruct

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

Definition at line 68 of file decode.hh.

◆ O3CPU

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

Definition at line 63 of file decode.hh.

◆ TimeStruct

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

Definition at line 70 of file decode.hh.

Member Enumeration Documentation

◆ DecodeStatus

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 76 of file decode.hh.

◆ ThreadStatus

template<class Impl >
enum DefaultDecode::ThreadStatus

Individual thread status.

Enumerator
Running 
Idle 
StartSquash 
Squashing 
Blocked 
Unblocking 

Definition at line 82 of file decode.hh.

Constructor & Destructor Documentation

◆ DefaultDecode()

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

Member Function Documentation

◆ block()

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 239 of file decode_impl.hh.

References DefaultDecode< Impl >::Blocked, DefaultDecode< Impl >::decodeStatus, DPRINTF, DefaultDecode< Impl >::skidInsert(), DefaultDecode< Impl >::toFetch, and DefaultDecode< Impl >::wroteToTimeBuffer.

Referenced by DefaultDecode< Impl >::checkSignalsAndUpdate(), and DefaultDecode< Impl >::decodeInsts().

◆ checkSignalsAndUpdate()

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

◆ checkStall()

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

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

Definition at line 218 of file decode_impl.hh.

References DPRINTF, and DefaultDecode< Impl >::stalls.

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

◆ clearStates()

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

Clear all thread-specific states.

Definition at line 95 of file decode_impl.hh.

◆ decode()

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

◆ decodeInsts()

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

◆ drainSanityCheck()

template<class Impl >
void DefaultDecode< Impl >::drainSanityCheck

Perform sanity checks after a drain.

Definition at line 196 of file decode_impl.hh.

References DefaultDecode< Impl >::insts, DefaultDecode< Impl >::numThreads, and DefaultDecode< Impl >::skidBuffer.

◆ fetchInstsValid()

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

Returns if there any instructions from fetch on this cycle.

Definition at line 232 of file decode_impl.hh.

References DefaultDecode< Impl >::fromFetch, and TimeBuffer< T >::size.

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

◆ isDrained()

template<class Impl >
bool DefaultDecode< Impl >::isDrained

◆ name()

template<class Impl >
std::string DefaultDecode< Impl >::name

Returns the name of decode.

Definition at line 117 of file decode_impl.hh.

◆ readStallSignals()

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

Reads all stall signals from the backwards communication timebuffer.

Definition at line 477 of file decode_impl.hh.

References DefaultDecode< Impl >::fromRename, DefaultDecode< Impl >::Stalls::rename, and DefaultDecode< Impl >::stalls.

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

◆ resetStage()

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

Definition at line 103 of file decode_impl.hh.

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

◆ setActiveThreads()

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

Sets pointer to list of active threads.

Definition at line 189 of file decode_impl.hh.

References DefaultDecode< Impl >::activeThreads.

◆ setDecodeQueue()

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 169 of file decode_impl.hh.

References DefaultDecode< Impl >::decodeQueue, TimeBuffer< T >::getWire(), and DefaultDecode< Impl >::toRename.

◆ setFetchQueue()

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

Sets pointer to time buffer coming from fetch.

Definition at line 179 of file decode_impl.hh.

References DefaultDecode< Impl >::fetchQueue, DefaultDecode< Impl >::fetchToDecodeDelay, DefaultDecode< Impl >::fromFetch, and TimeBuffer< T >::getWire().

◆ setTimeBuffer()

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

◆ skidInsert()

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 388 of file decode_impl.hh.

References DPRINTF, DefaultDecode< Impl >::insts, DefaultDecode< Impl >::skidBuffer, and DefaultDecode< Impl >::skidBufferMax.

Referenced by DefaultDecode< Impl >::block(), and DefaultDecode< Impl >::decode().

◆ skidsEmpty()

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

Returns if all of the skid buffers are empty.

Definition at line 412 of file decode_impl.hh.

References DefaultDecode< Impl >::activeThreads, and DefaultDecode< Impl >::skidBuffer.

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

◆ sortInsts()

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

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

Definition at line 467 of file decode_impl.hh.

References DefaultDecode< Impl >::fromFetch, ArmISA::i, DefaultDecode< Impl >::insts, and TimeBuffer< T >::size.

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

◆ squash() [1/2]

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

◆ squash() [2/2]

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

◆ startupStage()

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

Definition at line 88 of file decode_impl.hh.

◆ takeOverFrom()

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

Takes over from another CPU's thread.

Definition at line 131 of file decode.hh.

References DefaultDecode< Impl >::resetStage().

◆ tick()

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

◆ unblock()

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 269 of file decode_impl.hh.

References DefaultDecode< Impl >::decodeStatus, DPRINTF, DefaultDecode< Impl >::Running, DefaultDecode< Impl >::skidBuffer, DefaultDecode< Impl >::toFetch, and DefaultDecode< Impl >::wroteToTimeBuffer.

Referenced by DefaultDecode< Impl >::checkSignalsAndUpdate(), and DefaultDecode< Impl >::decode().

◆ updateStatus()

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

Member Data Documentation

◆ _status

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

Decode status.

Definition at line 93 of file decode.hh.

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

◆ activeThreads

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

◆ bdelayDoneSeqNum

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

SeqNum of Squashing Branch Delay Instruction (used for MIPS)

Definition at line 284 of file decode.hh.

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

◆ commitToDecodeDelay

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

Commit to decode delay.

Definition at line 263 of file decode.hh.

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

◆ cpu

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

◆ decodeQueue

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

Decode instruction queue.

Definition at line 226 of file decode.hh.

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

◆ decodeStatus

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

◆ decodeWidth

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

The width of decode, in instructions.

Definition at line 269 of file decode.hh.

Referenced by DefaultDecode< Impl >::decodeInsts(), and DefaultDecode< Impl >::DefaultDecode().

◆ fetchQueue

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

Fetch instruction queue interface.

Definition at line 232 of file decode.hh.

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

◆ fetchToDecodeDelay

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

Fetch to decode delay.

Definition at line 266 of file decode.hh.

Referenced by DefaultDecode< Impl >::DefaultDecode(), and DefaultDecode< Impl >::setFetchQueue().

◆ fromCommit

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

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

Definition at line 219 of file decode.hh.

Referenced by DefaultDecode< Impl >::checkSignalsAndUpdate(), and DefaultDecode< Impl >::setTimeBuffer().

◆ fromFetch

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

◆ fromIEW

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

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

Definition at line 216 of file decode.hh.

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

◆ fromRename

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

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

Definition at line 213 of file decode.hh.

Referenced by DefaultDecode< Impl >::readStallSignals(), and DefaultDecode< Impl >::setTimeBuffer().

◆ iewToDecodeDelay

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

IEW to decode delay.

Definition at line 260 of file decode.hh.

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

◆ insts

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

◆ numThreads

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

number of Active Threads

Definition at line 275 of file decode.hh.

Referenced by DefaultDecode< Impl >::drainSanityCheck(), and DefaultDecode< Impl >::isDrained().

◆ renameToDecodeDelay

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

Rename to decode delay.

Definition at line 257 of file decode.hh.

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

◆ skidBuffer

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

◆ skidBufferMax

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

Maximum size of the skid buffer.

Definition at line 281 of file decode.hh.

Referenced by DefaultDecode< Impl >::DefaultDecode(), and DefaultDecode< Impl >::skidInsert().

◆ squashAfterDelaySlot

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 293 of file decode.hh.

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

◆ squashInst

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

Instruction used for squashing branch (used for MIPS)

Definition at line 287 of file decode.hh.

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

◆ stalls

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

Tracks which stages are telling decode to stall.

Definition at line 254 of file decode.hh.

Referenced by DefaultDecode< Impl >::checkStall(), DefaultDecode< Impl >::DefaultDecode(), and DefaultDecode< Impl >::readStallSignals().

◆ stats

template<class Impl >
DefaultDecode::DecodeStats DefaultDecode< Impl >::stats
private

◆ timeBuffer

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

Time buffer interface.

Definition at line 210 of file decode.hh.

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

◆ toFetch

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

Wire to write information heading to previous stages.

Definition at line 223 of file decode.hh.

Referenced by DefaultDecode< Impl >::block(), DefaultDecode< Impl >::setTimeBuffer(), DefaultDecode< Impl >::squash(), and DefaultDecode< Impl >::unblock().

◆ toRename

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

Wire used to write any information heading to rename.

Definition at line 229 of file decode.hh.

Referenced by DefaultDecode< Impl >::decodeInsts(), and DefaultDecode< Impl >::setDecodeQueue().

◆ toRenameIndex

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

Index of instructions being sent to rename.

Definition at line 272 of file decode.hh.

Referenced by DefaultDecode< Impl >::decodeInsts(), and DefaultDecode< Impl >::tick().

◆ wroteToTimeBuffer

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 246 of file decode.hh.

Referenced by DefaultDecode< Impl >::block(), DefaultDecode< Impl >::decodeInsts(), DefaultDecode< Impl >::tick(), and DefaultDecode< Impl >::unblock().


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

Generated on Wed Sep 30 2020 14:02:23 for gem5 by doxygen 1.8.17