pyobj update_checkpoint
API Reference Manual  /  Python API  / 

comp

Name

comp

Synopsis

Python

import comp

class comp.CompException

Synopsis

class comp.CompException

Description

Error raised when methods in this module fail.

class comp.ConfigAttribute

Synopsis

class comp.ConfigAttribute(top, up)

Description

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.

Example

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

See Also

pyobj.Attribute

comp.SimpleConfigAttribute

Synopsis

comp.SimpleConfigAttribute(init, type, attr=1, val=[])

Description

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.

Example

class cpu_frequency(SimpleConfigAttribute(
                    None, 'i', simics.Sim_Attr_Required)):
    """Processor frequency in MHz."""

Return Value

comp.ConfigAttribute class

See Also

pyobj.Attribute, pyobj.ConfObject

class comp.StandardComponent

Synopsis

class comp.StandardComponent()

Description

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:

basename
String to prepend to component name when creating components when not specifying name.
component_icon
String with the name of the component icon.
component_queue
The default queue object for this component.
top_level
Default set to False.
system_icon
The system icon.
machine_icon
The machine icon.
cpu_list
List of processors in the component tree.
static_slots
Internal.
dynamic_slots
Internal.
object_list
Internal.
object_prefix
Internal.
top_component
Internal.
instantiated
Internal.
pending_cell_object_factories
Internal.
config_attributes
Internal.
system_info
Internal.
components
Internal.
domain
Internal.

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.

Example

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()

See Also

pyobj.ConfObject

comp.StandardComponent.add_component

Synopsis

comp.StandardComponent.add_component(slot, cls, attr, name='')

Description

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.

Return Value

Arrays of conf_object_t component object.

comp.StandardComponent.add_connector

Synopsis

comp.StandardComponent.add_connector(
    slot,
    type,
    hotpluggable,
    required,
    multi,
    direction
)

Description

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.

Return Value

Arrays of conf_object connector objects.

See Also

comp.StandardComponent.get_slot

comp.StandardComponent.add_pre_obj

Synopsis

comp.StandardComponent.add_pre_obj(slot, cls, name='', **attr)

Description

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).

Return Value

Arrays of pre conf objects.

comp.StandardComponent.add_pre_obj_with_name

Synopsis

comp.StandardComponent.add_pre_obj_with_name(slot, cls, name, **attr)

Description

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

Synopsis

comp.StandardComponent.add_slot(slot, val)

Description

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.

Return Value

New slot value, i.e. val.

comp.StandardComponent.connect

Synopsis

comp.StandardComponent.connect(cnt0, cnt1)

Description

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

Synopsis

comp.StandardComponent.copy_connector(slot, src)

Description

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.

Return Value

Arrays of conf_object connector objects.

See Also

comp.StandardComponent.get_slot

comp.StandardComponent.del_slot

Synopsis

comp.StandardComponent.del_slot(slot)

Description

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

Synopsis

comp.StandardComponent.get_slot(slot)

Description

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.

Return Value

Slot value.

comp.StandardComponent.has_slot

Synopsis

comp.StandardComponent.has_slot(slot)

Description

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

Synopsis

class comp.StandardConnectorComponent()

Description

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.

See Also

comp.StandardComponent

comp.StandardConnectorComponent.add_connector

Synopsis

comp.StandardConnectorComponent.add_connector(slot, cls)

Description

Add connector to component.

The slot argument is the slot name for the connector.

The cls argument is an instance of a connector class.

Return Value

The conf_object connector component.

comp.get_pre_obj_object

Synopsis

comp.get_pre_obj_object(pre)

Description

Return conf_object_t reference from pre_obj or a conf_object_t.

class comp.index_map_pre_obj

Synopsis

class comp.index_map_pre_obj(
    object_or_class_name=None,
    class_name=None,
    build_id=None,
    /,
    **attrs
)

Description

Implicitly created index-map pre-conf object.

class comp.pre_obj

Synopsis

class comp.pre_obj(
    object_or_class_name=None,
    class_name=None,
    build_id=None,
    /,
    **attrs
)

Description

Generate a pre_conf_object with a unique name.

class comp.pre_obj_noprefix

Synopsis

class comp.pre_obj_noprefix(
    object_or_class_name=None,
    class_name=None,
    build_id=None,
    /,
    **attrs
)

Description

Generate a pre_conf_object with a unique name, no prefix added.

pyobj update_checkpoint