gem5  v21.0.1.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
BaseCPU Class Referenceabstract

#include <base.hh>

Inheritance diagram for BaseCPU:
ClockedObject SimObject Clocked EventManager Serializable Drainable Stats::Group BaseKvmCPU BaseO3CPU BaseSimpleCPU CheckerCPU Iris::BaseCPU MinorCPU TraceCPU ArmKvmCPU BaseArmKvmCPU X86KvmCPU FullO3CPU< Impl > FullO3CPU< O3CPUImpl > AtomicSimpleCPU TimingSimpleCPU Checker< Impl > Checker< O3CPUImpl > DummyChecker Iris::CPU< CortexA76TC > Iris::CPU< CortexR52TC > Iris::CPU< TC >

Classes

struct  BaseCPUStats
 
struct  GlobalStats
 Global CPU statistics that are merged into the Root object. More...
 

Public Member Functions

virtual PortgetDataPort ()=0
 Purely virtual method that returns a reference to the data port. More...
 
virtual PortProxy::SendFunctionalFunc getSendFunctional ()
 Returns a sendFunctional delegate for use with port proxies. More...
 
virtual PortgetInstPort ()=0
 Purely virtual method that returns a reference to the instruction port. More...
 
int cpuId () const
 Reads this CPU's ID. More...
 
uint32_t socketId () const
 Reads this CPU's Socket ID. More...
 
RequestorID dataRequestorId () const
 Reads this CPU's unique data requestor ID. More...
 
RequestorID instRequestorId () const
 Reads this CPU's unique instruction requestor ID. More...
 
PortgetPort (const std::string &if_name, PortID idx=InvalidPortID) override
 Get a port on this CPU. More...
 
uint32_t taskId () const
 Get cpu task id. More...
 
void taskId (uint32_t id)
 Set cpu task id. More...
 
uint32_t getPid () const
 
void setPid (uint32_t pid)
 
void workItemBegin ()
 
void workItemEnd ()
 
Tick instCount ()
 
BaseInterruptsgetInterruptController (ThreadID tid)
 
virtual void wakeup (ThreadID tid)=0
 
void postInterrupt (ThreadID tid, int int_num, int index)
 
void clearInterrupt (ThreadID tid, int int_num, int index)
 
void clearInterrupts (ThreadID tid)
 
bool checkInterrupts (ThreadID tid) const
 
Trace::InstTracergetTracer ()
 Provide access to the tracer pointer. More...
 
virtual void activateContext (ThreadID thread_num)
 Notify the CPU that the indicated context is now active. More...
 
virtual void suspendContext (ThreadID thread_num)
 Notify the CPU that the indicated context is now suspended. More...
 
virtual void haltContext (ThreadID thread_num)
 Notify the CPU that the indicated context is now halted. More...
 
int findContext (ThreadContext *tc)
 Given a Thread Context pointer return the thread num. More...
 
virtual ThreadContextgetContext (int tn)
 Given a thread num get tho thread context for it. More...
 
unsigned numContexts ()
 Get the number of thread contexts available. More...
 
ThreadID contextToThread (ContextID cid)
 Convert ContextID to threadID. More...
 
 PARAMS (BaseCPU)
 
 BaseCPU (const Params &params, bool is_checker=false)
 
virtual ~BaseCPU ()
 
void init () override
 init() is called after all C++ SimObjects have been created and all ports are connected. More...
 
void startup () override
 startup() is the final initialization call before simulation. More...
 
void regStats () override
 Callback to set stat parameters. More...
 
void regProbePoints () override
 Register probe points for this object. More...
 
void registerThreadContexts ()
 
void deschedulePowerGatingEvent ()
 
void schedulePowerGatingEvent ()
 
virtual void switchOut ()
 Prepare for another CPU to take over execution. More...
 
virtual void takeOverFrom (BaseCPU *cpu)
 Load the state of a CPU from the previous CPU object, invoked on all new CPUs that are about to be switched in. More...
 
void flushTLBs ()
 Flush all TLBs in the CPU. More...
 
bool switchedOut () const
 Determine if the CPU is switched out. More...
 
virtual void verifyMemoryMode () const
 Verify that the system is in a memory mode supported by the CPU. More...
 
unsigned int cacheLineSize () const
 Get the cache line size of the system. More...
 
void serialize (CheckpointOut &cp) const override
 Serialize this object to the given output stream. More...
 
void unserialize (CheckpointIn &cp) override
 Reconstruct the state of this object from a checkpoint. More...
 
virtual void serializeThread (CheckpointOut &cp, ThreadID tid) const
 Serialize a single thread. More...
 
virtual void unserializeThread (CheckpointIn &cp, ThreadID tid)
 Unserialize one thread. More...
 
virtual Counter totalInsts () const =0
 
virtual Counter totalOps () const =0
 
void scheduleInstStop (ThreadID tid, Counter insts, const char *cause)
 Schedule an event that exits the simulation loops after a predefined number of instructions. More...
 
uint64_t getCurrentInstCount (ThreadID tid)
 Get the number of instructions executed by the specified thread on this CPU. More...
 
void traceFunctions (Addr pc)
 
void armMonitor (ThreadID tid, Addr address)
 
bool mwait (ThreadID tid, PacketPtr pkt)
 
void mwaitAtomic (ThreadID tid, ThreadContext *tc, BaseMMU *mmu)
 
AddressMonitorgetCpuAddrMonitor (ThreadID tid)
 
bool waitForRemoteGDB () const
 
- Public Member Functions inherited from ClockedObject
 ClockedObject (const ClockedObjectParams &p)
 
void serialize (CheckpointOut &cp) const override
 Serialize an object. More...
 
void unserialize (CheckpointIn &cp) override
 Unserialize an object. More...
 
