38#ifndef __CPU_O3_BAC_HH__
39#define __CPU_O3_BAC_HH__
54struct BaseO3CPUParams;
126 BAC(
CPU *_cpu,
const BaseO3CPUParams ¶ms);
133 std::string
name()
const;
Cycles is a wrapper class for representing cycle counts, i.e.
Basically a wrapper class to hold both the branch predictor and the BTB.
const Cycles decodeToFetchDelay
Decode to fetch delay.
bool isDrained() const
Has the stage drained?
CPU * cpu
Pointer to the main CPU.
void drainResume()
Resume after a drain.
TimeBuffer< TimeStruct >::wire fromFetch
Wire to get fetches's information from backwards time buffer.
std::list< ThreadID > * activeThreads
List of Active FTQ Threads.
Stalls stalls[MaxThreads]
Tracks which stages are telling the ftq to stall.
bool wroteToTimeBuffer
Variable that tracks if BAC has written to the time buffer this cycle.
bool checkStall(ThreadID tid) const
Checks if a thread is stalled.
const unsigned fetchTargetWidth
The maximum width of a fetch target.
const unsigned minInstSize
The minimum size an instruction can have in the current architecture.
void deactivateThread(ThreadID tid)
void startupStage()
Initialize stage.
void generateFetchTargets(ThreadID tid, bool &status_change)
Main function that feeds the FTQ with new fetch targets.
ThreadStatus
Individual thread status.
const Cycles fetchToBacDelay
Fetch to BAC delay.
const unsigned int cacheBlkSize
Cache block size.
void setFetchTargetQueue(FTQ *_ptr)
Connect the FTQ.
const Cycles bacToFetchDelay
BAC to fetch delay.
void takeOverFrom()
Takes over from another CPU's thread.
void updateBACStatus()
Updates overall BAC stage status; to be called at the end of each cycle.
const unsigned maxTakenPredPerCycle
ThreadStatus bacStatus[MaxThreads]
Per-thread status.
const unsigned maxFTPerCycle
void setActiveThreads(std::list< ThreadID > *at_ptr)
Sets pointer to list of active threads.
const ThreadID numThreads
Number of threads.
BACStatus _status
Decode status.
bool checkSignalsAndUpdate(ThreadID tid)
Checks all input signals and updates the status as necessary.
bool predict(ThreadID tid, const StaticInstPtr &inst, const FetchTargetPtr &ft, PCStateBase &pc)
The prediction function for the BAC stage.
bool updatePreDecode(ThreadID tid, const InstSeqNum seqNum, const StaticInstPtr &inst, PCStateBase &pc, const FetchTargetPtr &ft)
Pre-decode update --------------------------------------— After predecoding instruction in the fetch ...
void regProbePoints()
Registers probes and listeners.
BAC(CPU *_cpu, const BaseO3CPUParams ¶ms)
BAC constructor.
void drainStall(ThreadID tid)
Stall the fetch stage after reaching a safe drain point.
void drainSanityCheck() const
Perform sanity checks after a drain.
void resetStage()
Reset this pipeline stage.
bool updatePC(const DynInstPtr &inst, PCStateBase &fetch_pc, FetchTargetPtr &ft)
Calculate the next PC address depending on the instruction type and the branch prediction.
Addr alignToCacheBlock(Addr addr)
Align a address to the start of a cache block.
const Cycles commitToFetchDelay
Commit to fetch delay.
const bool decoupledFrontEnd
Enables the decoupled front-end.
FetchTargetPtr newFetchTarget(ThreadID tid, const PCStateBase &start_pc)
Create a new fetch target.
gem5::o3::BAC::BACStats stats
void switchToInactive()
Changes the status of this stage to inactive, and indicates this to the CPU.
bool checkAndUpdateBPUSignals(ThreadID tid)
Check the backward signals that update the BPU.
branch_prediction::BranchType BranchType
void setTimeBuffer(TimeBuffer< TimeStruct > *tb_ptr)
Sets the main backwards communication time buffer pointer.
void clearStates(ThreadID tid)
Clear all thread-specific states.
std::string name() const
Returns the name of the stage.
void switchToActive()
Changes the status of this stage to active, and indicates this to the CPU.
TimeBuffer< FetchStruct >::wire toFetch
Wire used to write any information heading to fetch.
void squashBpuHistories(ThreadID tid)
Squashes the BPU histories in the FTQ.
void tick()
Process all input signals and create the next fetch target.
std::unique_ptr< PCStateBase > bacPC[MaxThreads]
The decoupled PC which runs ahead of fetch.
TimeBuffer< TimeStruct >::wire fromDecode
Wire to get decode's information from backwards time buffer.
void squash(const PCStateBase &new_pc, ThreadID tid)
Squashes BAC for a specific thread and resets the PC.
branch_prediction::BPredUnit * bpu
BPredUnit.
BACStatus
Overall decoupled BPU stage status.
FTQ * ftq
Fetch target Queue.
TimeBuffer< TimeStruct > * timeBuffer
Time buffer interface.
TimeBuffer< TimeStruct >::wire fromCommit
Wire to get commit's information from backwards time buffer.
O3CPU class, has each of the stages (fetch through commit) within it, as well as all of the time buff...
A simple distribution stat.
This is a simple scalar statistic, like a counter.
A vector of scalar stats.
enums::BranchType BranchType
std::shared_ptr< FetchTarget > FetchTargetPtr
static constexpr int MaxThreads
RefCountingPtr< DynInst > DynInstPtr
Copyright (c) 2024 Arm Limited All rights reserved.
int16_t ThreadID
Thread index/ID type.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
RefCountingPtr< StaticInst > StaticInstPtr
Declaration of Statistics objects.
statistics::Vector preDecUpdate
Number of post updates.
BACStats(CPU *cpu, BAC *bac)
statistics::Scalar branches
Total number of branches detected.
statistics::Scalar predTakenBranches
Total number of branches predicted taken.
statistics::Scalar branchesNotLastuOp
Total number of fetched branches.
statistics::Scalar multiBranchInst
statistics::Scalar typeMissmatch
Stat for the two corner cases.
statistics::Scalar squashBranchCommit
statistics::Vector noHistByType
Number of branches undetected by the BPU.
statistics::Scalar squashBranchDecode
Stat for the number of squashes from decode and commit.
statistics::Scalar noBranchMisspredict
statistics::Scalar fetchTargets
Stat for total number fetch targets created.
static std::string statusStrings[ThreadStatusMax]
statistics::Distribution ftSizeDist
Distribution of number of bytes per fetch target.
statistics::Distribution ftNumber
statistics::Scalar branchMisspredict
Stat for total number of misspredicted instructions.
statistics::Vector status
Stat for total number of cycles spent in each BAC state.
Source of possible stalls.