gem5 v24.0.0.0
Loading...
Searching...
No Matches
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 BaseO3CPUParams &params)
 Decode constructor.
 
void startupStage ()
 
void clearStates (ThreadID tid)
 Clear all thread-specific states.
 
void resetStage ()
 
std::string name () const
 Returns the name of decode.
 
void setTimeBuffer (TimeBuffer< TimeStruct > *tb_ptr)
 Sets the main backwards communication time buffer pointer.
 
void setDecodeQueue (TimeBuffer< DecodeStruct > *dq_ptr)
 Sets pointer to time buffer used to communicate to the next stage.
 
void setFetchQueue (TimeBuffer< FetchStruct > *fq_ptr)
 Sets pointer to time buffer coming from fetch.
 
void setActiveThreads (std::list< ThreadID > *at_ptr)
 Sets pointer to list of active threads.
 
void drainSanityCheck () const
 Perform sanity checks after a drain.
 
bool isDrained () const
 Has the stage drained?
 
void takeOverFrom ()
 Takes over from another CPU's thread.
 
void tick ()
 Ticks decode, processing all input signals and decoding as many instructions as possible.
 
void decode (bool &status_change, ThreadID tid)
 Determines what to do based on decode's current status.
 
void decodeInsts (ThreadID tid)
 Processes instructions from fetch and passes them on to rename.
 
unsigned squash (ThreadID tid)
 Squashes due to commit signalling a squash.
 

Private Member Functions

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

Private Attributes

DecodeStatus _status
 Decode status.
 
ThreadStatus decodeStatus [MaxThreads]
 Per-thread status.
 
CPUcpu
 CPU interface.
 
TimeBuffer< TimeStruct > * timeBuffer
 Time buffer interface.
 
TimeBuffer< TimeStruct >::wire fromRename
 Wire to get rename's output from backwards time buffer.
 
TimeBuffer< TimeStruct >::wire fromIEW
 Wire to get iew's information from backwards time buffer.
 
TimeBuffer< TimeStruct >::wire fromCommit
 Wire to get commit's information from backwards time buffer.
 
TimeBuffer< TimeStruct >::wire toFetch
 Wire to write information heading to previous stages.
 
TimeBuffer< DecodeStruct > * decodeQueue
 Decode instruction queue.
 
TimeBuffer< DecodeStruct >::wire toRename
 Wire used to write any information heading to rename.
 
TimeBuffer< FetchStruct > * fetchQueue
 Fetch instruction queue interface.
 
TimeBuffer< FetchStruct >::wire fromFetch
 Wire to get fetch's output from fetch queue.
 
std::queue< DynInstPtrinsts [MaxThreads]
 Queue of all instructions coming from fetch this cycle.
 
std::queue< DynInstPtrskidBuffer [MaxThreads]
 Skid buffer between fetch and decode.
 
bool wroteToTimeBuffer
 Variable that tracks if decode has written to the time buffer this cycle.
 
Stalls stalls [MaxThreads]
 Tracks which stages are telling decode to stall.
 
Cycles renameToDecodeDelay
 Rename to decode delay.
 
Cycles iewToDecodeDelay
 IEW to decode delay.
 
Cycles commitToDecodeDelay
 Commit to decode delay.
 
Cycles fetchToDecodeDelay
 Fetch to decode delay.
 
unsigned decodeWidth
 The width of decode, in instructions.
 
unsigned toRenameIndex
 Index of instructions being sent to rename.
 
ThreadID numThreads
 number of Active Threads
 
std::list< ThreadID > * activeThreads
 List of active thread ids.
 
unsigned skidBufferMax
 Maximum size of the skid buffer.
 
Addr bdelayDoneSeqNum [MaxThreads]
 SeqNum of Squashing Branch Delay Instruction (used for MIPS)
 
DynInstPtr squashInst [MaxThreads]
 Instruction used for squashing branch (used for MIPS)
 
bool squashAfterDelaySlot [MaxThreads]
 Tells when their is a pending delay slot inst.
 
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 BaseO3CPUParams & 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 236 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 487 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 217 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 97 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 578 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 197 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 230 of file decode.cc.

References fromFetch.

Referenced by decode().

◆ isDrained()

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

Has the stage drained?

Definition at line 206 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 117 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 474 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 104 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 191 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 173 of file decode.cc.

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

◆ setFetchQueue()

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

Sets pointer to time buffer coming from fetch.

Definition at line 182 of file decode.cc.

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

◆ setTimeBuffer()

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

Sets the main backwards communication time buffer pointer.

Definition at line 159 of file decode.cc.

References commitToDecodeDelay, fromCommit, fromIEW, fromRename, gem5::TimeBuffer< T >::getWire(), 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 388 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 412 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 465 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 283 of file decode.cc.

References Blocked, cpu, decodeStatus, DPRINTF, fromFetch, gem5::ArmISA::i, insts, gem5::o3::CPU::removeInstsUntil(), gem5::ArmISA::set, 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 341 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 91 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 543 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 265 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 427 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(), squash(), 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(), squash(), 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(), 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(), 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 Jun 18 2024 16:24:20 for gem5 by doxygen 1.11.0