- Public Member Functions inherited from SimObject
const Paramsparams () const
 
 SimObject (const Params &p)
 
virtual ~SimObject ()
 
virtual const std::string name () const
 
virtual void loadState (CheckpointIn &cp)
 loadState() is called on each SimObject when restoring from a checkpoint. More...
 
virtual void initState ()
 initState() is called on each SimObject when not restoring from a checkpoint. More...
 
virtual void regProbeListeners ()
 Register probe listeners for this object. More...
 
ProbeManagergetProbeManager ()
 Get the probe manager for this object. More...
 
DrainState drain () override
 Provide a default implementation of the drain interface for objects that don't need draining. More...
 
virtual void memWriteback ()
 Write back dirty buffers to memory using functional writes. More...
 
virtual void memInvalidate ()
 Invalidate the contents of memory buffers. More...
 
void serialize (CheckpointOut &cp) const override
 Serialize an object. More...
 
void unserialize (CheckpointIn &cp) override
 Unserialize an object. More...
 
- Public Member Functions inherited from EventManager
EventQueueeventQueue () const
 
void schedule (Event &event, Tick when)
 
void deschedule (Event &event)
 
void reschedule (Event &event, Tick when, bool always=false)
 
void schedule (Event *event, Tick when)
 
void deschedule (Event *event)
 
void reschedule (Event *event, Tick when, bool always=false)
 
void wakeupEventQueue (Tick when=(Tick) -1)
 This function is not needed by the usual gem5 event loop but may be necessary in derived EventQueues which host gem5 on other schedulers. More...
 
void setCurTick (Tick newVal)
 
 EventManager (EventManager &em)
 Event manger manages events in the event queue. More...
 
 EventManager (EventManager *em)
 
 EventManager (EventQueue *eq)
 
- Public Member Functions inherited from Serializable
 Serializable ()
 
virtual ~Serializable ()
 
void serializeSection (CheckpointOut &cp, const char *name) const
 Serialize an object into a new section. More...
 
void serializeSection (CheckpointOut &cp, const std::string &name) const
 
void unserializeSection (CheckpointIn &cp, const char *name)
 Unserialize an a child object. More...
 
void unserializeSection (CheckpointIn &cp, const std::string &name)
 
- Public Member Functions inherited from Drainable
DrainState drainState () const
 Return the current drain state of an object. More...
 
virtual void notifyFork ()
 Notify a child process of a fork. More...
 
- Public Member Functions inherited from Stats::Group
 Group (Group *parent, const char *name=nullptr)
 Construct a new statistics group. More...
 
virtual ~Group ()
 
virtual void resetStats ()
 Callback to reset stats. More...
 
virtual void preDumpStats ()
 Callback before stats are dumped. More...
 
void addStat (Stats::Info *info)
 Register a stat with this group. More...
 
const std::map< std::string, Group * > & getStatGroups () const
 Get all child groups associated with this object. More...
 
const std::vector< Info * > & getStats () const
 Get all stats associated with this object. More...
 
void addStatGroup (const char *name, Group *block)
 Add a stat block as a child of this block. More...
 
const InforesolveStat (std::string name) const
 Resolve a stat by its name within this group. More...
 
void mergeStatGroup (Group *block)
 Merge the contents (stats & children) of a block to this block. More...
 
 Group ()=delete
 
 Group (const Group &)=delete
 
Groupoperator= (const Group &)=delete
 
- Public Member Functions inherited from Clocked
void updateClockPeriod ()
 Update the tick to the current tick. More...
 
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 caller to determine a future cycle. More...
 
Cycles curCycle () const
 Determine the current cycle, corresponding to a tick aligned to a clock edge. More...
 
Tick nextCycle () const
 Based on the clock of the object, determine the start tick of the first cycle that is at least one cycle in the future. More...
 
uint64_t frequency () const
 
Tick clockPeriod () const
 
double voltage () const
 
Cycles ticksToCycles (Tick t) const
 
Tick cyclesToTicks (Cycles c) const
 

Static Public Member Functions

static int numSimulatedCPUs ()
 
static Counter numSimulatedInsts ()
 
static Counter numSimulatedOps ()
 
- Static Public Member Functions inherited from SimObject
static void serializeAll (CheckpointOut &cp)
 Serialize all SimObjects in the system. More...
 
static SimObjectfind (const char *name)
 Find the SimObject with the given name and return a pointer to it. More...
 
- Static Public Member Functions inherited from Serializable
static const std::string & currentSection ()
 Gets the fully-qualified name of the active section. More...
 
static void serializeAll (const std::string &cpt_dir)
 Serializes all the SimObjects. More...
 
static void unserializeGlobals (CheckpointIn &cp)
 

Public Attributes

ThreadID numThreads
 Number of threads we're actually simulating (<= SMT_MAX_THREADS). More...
 
Systemsystem
 
BaseCPU::BaseCPUStats baseStats
 
Cycles syscallRetryLatency
 
- Public Attributes inherited from ClockedObject
PowerStatepowerState
 

Static Public Attributes

static const uint32_t invldPid = std::numeric_limits<uint32_t>::max()
 Invalid or unknown Pid. More...
 
static const Addr PCMask = ~((Addr)sizeof(TheISA::MachInst) - 1)
 

Protected Types

enum  CPUState { CPU_STATE_ON, CPU_STATE_SLEEP, CPU_STATE_WAKEUP }
 

Protected Member Functions

void updateCycleCounters (CPUState state)
 base method keeping track of cycle progression More...
 
void enterPwrGating ()
 
- Protected Member Functions inherited from Drainable
 Drainable ()
 
virtual ~Drainable ()
 
virtual void drainResume ()
 Resume execution after a successful drain. More...
 
void signalDrainDone () const
 Signal that an object is drained. More...
 
