comp
import comp
class comp.CompException
Error raised when methods in this module fail.
class comp.ConfigAttribute(top, up)
Component configuration attribute.
The ConfigAttribute class inherits the pyobj.Attribute class. The ConfigAttribute class just adds the special property to the pyobj.Attribute class that it is a config attribute.
A config attribute defines how the component should be configured. Therefore, all config attributes are also arguments to the new- and create- commands that are used to instantiate the component.
Because of this, the config attribute must always be documented and the default value of the attrattr member is Sim_Attr_Optional.
The ConfigAttribute class contains the valid member, which is a list of valid values for the config attribute. The list gives the user a hint about valid values when creating a component. There is no check that the value written to the attribute is a value in the list of valid values. The list of valid value(s) does not need to contain the default initial value for the config attribute, but it usually does. The valid list should at least contain one valid value even if several values are valid.
class foo(ConfigAttribute):
"""The foo attribute."""
valid = [667, 4711]
def _initialize(self): self.val = 4711
def getter(self): return self.val
def setter(self, val): self.val = val
comp.SimpleConfigAttribute(init, type, attr=1, val=[])
Simple component configuration attribute.
The pyobj.SimpleConfigAttribute method creates an attribute using the comp.ConfigAttribute class. The purpose of the method is to make it easier and faster to create a simple config attribute.
A config attribute defines how the component should be configured. Therefore, all config attributes are also arguments to the new- and create- commands that are used to instantiate the component.
The init argument is the initial value for the attribute. The type of the attribute is defined by the type string (currently objects āoā and dictionaries āDā are not supported). The attr argument sets the attribute kind. The default value for attr is Sim_Attr_Optional. The valid value(s) for the comp.ConfigAttribute class is set by the val argument. See the documentation for SIM_register_attribute for more information about the arguments.
class cpu_frequency(SimpleConfigAttribute(
None, 'i', simics.Sim_Attr_Required)):
"""Processor frequency in MHz."""
comp.ConfigAttribute class
class comp.StandardComponent()
Base class for components.
The StandardComponent class is the base class for components written in Python. It is a subclass of pyobj.ConfObject.
The class will automatically register the required component attributes. Any attribute may be overridden; however, overriding the internal attributes is not recommended.
The automatically registered attributes are:
False.The class will automatically implement the component interface. The individual methods of this interface are user-overridable.
Components will automatically get new- and create- commands that can be used to create and instantiate the component. It is possible to override this by setting _no_create_command or _no_new_command to object() to avoid to automatically get create- or new- commands.
class my_comp(StandardComponent):
"""The my_comp component."""
_class_desc = "my_comp"
class bar(SimpleConfigAttribute(
None, 'i', simics.Sim_Attr_Required)):
"""My favorite bar."""
class my_comp(StandardComponent):
"""The my_comp component."""
_class_desc = "my_comp"
_no_create_command = object()
comp.StandardComponent.add_component(slot, cls, attr, name='')
Add a subcomponent or arrays of subcomponents to the component.
The subcomponent(s) will be created immediately when the method is called.
The slot argument is the slot name concatenated with a nested array string, defining the number of subcomponents to create. Setting slot to foo will create one subcomponent in the slot foo, setting slot to foo[3] will create an array of three subcomponents in the slot foo, setting slot to foo[3][2] will create an array of three arrays of two arrays with subcomponents in the slot foo.
The cls is the component class, attr is arguments to the component, and name is an optional name.
Arrays of conf_object_t component object.
comp.StandardComponent.add_connector(
slot,
type,
hotpluggable,
required,
multi,
direction
)
Add connector to component.
Add a connector or nested array of connectors to the component. The connector(s) will be created immediately when the method is called.
The slot argument is the slot name concatenated with a nested array string, defining the number of connectors to create. Setting slot to foo will create one connector in the slot foo, setting slot to foo[3] will create an array of three connectors in the slot foo, setting slot to foo[3][2] will create an array of three arrays of two arrays with connectors in the slot foo.
The type is the type of connection as a string, hotpluggable is True or False depending on whether the connector is hot-pluggable, required is True if the connector must be connected before the component is instantiated, multi is True if the connector supports multiple connections, direction is a connector_direction_t which is up, down, or any.
Arrays of conf_object connector objects.
comp.StandardComponent.add_pre_obj(slot, cls, name='', **attr)
Add pre conf objects to the component.
The pre conf objects will be converted to regular conf objects when the component is instantiated.
The slot argument is the slot name concatenated with a nested array string, defining the number of pre objects to create. Setting slot to foo will create one pre object in the slot foo, setting slot to foo[3] will create an array of three pre objects in the slot foo, setting slot to foo[3][2] will create an array of three arrays of two arrays with pre objects in the slot foo. The cls argument is the type of object class to create. The name argument is deprecated. The attr argument is optional attribute values for the object(s).
Arrays of pre conf objects.
comp.StandardComponent.add_pre_obj_with_name(slot, cls, name, **attr)
Helper method which add a pre conf objects to the component.
This method supports distributed links that require a name as identifier. Internal only, use add_pre_obj().
comp.StandardComponent.add_slot(slot, val)
Add a slot to the component.
slot is the slot name and val is the value. The value must be a conf object, a pre conf object, or None, or nested lists of these types.
New slot value, i.e. val.
comp.StandardComponent.connect(cnt0, cnt1)
Connect two connectors cnt0 and cnt1.
The connectors must be connector objects. A comp.CompException exception will be raised if the connection failed.
comp.StandardComponent.copy_connector(slot, src)
Copy connector to component.
Copy connectors from another component. The slot argument is the new slot name for the connector in this component. The src argument is the name of the slot with connectors to copy. The src can be a relative slot name, see the get_slot method.
Arrays of conf_object connector objects.
comp.StandardComponent.del_slot(slot)
Delete slot in component.
The slot argument is the slot name. The function returns the slot value if the slot exists. All connectors in the slot will be converted to pre conf objects and the original connectors will be deleted when returning the slot value. A comp.CompException exception will be raised if the slot does not exist, the slot contains non connector conf objects, or the slot contains connectors that have been copied with the copy_connector method. Slots with sub components can not be deleted.
comp.StandardComponent.get_slot(slot)
Get a slot from the component.
slot is the slot name. slot can be a slot in this component or a hierarchical slot; e.g., looking up foo.bar will return the slot bar from the component in slot foo from this component. If the lookup fails, a comp.CompException exception will be raised.
Slot value.
comp.StandardComponent.has_slot(slot)
Return true if slot exists, otherwise False.
slot is the slot name. slot can be a slot in this component or a hierarchical slot; e.g., looking up foo.bar will return the slot bar from the component in slot foo from this component.
class comp.StandardConnectorComponent()
Convenience class for connector components.
The StandardConnectorComponent is a convenience class for connector components. It is a subclass of comp.StandardComponent and implements the component_connector interface.
comp.StandardConnectorComponent.add_connector(slot, cls)
Add connector to component.
The slot argument is the slot name for the connector.
The cls argument is an instance of a connector class.
The conf_object connector component.
comp.get_pre_obj_object(pre)
Return conf_object_t reference from pre_obj or a conf_object_t.
class comp.index_map_pre_obj(
object_or_class_name=None,
class_name=None,
build_id=None,
/,
**attrs
)
Implicitly created index-map pre-conf object.
class comp.pre_obj(
object_or_class_name=None,
class_name=None,
build_id=None,
/,
**attrs
)
Generate a pre_conf_object with a unique name.
class comp.pre_obj_noprefix(
object_or_class_name=None,
class_name=None,
build_id=None,
/,
**attrs
)
Generate a pre_conf_object with a unique name, no prefix added.