Instruction Elaboration¶
Instruction sets can be defined by using the !Inst tag. Instructions can inherit from one another, fixing the value of one enumerated field per level - in this way fields do not have to be replicated between definitions.
Instruction elaboration works in two phases:
In the first phase the elaborator collapses the inheritance list of a instruction to form a single description of the !Inst with all of inherited !Fields populated and with all fixed values resolved.
In the second phase the instruction definition is converted into a
DFCommandcontainingDFCommandFields- in this stage all placements are evaluated, and any overlaps between fields are detected and raised as exceptions.
Any field enumerations are transferred through into the DesignFormat description, and any values within the options list are transferred through as attributes.
Warning
This !Inst tag is likely to be refactored into a more generic !Command description tag, that builds on the ideas of ‘extending’ a base tag to add more functionality. This would be more suited to other uses than the existing !Inst instruction description - with the current implementation only one field can be overridden or fixed to a value per instruction layer, this is likely to be replaced with a more flexible mechanism.
API¶
-
blade.elaborate.instruction.elaborate_instruction(top, scope, max_depth)¶ Evaluate a !Inst and generate a DFCommand.
- Parameters
top – The top-level !Inst to elaborate from
scope – An ElaboratorScope object containing all documents included : directly or indirectly by the top module.
max_depth – The maximum depth to elaborate to (optional, not used)
- Returns
DesignFormat command representing the instruction
- Return type
DFCommand
-
blade.elaborate.instruction.resolve_instruction(inst, scope)¶ As !Inst have the ability to extend from other !Inst, this function resolves the instruction hierarchy and returns the inherited set of fields. It also takes into account ‘decode_f’ and ‘decode_e’ to fix values in inherited fields. Note this function can be called recursively with nested references.
- Parameters
inst – The instruction to resolve
scope – The ElaboratorScope object to use to resolve references
-
blade.elaborate.instruction.resolve_xref(xref=[], ref=None, scope=None, ctx={})¶ Resolve a value cross-reference either of the form ‘<inst>/<field>/<param>’ or of the form ‘$param’ (for reading other fields in the same object). Note that the modified context allows ‘self’ to be resolved in nested references.
- Parameters
xref – Tuple of items identifying a cross-referenced parameter
ref – Identifier of a referenced parameter on this instance (self-ref)
scope – The ElaboratorScope object for wider-crossreferencing
ctx – Context to use for resolving the cross-reference
- Returns
Tuple of the crossreferenced value and a modified context
- Return type
tuple