- Protected Member Functions inherited from Clocked
 Clocked (ClockDomain &clk_domain)
 Create a clocked object and set the clock domain based on the parameters. More...
 
 Clocked (Clocked &)=delete
 
Clockedoperator= (Clocked &)=delete
 
virtual ~Clocked ()
 Virtual destructor due to inheritance. More...
 
void resetClock () const
 Reset the object's clock using the current global tick value. More...
 
virtual void clockPeriodUpdated ()
 A hook subclasses can implement so they can do any extra work that's needed when the clock rate is changed. More...
 

Protected Attributes

Tick instCnt
 Instruction count used for SPARC misc register. More...
 
int _cpuId
 
const uint32_t _socketId
 Each cpu will have a socket ID that corresponds to its physical location in the system. More...
 
RequestorID _instRequestorId
 instruction side request id that must be placed in all requests More...
 
RequestorID _dataRequestorId
 data side request id that must be placed in all requests More...
 
uint32_t _taskId
 An intrenal representation of a task identifier within gem5. More...
 
uint32_t _pid
 The current OS process ID that is executing on this processor. More...
 
bool _switchedOut
 Is the CPU switched out or active? More...
 
const unsigned int _cacheLineSize
 Cache the cache line size that we get from the system. More...
 
std::vector< BaseInterrupts * > interrupts
 
std::vector< ThreadContext * > threadContexts
 
Trace::InstTracertracer
 
Cycles previousCycle
 
CPUState previousState
 
const Cycles pwrGatingLatency
 
const bool powerGatingOnIdle
 
EventFunctionWrapper enterPwrGatingEvent
 
- Protected Attributes inherited from SimObject
const SimObjectParams & _params
 Cached copy of the object parameters. More...
 
- Protected Attributes inherited from EventManager
EventQueueeventq
 A pointer to this object's event queue. More...
 

Static Protected Attributes

static std::unique_ptr< GlobalStatsglobalStats
 Pointer to the global stat structure. More...
 

Private Member Functions

void enableFunctionTrace ()
 
void traceFunctionsInternal (Addr pc)
 

Private Attributes

bool functionTracingEnabled
 
std::ostream * functionTraceStream
 
Addr currentFunctionStart
 
Addr currentFunctionEnd
 
Tick functionEntryTick
 
std::vector< AddressMonitoraddressMonitor
 

Static Private Attributes

static std::vector< BaseCPU * > cpuList
 Static global cpu list. More...
 

PMU Probe points.

ProbePoints::PMUUPtr ppRetiredInsts
 Instruction commit probe point. More...
 
ProbePoints::PMUUPtr ppRetiredInstsPC
 
ProbePoints::PMUUPtr ppRetiredLoads
 Retired load instructions. More...
 
ProbePoints::PMUUPtr ppRetiredStores
 Retired store instructions. More...
 
ProbePoints::PMUUPtr ppRetiredBranches
 Retired branches (any type) More...
 
ProbePoints::PMUUPtr ppAllCycles
 CPU cycle counter even if any thread Context is suspended. More...
 
ProbePoints::PMUUPtr ppActiveCycles
 CPU cycle counter, only counts if any thread contexts is active. More...
 
ProbePointArg< bool > * ppSleeping
 ProbePoint that signals transitions of threadContexts sets. More...
 
virtual void probeInstCommit (const StaticInstPtr &inst, Addr pc)
 Helper method to trigger PMU probes for a committed instruction. More...
 
ProbePoints::PMUUPtr pmuProbePoint (const char *name)
 Helper method to instantiate probe points belonging to this object. More...
 

Additional Inherited Members

- Public Types inherited from ClockedObject
using Params = ClockedObjectParams
 Parameters of ClockedObject. More...
 
- Public Types inherited from SimObject
typedef SimObjectParams Params
 

Detailed Description

Definition at line 104 of file base.hh.

Member Enumeration Documentation

◆ CPUState

enum BaseCPU::CPUState
protected
Enumerator
CPU_STATE_ON 
CPU_STATE_SLEEP 
CPU_STATE_WAKEUP 

Definition at line 522 of file base.hh.

Constructor & Destructor Documentation

◆ BaseCPU()

BaseCPU::BaseCPU ( const Params params,
bool  is_checker = false 
)

Definition at line 124 of file base.cc.

References enterPwrGating().

◆ ~BaseCPU()

BaseCPU::~BaseCPU ( )
virtual

Reimplemented in Iris::BaseCPU.

Definition at line 186 of file base.cc.

Member Function Documentation

◆ activateContext()

void BaseCPU::activateContext ( ThreadID  thread_num)
virtual

◆ armMonitor()

void BaseCPU::armMonitor ( ThreadID  tid,
Addr  address 
)

◆ cacheLineSize()

unsigned int BaseCPU::cacheLineSize ( ) const
inline

◆ checkInterrupts()

bool BaseCPU::checkInterrupts ( ThreadID  tid) const
inline

Definition at line 263 of file base.hh.

References FullSystem, and interrupts.

Referenced by BaseSimpleCPU::checkForInterrupts(), and Minor::Execute::isInterrupted().

◆ clearInterrupt()

void BaseCPU::clearInterrupt ( ThreadID  tid,
int  int_num,
int  index 
)
inline

◆ clearInterrupts()

void BaseCPU::clearInterrupts ( ThreadID  tid)
inline

Definition at line 257 of file base.hh.

References interrupts.

Referenced by ArmISA::Reset::invoke().

◆ contextToThread()

ThreadID BaseCPU::contextToThread ( ContextID  cid)
inline

Convert ContextID to threadID.

Definition at line 308 of file base.hh.

References threadContexts.

Referenced by Minor::LSQ::tryToSend().

◆ cpuId()

int BaseCPU::cpuId ( ) const
inline

