gem5  v20.1.0.0
Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | List of all members
BaseSimpleCPU Class Referenceabstract

#include <base.hh>

Inheritance diagram for BaseSimpleCPU:
BaseCPU AtomicSimpleCPU TimingSimpleCPU NonCachingSimpleCPU

Public Member Functions

 BaseSimpleCPU (BaseSimpleCPUParams *params)
 
virtual ~BaseSimpleCPU ()
 
void wakeup (ThreadID tid) override
 
void init () override
 
void checkForInterrupts ()
 
void setupFetchRequest (const RequestPtr &req)
 
void preExecute ()
 
void postExecute ()
 
void advancePC (const Fault &fault)
 
void haltContext (ThreadID thread_num) override
 Notify the CPU that the indicated context is now halted. More...
 
void regStats () override
 
void resetStats () override
 
virtual Fault readMem (Addr addr, uint8_t *data, unsigned size, Request::Flags flags, const std::vector< bool > &byte_enable=std::vector< bool >())
 
virtual Fault initiateMemRead (Addr addr, unsigned size, Request::Flags flags, const std::vector< bool > &byte_enable=std::vector< bool >())
 
virtual Fault writeMem (uint8_t *data, unsigned size, Addr addr, Request::Flags flags, uint64_t *res, const std::vector< bool > &byte_enable=std::vector< bool >())
 
virtual Fault amoMem (Addr addr, uint8_t *data, unsigned size, Request::Flags flags, AtomicOpFunctorPtr amo_op)
 
virtual Fault initiateMemAMO (Addr addr, unsigned size, Request::Flags flags, AtomicOpFunctorPtr amo_op)
 
void countInst ()
 
Counter totalInsts () const override
 
Counter totalOps () const override
 
void serializeThread (CheckpointOut &cp, ThreadID tid) const override
 Serialize a single thread. More...
 
void unserializeThread (CheckpointIn &cp, ThreadID tid) override
 Unserialize one thread. More...
 
virtual Fault initiateHtmCmd (Request::Flags flags)=0
 Hardware transactional memory commands (HtmCmds), e.g. More...
 
virtual void htmSendAbortSignal (HtmFailureFaultCause cause)=0
 This function is used to instruct the memory subsystem that a transaction should be aborted and the speculative state should be thrown away. More...
 
- Public Member Functions inherited from BaseCPU
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)
 
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...
 
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...
 
const Paramsparams () const
 
 BaseCPU (Params *params, bool is_checker=false)
 
virtual ~BaseCPU ()
 
void init () override
 
void startup () override
 
void regStats () override
 
void regProbePoints () override
 
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...
 
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, BaseTLB *dtb)
 
AddressMonitorgetCpuAddrMonitor (ThreadID tid)
 
bool waitForRemoteGDB () const
 
virtual void probeInstCommit (const StaticInstPtr &inst, Addr pc)
 Helper method to trigger PMU probes for a committed instruction. More...
 

Public Attributes

Trace::InstRecordtraceData
 
CheckerCPUchecker
 
std::vector< SimpleExecContext * > threadInfo
 
std::list< ThreadIDactiveThreads
 
TheISA::MachInst inst
 Current instruction. More...
 
StaticInstPtr curStaticInst
 
StaticInstPtr curMacroStaticInst
 
- Public Attributes inherited from BaseCPU
ThreadID numThreads
 Number of threads we're actually simulating (<= SMT_MAX_THREADS). More...
 
Systemsystem
 
Stats::Scalar numCycles
 
Stats::Scalar numWorkItemsStarted
 
Stats::Scalar numWorkItemsCompleted
 
Cycles syscallRetryLatency
 

Protected Types

enum  Status {
  Idle, Running, Faulting, ITBWaitResponse,
  IcacheRetry, IcacheWaitResponse, IcacheWaitSwitch, DTBWaitResponse,
  DcacheRetry, DcacheWaitResponse, DcacheWaitSwitch
}
 
- Protected Types inherited from BaseCPU
enum  CPUState { CPU_STATE_ON, CPU_STATE_SLEEP, CPU_STATE_WAKEUP }
 

