43#ifndef __CPU_O3_CPU_HH__
44#define __CPU_O3_CPU_HH__
70#include "params/BaseO3CPU.hh"
194 void init()
override;
395 std::set<InstSeqNum> snList;
517 return thread[tid]->getTC();
559 flags, res, std::move(amo_op), byte_enable);
ActivityRecorder helper class that informs the CPU if it can switch over to being idle or not.
void activity()
Records that there is activity this cycle.
void deactivateStage(const int idx)
Deactivates a stage.
void activateStage(const int idx)
Marks a stage as active.
void demapPage(Addr vaddr, uint64_t asn)
Tick clockEdge(Cycles cycles=Cycles(0)) const
Determine the tick when a cycle begins, by default the current one, but the argument also enables the...
Cycles is a wrapper class for representing cycle counts, i.e.
Ports are used to interface objects to each other.
ProbePointArg generates a point for the class of Arg.
Register ID: describe an architectural register with its class and index.
ThreadContext is the external interface to all thread state for anything outside of the CPU.
O3CPU class, has each of the stages (fetch through commit) within it, as well as all of the time buff...
std::vector< BaseISA * > isa
void instDone(ThreadID tid, const DynInstPtr &inst)
Function to tell the CPU that an instruction has completed.
IEW iew
The issue/execute/writeback stages.
gem5::Checker< DynInstPtr > * checker
Pointer to the checker, which can dynamically verify instruction results at run time.
void dumpInsts()
Debug function to print all instructions on the list.
void drainSanityCheck() const
Perform sanity checks after a drain.
void htmSendAbortSignal(ThreadID tid, uint64_t htm_uid, HtmFailureFaultCause cause) override
This function is used to instruct the memory subsystem that a transaction should be aborted and the s...
std::list< DynInstPtr > instList
List of all the instructions in flight.
RegVal getReg(PhysRegIdPtr phys_reg, ThreadID tid)
Fault pushRequest(const DynInstPtr &inst, bool isLoad, uint8_t *data, unsigned int size, Addr addr, Request::Flags flags, uint64_t *res, AtomicOpFunctorPtr amo_op=nullptr, const std::vector< bool > &byte_enable=std::vector< bool >())
CPU pushRequest function, forwards request to LSQ.
ListIt addInst(const DynInstPtr &inst)
Function to add instruction onto the head of the list of the instructions.
void setArchReg(const RegId ®, RegVal val, ThreadID tid)
ROB rob
The re-order buffer.
InstSeqNum globalSeqNum
The global sequence number counter.
void haltContext(ThreadID tid) override
Remove Thread from Active Threads List && Remove Thread Context from CPU.
TimeBuffer< DecodeStruct > decodeQueue
The decode stage's instruction queue.
EventFunctionWrapper tickEvent
The tick event used for scheduling CPU ticks.
void serializeThread(CheckpointOut &cp, ThreadID tid) const override
Serialize a single thread.
void startup() override
startup() is the final initialization call before simulation.
void drainResume() override
Resumes execution after a drain.
Rename rename
The dispatch stage.
void regProbePoints() override
Register probe points.
int numActiveThreads()
Returns the Number of Active Threads in the CPU.
UnifiedRenameMap::PerThreadUnifiedRenameMap PerThreadUnifiedRenameMap
void deactivateThread(ThreadID tid)
Remove Thread from Active Threads List.
Counter totalInsts() const override
Count the Total Instructions Committed in the CPU.
void trap(const Fault &fault, ThreadID tid, const StaticInstPtr &inst)
Traps to handle given fault.
CPU(const BaseO3CPUParams ¶ms)
Constructs a CPU with the given parameters.
ProbePointArg< PacketPtr > * ppInstAccessComplete
void exitThreads()
Terminate all threads that are ready to exit.
ThreadID getFreeTid()
Gets a free thread id.
std::vector< ThreadState * > thread
Pointers to all of the threads in the CPU.
void tick()
Ticks CPU, calling tick() on each stage, and checking the overall activity to see if the CPU should d...
void halt()
Halts the CPU.
void removeThread(ThreadID tid)
Remove all of a thread's context from CPU.
void commitDrained(ThreadID tid)
Commit has reached a safe point to drain a thread.
void unscheduleTickEvent()
Unschedule tick event, regardless of its current state.
gem5::o3::CPU::CPUStats cpuStats
UnifiedFreeList freeList
The free list.
Status _status
Overall CPU status.
std::list< DynInstPtr >::iterator ListIt
void activateContext(ThreadID tid) override
Add Thread to Active Threads List.
virtual void wakeup(ThreadID tid) override
bool removeInstsThisCycle
Records if instructions need to be removed this cycle due to being retired or squashed.
void setMiscReg(int misc_reg, RegVal val, ThreadID tid)
Sets a misc.
void activityThisCycle()
Records that there was time buffer activity this cycle.
std::vector< ThreadID > tids
Available thread ids in the cpu.
Port & getInstPort() override
Used by the fetch unit to get a hold of the instruction port.
ProbePointArg< std::pair< DynInstPtr, PacketPtr > > * ppDataAccessComplete
PerThreadUnifiedRenameMap commitRenameMap
The commit rename map.
void setMiscRegNoEffect(int misc_reg, RegVal val, ThreadID tid)
Sets a miscellaneous register.
void removeInstsUntil(const InstSeqNum &seq_num, ThreadID tid)
Remove all instructions younger than the given sequence number.
bool isDraining() const
Is the CPU draining?
std::queue< ListIt > removeList
List of all the instructions that will be removed at the end of this cycle.
TimeBuffer< FetchStruct > fetchQueue
The fetch stage's instruction queue.
void cleanUpRemovedInsts()
Cleans up all instructions on the remove list.
Commit commit
The commit stage.
void suspendContext(ThreadID tid) override
Remove Thread from Active Threads List.
void demapPage(Addr vaddr, uint64_t asn)
void unserializeThread(CheckpointIn &cp, ThreadID tid) override
Unserialize one thread.
void removeInstsNotInROB(ThreadID tid)
Remove all instructions that are not currently in the ROB.
void takeOverFrom(BaseCPU *oldCPU) override
Takes over from another CPU.
void switchOut() override
Switches out this CPU.
PhysRegFile regFile
The register file.
Cycles lastRunningCycle
The cycle that the CPU was last running, used for statistics.
bool tryDrain()
Check if the pipeline has drained and signal drain done.
ActivityRecorder activityRec
The activity recorder; used to tell if the CPU has any activity remaining or if it can go to idle and...
void processInterrupts(const Fault &interrupt)
Processes any an interrupt fault.
void squashFromTC(ThreadID tid)
Initiates a squash of all in-flight instructions for a given thread.
TimeBuffer< TimeStruct > timeBuffer
The main time buffer to do backwards communication.
Tick lastActivatedCycle
The cycle that the CPU was last activated by a new thread.
StageIdx
Enum to give each stage a specific index, so when calling activateStage() or deactivateStage(),...
int instcount
Count of total number of dynamic instructions in flight.
void deactivateStage(const StageIdx idx)
Changes a stage's status to inactive within the activity recorder.
void squashInstIt(const ListIt &instIt, ThreadID tid)
Removes the instruction pointed to by the iterator.
System * system
Pointer to the system.
Decode decode
The decode stage.
void verifyMemoryMode() const override
Verify that the system is in a memory mode supported by the CPU.
RegVal getArchReg(const RegId ®, ThreadID tid)
Architectural register accessors.
Port & getDataPort() override
Get the dcache port (used to find block size for translations).
TimeBuffer< IEWStruct > iewQueue
The IEW stage's instruction queue.
EventFunctionWrapper threadExitEvent
The exit event used for terminating all ready-to-exit threads.
DrainState drain() override
Starts draining the CPU's pipeline of all instructions in order to stop all memory accesses.
std::list< ThreadID > activeThreads
Active Threads List.
PerThreadUnifiedRenameMap renameMap
The rename map.
Fault getInterrupts()
Returns the Fault for any valid interrupt.
InstSeqNum getAndIncrementInstSeq()
Get the current instruction sequence number, and increment it.
void scheduleTickEvent(Cycles delay)
Schedule tick event, regardless of its current state.
RegVal readMiscRegNoEffect(int misc_reg, ThreadID tid) const
Register accessors.
bool isCpuDrained() const
Check if a system is in a drained state.
Fetch fetch
The fetch stage.
void addThreadToExitingList(ThreadID tid)
Insert tid to the list of threads trying to exit.
void pcState(const PCStateBase &new_pc_state, ThreadID tid)
Sets the commit PC state of a specific thread.
void scheduleThreadExitEvent(ThreadID tid)
If a thread is trying to exit and its corresponding trap event has been completed,...
void updateThreadPriority()
Update The Order In Which We Process Threads.
void setReg(PhysRegIdPtr phys_reg, RegVal val, ThreadID tid)
bool isThreadExiting(ThreadID tid) const
Is the thread trying to exit?
void removeFrontInst(const DynInstPtr &inst)
Remove an instruction from the front end of the list.
std::map< ThreadID, unsigned > threadMap
Mapping for system thread id to cpu id.
void * getWritableArchReg(const RegId ®, ThreadID tid)
RegVal readMiscReg(int misc_reg, ThreadID tid)
Reads a misc.
void init() override
Initialize the CPU.
void activateThread(ThreadID tid)
Add Thread to Active Threads List.
gem5::ThreadContext * tcBase(ThreadID tid)
Returns a pointer to a thread context.
void activateStage(const StageIdx idx)
Changes a stage's status to active within the activity recorder.
std::list< int > cpuWaitList
Threads Scheduled to Enter CPU.
Scoreboard scoreboard
Integer Register Scoreboard.
void * getWritableReg(PhysRegIdPtr phys_reg, ThreadID tid)
std::unordered_map< ThreadID, bool > exitingThreads
This is a list of threads that are trying to exit.
Counter totalOps() const override
Count the Total Ops (including micro ops) committed in the CPU.
void wakeCPU()
Wakes the CPU, rescheduling the CPU if it's not already active.
void insertThread(ThreadID tid)
Setup CPU to insert a thread's context.
TimeBuffer< RenameStruct > renameQueue
The rename stage's instruction queue.
Commit handles single threaded and SMT commit.
Decode class handles both single threaded and SMT decode.
Fetch class handles both single threaded and SMT fetch.
RequestPort & getInstPort()
IEW handles both single threaded and SMT IEW (issue/execute/writeback).
LSQ ldstQueue
Load / store queue.
Memory operation metadata.
Fault pushRequest(const DynInstPtr &inst, bool isLoad, uint8_t *data, unsigned int size, Addr addr, Request::Flags flags, uint64_t *res, AtomicOpFunctorPtr amo_op, const std::vector< bool > &byte_enable)
RequestPort & getDataPort()
Simple physical register file class.
Rename handles both single threaded and SMT rename.
Implements a simple scoreboard to track which registers are ready.
Derived ThreadContext class for use with the O3CPU.
FreeList class that simply holds the list of free integer and floating point registers.
std::array< UnifiedRenameMap, MaxThreads > PerThreadUnifiedRenameMap
This is a simple scalar statistic, like a counter.
std::unique_ptr< AtomicOpFunctor > AtomicOpFunctorPtr
DrainState drainState() const
Return the current drain state of an object.
DrainState
Object drain/handover states.
@ Draining
Draining buffers pending serialization/handover.
bool scheduled() const
Determine if the current event is scheduled.
void squash()
Squash the current event.
void schedule(Event &event, Tick when)
void reschedule(Event &event, Tick when, bool always=false)
bool squashed() const
Check whether the event is squashed.
#define panic(...)
This implements a cprintf based panic() function.
const Params & params() const
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::ostream CheckpointOut
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
uint64_t Tick
Tick count type.
Declaration of Statistics objects.
statistics::Scalar timesIdled
Stat for total number of times the CPU is descheduled.
statistics::Scalar quiesceCycles
Stat for total number of cycles the CPU spends descheduled due to a quiesce operation or waiting for ...
statistics::Scalar idleCycles
Stat for total number of cycles the CPU spends descheduled.