◆ dataRequestorId()

RequestorID BaseCPU::dataRequestorId ( ) const
inline

◆ deschedulePowerGatingEvent()

void BaseCPU::deschedulePowerGatingEvent ( )

◆ enableFunctionTrace()

void BaseCPU::enableFunctionTrace ( )
private

Definition at line 181 of file base.cc.

References functionTracingEnabled.

◆ enterPwrGating()

void BaseCPU::enterPwrGating ( )
protected

Definition at line 530 of file base.cc.

References RiscvISA::OFF, ClockedObject::powerState, and PowerState::set().

Referenced by BaseCPU().

◆ findContext()

int BaseCPU::findContext ( ThreadContext tc)

Given a Thread Context pointer return the thread num.

Definition at line 473 of file base.cc.

References threadContexts.

◆ flushTLBs()

void BaseCPU::flushTLBs ( )

Flush all TLBs in the CPU.

This method is mainly used to flush stale translations when switching CPUs. It is also exported to the Python world to allow it to request a TLB flush after draining the CPU to make it easier to compare traces when debugging handover/checkpointing.

Definition at line 612 of file base.cc.

References BaseMMU::flushAll(), ThreadContext::getCheckerCpuPtr(), ThreadContext::getMMUPtr(), CheckerCPU::getMMUPtr(), ArmISA::i, and threadContexts.

Referenced by switchOut().

◆ getContext()

virtual ThreadContext* BaseCPU::getContext ( int  tn)
inlinevirtual

◆ getCpuAddrMonitor()

AddressMonitor* BaseCPU::getCpuAddrMonitor ( ThreadID  tid)
inline

◆ getCurrentInstCount()

Tick BaseCPU::getCurrentInstCount ( ThreadID  tid)

Get the number of instructions executed by the specified thread on this CPU.

Used by Python to control simulation.

Parameters
tidThread monitor
Returns
Number of instructions executed

Definition at line 673 of file base.cc.

References threadContexts.

Referenced by scheduleInstStop().

◆ getDataPort()

virtual Port& BaseCPU::getDataPort ( )
pure virtual

Purely virtual method that returns a reference to the data port.

All subclasses must implement this method.

Returns
a reference to the data port

Implemented in FullO3CPU< Impl >, FullO3CPU< O3CPUImpl >, TimingSimpleCPU, AtomicSimpleCPU, MinorCPU, CheckerCPU, BaseKvmCPU, Iris::BaseCPU, and TraceCPU.

Referenced by getPort(), getSendFunctional(), TraceCPU::takeOverFrom(), and takeOverFrom().

◆ getInstPort()

virtual Port& BaseCPU::getInstPort ( )
pure virtual

Purely virtual method that returns a reference to the instruction port.

All subclasses must implement this method.

Returns
a reference to the instruction port

Implemented in FullO3CPU< Impl >, FullO3CPU< O3CPUImpl >, TimingSimpleCPU, AtomicSimpleCPU, MinorCPU, CheckerCPU, BaseKvmCPU, Iris::BaseCPU, and TraceCPU.

Referenced by getPort(), TraceCPU::takeOverFrom(), and takeOverFrom().

◆ getInterruptController()

BaseInterrupts* BaseCPU::getInterruptController ( ThreadID  tid)
inline

◆ getPid()

uint32_t BaseCPU::getPid ( ) const
inline

Definition at line 223 of file base.hh.

References _pid.

Referenced by takeOverFrom().

◆ getPort()

Port & BaseCPU::getPort ( const std::string &  if_name,
PortID  idx = InvalidPortID 
)
overridevirtual

Get a port on this CPU.

All CPUs have a data and instruction port, and this method uses getDataPort and getInstPort of the subclasses to resolve the two ports.

Parameters
if_namethe port name
idxignored index
Returns
a reference to the port with the given name

Reimplemented from SimObject.

Definition at line 406 of file base.cc.

References getDataPort(), getInstPort(), and SimObject::getPort().

Referenced by FastModel::CortexA76::getPort().

◆ getSendFunctional()

virtual PortProxy::SendFunctionalFunc BaseCPU::getSendFunctional ( )
inlinevirtual

Returns a sendFunctional delegate for use with port proxies.

Reimplemented in Iris::BaseCPU.

Definition at line 179 of file base.hh.

References getDataPort().

Referenced by ThreadState::initMemProxies().

◆ getTracer()

Trace::InstTracer* BaseCPU::getTracer ( )
inline

Provide access to the tracer pointer.

Definition at line 284 of file base.hh.

References tracer.

◆ haltContext()

void BaseCPU::haltContext ( ThreadID  thread_num)
virtual

Notify the CPU that the indicated context is now halted.

Reimplemented in FullO3CPU< Impl >, FullO3CPU< O3CPUImpl >, BaseSimpleCPU, and BaseKvmCPU.

Definition at line 524 of file base.cc.

References CPU_STATE_SLEEP, and updateCycleCounters().

Referenced by SimpleThread::halt().

◆ init()

void BaseCPU::init ( )
overridevirtual

init() is called after all C++ SimObjects have been created and all ports are connected.

Initializations that are independent of unserialization but rely on a fully instantiated and connected SimObject graph should be done here.

Reimplemented from SimObject.

Reimplemented in FullO3CPU< Impl >, FullO3CPU< O3CPUImpl >, MinorCPU, BaseSimpleCPU, CheckerCPU, BaseKvmCPU, AtomicSimpleCPU, TimingSimpleCPU, and TraceCPU.

Definition at line 269 of file base.cc.

References MipsISA::event, ArmISA::i, numThreads, SimObject::params(), registerThreadContexts(), scheduleInstStop(), threadContexts, and verifyMemoryMode().

