simics — A Python framework for creating Simics classes.
import simics
class simics.confclass(
classname: 'str' = '',
parent: "Optional['confclass']" = None,
*,
pseudo: 'bool' = False,
doc: 'Optional[str]' = None,
short_doc: 'Optional[str]' = None,
register: 'Optional[bool]' = None,
**kwd: 'Any'
)
The class confclass is used to define and register a Simics class. The intended use is to create a confclass object as a class member in the custom Python class implementation used to implement the Simics class. The confclass instance also has specific namespace members that allows adding attributes and other other features (see below).
The class confclass is available either from confclass.confclass or from simics.confclass.
classname to the chosen Simics class name.confclass, set parent to the parent’s confclass instance.pseudo to True to make a Sim_Class_Kind_Pseudo class.short_doc to a one-liner describing the class and set doc to a longer description text.register to false. The Simics class can be registered by calling register on the confclass instance.To override the conf_class_t callbacks, use these decorators:
<confclass>.command.info or <confclass>.command.status as decorator for the methods used to implement the info and status commands.<confclass>.<interface name><function name> as decorator on the method that implements the <function name> in the <interface name> interface.Here is a simple example of how to add a Simics class named class1 with attribute attr1 using the .attr namespace:
class Class1:
cls = simics.confclass(classname="class1")
cls.attr.attr1("i", default=1)
For more extensive tutorials on how to write custom Simics class with confclass, see section Modeling with Python (confclass) in Model Builder User's Guide.
simics.confclass.attr
Namespace for adding attributes. Append a valid attribute name, and call (arguments below) it to create an attribute.
After the call, the namespace entry contains an object that has getter and setter properties that can be used to decorate custom attribute accessor functions.
If no custom getter or setter is provided, default accessors are automatically created. These default accessors read and write to the Python instance attribute with the same name as the Simics attribute (e.g., self.my_attr).
"i", "[i*]").attr_attr_t). Default is Sim_Attr_Required.The kind argument defaults to Sim_Attr_Required. It is modified by other arguments:
default is provided and kind is Sim_Attr_Required, kind becomes Sim_Attr_Optional.optional is True, kind becomes Sim_Attr_Optional.pseudo is True, kind becomes Sim_Attr_Pseudo.If read_only or write_only is True, pseudo must also be True, as attributes saved in checkpoints must be both readable and writable.
simics.confclass.command
Contains info and status properties that should be used as decorators on functions that works as info or status commands.
simics.confclass.deinit
Decorator for ‘deinit’ class method.
simics.confclass.event
Namespace for adding events. Append an event name and call it to declare an event. Use decorators on the resulting object to set callback, destroy, describe, get_value, and set_value.
simics.confclass.finalize
Decorator for ‘finalize’ class method.
simics.confclass.iface
Namespace for adding interface implementations. Use the <confclass><interface name>.<function name> as decorator to decorate interface functions. The interface must be accessible from Python.
In the below example, the signal interface is implemented by using cls.iface.signal.signal_raise and cls.iface.signal.signal_lower to decorate the custom interface functions signal_raise and signal_lower.
class MyDevice:
cls = simics.confclass(classname="my_device")
@cls.iface.signal.signal_raise
def signal_raise(self):
pass
@cls.iface.signal.signal_lower
def signal_lower(self):
pass
simics.confclass.init
Decorator for ‘init’ class method.
simics.confclass.o
Namespace for adding port objects. Append a valid object name, possibly a hierarchy, and call add a port object.
If unset, a class name will be chosen based on the last item in the namespaced name. If classname is set to a string starting with a dot, the classname will be prefixed with the parent’s class name. In these two cases (unset or starting with a dot), the Python class will be the parent’s Python class, and a new confclass object will be returned.
It is also possible to specify an existing class name. In this case, the call will return None, and the port object’s Python class will be an instance of the existing class, if such exists.
Optional string that describes the port object in the documentation of the parent object.
simics.confclass.objects_finalized
Decorator for ‘objects_finalized’ class method.
class simics.CriticalErrors(errors, function=None)
Represents critical errors caused by C code called from Python.
This exception is raised when returning to Python from a C function that directly or indirectly caused one or more serious, but recoverable, errors. Elaborate error descriptions are printed when the errors occur, but because of error recovery, the C function will be able to continue without being aware of the error.
A C function can cause more than one error; all these are combined into a single Python exception. The main purpose of the exception is to aid debugging, usually by providing a nice Python traceback.
class simics.pre_conf_object(
object_or_class_name=None,
class_name=None,
build_id=None,
/,
**attrs
)
A class for Simics configuration object to instantiate.
A class representing a future Simics configuration object named object_name, of class class_name. If object_name is None, a unique name will be generated.
The build_id of the object can be specified when using the pre_conf_object class during checkpoints update. Refer to Model Builder User's Guide for more information.
Future configuration attributes are set using normal Python class members:
a = pre_conf_object("test_object", "test-class")
a.value = 42
After using a pre_conf_object object to create a configuration object, the created object can be obtained by passing the pre_conf_object’s name member to SIM_get_object().
simics.pre_conf_object.classname
classname
simics.pre_conf_object.name
object name