Protected Member Functions

void checkPcEventQueue ()
 
void swapActiveThread ()
 
void traceFault ()
 Handler used when encountering a fault; its purpose is to tear down the InstRecord. More...
 
- Protected Member Functions inherited from BaseCPU
void updateCycleCounters (CPUState state)
 base method keeping track of cycle progression More...
 
void enterPwrGating ()
 
ProbePoints::PMUUPtr pmuProbePoint (const char *name)
 Helper method to instantiate probe points belonging to this object. More...
 

Protected Attributes

ThreadID curThread
 
BPredUnitbranchPred
 
Status _status
 
- Protected Attributes inherited from BaseCPU
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
 
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...
 

Additional Inherited Members

- Public Types inherited from BaseCPU
typedef BaseCPUParams Params
 
- Static Public Member Functions inherited from BaseCPU
static int numSimulatedInsts ()
 
static int numSimulatedOps ()
 
static void wakeup (ThreadID tid)
 
static int numSimulatedCPUs ()
 
static Counter numSimulatedInsts ()
 
static Counter numSimulatedOps ()
 
- Static Public Attributes inherited from BaseCPU
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)
 

Detailed Description

Definition at line 80 of file base.hh.

Member Enumeration Documentation

◆ Status

enum BaseSimpleCPU::Status
protected
Enumerator
Idle 
Running 
Faulting 
ITBWaitResponse 
IcacheRetry 
IcacheWaitResponse 
IcacheWaitSwitch 
DTBWaitResponse 
DcacheRetry 
DcacheWaitResponse 
DcacheWaitSwitch 

Definition at line 107 of file base.hh.

Constructor & Destructor Documentation

◆ BaseSimpleCPU()

BaseSimpleCPU::BaseSimpleCPU ( BaseSimpleCPUParams *  params)

◆ ~BaseSimpleCPU()

BaseSimpleCPU::~BaseSimpleCPU ( )
virtual

Definition at line 198 of file base.cc.

Member Function Documentation

◆ advancePC()

void BaseSimpleCPU::advancePC ( const Fault fault)

◆ amoMem()

virtual Fault BaseSimpleCPU::amoMem ( Addr  addr,
uint8_t *  data,
unsigned  size,
Request::Flags  flags,
AtomicOpFunctorPtr  amo_op 
)
inlinevirtual

Reimplemented in AtomicSimpleCPU.

Definition at line 162 of file base.hh.

References panic.

Referenced by SimpleExecContext::amoMem().

◆ checkForInterrupts()

void BaseSimpleCPU::checkForInterrupts ( )

◆ checkPcEventQueue()

void BaseSimpleCPU::checkPcEventQueue ( )
protected

Definition at line 133 of file base.cc.

References curThread, MipsISA::pc, BaseCPU::threadContexts, and threadInfo.

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

◆ countInst()

void BaseSimpleCPU::countInst ( )

◆ haltContext()

void BaseSimpleCPU::haltContext ( ThreadID  thread_num)
overridevirtual

Notify the CPU that the indicated context is now halted.

Reimplemented from BaseCPU.

Definition at line 203 of file base.cc.

References BaseCPU::CPU_STATE_SLEEP, BaseCPU::suspendContext(), and BaseCPU::updateCycleCounters().

◆ htmSendAbortSignal()

virtual void BaseSimpleCPU::htmSendAbortSignal ( HtmFailureFaultCause  cause)
pure virtual

This function is used to instruct the memory subsystem that a transaction should be aborted and the speculative state should be thrown away.

This is called in the transaction's very last breath in the core. Afterwards, the core throws away its speculative state and resumes execution at the point the transaction started, i.e. reverses time. When instruction execution resumes, the core expects the memory subsystem to be in a stable, i.e. pre-speculative, state as well.

Implemented in TimingSimpleCPU, and AtomicSimpleCPU.

Referenced by SimpleThread::htmAbortTransaction().

◆ init()

void BaseSimpleCPU::init ( )
override

Definition at line 122 of file base.cc.

References BaseCPU::init(), and BaseCPU::threadContexts.