Referenced by BaseKvmCPU::init(), BaseSimpleCPU::init(), Iris::BaseCPU::init(), MinorCPU::init(), TraceCPU::init(), and FullO3CPU< O3CPUImpl >::init().

◆ instCount()

Tick BaseCPU::instCount ( )
inline

◆ instRequestorId()

RequestorID BaseCPU::instRequestorId ( ) const
inline

Reads this CPU's unique instruction requestor ID.

Definition at line 203 of file base.hh.

References _instRequestorId.

Referenced by Minor::Fetch1::fetchLine(), and BaseSimpleCPU::setupFetchRequest().

◆ mwait()

bool BaseCPU::mwait ( ThreadID  tid,
PacketPtr  pkt 
)

◆ mwaitAtomic()

void BaseCPU::mwaitAtomic ( ThreadID  tid,
ThreadContext tc,
BaseMMU mmu 
)

◆ numContexts()

unsigned BaseCPU::numContexts ( )
inline

Get the number of thread contexts available.

Definition at line 303 of file base.hh.

References threadContexts.

◆ numSimulatedCPUs()

static int BaseCPU::numSimulatedCPUs ( )
inlinestatic

Definition at line 578 of file base.hh.

References cpuList.

◆ numSimulatedInsts()

static Counter BaseCPU::numSimulatedInsts ( )
inlinestatic

◆ numSimulatedOps()

static Counter BaseCPU::numSimulatedOps ( )
inlinestatic

Definition at line 590 of file base.hh.

References cpuList, ArmISA::i, Stats::total, and totalOps().

Referenced by BaseCPU::GlobalStats::GlobalStats().

◆ PARAMS()

BaseCPU::PARAMS ( BaseCPU  )

◆ pmuProbePoint()

ProbePoints::PMUUPtr BaseCPU::pmuProbePoint ( const char *  name)
protected

Helper method to instantiate probe points belonging to this object.

Parameters
nameName of the probe point.
Returns
A unique_ptr to the new probe point.

Definition at line 328 of file base.cc.

References SimObject::getProbeManager(), and SimObject::name().

Referenced by regProbePoints().

◆ postInterrupt()

void BaseCPU::postInterrupt ( ThreadID  tid,
int  int_num,
int  index 
)

◆ probeInstCommit()

void BaseCPU::probeInstCommit ( const StaticInstPtr inst,
Addr  pc 
)
virtual

Helper method to trigger PMU probes for a committed instruction.

Parameters
instInstruction that just committed
pcPC of the instruction that just committed

Definition at line 353 of file base.cc.

References StaticInst::isAtomic(), StaticInst::isControl(), StaticInst::isLastMicroop(), StaticInst::isLoad(), StaticInst::isMicroop(), StaticInst::isStore(), MipsISA::pc, ppRetiredBranches, ppRetiredInsts, ppRetiredInstsPC, ppRetiredLoads, and ppRetiredStores.

Referenced by Minor::Execute::doInstCommitAccounting(), FullO3CPU< O3CPUImpl >::instDone(), and BaseSimpleCPU::postExecute().

◆ registerThreadContexts()

void BaseCPU::registerThreadContexts ( )

◆ regProbePoints()

void BaseCPU::regProbePoints ( )
overridevirtual

Register probe points for this object.

No probe points by default, so do nothing in base.

Reimplemented from SimObject.

Reimplemented in AtomicSimpleCPU, FullO3CPU< Impl >, and FullO3CPU< O3CPUImpl >.

Definition at line 337 of file base.cc.

References SimObject::getProbeManager(), pmuProbePoint(), ppActiveCycles, ppAllCycles, ppRetiredBranches, ppRetiredInsts, ppRetiredInstsPC, ppRetiredLoads, ppRetiredStores, and ppSleeping.

Referenced by FullO3CPU< O3CPUImpl >::regProbePoints(), and AtomicSimpleCPU::regProbePoints().

◆ regStats()

void BaseCPU::regStats ( )
overridevirtual

Callback to set stat parameters.

This callback is typically used for complex stats (e.g., distributions) that need parameters in addition to a name and a description. Stat names and descriptions should typically be set from the constructor usingo from the constructor using the ADD_STAT macro.

Reimplemented from Stats::Group.

Reimplemented in MinorCPU.

Definition at line 382 of file base.cc.

References ccprintf(), globalStats, ArmISA::i, SimObject::name(), Stats::Group::regStats(), Root::root(), and threadContexts.

Referenced by MinorCPU::regStats().

◆ scheduleInstStop()

void BaseCPU::scheduleInstStop ( ThreadID  tid,
Counter  insts,
const char *  cause 
)

Schedule an event that exits the simulation loops after a predefined number of instructions.

This method is usually called from the configuration script to get an exit event some time in the future. It is typically used when the script wants to simulate for a specific number of instructions rather than ticks.

Parameters
tidThread monitor.
instsNumber of instructions into the future.
causeCause to signal in the exit event.

Definition at line 664 of file base.cc.

References MipsISA::event, getCurrentInstCount(), and threadContexts.

Referenced by init().

◆ schedulePowerGatingEvent()

void BaseCPU::schedulePowerGatingEvent ( )

◆ serialize()

void BaseCPU::serialize ( CheckpointOut cp) const
overridevirtual

Serialize this object to the given output stream.

Note
CPU models should normally overload the serializeThread() method instead of the serialize() method as this provides a uniform data format for all CPU models and promotes better code reuse.
Parameters
cpThe stream to serialize to.

Implements Serializable.

Reimplemented in CheckerCPU, and MinorCPU.

Definition at line 626 of file base.cc.

References _pid, _switchedOut, csprintf(), ArmISA::i, instCnt, interrupts, numThreads, SERIALIZE_SCALAR, and serializeThread().

