simics pyobj
API Reference Manual  /  Python API  / 

blueprints

Name

blueprints

Synopsis

Python

import blueprints

blueprints.Alias

Synopsis

blueprints.Alias(iface: ~StateT) -> ~StateT

Description

Return state which will provide aliases to the original state rather than actual values when its attributes are dereferenced.

blueprints.expand

Synopsis

blueprints.expand(
    *args,
    params=None,
    logger=<RootLogger root (WARNING)>,
    **kwd
) -> blueprints.impl.BlueprintBuilder

Description

Expand a blueprint and return the resulting Builder object, for inspection or instantiation. Either a single blueprint function is given, which is then expanded at the empty namespace (i.e. the object hierarchy root), or a top namespace name and blueprint function is given.

Blueprint parameters can be provided using the ‘params’ argument, as a (nested) dict, name -> value.

class blueprints.Builder

Synopsis

class blueprints.Builder(builder: 'BlueprintBuilder')

Description

Interface used by blueprint functions to add objects and handle state.

A Builder instance is passed as the first argument to a blueprint function. Its methods are primarily used to add objects and sub-blueprints and to handle state.

blueprints.Builder.alias_state

Synopsis

blueprints.Builder.alias_state(
    src: blueprints.types.Namespace,
    type: type[~StateT],
    dst: blueprints.types.Namespace
) -> ~StateT

Description

Re-binds the state structure of type ‘type’ bound at ‘src’ to the node at ‘dst’. This is typically done when connecting sub-systems. The transferred state is returned.

blueprints.Builder.at_post_instantiate

Synopsis

blueprints.Builder.at_post_instantiate(
    name: blueprints.types.Namespace,
    cb: Callable,
    **kwds
)

Description

Register a post-instantiate callback at the node ‘ns’. The callbacks will be called in registration order after the configuration has been instantiated, and the ‘kwds’ parameters will be provided. If any callback throws an exception, a warning is printed, but all post-instantiate callbacks will run.

blueprints.Builder.create_config

Synopsis

blueprints.Builder.create_config(
    name: blueprints.types.Namespace,
    config: type[~ConfigT]
) -> ~ConfigT

Description

This method is analogous to expose_state, but for Config sub-types.

blueprints.Builder.error

Synopsis

blueprints.Builder.error(*args)

Description

Report an error.

blueprints.Builder.establish_binding

Synopsis

blueprints.Builder.establish_binding(
    type: type[~BindingT],
    src: blueprints.types.Namespace,
    dst: blueprints.types.Namespace
) -> ~StateT

Description

