gem5 v24.0.0.0
|
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 ¶ms) | |
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. | |
CPU * | cpu |
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< DynInstPtr > | insts [MaxThreads] |
Queue of all instructions coming from fetch this cycle. | |
std::queue< DynInstPtr > | skidBuffer [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 |
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.
gem5::o3::Decode::Decode | ( | CPU * | _cpu, |
const BaseO3CPUParams & | params ) |
Decode constructor.
Definition at line 64 of file decode.cc.
References bdelayDoneSeqNum, decodeStatus, decodeWidth, fatal, fetchToDecodeDelay, Idle, gem5::o3::MaxThreads, gem5::o3::MaxWidth, skidBufferMax, squashAfterDelaySlot, squashInst, and stalls.
|
private |
Switches decode to blocking, and signals back that decode has become blocked.
Definition at line 236 of file decode.cc.
References Blocked, decodeStatus, DPRINTF, skidInsert(), toFetch, and wroteToTimeBuffer.
Referenced by checkSignalsAndUpdate(), and decodeInsts().
|
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().
|
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().
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().
void gem5::o3::Decode::decode | ( | bool & | status_change, |
ThreadID | tid ) |
Determines what to do based on decode's current status.
status_change | decode() sets this variable if there was a status change (ie switching from from blocking to unblocking). |
tid | Thread 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().
void gem5::o3::Decode::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 622 of file decode.cc.
References block(), gem5::o3::Decode::DecodeStats::branchMispred, gem5::o3::Decode::DecodeStats::branchResolved, gem5::o3::Decode::DecodeStats::controlMispred, gem5::curTick(), gem5::o3::Decode::DecodeStats::decodedInsts, decodeStatus, decodeWidth, DPRINTF, gem5::o3::Decode::DecodeStats::idleCycles, insts, panic, gem5::o3::Decode::DecodeStats::runCycles, Running, skidBuffer, squash(), gem5::o3::Decode::DecodeStats::squashedInsts, stats, toRename, toRenameIndex, gem5::o3::Decode::DecodeStats::unblockCycles, Unblocking, and wroteToTimeBuffer.
Referenced by decode().
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().
|
private |
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().
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().
|
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().
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().
Sets pointer to list of active threads.
Definition at line 191 of file decode.cc.
References activeThreads.
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.
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().
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.
|
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.
|
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().
|
private |
|
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().
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.
void gem5::o3::Decode::startupStage | ( | ) |
Definition at line 91 of file decode.cc.
References resetStage().
Referenced by gem5::o3::CPU::startup().
|
inline |
Takes over from another CPU's thread.
Definition at line 132 of file decode.hh.
References resetStage().
Referenced by gem5::o3::CPU::takeOverFrom().
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().
|
private |
Switches decode to unblocking if the skid buffer is empty, and signals back that decode has unblocked.
Definition at line 265 of file decode.cc.
References decodeStatus, DPRINTF, Running, skidBuffer, toFetch, and wroteToTimeBuffer.
Referenced by checkSignalsAndUpdate(), and decode().
|
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().
|
private |
Decode status.
Definition at line 94 of file decode.hh.
Referenced by resetStage(), and updateStatus().
List of active thread ids.
Definition at line 280 of file decode.hh.
Referenced by setActiveThreads(), skidsEmpty(), tick(), and updateStatus().
|
private |
|
private |
|
private |
|
private |
|
private |
Per-thread status.
Definition at line 97 of file decode.hh.
Referenced by block(), checkSignalsAndUpdate(), clearStates(), Decode(), decode(), decodeInsts(), isDrained(), resetStage(), squash(), squash(), unblock(), and updateStatus().
|
private |
The width of decode, in instructions.
Definition at line 271 of file decode.hh.
Referenced by Decode(), and decodeInsts().
|
private |
Fetch instruction queue interface.
Definition at line 233 of file decode.hh.
Referenced by setFetchQueue().
|
private |
Fetch to decode delay.
Definition at line 268 of file decode.hh.
Referenced by Decode(), and setFetchQueue().
|
private |
Wire to get commit's information from backwards time buffer.
Definition at line 220 of file decode.hh.
Referenced by checkSignalsAndUpdate(), and setTimeBuffer().
|
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().
|
private |
Wire to get iew's information from backwards time buffer.
Definition at line 217 of file decode.hh.
Referenced by setTimeBuffer().
|
private |
Wire to get rename's output from backwards time buffer.
Definition at line 214 of file decode.hh.
Referenced by readStallSignals(), and setTimeBuffer().
|
private |
|
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().
|
private |
number of Active Threads
Definition at line 277 of file decode.hh.
Referenced by drainSanityCheck(), isDrained(), and resetStage().
|
private |
|
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().
|
private |
Maximum size of the skid buffer.
Definition at line 283 of file decode.hh.
Referenced by Decode(), and skidInsert().
|
private |
|
private |
|
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().
|
private |
Referenced by decode(), and decodeInsts().
|
private |
|
private |
|
private |
Wire used to write any information heading to rename.
Definition at line 230 of file decode.hh.
Referenced by decodeInsts(), and setDecodeQueue().
|
private |
Index of instructions being sent to rename.
Definition at line 274 of file decode.hh.
Referenced by decodeInsts(), and tick().
|
private |