Referenced by TimingSimpleCPU::init(), and AtomicSimpleCPU::init().

◆ initiateHtmCmd()

virtual Fault BaseSimpleCPU::initiateHtmCmd ( Request::Flags  flags)
pure virtual

Hardware transactional memory commands (HtmCmds), e.g.

start a transaction and commit a transaction, are memory operations but are neither really (true) loads nor stores. For this reason the interface is extended and initiateHtmCmd() is used to instigate the command.

Implemented in TimingSimpleCPU, and AtomicSimpleCPU.

Referenced by SimpleExecContext::initiateHtmCmd().

◆ initiateMemAMO()

virtual Fault BaseSimpleCPU::initiateMemAMO ( Addr  addr,
unsigned  size,
Request::Flags  flags,
AtomicOpFunctorPtr  amo_op 
)
inlinevirtual

Reimplemented in TimingSimpleCPU.

Definition at line 167 of file base.hh.

References panic.

Referenced by SimpleExecContext::initiateMemAMO().

◆ initiateMemRead()

virtual Fault BaseSimpleCPU::initiateMemRead ( Addr  addr,
unsigned  size,
Request::Flags  flags,
const std::vector< bool > &  byte_enable = std::vector<bool>() 
)
inlinevirtual

Reimplemented in TimingSimpleCPU.

Definition at line 150 of file base.hh.

References panic.

Referenced by SimpleExecContext::initiateMemRead().

◆ postExecute()

void BaseSimpleCPU::postExecute ( )

◆ preExecute()

void BaseSimpleCPU::preExecute ( )

◆ readMem()

virtual Fault BaseSimpleCPU::readMem ( Addr  addr,
uint8_t *  data,
unsigned  size,
Request::Flags  flags,
const std::vector< bool > &  byte_enable = std::vector<bool>() 
)
inlinevirtual

Reimplemented in AtomicSimpleCPU.

Definition at line 144 of file base.hh.

References panic.

Referenced by SimpleExecContext::readMem().

◆ regStats()

void BaseSimpleCPU::regStats ( )
override

Definition at line 212 of file base.cc.

References Stats::constant(), SimpleExecContext::dcacheStallCycles, Stats::DataWrap< Derived, InfoProxyType >::desc(), Stats::dist, Stats::DataWrap< Derived, InfoProxyType >::flags(), ArmISA::i, SimpleExecContext::icacheStallCycles, SimpleExecContext::idleFraction, Stats::VectorBase< Derived, Stor >::init(), name(), Stats::DataWrap< Derived, InfoProxyType >::name(), SimpleExecContext::notIdleFraction, Stats::nozero, Num_OpClasses, SimpleExecContext::numBranches, SimpleExecContext::numBranchMispred, SimpleExecContext::numBusyCycles, SimpleExecContext::numCallsReturns, SimpleExecContext::numCCRegReads, SimpleExecContext::numCCRegWrites, SimpleExecContext::numCondCtrlInsts, BaseCPU::numCycles, SimpleExecContext::numFpAluAccesses, SimpleExecContext::numFpInsts, SimpleExecContext::numFpRegReads, SimpleExecContext::numFpRegWrites, SimpleExecContext::numIdleCycles, SimpleExecContext::numInsts, SimpleExecContext::numIntAluAccesses, SimpleExecContext::numIntInsts, SimpleExecContext::numIntRegReads, SimpleExecContext::numIntRegWrites, SimpleExecContext::numLoadInsts, SimpleExecContext::numMemRefs, SimpleExecContext::numOps, SimpleExecContext::numPredictedBranches, SimpleExecContext::numStoreInsts, BaseCPU::numThreads, SimpleExecContext::numVecAluAccesses, SimpleExecContext::numVecInsts, SimpleExecContext::numVecRegReads, SimpleExecContext::numVecRegWrites, Stats::pdf, Stats::DataWrap< Derived, InfoProxyType >::prereq(), BaseCPU::regStats(), SimpleExecContext::statExecutedInstType, Stats::DataWrapVec< Derived, InfoProxyType >::subname(), threadInfo, sc_dt::to_string(), and Stats::total.

