41#ifndef __CPU_O3_FETCH_HH__
42#define __CPU_O3_FETCH_HH__
54#include "enums/SMTFetchPolicy.hh"
63struct BaseO3CPUParams;
154 return "CPU FetchFinishTranslation";
205 Fetch(
CPU *_cpu,
const BaseO3CPUParams ¶ms);
208 std::string
name()
const;
349 void fetch(
bool &status_change);
Cycles is a wrapper class for representing cycle counts, i.e.
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
ProbePointArg generates a point for the class of Arg.
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Basically a wrapper class to hold both the branch predictor and the BTB.
O3CPU class, has each of the stages (fetch through commit) within it, as well as all of the time buff...
void finish(const Fault &fault, const RequestPtr &req, gem5::ThreadContext *tc, BaseMMU::Mode mode)
void markDelayed()
Signal that the translation has been delayed due to a hw page table walk.
FetchTranslation(Fetch *_fetch)
const char * description() const
Return a C string describing the event.
void setReq(const RequestPtr &_req)
FinishTranslationEvent(Fetch *_fetch)
void process()
Process the delayed finish translation.
void setFault(Fault _fault)
IcachePort class for instruction fetch.
Fetch * fetch
Pointer to fetch.
virtual bool recvTimingResp(PacketPtr pkt)
Timing version of receive.
IcachePort(Fetch *_fetch, CPU *_cpu)
Default constructor.
virtual void recvReqRetry()
Handles doing a retry of a failed fetch.
Fetch class handles both single threaded and SMT fetch.
gem5::o3::Fetch::FetchStatGroup fetchStats
bool wroteToTimeBuffer
Variable that tracks if fetch has written to the time buffer this cycle.
void deactivateThread(ThreadID tid)
For priority-based fetch policies, need to keep update priorityList.
FetchStatus
Overall fetch status.
std::list< ThreadID > * activeThreads
List of Active Threads.
TimeBuffer< TimeStruct >::wire fromCommit
Wire to get commit's information from backwards time buffer.
Cycles renameToFetchDelay
Rename to fetch delay.
StaticInstPtr macroop[MaxThreads]
void fetch(bool &status_change)
Does the actual fetching of instructions and passing them on to the next stage.
void takeOverFrom()
Takes over from another CPU's thread.
uint8_t * fetchBuffer[MaxThreads]
The fetch data that is being fetched and buffered.
void doSquash(const PCStateBase &new_pc, const DynInstPtr squashInst, ThreadID tid)
Squashes a specific thread and resets the PC.
TimeBuffer< FetchStruct >::wire toDecode
Wire used to write any information heading to decode.
void setActiveThreads(std::list< ThreadID > *at_ptr)
Sets pointer to list of active threads.
bool lookupAndUpdateNextPC(const DynInstPtr &inst, PCStateBase &pc)
Looks up in the branch predictor to see if the next PC should be either next PC+=MachInst or a branch...
ThreadStatus fetchStatus[MaxThreads]
Per-thread status.
ThreadID numThreads
Number of threads.
TimeBuffer< TimeStruct >::wire fromDecode
Wire to get decode's information from backwards time buffer.
ProbePointArg< DynInstPtr > * ppFetch
Probe points.
TimeBuffer< TimeStruct >::wire fromRename
Wire to get rename's information from backwards time buffer.
void squash(const PCStateBase &new_pc, const InstSeqNum seq_num, DynInstPtr squashInst, ThreadID tid)
Squashes a specific thread and resets the PC.
void squashFromDecode(const PCStateBase &new_pc, const DynInstPtr squashInst, const InstSeqNum seq_num, ThreadID tid)
Squashes a specific thread and resets the PC.
FetchStatus updateFetchStatus()
Updates overall fetch stage status; to be called at the end of each cycle.
ThreadID getFetchingThread()
Returns the appropriate thread to fetch, given the fetch policy.
bool fetchBufferValid[MaxThreads]
Whether or not the fetch buffer data is valid.
void startupStage()
Initialize stage.
void pipelineIcacheAccesses(ThreadID tid)
Pipeline the next I-cache access to the current one.
std::string name() const
Returns the name of fetch.
void wakeFromQuiesce()
Tells fetch to wake up from a quiesce instruction.
void switchToActive()
Changes the status of this stage to active, and indicates this to the CPU.
void switchToInactive()
Changes the status of this stage to inactive, and indicates this to the CPU.
int numInst
Tracks how many instructions has been fetched this cycle.
bool fetchCacheLine(Addr vaddr, ThreadID tid, Addr pc)
Fetches the cache line that contains the fetch PC.
Cycles decodeToFetchDelay
Decode to fetch delay.
bool issuePipelinedIfetch[MaxThreads]
Set to true if a pipelined I-cache request should be issued.
Addr fetchBufferAlignPC(Addr addr)
Align a PC to the start of a fetch buffer block.
FetchStatus _status
Fetch status.
bool delayedCommit[MaxThreads]
Can the fetch stage redirect from an interrupt on this instruction?
ThreadID threadFetched
Thread ID being fetched.
SMTFetchPolicy fetchPolicy
Fetch policy.
Addr cacheBlkSize
Cache block size.
branch_prediction::BPredUnit * branchPred
BPredUnit.
void drainSanityCheck() const
Perform sanity checks after a drain.
unsigned fetchWidth
The width of fetch in instructions.
unsigned fetchQueueSize
The size of the fetch queue in micro-ops.
InstDecoder * decoder[MaxThreads]
The decoder.
TimeBuffer< TimeStruct >::wire fromIEW
Wire to get iew's information from backwards time buffer.
void regProbePoints()
Registers probes.
bool checkSignalsAndUpdate(ThreadID tid)
Checks all input signals and updates the status as necessary.
bool checkStall(ThreadID tid) const
Checks if a thread is stalled.
IcachePort icachePort
Instruction port.
ThreadStatus
Individual thread status.
void setTimeBuffer(TimeBuffer< TimeStruct > *time_buffer)
Sets the main backwards communication time buffer pointer.
void processCacheCompletion(PacketPtr pkt)
Processes cache completion event.
ThreadID iqCount()
Returns the appropriate thread to fetch using the IQ count policy.
RequestPort & getInstPort()
Addr fetchBufferMask
Mask to align a fetch address to a fetch buffer boundary.
void recvReqRetry()
Handles retrying the fetch access.
bool checkInterrupt(Addr pc)
Check if an interrupt is pending and that we need to handle.
Cycles iewToFetchDelay
IEW to fetch delay.
void resetStage()
Reset this pipeline stage.
Fetch(CPU *_cpu, const BaseO3CPUParams ¶ms)
Fetch constructor.
void drainStall(ThreadID tid)
Stall the fetch stage after reaching a safe drain point.
Counter lastIcacheStall[MaxThreads]
Icache stall statistics.
int instSize
Size of instructions.
ProbePointArg< RequestPtr > * ppFetchRequestSent
To probe when a fetch request is successfully sent.
Cycles commitToFetchDelay
Commit to fetch delay.
RequestPtr memReq[MaxThreads]
Memory request used to access cache.
TimeBuffer< TimeStruct > * timeBuffer
Time buffer interface.
void profileStall(ThreadID tid)
Profile the reasons of fetch stall.
ThreadID roundRobin()
Returns the appropriate thread to fetch using a round robin policy.
Addr fetchBufferPC[MaxThreads]
The PC of the first instruction loaded into the fetch buffer.
void drainResume()
Resume after a drain.
void clearStates(ThreadID tid)
Clear all thread-specific states.
void finishTranslation(const Fault &fault, const RequestPtr &mem_req)
bool interruptPending
Checks if there is an interrupt pending.
std::unique_ptr< PCStateBase > pc[MaxThreads]
ThreadID lsqCount()
Returns the appropriate thread to fetch using the LSQ count policy.
Stalls stalls[MaxThreads]
Tracks which stages are telling fetch to stall.
DynInstPtr buildInst(ThreadID tid, StaticInstPtr staticInst, StaticInstPtr curMacroop, const PCStateBase &this_pc, const PCStateBase &next_pc, bool trace)
bool isDrained() const
Has the stage drained?
Addr fetchOffset[MaxThreads]
std::deque< DynInstPtr > fetchQueue[MaxThreads]
Queue of fetched instructions.
PacketPtr retryPkt
The packet that is waiting to be retried.
std::list< ThreadID > priorityList
List that has the threads organized by priority.
FinishTranslationEvent finishTranslationEvent
Event used to delay fault generation of translation faults.
ThreadID retryTid
The thread that is waiting on the cache to tell fetch to retry.
void tick()
Ticks the fetch stage, processing all inputs signals and fetching as many instructions as possible.
ThreadID numFetchingThreads
Number of threads that are actively fetching.
unsigned fetchBufferSize
The size of the fetch buffer in bytes.
void setFetchQueue(TimeBuffer< FetchStruct > *fq_ptr)
Sets pointer to time buffer used to communicate to the next stage.
CPU * cpu
Pointer to the O3CPU.
unsigned decodeWidth
The width of decode in instructions.
bool cacheBlocked
Is the cache blocked? If so no threads can access it.
ThreadID branchCount()
Returns the appropriate thread to fetch using the branch count policy.
A simple distribution stat.
This is a simple scalar statistic, like a counter.
static constexpr int MaxThreads
double Counter
All counters are of 64-bit values.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
std::shared_ptr< FaultBase > Fault
int16_t ThreadID
Thread index/ID type.
std::shared_ptr< Request > RequestPtr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Declaration of the Packet class.
Declaration of Statistics objects.
statistics::Scalar icacheSquashes
Total number of outstanding icache accesses that were dropped due to a squash.
statistics::Scalar pendingDrainCycles
Total number of cycles spent in waiting for drains.
statistics::Scalar cacheLines
Stat for total number of fetched cache lines.
statistics::Scalar blockedCycles
Total number of cycles spent blocked.
statistics::Scalar idleCycles
Stat for total number of cycles spent blocked due to other stages in the pipeline.
statistics::Scalar predictedBranches
Stat for total number of predicted branches.
statistics::Scalar noActiveThreadStallCycles
Total number of stall cycles caused by no active threads to run.
statistics::Scalar pendingQuiesceStallCycles
Total number of stall cycles caused by pending quiesce instructions.
statistics::Scalar icacheWaitRetryStallCycles
Total number of stall cycles caused by I-cache wait retrys.
statistics::Scalar pendingTrapStallCycles
Total number of stall cycles caused by pending traps.
statistics::Scalar cycles
Stat for total number of cycles spent fetching.
statistics::Scalar miscStallCycles
Total number of cycles spent in any other state.
statistics::Scalar tlbCycles
Stat for total number of cycles spent waiting for translation.
statistics::Scalar squashCycles
Stat for total number of cycles spent squashing.
FetchStatGroup(CPU *cpu, Fetch *fetch)
statistics::Formula idleRate
Rate of how often fetch was idle.
statistics::Scalar tlbSquashes
Total number of outstanding tlb accesses that were dropped due to a squash.
statistics::Distribution nisnDist
Distribution of number of instructions fetched each cycle.
Source of possible stalls.