gem5 v24.0.0.0
|
Abstract superclass for simulation objects. More...
#include <sim_object.hh>
Public Types | |
typedef SimObjectParams | Params |
Public Member Functions | |
const Params & | params () 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. | |
virtual void | loadState (CheckpointIn &cp) |
loadState() is called on each SimObject when restoring from a checkpoint. | |
virtual void | initState () |
initState() is called on each SimObject when not restoring from a checkpoint. | |
virtual void | regProbePoints () |
Register probe points for this object. | |
virtual void | regProbeListeners () |
Register probe listeners for this object. | |
ProbeManager * | getProbeManager () |
Get the probe manager for this object. | |
virtual Port & | getPort (const std::string &if_name, PortID idx=InvalidPortID) |
Get a port with a given name and index. | |
virtual void | startup () |
startup() is the final initialization call before simulation. | |
DrainState | drain () override |
Provide a default implementation of the drain interface for objects that don't need draining. | |
virtual void | memWriteback () |
Write back dirty buffers to memory using functional writes. | |
virtual void | memInvalidate () |
Invalidate the contents of memory buffers. | |
void | serialize (CheckpointOut &cp) const override |
Serialize an object. | |
void | unserialize (CheckpointIn &cp) override |
Unserialize an object. | |
Public Member Functions inherited from gem5::EventManager | |
EventQueue * | eventQueue () 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. | |
void | setCurTick (Tick newVal) |
EventManager (EventManager &em) | |
Event manger manages events in the event queue. | |
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. | |
void | serializeSection (CheckpointOut &cp, const std::string &name) const |
void | unserializeSection (CheckpointIn &cp, const char *name) |
Unserialize an a child object. | |
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. | |
virtual void | notifyFork () |
Notify a child process of a fork. | |
Public Member Functions inherited from gem5::statistics::Group | |
Group (Group *parent, const char *name=nullptr) | |
Construct a new statistics group. | |
virtual | ~Group () |
virtual void | regStats () |
Callback to set stat parameters. | |
virtual void | resetStats () |
Callback to reset stats. | |
virtual void | preDumpStats () |
Callback before stats are dumped. | |
void | addStat (statistics::Info *info) |
Register a stat with this group. | |
const std::map< std::string, Group * > & | getStatGroups () const |
Get all child groups associated with this object. | |
const std::vector< Info * > & | getStats () const |
Get all stats associated with this object. | |
void | addStatGroup (const char *name, Group *block) |
Add a stat block as a child of this block. | |
const Info * | resolveStat (std::string name) const |
Resolve a stat by its name within this group. | |
void | mergeStatGroup (Group *block) |
Merge the contents (stats & children) of a block to this block. | |
Group ()=delete | |
Group (const Group &)=delete | |
Group & | operator= (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. | |
static SimObject * | find (const char *name) |
Find the SimObject with the given name and return a pointer to it. | |
static void | setSimObjectResolver (SimObjectResolver *resolver) |
There is a single object name resolver, and it is only set when simulation is restoring from checkpoints. | |
static SimObjectResolver * | getSimObjectResolver () |
There is a single object name resolver, and it is only set when simulation is restoring from checkpoints. | |
Static Public Member Functions inherited from gem5::Serializable | |
static const std::string & | currentSection () |
Gets the fully-qualified name of the active section. | |
static void | generateCheckpointOut (const std::string &cpt_dir, std::ofstream &outstream) |
Generate a checkpoint file so that the serialization can be routed to it. | |
Protected Attributes | |
const SimObjectParams & | _params |
Cached copy of the object parameters. | |
Protected Attributes inherited from gem5::EventManager | |
EventQueue * | eventq |
A pointer to this object's event queue. | |
Private Types | |
typedef std::vector< SimObject * > | SimObjectList |
Private Attributes | |
ProbeManager * | probeManager |
Manager coordinates hooking up probe points with listeners. | |
Static Private Attributes | |
static SimObjectList | simObjectList |
List of all instantiated simulation objects. | |
static SimObjectResolver * | _objNameResolver = NULL |
Helper to resolve an object given its name. | |
Additional Inherited Members | |
Protected Member Functions inherited from gem5::Drainable | |
Drainable () | |
virtual | ~Drainable () |
virtual void | drainResume () |
Resume execution after a successful drain. | |
void | signalDrainDone () const |
Signal that an object is drained. | |
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:
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 *FooParamscreate() 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
We provide the PARAMS(..) macro as syntactic sugar to replace the code above with a much simpler:
Definition at line 146 of file sim_object.hh.
typedef SimObjectParams gem5::SimObject::Params |
Definition at line 170 of file sim_object.hh.
|
private |
Definition at line 150 of file sim_object.hh.
|
virtual |
Definition at line 67 of file sim_object.cc.
References probeManager.
|
inlineoverridevirtual |
Provide a default implementation of the drain interface for objects that don't need draining.
Implements gem5::Drainable.
Reimplemented in gem5::ArmISA::TableWalker, gem5::memory::SimpleMemory, gem5::SMMUv3, gem5::SMMUv3DeviceInterface, gem5::TimingSimpleCPU, and gem5::UFSHostDevice.
Definition at line 286 of file sim_object.hh.
References gem5::Drained.
|
static |
There is a single object name resolver, and it is only set when simulation is restoring from checkpoints.
Definition at line 171 of file sim_object.cc.
References _objNameResolver.
Referenced by gem5::objParamIn().
|
inlineoverridevirtual |
Serialize an object.
Output an object's state into the current checkpoint section.
cp | Checkpoint state |
Implements gem5::Serializable.
Reimplemented in gem5::MipsISA::TLB, gem5::PowerISA::TLB, gem5::ps2::TouchKit, gem5::RiscvISA::TLB, gem5::SMMUv3, gem5::Sp804, gem5::Sp805, gem5::SparcISA::TLB, gem5::SrcClockDomain, gem5::System, gem5::SystemCounter, gem5::TickedObject, gem5::TrafficGen, gem5::Uart8250, gem5::UFSHostDevice, gem5::VGic, gem5::VirtIO9PProxy, gem5::VirtIODeviceBase, gem5::VoltageDomain, gem5::X86ISA::Speaker, and gem5::X86ISA::TLB.
Definition at line 315 of file sim_object.hh.
|
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 132 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().
|
static |
There is a single object name resolver, and it is only set when simulation is restoring from checkpoints.
Pointer | to the single sim object name resolver. |
Definition at line 164 of file sim_object.cc.
References _objNameResolver.
Referenced by gem5::pybind_init_core().
|
inlineoverridevirtual |
Unserialize an object.
Read an object's state from the current checkpoint section.
cp | Checkpoint state |
Implements gem5::Serializable.
Reimplemented in gem5::MipsISA::TLB, gem5::PowerISA::TLB, gem5::ps2::TouchKit, gem5::RiscvISA::TLB, gem5::SMMUv3, gem5::Sp804, gem5::Sp805, gem5::SparcISA::TLB, gem5::SrcClockDomain, gem5::System, gem5::SystemCounter, gem5::TickedObject, gem5::TrafficGen, gem5::Uart8250, gem5::UFSHostDevice, gem5::VGic, gem5::VirtIO9PProxy, gem5::VirtIODeviceBase, gem5::VoltageDomain, gem5::X86ISA::Speaker, and gem5::X86ISA::TLB.
Definition at line 316 of file sim_object.hh.
|
staticprivate |
Helper to resolve an object given its name.
Definition at line 156 of file sim_object.hh.
Referenced by getSimObjectResolver(), and setSimObjectResolver().
|
private |
Manager coordinates hooking up probe points with listeners.
Definition at line 159 of file sim_object.hh.
Referenced by getProbeManager(), SimObject(), and ~SimObject().
|
staticprivate |
List of all instantiated simulation objects.
Definition at line 153 of file sim_object.hh.
Referenced by find(), serializeAll(), and SimObject().