Reads the Binding of type ‘type’, which must have been exposed at node ‘src’ and re-exposes it at node `dst“.

This facilitates “connecting” blueprints expanded at these nodes.

Note that a Binding is a 1-1 channel and hence can only be read once.

blueprints.Builder.expand

Synopsis

blueprints.Builder.expand(
    parent: blueprints.types.Namespace,
    name: str,
    kind: Union[Callable, ForwardRef('BlueprintFun')],
    **kwd
)

Description

Expand a blueprint at the node ‘name’ under the ‘parent’ namespace. Any supplied keyword parameters represent blueprint arguments.

blueprints.Builder.expose_state

Synopsis

blueprints.Builder.expose_state(
    name: blueprints.types.Namespace,
    state: Union[~StateT, type[~StateT]]
) -> ~StateT

Description

Binds a state structure to the namespace node ‘ns’ and returns it.

If ‘state’ is a state type, then an instance of this state is created and bound to the node.

If ‘state’ is a state instance, then that instance is bound to the specified node. Note that a specific state instance can be bound to multiple nodes.

blueprints.Builder.get_config

Synopsis

blueprints.Builder.get_config(
    name: blueprints.types.Namespace,
    config: type[~ConfigT]
) -> ~ConfigT

Description

This method is analogous to read_state, but for Config sub-types.

blueprints.Builder.obj

Synopsis

blueprints.Builder.obj(
    name: blueprints.types.Namespace,
    conf_class: str,
    **kwd
) -> blueprints.simtypes.ConfObject | None

Description

Add an object to the blueprint, with a name derived from the ‘ns’ namespace object. Any supplied keyword parameters represent object attributes.

blueprints.Builder.read_state

Synopsis

blueprints.Builder.read_state(
    name: blueprints.types.Namespace,
    state: type[~StateT],
    *,
    private=False,
    allow_local=False
) -> ~StateT

Description

Returns a state instance of type ‘state’ obtained from the node ‘ns’. If the node ‘ns’ does not provide the state, then the state is obtained from the first hierarchical ancestor which provides it.

If no ancestor provides the state, or if ‘private’ is set to True, then a local state instance is created and returned instead. The same state instance will always be returned for a specific value of ‘ns’. A local state is not accepted if ‘allow_local’ is set to True.

State instances are bound to a specific node with the ‘expose_state’ method.

blueprints.Builder.set

Synopsis

blueprints.Builder.set(
    name: blueprints.types.Namespace,
    **kwd
) -> blueprints.simtypes.ConfObject | None

Description

Set attributes on an object. This must be a descendant of an object already registered using obj(). Any supplied keyword parameters represent object attributes.

blueprints.blueprint

Synopsis

blueprints.blueprint(
    params: list[blueprints.data.ParamBase] | None = None,
    name: str | None = None
) -> Callable

Description

Decorator for adding blueprint parameters.

class blueprints.BlueprintFun

Synopsis

class blueprints.BlueprintFun(
    comp: Optional[Callable[[blueprints.api.Builder, blueprints.types.Namespace], NoneType]] = None
)

Description

Container type which holds a blueprint function

blueprints.BlueprintFun.comp

Synopsis

blueprints.BlueprintFun.comp

Description

Alias for field number 0

class blueprints.BlueprintError

Synopsis

class blueprints.BlueprintError

Description

Exception raised by the blueprint framework on errors.

Examples are invalid blueprint parameters or illegal state usage.

class blueprints.ConfObject

Synopsis

class blueprints.ConfObject(obj: blueprints.types.Namespace | None = None)

Description

Python representation of a Simics object.

blueprints.ConfObject.obj

Synopsis

blueprints.ConfObject.obj

Description

Alias for field number 0

blueprints.Default

Synopsis

blueprints.Default(val: ~T) -> ~T

Description

Function used to attach DEFAULT priority to the value ‘val’.

class blueprints.DefaultTarget

Synopsis

class blueprints.DefaultTarget(
    port: blueprints.simtypes.Port | blueprints.types.Namespace | blueprints.simtypes.ConfObject,
    function: int = 0,
    offset: int = 0,
    target: blueprints.simtypes.Port | blueprints.types.Namespace | blueprints.simtypes.ConfObject | None = None,
    align_size: int = 0,
    byte_swap: int = 0
)

Description

Tuple representing a memory-space default target

blueprints.DefaultTarget.align_size

Synopsis

blueprints.DefaultTarget.align_size

Description

Alias for field number 4

blueprints.DefaultTarget.byte_swap

Synopsis

blueprints.DefaultTarget.byte_swap

Description

Alias for field number 5

blueprints.DefaultTarget.function

Synopsis

blueprints.DefaultTarget.function

Description

Alias for field number 1

blueprints.DefaultTarget.offset

Synopsis

blueprints.DefaultTarget.offset

Description

Alias for field number 2

blueprints.DefaultTarget.port

Synopsis

blueprints.DefaultTarget.port

Description

Alias for field number 0

blueprints.DefaultTarget.target

Synopsis

blueprints.DefaultTarget.target

Description

Alias for field number 3

blueprints.instantiate

Synopsis

blueprints.instantiate(
    *args,
    prefix='',
    **kwd
) -> blueprints.impl.BlueprintBuilder

Description

Expand blueprint and instantiate the result. The arguments are the same as for expand(), except that a prefix string can be specified, which is added to all object names, hence facilitating instantiating the blueprint system inside a given object hierarchy.

class blueprints.State

Synopsis

class blueprints.State()

Description

Base class for all blueprint state classes. Each state class is a fixed collection of fields, a shared data structure. It can also carry configurational information.

class blueprints.StateMap

Synopsis

class blueprints.StateMap(iface_type: type[~StateT])

Description

Map type, to be used in state definitions.

Maps arbitrary keys to state instances of the type given to the constructor. State instances are created on demand when a key is accessed, and the same instance is returned for the same key.

class blueprints.List

Synopsis

class blueprints.List()

Description

List type, to be used in state definitions. Multiple blueprints can contribute elements to the same list. Created automatically for state values which has an empty list as default value.

class blueprints.MemMap

Synopsis

class blueprints.MemMap(
    base: int,
    port: blueprints.simtypes.Port | blueprints.types.Namespace | blueprints.simtypes.ConfObject,
    function: int,
    offset: int,
    length: int,
    target: blueprints.simtypes.Port | blueprints.types.Namespace | blueprints.simtypes.ConfObject | None = None,
    priority: int = 0,
    align_size: int = 0,
    byteswap: int = 0
)

Description

Tuple representing a memory-space mapping

blueprints.MemMap.align_size

Synopsis

blueprints.MemMap.align_size

Description

Alias for field number 7

blueprints.MemMap.base

Synopsis

blueprints.MemMap.base

Description

Alias for field number 0

blueprints.MemMap.byteswap

Synopsis

blueprints.MemMap.byteswap

Description

Alias for field number 8

blueprints.MemMap.function

Synopsis

blueprints.MemMap.function

Description

Alias for field number 2

blueprints.MemMap.length

Synopsis

blueprints.MemMap.length

Description

Alias for field number 4

blueprints.MemMap.offset

Synopsis

blueprints.MemMap.offset

Description

Alias for field number 3

blueprints.MemMap.port

Synopsis

blueprints.MemMap.port

Description

Alias for field number 1

blueprints.MemMap.priority

Synopsis

blueprints.MemMap.priority

Description

Alias for field number 6

blueprints.MemMap.target

Synopsis

blueprints.MemMap.target

Description

Alias for field number 5

class blueprints.Namespace

Synopsis

class blueprints.Namespace(_name: str) -> None

Description

The Namespace class represents a hierarchical name where Simics objects and blueprints can be added. Basically a string.

blueprints.Namespace.is_descendant_of

Synopsis

blueprints.Namespace.is_descendant_of(ns: 'Namespace')

Description

Is ns an ancestor of self?

blueprints.Override

Synopsis

blueprints.Override(val: ~T) -> ~T

Description

Function used to attach OVERRIDE priority to the value ‘val’.

class blueprints.Port

Synopsis

class blueprints.Port(
    obj: blueprints.types.Namespace | blueprints.simtypes.ConfObject | None = None,
    port: str | None = None
)

Description

Python representation of a Simics interconnect on a conf object.

blueprints.Port.obj

Synopsis

blueprints.Port.obj

Description

Alias for field number 0

blueprints.Port.port

Synopsis

blueprints.Port.port

Description

Alias for field number 1

class blueprints.Priority

Synopsis

class blueprints.Priority(
    value,
    names=None,
    *,
    module=None,
    qualname=None,
    type=None,
    start=1
)

Description

Priority of a value written to a state field.

When multiple blueprints write to the same field, the value with the highest priority is used. Writing different values with the same priority is an error. Values are written with NORMAL priority unless wrapped using Default() or Override().

class blueprints.PriorityValue

Synopsis

class blueprints.PriorityValue(
    val: Any,
    priority: blueprints.types.Priority = <Priority.NORMAL: 0>
)

Description

A value together with its Priority.

Assigning a PriorityValue to a state field writes the value with the given priority. Normally created using Default() or Override() rather than directly.

blueprints.PriorityValue.priority

Synopsis

blueprints.PriorityValue.priority

Description

Alias for field number 1

blueprints.PriorityValue.val

Synopsis

blueprints.PriorityValue.val

Description

Alias for field number 0

class blueprints.SignalPort

Synopsis

class blueprints.SignalPort(
    obj: blueprints.types.Namespace | blueprints.simtypes.ConfObject | None = None,
    port: str | None = None
)

Description

Python representation of a Simics signal interconnect on a conf object.

class blueprints.Param

Synopsis

class blueprints.Param(
    name: str,
    desc: str,
    config: type[blueprints.types.Config],
    ptype=None,
    default=None,
    member_name=None,
    allow_empty=True,
    advanced=0,
    telemetry=False
)

Description

Blueprint parameter definition.

Each parameter is tied to a data member of a Config class, from which its default value and type are obtained.

class blueprints.ParamGroup

Synopsis

class blueprints.ParamGroup(*args, **kwargs)

Description

Blueprint parameter group declaration.

Imports the parameters of another blueprint as a sub-tree.

ParamGroup(name, members) with a list of parameter definitions can also be used to group parameters explicitly.

class blueprints.Config

Synopsis

class blueprints.Config()

Description

Blueprint configuration state.

class blueprints.Binding

Synopsis

class blueprints.Binding()

Description

1-1 connection between two blueprints.

class blueprints.DataAttr

Synopsis

class blueprints.DataAttr(v: Any)

Description

Wrapper for an attribute value that is passed to the object verbatim.

No resolution of object references is done on the wrapped value. Useful for data attribute values such as tuples of bytes.

simics pyobj