Referenced by MinorCPU::serialize(), and Iris::BaseCPU::serializeThread().

◆ serializeThread()

virtual void BaseCPU::serializeThread ( CheckpointOut cp,
ThreadID  tid 
) const
inlinevirtual

Serialize a single thread.

Parameters
cpThe stream to serialize to.
tidID of the current thread.

Reimplemented in FullO3CPU< Impl >, FullO3CPU< O3CPUImpl >, BaseSimpleCPU, MinorCPU, Iris::BaseCPU, and BaseKvmCPU.

Definition at line 423 of file base.hh.

Referenced by serialize().

◆ setPid()

void BaseCPU::setPid ( uint32_t  pid)
inline

Definition at line 224 of file base.hh.

References _pid.

Referenced by ArmISA::DumpStats::process().

◆ socketId()

uint32_t BaseCPU::socketId ( ) const
inline

Reads this CPU's Socket ID.

Definition at line 198 of file base.hh.

References _socketId.

Referenced by ThreadState::socketId(), and Iris::ThreadContext::socketId().

◆ startup()

void BaseCPU::startup ( )
overridevirtual

startup() is the final initialization call before simulation.

All state is initialized (including unserialized state, if any, such as the curTick() value), so this is the appropriate place to schedule initial event(s) for objects that need them.

Reimplemented from SimObject.

Reimplemented in FullO3CPU< Impl >, FullO3CPU< O3CPUImpl >, MinorCPU, BaseKvmCPU, and X86KvmCPU.

Definition at line 312 of file base.cc.

References _switchedOut, PowerState::get(), RiscvISA::OFF, SimObject::params(), ClockedObject::powerState, and PowerState::set().

Referenced by BaseKvmCPU::startup(), MinorCPU::startup(), and FullO3CPU< O3CPUImpl >::startup().

◆ suspendContext()

void BaseCPU::suspendContext ( ThreadID  thread_num)
virtual

◆ switchedOut()

bool BaseCPU::switchedOut ( ) const
inline

◆ switchOut()

void BaseCPU::switchOut ( )
virtual

Prepare for another CPU to take over execution.

When this method exits, all internal state should have been flushed. After the method returns, the simulator calls takeOverFrom() on the new CPU with this CPU as its parameter.

Reimplemented in FullO3CPU< Impl >, TimingSimpleCPU, FullO3CPU< O3CPUImpl >, AtomicSimpleCPU, MinorCPU, BaseKvmCPU, Checker< Impl >, and Checker< O3CPUImpl >.

Definition at line 536 of file base.cc.

References _switchedOut, flushTLBs(), RiscvISA::OFF, ClockedObject::powerState, and PowerState::set().

Referenced by BaseKvmCPU::switchOut(), MinorCPU::switchOut(), AtomicSimpleCPU::switchOut(), TimingSimpleCPU::switchOut(), and FullO3CPU< O3CPUImpl >::switchOut().

◆ takeOverFrom()

void BaseCPU::takeOverFrom ( BaseCPU cpu)
virtual

◆ taskId() [1/2]

uint32_t BaseCPU::taskId ( ) const
inline

◆ taskId() [2/2]

void BaseCPU::taskId ( uint32_t  id)
inline

Set cpu task id.

Definition at line 221 of file base.hh.

References _taskId, and ArmISA::id.

◆ totalInsts()

virtual Counter BaseCPU::totalInsts ( ) const
pure virtual

◆ totalOps()

virtual Counter BaseCPU::totalOps ( ) const
pure virtual

◆ traceFunctions()

void BaseCPU::traceFunctions ( Addr  pc)
inline

Definition at line 572 of file base.hh.

References functionTracingEnabled, MipsISA::pc, and traceFunctionsInternal().

Referenced by BaseSimpleCPU::postExecute().

◆ traceFunctionsInternal()

void BaseCPU::traceFunctionsInternal ( Addr  pc)
private

◆ unserialize()

void BaseCPU::unserialize ( CheckpointIn cp)
overridevirtual

Reconstruct the state of this object from a checkpoint.

Note
CPU models should normally overload the unserializeThread() method instead of the unserialize() method as this provides a uniform data format for all CPU models and promotes better code reuse.
Parameters
cpThe checkpoint use.

Implements Serializable.

Reimplemented in CheckerCPU, and MinorCPU.

Definition at line 647 of file base.cc.

References _pid, _switchedOut, csprintf(), ArmISA::i, instCnt, interrupts, numThreads, UNSERIALIZE_SCALAR, and unserializeThread().

Referenced by MinorCPU::unserialize().

◆ unserializeThread()

virtual void BaseCPU::unserializeThread ( CheckpointIn cp,
ThreadID  tid 
)
inlinevirtual

Unserialize one thread.

Parameters
cpThe checkpoint use.
tidID of the current thread.

Reimplemented in FullO3CPU< Impl >, FullO3CPU< O3CPUImpl >, BaseSimpleCPU, MinorCPU, and BaseKvmCPU.

Definition at line 431 of file base.hh.

Referenced by unserialize().

◆ updateCycleCounters()

void BaseCPU::updateCycleCounters ( CPUState  state)
inlineprotected

◆ verifyMemoryMode()

virtual void BaseCPU::verifyMemoryMode ( ) const
inlinevirtual

Verify that the system is in a memory mode supported by the CPU.

Implementations are expected to query the system for the current memory mode and ensure that it is what the CPU model expects. If the check fails, the implementation should terminate the simulation using fatal().

Reimplemented in FullO3CPU< Impl >, TimingSimpleCPU, AtomicSimpleCPU, BaseKvmCPU, and NonCachingSimpleCPU.

Definition at line 378 of file base.hh.

Referenced by init().

◆ waitForRemoteGDB()

bool BaseCPU::waitForRemoteGDB ( ) const

