gem5  v22.1.0.0
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Private Types | Private Attributes | Static Private Attributes | List of all members
gem5::SimObject Class Reference

Abstract superclass for simulation objects. More...

#include <sim_object.hh>

Inheritance diagram for gem5::SimObject:
gem5::EventManager gem5::Serializable gem5::Drainable gem5::statistics::Group gem5::Named gem5::AbstractNVM gem5::AddrMapper gem5::ArmISA::PMU gem5::ArmInterruptPinGen gem5::ArmRelease gem5::ArmSemihosting gem5::BaseISA gem5::BaseIndexingPolicy gem5::BaseInterrupts gem5::BaseMMU gem5::BaseMemProbe gem5::BaseTLB gem5::ClockDomain gem5::ClockedObject gem5::CommMonitor gem5::DVFSHandler gem5::DirectedGenerator gem5::DiskImage gem5::Display gem5::DistEtherLink gem5::Doorbell gem5::EmulatedDriver gem5::EtherBus gem5::EtherDump gem5::EtherLink gem5::EtherSwitch gem5::EtherTapBase gem5::ExternalMaster gem5::ExternalSlave gem5::FUDesc gem5::GPUDispatcher gem5::GenericTimer gem5::Gicv2mFrame gem5::GoodbyeObject gem5::HelloObject gem5::I2CDevice gem5::IdeDisk gem5::InstDecoder gem5::KvmVM gem5::MemChecker gem5::MemCheckerMonitor gem5::MinorFU gem5::MinorFUPool gem5::MinorFUTiming gem5::MinorOpClass gem5::MinorOpClassSet gem5::OpDesc gem5::OutgoingRequestBridge gem5::PMAChecker gem5::PMP gem5::PciBar gem5::Platform gem5::PoolManager gem5::PortTerminator gem5::PowerModel gem5::PowerModelState gem5::PowerState gem5::ProbeListenerObject gem5::Process gem5::RealViewTemperatureSensor gem5::RedirectPath gem5::RegisterFile gem5::RegisterManager gem5::RiscvRTC gem5::Root gem5::SerialDevice gem5::SimpleDisk gem5::SimpleMemobj gem5::SimpleObject gem5::SnoopFilter gem5::SouthBridge gem5::SubSystem gem5::SysBridge gem5::System gem5::SystemCounter gem5::ThermalCapacitor gem5::ThermalDomain gem5::ThermalNode gem5::ThermalReference gem5::ThermalResistor gem5::ThreadBridge gem5::TimingExpr gem5::UFSHostDevice::UFSSCSIDevice gem5::VirtIODeviceBase gem5::VncInput gem5::VoltageDomain gem5::Wavefront gem5::Workload gem5::WriteAllocator gem5::X86ISA::ACPI::MADT::Record gem5::X86ISA::ACPI::RSDP gem5::X86ISA::ACPI::SysDescTable gem5::X86ISA::E820Entry gem5::X86ISA::E820Table gem5::X86ISA::intelmp::BaseConfigEntry gem5::X86ISA::intelmp::ConfigTable gem5::X86ISA::intelmp::ExtConfigEntry gem5::X86ISA::intelmp::FloatingPointer gem5::X86ISA::smbios::SMBiosStructure gem5::X86ISA::smbios::SMBiosTable gem5::bloom_filter::Base gem5::branch_prediction::BPredUnit gem5::branch_prediction::IndirectPredictor gem5::branch_prediction::LoopPredictor gem5::branch_prediction::StatisticalCorrector gem5::branch_prediction::TAGEBase gem5::compression::Base gem5::fastmodel::CortexA76Cluster gem5::fastmodel::CortexR52Cluster gem5::memory::SharedMemoryServer gem5::memory::qos::Policy gem5::memory::qos::TurnaroundPolicy gem5::o3::FUPool gem5::prefetch::DeltaCorrelatingPredictionTables gem5::ps2::Device gem5::qemu::FwCfgItemFactoryBase gem5::replacement_policy::Base gem5::ruby::BaseRoutingUnit gem5::ruby::BasicLink gem5::ruby::CacheMemory gem5::ruby::DirectoryMemory gem5::ruby::FaultModel gem5::ruby::MessageBuffer gem5::ruby::RubyPrefetcher gem5::ruby::WireBuffer gem5::scmi::Communication gem5::scmi::VirtualChannel gem5::trace::InstTracer sc_gem5::Kernel

Public Types

typedef SimObjectParams Params
 

Public Member Functions

const Paramsparams () const
 
 SimObject (const Params &p)
 
