gem5  v21.1.0.2
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
gem5::o3::Decode Class Reference

Decode 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

 Decode (CPU *_cpu, const O3CPUParams &params)
 Decode 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 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 [MaxThreads]
 Per-thread status. More...
 
CPUcpu
 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 [MaxThreads]
 Queue of all instructions coming from fetch this cycle. More...
 
std::queue< DynInstPtrskidBuffer [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 [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 [MaxThreads]
 SeqNum of Squashing Branch Delay Instruction (used for MIPS) More...
 
DynInstPtr squashInst [MaxThreads]
 Instruction used for squashing branch (used for MIPS) More...
 
bool squashAfterDelaySlot [MaxThreads]
 Tells when their is a pending delay slot inst. More...
 
gem5::o3::Decode::DecodeStats stats
 

Detailed Description

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

Member Enumeration Documentation

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

◆ ThreadStatus

Individual thread status.

Enumerator
Running 
Idle 
StartSquash 
Squashing 
Blocked 
Unblocking 

Definition at line 82 of file decode.hh.

Constructor & Destructor Documentation

◆ Decode()

gem5::o3::Decode::Decode ( CPU _cpu,
const O3CPUParams &  params 
)

Member Function Documentation

◆ block()

bool gem5::o3::Decode::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 237 of file decode.cc.

References Blocked, decodeStatus, DPRINTF, skidInsert(), toFetch, and wroteToTimeBuffer.

Referenced by checkSignalsAndUpdate(), and decodeInsts().

◆ checkSignalsAndUpdate()

bool gem5::o3::Decode::checkSignalsAndUpdate ( ThreadID  tid)
private

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

Definition at line 488 of file decode.cc.

References block(), Blocked, checkStall(), decodeStatus, DPRINTF, fromCommit, readStallSignals(), Running, squash(), Squashing, unblock(), and Unblocking.

Referenced by tick().

◆ checkStall()

bool gem5::o3::Decode::checkStall ( ThreadID  tid) const
private

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

Definition at line 218 of file decode.cc.

References DPRINTF, and stalls.

Referenced by checkSignalsAndUpdate().

◆ clearStates()

void gem5::o3::Decode::clearStates ( ThreadID  tid)

Clear all thread-specific states.

Definition at line 98 of file decode.cc.

References decodeStatus, Idle, gem5::o3::Decode::Stalls::rename, and stalls.

Referenced by gem5::o3::CPU::removeThread().

◆ decode()

void gem5::o3::Decode::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 579 of file decode.cc.

References Blocked, gem5::o3::Decode::DecodeStats::blockedCycles, decodeInsts(), decodeStatus, DPRINTF, fetchInstsValid(), Idle, Running, skidInsert(), skidsEmpty(), gem5::o3::Decode::DecodeStats::squashCycles, Squashing, stats, unblock(), and Unblocking.

Referenced by tick().

◆ decodeInsts()

void gem5::o3::Decode::decodeInsts ( ThreadID  tid)

◆ drainSanityCheck()

void gem5::o3::Decode::drainSanityCheck ( ) const

Perform sanity checks after a drain.

Definition at line 198 of file decode.cc.

References insts, numThreads, and skidBuffer.

Referenced by gem5::o3::CPU::drainSanityCheck().

◆ fetchInstsValid()

bool gem5::o3::Decode::fetchInstsValid ( )
private

Returns if there any instructions from fetch on this cycle.

Definition at line 231 of file decode.cc.

References fromFetch.

Referenced by decode().

◆ isDrained()

bool gem5::o3::Decode::isDrained ( ) const

Has the stage drained?

Definition at line 207 of file decode.cc.

References decodeStatus, Idle, insts, numThreads, Running, and skidBuffer.

Referenced by gem5::o3::CPU::isCpuDrained().

◆ name()

std::string gem5::o3::Decode::name ( ) const

Returns the name of decode.

Definition at line 118 of file decode.cc.

References cpu, and gem5::Named::name().

◆ readStallSignals()

void gem5::o3::Decode::readStallSignals ( ThreadID  tid)
private

Reads all stall signals from the backwards communication timebuffer.

Definition at line 475 of file decode.cc.

References fromRename, gem5::o3::Decode::Stalls::rename, and stalls.

Referenced by checkSignalsAndUpdate().

◆ resetStage()

void gem5::o3::Decode::resetStage ( )

Definition at line 105 of file decode.cc.

References _status, decodeStatus, Idle, Inactive, numThreads, gem5::o3::Decode::Stalls::rename, and stalls.

Referenced by startupStage(), and takeOverFrom().

◆ setActiveThreads()

void gem5::o3::Decode::setActiveThreads ( std::list< ThreadID > *  at_ptr)

Sets pointer to list of active threads.

Definition at line 192 of file decode.cc.

References activeThreads.

◆ setDecodeQueue()

void gem5::o3::Decode::setDecodeQueue ( TimeBuffer< DecodeStruct > *  dq_ptr)

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

Definition at line 174 of file decode.cc.

References decodeQueue, and toRename.

◆ setFetchQueue()

void gem5::o3::Decode::setFetchQueue ( TimeBuffer< FetchStruct > *  fq_ptr)

Sets pointer to time buffer coming from fetch.

Definition at line 183 of file decode.cc.

References fetchQueue, fetchToDecodeDelay, and fromFetch.

◆ setTimeBuffer()

void gem5::o3::Decode::setTimeBuffer ( TimeBuffer< TimeStruct > *  tb_ptr)

Sets the main backwards communication time buffer pointer.

Definition at line 160 of file decode.cc.

References commitToDecodeDelay, fromCommit, fromIEW, fromRename, iewToDecodeDelay, renameToDecodeDelay, timeBuffer, and toFetch.

◆ skidInsert()

void gem5::o3::Decode::skidInsert ( ThreadID  tid)
private

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

Definition at line 389 of file decode.cc.

References DPRINTF, insts, skidBuffer, and skidBufferMax.

Referenced by block(), and decode().

◆ skidsEmpty()

bool gem5::o3::Decode::skidsEmpty ( )
private

Returns if all of the skid buffers are empty.

Definition at line 413 of file decode.cc.

References activeThreads, and skidBuffer.

Referenced by decode().

◆ sortInsts()

void gem5::o3::Decode::sortInsts ( )
private

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

Definition at line 466 of file decode.cc.

References fromFetch, gem5::ArmISA::i, and insts.

Referenced by tick().

◆ squash() [1/2]

void gem5::o3::Decode::squash ( const 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 284 of file decode.cc.

References Blocked, cpu, decodeStatus, DPRINTF, fromFetch, gem5::ArmISA::i, insts, gem5::o3::CPU::removeInstsUntil(), skidBuffer, Squashing, toFetch, and Unblocking.

Referenced by checkSignalsAndUpdate(), and decodeInsts().

◆ squash() [2/2]

unsigned gem5::o3::Decode::squash ( ThreadID  tid)

Squashes due to commit signalling a squash.

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

Definition at line 342 of file decode.cc.

References Blocked, decodeStatus, DPRINTF, fromFetch, gem5::FullSystem, gem5::ArmISA::i, insts, skidBuffer, Squashing, toFetch, and Unblocking.

◆ startupStage()

void gem5::o3::Decode::startupStage ( )

Definition at line 92 of file decode.cc.

References resetStage().

Referenced by gem5::o3::CPU::startup().

◆ takeOverFrom()

void gem5::o3::Decode::takeOverFrom ( )
inline

Takes over from another CPU's thread.

Definition at line 132 of file decode.hh.

References resetStage().

Referenced by gem5::o3::CPU::takeOverFrom().

◆ tick()

void gem5::o3::Decode::tick ( )

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

Definition at line 544 of file decode.cc.

References activeThreads, gem5::o3::CPU::activityThisCycle(), checkSignalsAndUpdate(), cpu, decode(), DPRINTF, sortInsts(), toRenameIndex, updateStatus(), and wroteToTimeBuffer.

Referenced by gem5::o3::CPU::tick().

◆ unblock()

bool gem5::o3::Decode::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 266 of file decode.cc.

References decodeStatus, DPRINTF, Running, skidBuffer, toFetch, and wroteToTimeBuffer.

Referenced by checkSignalsAndUpdate(), and decode().

◆ updateStatus()

void gem5::o3::Decode::updateStatus ( )
private

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

Definition at line 428 of file decode.cc.

References _status, gem5::o3::CPU::activateStage(), Active, activeThreads, cpu, gem5::o3::CPU::deactivateStage(), gem5::o3::CPU::DecodeIdx, decodeStatus, DPRINTF, Inactive, and Unblocking.

Referenced by tick().

Member Data Documentation

◆ _status

DecodeStatus gem5::o3::Decode::_status
private

Decode status.

Definition at line 94 of file decode.hh.

Referenced by resetStage(), and updateStatus().

◆ activeThreads

std::list<ThreadID>* gem5::o3::Decode::activeThreads
private

List of active thread ids.

Definition at line 280 of file decode.hh.

Referenced by setActiveThreads(), skidsEmpty(), tick(), and updateStatus().

◆ bdelayDoneSeqNum

Addr gem5::o3::Decode::bdelayDoneSeqNum[MaxThreads]
private

SeqNum of Squashing Branch Delay Instruction (used for MIPS)

Definition at line 286 of file decode.hh.

Referenced by Decode().

◆ commitToDecodeDelay

Cycles gem5::o3::Decode::commitToDecodeDelay
private

Commit to decode delay.

Definition at line 265 of file decode.hh.

Referenced by setTimeBuffer().

◆ cpu

CPU* gem5::o3::Decode::cpu
private

CPU interface.

Definition at line 208 of file decode.hh.

Referenced by name(), squash(), tick(), and updateStatus().

◆ decodeQueue

TimeBuffer<DecodeStruct>* gem5::o3::Decode::decodeQueue
private

Decode instruction queue.

Definition at line 227 of file decode.hh.

Referenced by setDecodeQueue().

◆ decodeStatus

ThreadStatus gem5::o3::Decode::decodeStatus[MaxThreads]
private

◆ decodeWidth

unsigned gem5::o3::Decode::decodeWidth
private

The width of decode, in instructions.

Definition at line 271 of file decode.hh.

Referenced by Decode(), and decodeInsts().

◆ fetchQueue

TimeBuffer<FetchStruct>* gem5::o3::Decode::fetchQueue
private

Fetch instruction queue interface.

Definition at line 233 of file decode.hh.

Referenced by setFetchQueue().

◆ fetchToDecodeDelay

Cycles gem5::o3::Decode::fetchToDecodeDelay
private

Fetch to decode delay.

Definition at line 268 of file decode.hh.

Referenced by Decode(), and setFetchQueue().

◆ fromCommit

TimeBuffer<TimeStruct>::wire gem5::o3::Decode::fromCommit
private

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

Definition at line 220 of file decode.hh.

Referenced by checkSignalsAndUpdate(), and setTimeBuffer().

◆ fromFetch

TimeBuffer<FetchStruct>::wire gem5::o3::Decode::fromFetch
private

Wire to get fetch's output from fetch queue.

Definition at line 236 of file decode.hh.

Referenced by fetchInstsValid(), setFetchQueue(), sortInsts(), and squash().

◆ fromIEW

TimeBuffer<TimeStruct>::wire gem5::o3::Decode::fromIEW
private

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

Definition at line 217 of file decode.hh.

Referenced by setTimeBuffer().

◆ fromRename

TimeBuffer<TimeStruct>::wire gem5::o3::Decode::fromRename
private

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

Definition at line 214 of file decode.hh.

Referenced by readStallSignals(), and setTimeBuffer().

◆ iewToDecodeDelay

Cycles gem5::o3::Decode::iewToDecodeDelay
private

IEW to decode delay.

Definition at line 262 of file decode.hh.

Referenced by setTimeBuffer().

◆ insts

std::queue<DynInstPtr> gem5::o3::Decode::insts[MaxThreads]
private

Queue of all instructions coming from fetch this cycle.

Definition at line 239 of file decode.hh.

Referenced by decodeInsts(), drainSanityCheck(), isDrained(), skidInsert(), sortInsts(), and squash().

◆ numThreads

ThreadID gem5::o3::Decode::numThreads
private

number of Active Threads

Definition at line 277 of file decode.hh.

Referenced by drainSanityCheck(), isDrained(), and resetStage().

◆ renameToDecodeDelay

Cycles gem5::o3::Decode::renameToDecodeDelay
private

Rename to decode delay.

Definition at line 259 of file decode.hh.

Referenced by setTimeBuffer().

◆ skidBuffer

std::queue<DynInstPtr> gem5::o3::Decode::skidBuffer[MaxThreads]
private

Skid buffer between fetch and decode.

Definition at line 242 of file decode.hh.

Referenced by decodeInsts(), drainSanityCheck(), isDrained(), skidInsert(), skidsEmpty(), squash(), and unblock().

◆ skidBufferMax

unsigned gem5::o3::Decode::skidBufferMax
private

Maximum size of the skid buffer.

Definition at line 283 of file decode.hh.

Referenced by Decode(), and skidInsert().

◆ squashAfterDelaySlot

bool gem5::o3::Decode::squashAfterDelaySlot[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 295 of file decode.hh.

Referenced by Decode().

◆ squashInst

DynInstPtr gem5::o3::Decode::squashInst[MaxThreads]
private

Instruction used for squashing branch (used for MIPS)

Definition at line 289 of file decode.hh.

Referenced by Decode().

◆ stalls

Stalls gem5::o3::Decode::stalls[MaxThreads]
private

Tracks which stages are telling decode to stall.

Definition at line 256 of file decode.hh.

Referenced by checkStall(), clearStates(), Decode(), readStallSignals(), and resetStage().

◆ stats

gem5::o3::Decode::DecodeStats gem5::o3::Decode::stats
private

Referenced by decode(), and decodeInsts().

◆ timeBuffer

TimeBuffer<TimeStruct>* gem5::o3::Decode::timeBuffer
private

Time buffer interface.

Definition at line 211 of file decode.hh.

Referenced by setTimeBuffer().

◆ toFetch

TimeBuffer<TimeStruct>::wire gem5::o3::Decode::toFetch
private

Wire to write information heading to previous stages.

Definition at line 224 of file decode.hh.

Referenced by block(), setTimeBuffer(), squash(), and unblock().

◆ toRename

TimeBuffer<DecodeStruct>::wire gem5::o3::Decode::toRename
private

Wire used to write any information heading to rename.

Definition at line 230 of file decode.hh.

Referenced by decodeInsts(), and setDecodeQueue().

◆ toRenameIndex

unsigned gem5::o3::Decode::toRenameIndex
private

Index of instructions being sent to rename.

Definition at line 274 of file decode.hh.

Referenced by decodeInsts(), and tick().

◆ wroteToTimeBuffer

bool gem5::o3::Decode::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.

Referenced by block(), decodeInsts(), tick(), and unblock().


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

Generated on Tue Sep 21 2021 12:31:42 for gem5 by doxygen 1.8.17