Definition at line 728 of file base.cc.

References SimObject::params().

◆ wakeup()

virtual void BaseCPU::wakeup ( ThreadID  tid)
pure virtual

◆ workItemBegin()

void BaseCPU::workItemBegin ( )
inline

Definition at line 226 of file base.hh.

References baseStats, and BaseCPU::BaseCPUStats::numWorkItemsStarted.

Referenced by PseudoInst::workbegin().

◆ workItemEnd()

void BaseCPU::workItemEnd ( )
inline

Definition at line 227 of file base.hh.

References baseStats, and BaseCPU::BaseCPUStats::numWorkItemsCompleted.

Referenced by PseudoInst::workend().

Member Data Documentation

◆ _cacheLineSize

const unsigned int BaseCPU::_cacheLineSize
protected

Cache the cache line size that we get from the system.

Definition at line 146 of file base.hh.

Referenced by cacheLineSize().

◆ _cpuId

int BaseCPU::_cpuId
protected

Definition at line 116 of file base.hh.

Referenced by cpuId(), registerThreadContexts(), and takeOverFrom().

◆ _dataRequestorId

RequestorID BaseCPU::_dataRequestorId
protected

data side request id that must be placed in all requests

Definition at line 129 of file base.hh.

Referenced by dataRequestorId(), and FullO3CPU< O3CPUImpl >::htmSendAbortSignal().

◆ _instRequestorId

RequestorID BaseCPU::_instRequestorId
protected

instruction side request id that must be placed in all requests

Definition at line 126 of file base.hh.

Referenced by instRequestorId().

◆ _pid

uint32_t BaseCPU::_pid
protected

The current OS process ID that is executing on this processor.

This is used to generate a taskId

Definition at line 140 of file base.hh.

Referenced by getPid(), serialize(), setPid(), takeOverFrom(), and unserialize().

◆ _socketId

const uint32_t BaseCPU::_socketId
protected

Each cpu will have a socket ID that corresponds to its physical location in the system.

This is usually used to bucket cpu cores under single DVFS domain. This information may also be required by the OS to identify the cpu core grouping (as in the case of ARM via MPIDR register)

Definition at line 123 of file base.hh.

Referenced by socketId().

◆ _switchedOut

bool BaseCPU::_switchedOut
protected

Is the CPU switched out or active?

Definition at line 143 of file base.hh.

Referenced by serialize(), startup(), switchedOut(), switchOut(), takeOverFrom(), and unserialize().

◆ _taskId

uint32_t BaseCPU::_taskId
protected

An intrenal representation of a task identifier within gem5.

This is used so the CPU can add which taskId (which is an internal representation of the OS process ID) to each request so components in the memory system can track which process IDs are ultimately interacting with them

Definition at line 136 of file base.hh.

Referenced by takeOverFrom(), and taskId().

◆ addressMonitor

std::vector<AddressMonitor> BaseCPU::addressMonitor
private

Definition at line 612 of file base.hh.

Referenced by armMonitor(), getCpuAddrMonitor(), mwait(), and mwaitAtomic().

◆ baseStats

BaseCPU::BaseCPUStats BaseCPU::baseStats

◆ cpuList

std::vector< BaseCPU * > BaseCPU::cpuList
staticprivate

Static global cpu list.

Definition at line 569 of file base.hh.

Referenced by numSimulatedCPUs(), numSimulatedInsts(), and numSimulatedOps().

◆ currentFunctionEnd

Addr BaseCPU::currentFunctionEnd
private

Definition at line 563 of file base.hh.

Referenced by traceFunctionsInternal().

◆ currentFunctionStart

Addr BaseCPU::currentFunctionStart
private

Definition at line 562 of file base.hh.

Referenced by traceFunctionsInternal().

◆ enterPwrGatingEvent

EventFunctionWrapper BaseCPU::enterPwrGatingEvent
protected

◆ functionEntryTick

Tick BaseCPU::functionEntryTick
private

Definition at line 564 of file base.hh.

Referenced by traceFunctionsInternal().

◆ functionTraceStream

std::ostream* BaseCPU::functionTraceStream
private

Definition at line 561 of file base.hh.

Referenced by traceFunctionsInternal().

◆ functionTracingEnabled

bool BaseCPU::functionTracingEnabled
private

Definition at line 560 of file base.hh.

Referenced by enableFunctionTrace(), and traceFunctions().

◆ globalStats

std::unique_ptr< BaseCPU::GlobalStats > BaseCPU::globalStats
staticprotected

Pointer to the global stat structure.

This needs to be constructed from regStats since we merge it into the root group.

Definition at line 163 of file base.hh.

Referenced by regStats().

◆ instCnt

Tick BaseCPU::instCnt
protected

Instruction count used for SPARC misc register.

Todo:
unify this with the counters that cpus individually keep

Definition at line 110 of file base.hh.

Referenced by TimingSimpleCPU::completeIfetch(), instCount(), serialize(), AtomicSimpleCPU::tick(), and unserialize().

◆ interrupts

std::vector<BaseInterrupts*> BaseCPU::interrupts
protected

◆ invldPid

const uint32_t BaseCPU::invldPid = std::numeric_limits<uint32_t>::max()
static

Invalid or unknown Pid.

Possible when operating system is not present or has not assigned a pid yet

Definition at line 278 of file base.hh.

Referenced by ArmISA::FsLinux::startup().

◆ numThreads

ThreadID BaseCPU::numThreads

Number of threads we're actually simulating (<= SMT_MAX_THREADS).

This is a constant for the duration of the simulation.

Definition at line 378 of file base.hh.

