Task Context Variables¶
Contexts variables are used to automatically pass data from parent tasks to child tasks. When reading a context variable, the value set by the first task–starting from the current task following parents up to the root task–is used.
- yosys_mau.task_loop.context.task_context(cls)¶
Decorator for a class defining a group of task context variables.
Note that this decorator replaces the class with a singleton instance of the class with all annotated non-descriptor attributes wrapped in a
TaskContextDescriptor. Existing non-descriptor attribute values are used as default values for the new descriptor.Todo
Example for
task_context- Parameters:
cls (type[T])
- Return type:
T
- class yosys_mau.task_loop.context.TaskContextDescriptor(default=<yosys_mau.task_loop.context._MISSING_TYPE object>)¶
A descriptor that stores a value per
Task.When assigning or deleting the attribute from within the task loop, this affects the value stored for the current task.
With no task loop running, this affects the default value for the attribute.
When reading the attribute, this performs a lookup in the task hierarchy, starting from the current task and going up to the root task. If no value is found the default value is returned.
- Parameters:
default (T | _MISSING_TYPE)
- property default: T¶
The default value for this context variable.
It is possible to subclass this descriptor and to override this property to provide a custom dynamic behavior for the default value while retaining the same lookup and assignment behavior for values associated to tasks.
- class yosys_mau.task_loop.context.InlineContextVar(context_var_group, name)¶
A descriptor that makes a task context variable available as an attribute of a task.
This has to be used within subclasses of
Task. Accessing the corresponding attribute of aTaskinstance behaves as if that task was the current task and the task context variable was accessed.Todo
Example to illustrate the previous paragraph.
- Parameters:
context – The task context variable group that contains the task context variable.
name (str) – The name of the task context variable within this group.
context_var_group (Any)
- class yosys_mau.task_loop.context.TaskContextDict(default=None)¶
Descriptor for a task context variable that is a mapping where each value is scoped individually.
Todo
Document
TaskContextDictmembers- Parameters:
default (MutableMapping[K, V] | None)