virtual ~SimObject ()
 
virtual void init ()
 init() is called after all C++ SimObjects have been created and all ports are connected. More...
 
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 regProbePoints ()
 Register probe points for this object. More...
 
virtual void regProbeListeners ()
 Register probe listeners for this object. More...
 
ProbeManagergetProbeManager ()
 Get the probe manager for this object. More...
 
virtual PortgetPort (const std::string &if_name, PortID idx=InvalidPortID)
 Get a port with a given name and index. More...
 
virtual void startup ()
 startup() is the final initialization call before simulation. 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 gem5::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 gem5::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 gem5::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 gem5::statistics::Group
 Group (Group *parent, const char *name=nullptr)
 Construct a new statistics group. More...
 
virtual ~Group ()
 
virtual void regStats ()
 Callback to set stat parameters. More...
 
virtual void resetStats ()
 Callback to reset stats. More...
 
virtual void preDumpStats ()
 Callback before stats are dumped. More...
 
void addStat (statistics::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 gem5::Named
 Named (const std::string &name_)
 
virtual ~Named ()=default
 
virtual std::string name () const
 

Static Public Member Functions

static void serializeAll (const std::string &cpt_dir)
 Create a checkpoint by serializing 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 void setSimObjectResolver (SimObjectResolver *resolver)
 There is a single object name resolver, and it is only set when simulation is restoring from checkpoints. More...
 
static SimObjectResolvergetSimObjectResolver ()
 There is a single object name resolver, and it is only set when simulation is restoring from checkpoints. More...
 
- Static Public Member Functions inherited from gem5::Serializable
static const std::string & currentSection ()
 Gets the fully-qualified name of the active section. More...
 
static void generateCheckpointOut (const std::string &cpt_dir, std::ofstream &outstream)
 Generate a checkpoint file so that the serialization can be routed to it. More...
 

Protected Attributes

const SimObjectParams & _params
 Cached copy of the object parameters. More...
 
- Protected Attributes inherited from gem5::EventManager
EventQueueeventq
 A pointer to this object's event queue. More...
 

Private Types

typedef std::vector< SimObject * > SimObjectList
 

Private Attributes

ProbeManagerprobeManager
 Manager coordinates hooking up probe points with listeners. More...
 

Static Private Attributes

static SimObjectList simObjectList
 List of all instantiated simulation objects. More...
 
static SimObjectResolver_objNameResolver = NULL
 Helper to resolve an object given its name. More...
 

Additional Inherited Members

- Protected Member Functions inherited from gem5::Drainable
 Drainable ()
 
virtual ~Drainable ()
 
virtual void drainResume ()
 Resume execution after a successful drain. More...
 
void signalDrainDone () const
 Signal that an object is drained. More...
 

Detailed Description

Abstract superclass for simulation objects.

Represents things that correspond to physical components and can be specified via the config file (CPUs, caches, etc.).

SimObject initialization is controlled by the instantiate method in src/python/m5/simulate.py. There are slightly different initialization paths when starting the simulation afresh and when loading from a checkpoint. After instantiation and connecting ports, simulate.py initializes the object using the following call sequence:

  1. SimObject::init()
  2. SimObject::regStats()
  3. SimObject::resetStats()
  4. SimObject::startup()
  5. Drainable::drainResume() if resuming from a checkpoint.
Note
Whenever a method is called on all objects in the simulator's object tree (e.g., init(), startup(), or loadState()), a pre-order depth-first traversal is performed (see descendants() in SimObject.py). This has the effect of calling the method on the parent node before its children.

The python version of a SimObject class actually represents its Params structure which holds all its parameter settings and its name. When python needs to create a C++ instance of one of those classes, it uses the Params struct's create() method which returns one instance, set up with the parameters in the struct.

When writing a SimObject class, there are three different cases as far as what you need to do to support the create() method, for hypothetical class Foo.

If you have a constructor with a signature like this:

Foo(const FooParams &)

you don't have to do anything, a create method will be automatically defined which will call your constructor and return that instance. You should use this option most of the time.

If you have a constructor with that signature but still want to define your own create method for some reason, you can do that by providing an alternative implementation which will override the default. It should have this signature:

Foo *FooParams::create() const;

If you don't have a constructor with that signature at all, then you must implement the create method with that signature which will build your object in some other way.

A reference to the SimObjectParams will be returned via the params() API. It is quite common for a derived class (DerivSimObject) to access its derived parameters by downcasting the SimObjectParam to DerivSimObjectParams

using Params = DerivSimObjectParams;
const Params &
params() const
{
return reinterpret_cast<const Params&>(_params);
}
SimObjectParams Params
Definition: sim_object.hh:170
const Params & params() const
Definition: sim_object.hh:176
const SimObjectParams & _params
Cached copy of the object parameters.
Definition: sim_object.hh:167

We provide the PARAMS(..) macro as syntactic sugar to replace the code above with a much simpler:

PARAMS(DerivSimObject);
#define PARAMS(type)
Definition: sim_object.hh:371

Definition at line 146 of file sim_object.hh.

Member Typedef Documentation

◆ Params

typedef SimObjectParams gem5::SimObject::Params

Definition at line 170 of file sim_object.hh.

◆ SimObjectList

Definition at line 150 of file sim_object.hh.

Constructor & Destructor Documentation

◆ ~SimObject()

gem5::SimObject::~SimObject ( )
virtual

Definition at line 70 of file sim_object.cc.

References probeManager.

Member Function Documentation

◆ drain()

DrainState gem5::SimObject::drain ( )
inlineoverridevirtual

Provide a default implementation of the drain interface for objects that don't need draining.

Implements gem5::Drainable.

Definition at line 286 of file sim_object.hh.

References gem5::Drained.

◆ getSimObjectResolver()

SimObjectResolver * gem5::SimObject::getSimObjectResolver ( )
static

There is a single object name resolver, and it is only set when simulation is restoring from checkpoints.

Returns
Pointer to the single sim object name resolver.

Definition at line 198 of file sim_object.cc.

References _objNameResolver.

Referenced by gem5::objParamIn().

◆ serialize()

void gem5::SimObject::serialize ( CheckpointOut cp) const
inlineoverridevirtual

Serialize an object.

Output an object's state into the current checkpoint section.

Parameters
cpCheckpoint state

Implements gem5::Serializable.

Reimplemented in gem5::VoltageDomain, gem5::TickedObject, and gem5::System.

Definition at line 315 of file sim_object.hh.

Referenced by gem5::SrcClockDomain::serialize().

◆ serializeAll()

void gem5::SimObject::serializeAll ( const std::string &  cpt_dir)
static

Create a checkpoint by serializing all SimObjects in the system.

This is the entry point in the process of checkpoint creation, so it will create the checkpoint file and then unfold into the serialization of all the sim objects declared.

Each SimObject instance is explicitly and individually serialized in its own section. As such, the serialization functions should not be called on sim objects anywhere else; otherwise, these objects would be needlessly serialized more than once.

Definition at line 135 of file sim_object.cc.

References gem5::Serializable::generateCheckpointOut(), gem5::Named::name(), gem5::PowerISA::ri, gem5::Serializable::serializeSection(), and simObjectList.

Referenced by gem5::debug_serialize(), and gem5::pybind_init_core().

◆ setSimObjectResolver()

void gem5::SimObject::setSimObjectResolver ( SimObjectResolver resolver)
static

There is a single object name resolver, and it is only set when simulation is restoring from checkpoints.

Parameters
Pointerto the single sim object name resolver.

Definition at line 191 of file sim_object.cc.

References _objNameResolver.

Referenced by gem5::pybind_init_core().

◆ unserialize()

void gem5::SimObject::unserialize ( CheckpointIn cp)
inlineoverridevirtual

Unserialize an object.

Read an object's state from the current checkpoint section.

Parameters
cpCheckpoint state

Implements gem5::Serializable.

Reimplemented in gem5::VoltageDomain, gem5::TickedObject, and gem5::System.

Definition at line 316 of file sim_object.hh.

Referenced by gem5::SrcClockDomain::unserialize().

Member Data Documentation

◆ _objNameResolver

SimObjectResolver * gem5::SimObject::_objNameResolver = NULL
staticprivate

Helper to resolve an object given its name.

Definition at line 156 of file sim_object.hh.

Referenced by getSimObjectResolver(), and setSimObjectResolver().

◆ probeManager

ProbeManager* gem5::SimObject::probeManager
private

Manager coordinates hooking up probe points with listeners.

Definition at line 159 of file sim_object.hh.

Referenced by getProbeManager(), SimObject(), and ~SimObject().

◆ simObjectList

SimObject::SimObjectList gem5::SimObject::simObjectList
staticprivate

List of all instantiated simulation objects.

Definition at line 153 of file sim_object.hh.

Referenced by find(), serializeAll(), and SimObject().


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

Generated on Wed Dec 21 2022 10:23:31 for gem5 by doxygen 1.9.1