Referenced by AtomicSimpleCPU::activateContext(), TimingSimpleCPU::activateContext(), armMonitor(), BaseSimpleCPU::BaseSimpleCPU(), Minor::Execute::checkInterrupts(), Minor::Execute::drain(), Minor::Pipeline::drainResume(), MinorCPU::drainResume(), AtomicSimpleCPU::drainResume(), TimingSimpleCPU::drainResume(), Minor::Execute::drainResume(), Minor::Decode::evaluate(), Minor::Fetch2::evaluate(), Minor::Execute::evaluate(), Minor::Fetch1::evaluate(), FullO3CPU< Impl >::FullO3CPUStats::FullO3CPUStats(), getCpuAddrMonitor(), FullO3CPU< O3CPUImpl >::getFreeTid(), BaseKvmCPU::init(), FullO3CPU< O3CPUImpl >::init(), init(), Minor::Execute::isDrained(), Minor::Fetch1::isDrained(), MinorCPU::MinorCPU(), Minor::MinorStats::MinorStats(), mwait(), mwaitAtomic(), MinorCPU::randomPriority(), AtomicSimpleCPU::AtomicCPUDPort::recvAtomicSnoop(), AtomicSimpleCPU::AtomicCPUDPort::recvFunctionalSnoop(), TimingSimpleCPU::DcachePort::recvFunctionalSnoop(), TimingSimpleCPU::DcachePort::recvTimingSnoopReq(), Minor::LSQ::recvTimingSnoopReq(), registerThreadContexts(), MinorCPU::roundRobinPriority(), serialize(), MinorCPU::startup(), AtomicSimpleCPU::suspendContext(), TimingSimpleCPU::suspendContext(), BaseSimpleCPU::swapActiveThread(), takeOverFrom(), TimingSimpleCPU::threadSnoop(), AtomicSimpleCPU::threadSnoop(), Minor::LSQ::threadSnoop(), AtomicSimpleCPU::tick(), unserialize(), MinorCPU::wakeup(), and Minor::Execute::~Execute().

◆ PCMask

const Addr BaseCPU::PCMask = ~((Addr)sizeof(TheISA::MachInst) - 1)
static

◆ powerGatingOnIdle

const bool BaseCPU::powerGatingOnIdle
protected

Definition at line 633 of file base.hh.

Referenced by schedulePowerGatingEvent(), and suspendContext().

◆ ppActiveCycles

ProbePoints::PMUUPtr BaseCPU::ppActiveCycles
protected

CPU cycle counter, only counts if any thread contexts is active.

Definition at line 509 of file base.hh.

Referenced by regProbePoints(), and updateCycleCounters().

◆ ppAllCycles

ProbePoints::PMUUPtr BaseCPU::ppAllCycles
protected

CPU cycle counter even if any thread Context is suspended.

Definition at line 506 of file base.hh.

Referenced by regProbePoints(), and updateCycleCounters().

◆ ppRetiredBranches

ProbePoints::PMUUPtr BaseCPU::ppRetiredBranches
protected

Retired branches (any type)

Definition at line 503 of file base.hh.

Referenced by probeInstCommit(), and regProbePoints().

◆ ppRetiredInsts

ProbePoints::PMUUPtr BaseCPU::ppRetiredInsts
protected

Instruction commit probe point.

This probe point is triggered whenever one or more instructions are committed. It is normally triggered once for every instruction. However, CPU models committing bundles of instructions may call notify once for the entire bundle.

Definition at line 494 of file base.hh.

Referenced by probeInstCommit(), and regProbePoints().

◆ ppRetiredInstsPC

ProbePoints::PMUUPtr BaseCPU::ppRetiredInstsPC
protected

Definition at line 495 of file base.hh.

Referenced by probeInstCommit(), and regProbePoints().

◆ ppRetiredLoads

ProbePoints::PMUUPtr BaseCPU::ppRetiredLoads
protected

Retired load instructions.

Definition at line 498 of file base.hh.

Referenced by probeInstCommit(), and regProbePoints().

◆ ppRetiredStores

ProbePoints::PMUUPtr BaseCPU::ppRetiredStores
protected

Retired store instructions.

Definition at line 500 of file base.hh.

Referenced by probeInstCommit(), and regProbePoints().

◆ ppSleeping

ProbePointArg<bool>* BaseCPU::ppSleeping
protected

ProbePoint that signals transitions of threadContexts sets.

The ProbePoint reports information through it bool parameter.

  • If the parameter is true then the last enabled threadContext of the CPU object was disabled.
  • If the parameter is false then a threadContext was enabled, all the remaining threadContexts are disabled.

Definition at line 519 of file base.hh.

Referenced by regProbePoints(), and updateCycleCounters().

◆ previousCycle

Cycles BaseCPU::previousCycle
protected

Definition at line 528 of file base.hh.

Referenced by takeOverFrom(), and updateCycleCounters().

◆ previousState

CPUState BaseCPU::previousState
protected

Definition at line 529 of file base.hh.

Referenced by takeOverFrom(), and updateCycleCounters().

◆ pwrGatingLatency

const Cycles BaseCPU::pwrGatingLatency
protected

Definition at line 632 of file base.hh.

Referenced by schedulePowerGatingEvent(), and suspendContext().

◆ syscallRetryLatency

Cycles BaseCPU::syscallRetryLatency

Definition at line 626 of file base.hh.

Referenced by TimingSimpleCPU::advanceInst(), and AtomicSimpleCPU::tick().

◆ system

System* BaseCPU::system

◆ threadContexts

std::vector<ThreadContext *> BaseCPU::threadContexts
protected

◆ tracer

Trace::InstTracer* BaseCPU::tracer
protected

Definition at line 271 of file base.hh.

Referenced by getTracer(), and BaseSimpleCPU::preExecute().


The documentation for this class was generated from the following files:

Generated on Tue Jun 22 2021 15:28:35 for gem5 by doxygen 1.8.17