◆ resetStats()

void BaseSimpleCPU::resetStats ( )
override

Definition at line 397 of file base.cc.

References _status, Idle, and threadInfo.

◆ serializeThread()

void BaseSimpleCPU::serializeThread ( CheckpointOut cp,
ThreadID  tid 
) const
overridevirtual

Serialize a single thread.

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

Reimplemented from BaseCPU.

Definition at line 406 of file base.cc.

References _status, Idle, Running, and threadInfo.

◆ setupFetchRequest()

void BaseSimpleCPU::setupFetchRequest ( const RequestPtr req)

◆ swapActiveThread()

void BaseSimpleCPU::swapActiveThread ( )
protected

◆ totalInsts()

Counter BaseSimpleCPU::totalInsts ( ) const
overridevirtual

Implements BaseCPU.

Definition at line 177 of file base.cc.

References threadInfo.

◆ totalOps()

Counter BaseSimpleCPU::totalOps ( ) const
overridevirtual

Implements BaseCPU.

Definition at line 188 of file base.cc.

References threadInfo.

◆ traceFault()

void BaseSimpleCPU::traceFault ( )
protected

Handler used when encountering a fault; its purpose is to tear down the InstRecord.

If a fault is meant to be traced, the handler won't delete the record and it will annotate the record as coming from a faulting instruction.

Definition at line 436 of file base.cc.

References DTRACE, Trace::InstRecord::setFaulting(), and traceData.

Referenced by TimingSimpleCPU::completeDataAccess(), TimingSimpleCPU::completeIfetch(), AtomicSimpleCPU::tick(), and TimingSimpleCPU::translationFault().

◆ unserializeThread()

void BaseSimpleCPU::unserializeThread ( CheckpointIn cp,
ThreadID  tid 
)
overridevirtual

Unserialize one thread.

Parameters
cpThe checkpoint use.
tidID of the current thread.

Reimplemented from BaseCPU.

Definition at line 414 of file base.cc.

References threadInfo.

◆ wakeup()

void BaseSimpleCPU::wakeup ( ThreadID  tid)
overridevirtual

◆ writeMem()

virtual Fault BaseSimpleCPU::writeMem ( uint8_t *  data,
unsigned  size,
Addr  addr,
Request::Flags  flags,
uint64_t *  res,
const std::vector< bool > &  byte_enable = std::vector<bool>() 
)
inlinevirtual

Reimplemented in TimingSimpleCPU, and AtomicSimpleCPU.

Definition at line 156 of file base.hh.

References panic.

Referenced by SimpleExecContext::writeMem().

Member Data Documentation

◆ _status

Status BaseSimpleCPU::_status
protected

◆ activeThreads

std::list<ThreadID> BaseSimpleCPU::activeThreads

◆ branchPred

BPredUnit* BaseSimpleCPU::branchPred
protected

Definition at line 84 of file base.hh.

Referenced by advancePC(), and preExecute().

◆ checker

CheckerCPU* BaseSimpleCPU::checker

Definition at line 96 of file base.hh.

Referenced by BaseSimpleCPU().

◆ curMacroStaticInst

StaticInstPtr BaseSimpleCPU::curMacroStaticInst

Definition at line 104 of file base.hh.

Referenced by advancePC(), TimingSimpleCPU::fetch(), preExecute(), and AtomicSimpleCPU::tick().

◆ curStaticInst

StaticInstPtr BaseSimpleCPU::curStaticInst

◆ curThread

ThreadID BaseSimpleCPU::curThread
protected

◆ inst

TheISA::MachInst BaseSimpleCPU::inst

Current instruction.

Definition at line 102 of file base.hh.

Referenced by preExecute(), TimingSimpleCPU::sendFetch(), and AtomicSimpleCPU::tick().

◆ threadInfo

std::vector<SimpleExecContext*> BaseSimpleCPU::threadInfo

◆ traceData

Trace::InstRecord* BaseSimpleCPU::traceData

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

Generated on Wed Sep 30 2020 14:02:21 for gem5 by doxygen 1.8.17