blueprints
import blueprints
blueprints.Alias(iface: ~StateT) -> ~StateT
Return state which will provide aliases to the original state rather than actual values when its attributes are dereferenced.
blueprints.expand(
*args,
params=None,
logger=<RootLogger root (WARNING)>,
**kwd
) -> blueprints.impl.BlueprintBuilder
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(builder: 'BlueprintBuilder')
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(
src: blueprints.types.Namespace,
type: type[~StateT],
dst: blueprints.types.Namespace
) -> ~StateT
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(
name: blueprints.types.Namespace,
cb: Callable,
**kwds
)
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(
name: blueprints.types.Namespace,
config: type[~ConfigT]
) -> ~ConfigT
This method is analogous to expose_state, but for Config sub-types.
blueprints.Builder.error(*args)
Report an error.
blueprints.Builder.establish_binding(
type: type[~BindingT],
src: blueprints.types.Namespace,
dst: blueprints.types.Namespace
) -> ~StateT
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(
parent: blueprints.types.Namespace,
name: str,
kind: Union[Callable, ForwardRef('BlueprintFun')],
**kwd
)
Expand a blueprint at the node ‘name’ under the ‘parent’ namespace. Any supplied keyword parameters represent blueprint arguments.
blueprints.Builder.expose_state(
name: blueprints.types.Namespace,
state: Union[~StateT, type[~StateT]]
) -> ~StateT
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(
name: blueprints.types.Namespace,
config: type[~ConfigT]
) -> ~ConfigT
This method is analogous to read_state, but for Config sub-types.
blueprints.Builder.obj(
name: blueprints.types.Namespace,
conf_class: str,
**kwd
) -> blueprints.simtypes.ConfObject | None
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(
name: blueprints.types.Namespace,
state: type[~StateT],
*,
private=False,
allow_local=False
) -> ~StateT
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(
name: blueprints.types.Namespace,
**kwd
) -> blueprints.simtypes.ConfObject | None
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(
params: list[blueprints.data.ParamBase] | None = None,
name: str | None = None
) -> Callable
Decorator for adding blueprint parameters.
class blueprints.BlueprintFun(
comp: Optional[Callable[[blueprints.api.Builder, blueprints.types.Namespace], NoneType]] = None
)
Container type which holds a blueprint function
blueprints.BlueprintFun.comp
Alias for field number 0
class blueprints.BlueprintError
Exception raised by the blueprint framework on errors.
Examples are invalid blueprint parameters or illegal state usage.
class blueprints.ConfObject(obj: blueprints.types.Namespace | None = None)
Python representation of a Simics object.
blueprints.ConfObject.obj
Alias for field number 0
blueprints.Default(val: ~T) -> ~T
Function used to attach DEFAULT priority to the value ‘val’.
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
)
Tuple representing a memory-space default target
blueprints.DefaultTarget.align_size
Alias for field number 4
blueprints.DefaultTarget.byte_swap
Alias for field number 5
blueprints.DefaultTarget.function
Alias for field number 1
blueprints.DefaultTarget.offset
Alias for field number 2
blueprints.DefaultTarget.port
Alias for field number 0
blueprints.DefaultTarget.target
Alias for field number 3
blueprints.instantiate(
*args,
prefix='',
**kwd
) -> blueprints.impl.BlueprintBuilder
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()
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(iface_type: type[~StateT])
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()
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(
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
)
Tuple representing a memory-space mapping
blueprints.MemMap.align_size
Alias for field number 7
blueprints.MemMap.base
Alias for field number 0
blueprints.MemMap.byteswap
Alias for field number 8
blueprints.MemMap.function
Alias for field number 2
blueprints.MemMap.length
Alias for field number 4
blueprints.MemMap.offset
Alias for field number 3
blueprints.MemMap.port
Alias for field number 1
blueprints.MemMap.priority
Alias for field number 6
blueprints.MemMap.target
Alias for field number 5
class blueprints.Namespace(_name: str) -> None
The Namespace class represents a hierarchical name where Simics objects and blueprints can be added. Basically a string.
blueprints.Namespace.is_descendant_of(ns: 'Namespace')
Is ns an ancestor of self?
blueprints.Override(val: ~T) -> ~T
Function used to attach OVERRIDE priority to the value ‘val’.
class blueprints.Port(
obj: blueprints.types.Namespace | blueprints.simtypes.ConfObject | None = None,
port: str | None = None
)
Python representation of a Simics interconnect on a conf object.
blueprints.Port.obj
Alias for field number 0
blueprints.Port.port
Alias for field number 1
class blueprints.Priority(
value,
names=None,
*,
module=None,
qualname=None,
type=None,
start=1
)
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(
val: Any,
priority: blueprints.types.Priority = <Priority.NORMAL: 0>
)
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
Alias for field number 1
blueprints.PriorityValue.val
Alias for field number 0
class blueprints.SignalPort(
obj: blueprints.types.Namespace | blueprints.simtypes.ConfObject | None = None,
port: str | None = None
)
Python representation of a Simics signal interconnect on a conf object.
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
)
Blueprint parameter definition.
Each parameter is tied to a data member of a Config class, from which its default value and type are obtained.
name: user-facing parameter name, and the name of the Config member unless member_name is given.desc: user-facing description.config: the Config class the parameter is bound to.ptype: parameter type. Required if the default value is None, otherwise obtained from the Config member.default: default value, overriding the Config member default.member_name: name of the Config member, if different from name.allow_empty: whether an empty value is accepted.advanced: advanced level used by the target parameter framework.telemetry: whether the parameter is included in telemetry.class blueprints.ParamGroup(*args, **kwargs)
Blueprint parameter group declaration.
Imports the parameters of another blueprint as a sub-tree.
name: name of the sub-tree. The importing blueprint must expand import_bp at a namespace matching this name (or the value of the ns parameter, if set).desc: user-facing description.import_bp: name of the blueprint whose parameters are imported.ns: name of a parameter whose value gives the namespace where import_bp is expanded, if different from name.count: name of an integer parameter giving the number of copies of the imported blueprint, for dynamic parameters.enable: name of a boolean parameter controlling whether the imported blueprint is added at all, for dynamic parameters.ParamGroup(name, members) with a list of parameter definitions can also be used to group parameters explicitly.
class blueprints.Config()
Blueprint configuration state.
class blueprints.Binding()
1-1 connection between two blueprints.
class blueprints.DataAttr(v: Any)
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.