hwt.hdl.statements package¶
Subpackages¶
- hwt.hdl.statements.utils package
- Submodules
- hwt.hdl.statements.utils.comparison module
- hwt.hdl.statements.utils.ioDiscovery module
- hwt.hdl.statements.utils.listOfHdlStatements module
ListOfHdlStatementListOfHdlStatement.__init__()ListOfHdlStatement._iter_stms_with_branches()ListOfHdlStatement._registerOutput()ListOfHdlStatement._unregisterOutput()ListOfHdlStatement.append()ListOfHdlStatement.discard()ListOfHdlStatement.extend()ListOfHdlStatement.insert()ListOfHdlStatement.iterStatementsWithOutput()ListOfHdlStatement.pop()ListOfHdlStatement.remove()ListOfHdlStatement.replace()ListOfHdlStatement.sort()
- hwt.hdl.statements.utils.reduction module
- hwt.hdl.statements.utils.signalCut module
Submodules¶
hwt.hdl.statements.assignmentContainer module¶
- class hwt.hdl.statements.assignmentContainer.HdlAssignmentContainer(src: RtlSignalBase | HConst, dst: RtlSignalBase, indexes: List[RtlSignalBase | HConst] | None = None, virtual_only=False, parentStm: HdlStatement | None = None, parentStmList: ListOfHdlStatement | None = None, sensitivity: SetList | None = None, event_dependent_from_branch: int | None = None)[source]¶
Bases:
HdlStatementAssignment container
- Variables:
~.src – source
~.dst – destination signal
~.indexes – description of index selector on dst (list of Index/Slice objects) (f.e. [0, 1] means dst[0][1])
__instCntr – counter used for generating instance ids
~._instId – internally used only for intuitive sorting of statements
- _DEEPCOPY_SHALLOW_ONLY = ('_inputs', '_outputs', '_enclosed_for', '_sensitivity', 'indexes')¶
- _DEEPCOPY_SKIP = ('parentStm', 'parentStmList', 'src', 'dst', 'indexes')¶
- __init__(src: RtlSignalBase | HConst, dst: RtlSignalBase, indexes: List[RtlSignalBase | HConst] | None = None, virtual_only=False, parentStm: HdlStatement | None = None, parentStmList: ListOfHdlStatement | None = None, sensitivity: SetList | None = None, event_dependent_from_branch: int | None = None)[source]¶
- Parameters:
dst – destination to assign to
src – source which is assigned from
indexes – description of index selector on dst (list of Index/Slice objects) (f.e. [[0], [1]] means dst[0][1])
virtual_only – flag indicates that this assignments is only virtual and should not be added into netlist, because it is only for internal notation
- _collect_inputs() None[source]¶
Collect inputs from all child statements to
_inputattribute on this object
- _cut_off_drivers_of(sig: RtlSignalBase)[source]¶
- _fill_enclosure(enclosure: Dict[RtlSignalBase, HdlStatement])[source]¶
The assignment does not have any uncovered code branches
- _is_mergable(other: HdlStatement) bool[source]¶
- _iter_stms() Generator[HdlStatement, None, None][source]¶
- _iter_stms_for_output(output: RtlSignalBase) Generator[HdlStatement, None, None][source]¶
- _replace_input_nested(topStm: HdlStatement, toReplace: Tuple[RtlSignalBase, RtlSignalBase] | Dict[RtlSignalBase, RtlSignalBase]) None[source]¶
- _try_reduce() Tuple[ListOfHdlStatement, bool][source]¶
hwt.hdl.statements.codeBlockContainer module¶
- class hwt.hdl.statements.codeBlockContainer.HdlStmCodeBlockContainer[source]¶
Bases:
HdlStatementHdl block statement used also to represent a HDL process
- Variables:
~.name – name used as id in target HDL
~.statements – list of statements in body of process
- Note:
HdlStmCodeBlockContainer do not have to be process in target HDL, for example simple process which contains only unconditional assignment will be rendered just as assignment. It depends on capabilities of the target HDL.
- _cut_off_drivers_of(sig: RtlSignalBase)[source]¶
- _iter_stms() Generator[HdlStatement, None, None][source]¶
- _iter_stms_for_output(output: RtlSignalBase) Generator[HdlStatement, None, None][source]¶
- _replace_child_statement(stm: HdlStatement, replacement: ListOfHdlStatement, update_io: bool) None[source]¶
- _try_reduce() Tuple[List[HdlStatement], bool][source]¶
- classmethod from_known_io(name: str, statements: ListOfHdlStatement, sensitivity: Set[RtlSignal], inputs: SetList, outputs: SetList) HdlStmCodeBlockContainer[source]¶
hwt.hdl.statements.ifContainter module¶
hwt.hdl.statements.statement module¶
- class hwt.hdl.statements.statement.HdlStatement(parentStm: HdlStatement | None = None, parentStmList: ListOfHdlStatement | None = None, sensitivity: SetList | None = None, event_dependent_from_branch: int | None = None)[source]¶
Bases:
HdlObject- Variables:
~._event_dependent_from_branch – index of code branch if statement is event (clk) dependent else None
~.parentStm – parent instance of HdlStatement or None
~.parentStmList – list in parent statement where this statement is stored
~._inputs – SetList of input signals for this statement (All input signals which are directly used in any statement. Note that the expression is also the signal.)
~._outputs – SetList of output signals for this statement
~._sensitivity – SetList of input signals or (rising/falling) operator
~._enclosed_for – set of outputs for which this statement is enclosed (for which there is not any unused branch)
~.rank – number of used branches in statement, used as pre-filter for statement comparing
- _DEEPCOPY_SHALLOW_ONLY = ('_inputs', '_outputs', '_enclosed_for', '_sensitivity')¶
- _DEEPCOPY_SKIP = ('parentStm', 'parentStmList')¶
- __init__(parentStm: HdlStatement | None = None, parentStmList: ListOfHdlStatement | None = None, sensitivity: SetList | None = None, event_dependent_from_branch: int | None = None)[source]¶
- _clean_signal_meta()[source]¶
Clean informations about enclosure for outputs and sensitivity of this statement
- _collect_inputs() None[source]¶
Collect inputs from all child statements to
_inputattribute on this object
- _collect_io() None[source]¶
Collect inputs/outputs from all child statements to
_input/_outputattribute on this object
- _collect_outputs() None[source]¶
Collect inputs from all child statements to
_outputattribute on this object
- _cut_off_drivers_of(sig: RtlSignalBase) None | HdlStatement | List[HdlStatement][source]¶
Cut all logic from statements which drives signal sig.
- Parameters:
sig – signal which drivers should be removed
- Returns:
A statement or statement list which was cut off from the original statement
- _cut_off_drivers_of_regenerate_io(cut_off_sig: RtlSignalBase, cut_of_smt: HdlStatement)[source]¶
Update _inputs/_outputs after some part of statement was cut of
- Parameters:
cut_off_sig – a signal which driver is a cut_of_stm
cut_of_smt – the statement wich was cut off from original statement (selected by cut_off_sig)
- _destroy()[source]¶
Disconnect this statement from signals and delete it from RtlNetlist context
- Attention:
signal endpoints/drivers will be altered that means they can not be used for iteration
- _discover_enclosure() None[source]¶
Discover all outputs for which is this statement enclosed _enclosed_for property (has driver in all code branches)
- _discover_sensitivity(seen: set) None[source]¶
discover all sensitivity signals and store them to _sensitivity property
- _fill_enclosure(enclosure: Dict[RtlSignalBase, Callable[[], HdlStatement]]) None[source]¶
Add assignments to a default values to a code branches which are not assigning to specified output signal.
- Attention:
enclosure has to be discoverd first use _discover_enclosure() method
- _is_enclosed() bool[source]¶
- Returns:
True if every branch in statement assignas to all output signals else False
- _is_mergable(other: HdlStatement) bool[source]¶
- _iter_stms_for_output(output: RtlSignalBase) Generator[HdlStatement, None, None][source]¶
- Returns:
iterator of sub statements which have specified output as an output
- _merge_with_other_stm(other: HdlStatement) None[source]¶
- Attention:
statements has to be mergable (to check use _is_mergable method)
- _on_merge(other: HdlStatement)[source]¶
After merging statements update IO, sensitivity and context
- Attention:
rank is not updated
- _on_parent_event_dependent()[source]¶
After parent statement become event dependent propagate event dependency flag to child statements
- _on_reduce(self_reduced: bool, io_changed: bool, result_statements: List[HdlStatement]) None[source]¶
Update signal IO after reduce attempt
- Parameters:
self_reduced – if True this object was reduced
io_changed – if True IO of this object may changed and has to be updated
result_statements – list of statements which are result of reduce operation on this statement
- _register_stements(statements: List[HdlStatement], target: ListOfHdlStatements)[source]¶
Append statements to this container
- _replace_child_statement(stm: HdlStatement, replacement: List[HdlStatement], update_io: bool) None[source]¶
Replace a child statement with a list of other statements
- Attention:
original statement is destroyed and entirely removed from circuit
- Note:
sensitivity/endoints are actualized
- _replace_input(toReplace: Tuple[RtlSignalBase, RtlSignalBase] | Dict[RtlSignalBase, RtlSignalBase]) bool[source]¶
Replace input signal with another :return: True if the expression was present in this statement (and was replaced) :note: sensitivity/endpoints are actualized :note: calling on children does not update parent’s _inputs, _sensitivity or _enclosed_for
- _replace_input_nested(topStm: HdlStatement, toReplace: Tuple[RtlSignalBase, RtlSignalBase] | Dict[RtlSignalBase, RtlSignalBase]) None[source]¶
- _replace_input_update_sensitivity_and_inputs(toReplace: Tuple[RtlSignalBase, RtlSignalBase] | Dict[RtlSignalBase, RtlSignalBase])[source]¶
This function updates _sensitivity and _inputs containers after the input was replaced in this statement.
- Attention:
it does not perform the replace of the input. It should be called after the replace.
- _set_parent_stm(parentStm: HdlStatement, parentStmList: ListOfHdlStatements)[source]¶
Assign parent statement and propagate dependency flags if necessary
- _try_cut_off_whole_stm(sig: RtlSignalBase) bool[source]¶
Try cut of output from statement and if this is only output of statement cut off whole statement. Otherwise prepare for cutting of the signal from this statement.
- Parameters:
sig – signal which drivers should be removed
- Returns:
true if was removed or False if pruning of sig from this statement is required
- _try_reduce() Tuple[List[HdlStatement], bool][source]¶
- isSame(other: HdlStatement) bool[source]¶
- Returns:
True if other has same meaning as self