hwt.hdl.statements package¶
Subpackages¶
Submodules¶
hwt.hdl.statements.assignmentContainer module¶
-
class
hwt.hdl.statements.assignmentContainer.
HdlAssignmentContainer
(src: Union[hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase, hwt.hdl.value.HValue], dst: hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase, indexes: Optional[List[Union[hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase, hwt.hdl.value.HValue]]] = None, virtual_only=False, parentStm: Optional[hwt.hdl.statements.statement.HdlStatement] = None, parentStmList: Optional[hwt.hdl.statements.utils.listOfHdlStatements.ListOfHdlStatement] = None, sensitivity: Optional[hwt.pyUtils.uniqList.UniqList] = None, event_dependent_from_branch: Optional[int] = None)[source]¶ Bases:
hwt.hdl.statements.statement.HdlStatement
Assignment 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')¶
-
_HdlAssignmentContainer__instCntr
= 0¶
-
__init__
(src: Union[hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase, hwt.hdl.value.HValue], dst: hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase, indexes: Optional[List[Union[hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase, hwt.hdl.value.HValue]]] = None, virtual_only=False, parentStm: Optional[hwt.hdl.statements.statement.HdlStatement] = None, parentStmList: Optional[hwt.hdl.statements.utils.listOfHdlStatements.ListOfHdlStatement] = None, sensitivity: Optional[hwt.pyUtils.uniqList.UniqList] = None, event_dependent_from_branch: Optional[int] = 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
_input
attribute on this object
-
_cut_off_drivers_of
(sig: hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase)[source]¶ See: hwt.hdl.statements.statement.HdlStatement._cut_off_drivers_of()
-
_discover_enclosure
() → None[source]¶ See: hwt.hdl.statements.statement.HdlStatement._discover_enclosure()
-
_discover_sensitivity
(seen: set) → None[source]¶ See: hwt.hdl.statements.statement.HdlStatement._discover_sensitivity()
-
_fill_enclosure
(enclosure: Dict[hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase, hwt.hdl.statements.statement.HdlStatement])[source]¶ The assignment does not have any uncovered code branches
See: hwt.hdl.statements.statement.HdlStatement._fill_enclosure()
-
_is_mergable
(other: hwt.hdl.statements.statement.HdlStatement) → bool[source]¶ See: hwt.hdl.statements.statement.HdlStatement._is_mergable()
-
_iter_stms
() → Generator[hwt.hdl.statements.statement.HdlStatement, None, None][source]¶ See: hwt.hdl.statements.statement.HdlStatement._iter_stms()
-
_iter_stms_for_output
(output: hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase) → Generator[hwt.hdl.statements.statement.HdlStatement, None, None][source]¶ See: hwt.hdl.statements.statement.HdlStatement._iter_stms_for_output()
-
_on_parent_event_dependent
()[source]¶ See: hwt.hdl.statements.statement.HdlStatement._on_parent_event_dependent()
-
_replace_input_nested
(topStm: hwt.hdl.statements.statement.HdlStatement, toReplace: Union[Tuple[hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase, hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase], Dict[hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase, hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase]]) → None[source]¶ See: hwt.hdl.statements.statement.HdlStatement._replace_input()
-
_try_reduce
() → Tuple[hwt.hdl.statements.utils.listOfHdlStatements.ListOfHdlStatement, bool][source]¶ See: hwt.hdl.statements.statement.HdlStatement._try_reduce()
-
isSame
(other)[source]¶ See: hwt.hdl.statements.statement.HdlStatement.isSame()
hwt.hdl.statements.codeBlockContainer module¶
-
class
hwt.hdl.statements.codeBlockContainer.
HdlStmCodeBlockContainer
[source]¶ Bases:
hwt.hdl.statements.statement.HdlStatement
Hdl 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: hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase)[source]¶ See: hwt.hdl.statements.statement.HdlStatement._cut_off_drivers_of()
-
_iter_stms
() → Generator[hwt.hdl.statements.statement.HdlStatement, None, None][source]¶ See: hwt.hdl.statements.statement.HdlStatement._iter_stms()
-
_iter_stms_for_output
(output: hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase) → Generator[hwt.hdl.statements.statement.HdlStatement, None, None][source]¶ See: hwt.hdl.statements.statement.HdlStatement._iter_stms_for_output()
-
_replace_child_statement
(stm: hwt.hdl.statements.statement.HdlStatement, replacement: hwt.hdl.statements.utils.listOfHdlStatements.ListOfHdlStatement, update_io: bool) → None[source]¶ See: hwt.hdl.statements.statement.HdlStatement._replace_child_statement()
-
_try_reduce
() → Tuple[List[hwt.hdl.statements.statement.HdlStatement], bool][source]¶ See: hwt.hdl.statements.statement.HdlStatement._try_reduce()
hwt.hdl.statements.ifContainter module¶
-
class
hwt.hdl.statements.ifContainter.
IfContainer
(cond: hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase, ifTrue=None, ifFalse=None, elIfs=None, parentStm=None, event_dependent_from_branch: Optional[int] = None)[source]¶ Bases:
hwt.hdl.statements.statement.HdlStatement
Structural container of if statement for hdl rendering
Variables: - _ifTrue_enclosed_for – set of signals for which if ifTrue branch enclosed (has not branch where signal is not assignment)
- _elIfs_enclosed_for – list of sets of enclosed signals for each elif
- _ifFalse_enclosed_for – set of enclosed signals for ifFalse branch
-
_DEEPCOPY_SHALLOW_ONLY
= ('_inputs', '_outputs', '_enclosed_for', '_sensitivity', '_ifTrue_enclosed_for', '_elIfs_enclosed_for', '_ifFalse_enclosed_for')¶
-
_DEEPCOPY_SKIP
= ('parentStm', 'parentStmList', 'cond', 'elIfs')¶
-
__init__
(cond: hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase, ifTrue=None, ifFalse=None, elIfs=None, parentStm=None, event_dependent_from_branch: Optional[int] = None)[source]¶ Parameters: - cond – RtlSignal as conditions for this if
- ifTrue – list of statements which should be active if cond. is met
- elIfs – list of tuples (list of conditions, list of statements)
- ifFalse – list of statements which should be active if cond. and any other cond. in elIfs is met
-
_clean_signal_meta
()[source]¶ See: hwt.hdl.statements.statement.HdlStatement._clean_signal_meta()
-
_collect_inputs
() → None[source]¶ See: hwt.hdl.statements.statement.HdlStatement._collect_inputs()
-
_collect_io
()[source]¶ See: hwt.hdl.statements.statement.HdlStatement._collect_io()
-
_cut_off_drivers_of
(sig: hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase)[source]¶ See: hwt.hdl.statements.statement.HdlStatement._cut_off_drivers_of()
-
_discover_enclosure
()[source]¶ See: hwt.hdl.statements.statement.HdlStatement._discover_enclosure()
-
_discover_sensitivity
(seen: set) → None[source]¶ See: hwt.hdl.statements.statement.HdlStatement._discover_sensitivity()
-
_fill_enclosure
(enclosure: Dict[hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase, Callable[[], hwt.hdl.statements.statement.HdlStatement]]) → None[source]¶ See: hwt.hdl.statements.statement.HdlStatement._fill_enclosure()
-
_is_mergable
(other: hwt.hdl.statements.statement.HdlStatement) → bool[source]¶ See: hwt.hdl.statements.statement.HdlStatement._is_mergable()
-
_iter_all_elifs
() → Generator[Tuple[hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase, hwt.hdl.statements.utils.listOfHdlStatements.ListOfHdlStatement], None, None][source]¶
-
_iter_stms
() → Generator[hwt.hdl.statements.statement.HdlStatement, None, None][source]¶ See: hwt.hdl.statements.statement.HdlStatement._iter_stms()
-
_iter_stms_for_output
(output: hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase) → Generator[hwt.hdl.statements.statement.HdlStatement, None, None][source]¶ See: hwt.hdl.statements.statement.HdlStatement._iter_stms_for_output()
-
_merge_nested_if_from_else
(ifStm: hwt.hdl.statements.ifContainter.IfContainer)[source]¶ Merge nested IfContarner form else branch to this IfContainer as elif and else branches
-
_merge_with_other_stm
(other: hwt.hdl.statements.ifContainter.IfContainer) → None[source]¶ See: hwt.hdl.statements.statement.HdlStatement._merge_with_other_stm()
-
_replace_child_statement
(stm: hwt.hdl.statements.statement.HdlStatement, replacement: hwt.hdl.statements.utils.listOfHdlStatements.ListOfHdlStatement, update_io: bool) → None[source]¶ See: hwt.hdl.statements.statement.HdlStatement._replace_child_statement()
-
_replace_input_nested
(topStm: hwt.hdl.statements.statement.HdlStatement, toReplace: Union[Tuple[hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase, hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase], Dict[hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase, hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase]]) → None[source]¶ See: hwt.hdl.statements.statement.HdlStatement._replace_input()
-
_try_reduce
() → Tuple[bool, hwt.hdl.statements.utils.listOfHdlStatements.ListOfHdlStatement][source]¶ See: hwt.hdl.statements.statement.HdlStatement._try_reduce()
-
isSame
(other: hwt.hdl.statements.statement.HdlStatement) → bool[source]¶ See: hwt.hdl.statements.statement.HdlStatement.isSame()
hwt.hdl.statements.statement module¶
-
class
hwt.hdl.statements.statement.
HdlStatement
(parentStm: Optional[HdlStatement] = None, parentStmList: Optional[ListOfHdlStatement] = None, sensitivity: Optional[hwt.pyUtils.uniqList.UniqList] = None, event_dependent_from_branch: Optional[int] = None)[source]¶ Bases:
hwt.hdl.hdlObject.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 – UniqList 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 – UniqList of output signals for this statement
- _sensitivity – UniqList 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: Optional[HdlStatement] = None, parentStmList: Optional[ListOfHdlStatement] = None, sensitivity: Optional[hwt.pyUtils.uniqList.UniqList] = None, event_dependent_from_branch: Optional[int] = None)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
_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
_input
attribute on this object
-
_collect_io
() → None[source]¶ Collect inputs/outputs from all child statements to
_input
/_output
attribute on this object
-
_collect_outputs
() → None[source]¶ Collect inputs from all child statements to
_output
attribute on this object
-
_cut_off_drivers_of
(sig: hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase) → Union[None, hwt.hdl.statements.statement.HdlStatement, List[hwt.hdl.statements.statement.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: hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase, cut_of_smt: hwt.hdl.statements.statement.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[hwt.synthesizer.rtlLevel.mainBases.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
-
_iter_stms_for_output
(output: hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase) → Generator[hwt.hdl.statements.statement.HdlStatement, None, None][source]¶ Returns: iterator of sub statements which have specified output as an output
-
_merge_with_other_stm
(other: hwt.hdl.statements.statement.HdlStatement) → None[source]¶ Attention: statements has to be mergable (to check use _is_mergable method)
-
_on_merge
(other: hwt.hdl.statements.statement.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: hwt.hdl.statements.statement.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: Union[Tuple[hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase, hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase], Dict[hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase, hwt.synthesizer.rtlLevel.mainBases.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: hwt.hdl.statements.statement.HdlStatement, toReplace: Union[Tuple[hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase, hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase], Dict[hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase, hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase]]) → None[source]¶
-
_replace_input_update_sensitivity_and_inputs
(toReplace: Union[Tuple[hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase, hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase], Dict[hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase, hwt.synthesizer.rtlLevel.mainBases.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: hwt.synthesizer.rtlLevel.mainBases.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
hwt.hdl.statements.switchContainer module¶
-
class
hwt.hdl.statements.switchContainer.
SwitchContainer
(switchOn: hwt.synthesizer.rtlLevel.rtlSignal.RtlSignal, cases: List[Tuple[hwt.hdl.value.HValue, hwt.hdl.statements.utils.listOfHdlStatements.ListOfHdlStatement]], default: Optional[hwt.hdl.statements.utils.listOfHdlStatements.ListOfHdlStatement] = None, parentStm: hwt.hdl.statements.statement.HdlStatement = None, event_dependent_from_branch: Optional[int] = None)[source]¶ Bases:
hwt.hdl.statements.statement.HdlStatement
Structural container for switch statement for hdl rendering
Variables: - switchOn – select signal of switch
- cases – list of tuples (value, statements)
- default – list of statements (for branch “default”)
- _case_value_index – dictionary {value:index} for every case in cases
- _case_enclosed_for – list of sets of enclosed signal for each case branch
- _default_enclosed_for – set of enclosed signals for branch default
-
_DEEPCOPY_SHALLOW_ONLY
= ('_inputs', '_outputs', '_enclosed_for', '_sensitivity', '_case_value_index', '_case_enclosed_for', '_default_enclosed_for')¶
-
_DEEPCOPY_SKIP
= ('parentStm', 'parentStmList', 'switchOn', 'cases')¶
-
__init__
(switchOn: hwt.synthesizer.rtlLevel.rtlSignal.RtlSignal, cases: List[Tuple[hwt.hdl.value.HValue, hwt.hdl.statements.utils.listOfHdlStatements.ListOfHdlStatement]], default: Optional[hwt.hdl.statements.utils.listOfHdlStatements.ListOfHdlStatement] = None, parentStm: hwt.hdl.statements.statement.HdlStatement = None, event_dependent_from_branch: Optional[int] = None)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
_clean_signal_meta
()[source]¶ See: hwt.hdl.statements.statement.HdlStatement._clean_signal_meta()
-
_collect_inputs
() → None[source]¶ See: hwt.hdl.statements.statement.HdlStatement._collect_inputs()
-
_collect_io
()[source]¶ See: hwt.hdl.statements.statement.HdlStatement._collect_io()
-
_cut_off_drivers_of
(sig: hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase)[source]¶ See: hwt.hdl.statements.statement.HdlStatement._cut_off_drivers_of()
-
_discover_enclosure
() → None[source]¶ See: hwt.hdl.statements.statement.HdlStatement._discover_enclosure()
-
_discover_sensitivity
(seen) → None[source]¶ See: hwt.hdl.statements.statement.HdlStatement._discover_sensitivity()
-
_fill_enclosure
(enclosure: Dict[hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase, Callable[[], hwt.hdl.statements.statement.HdlStatement]]) → None[source]¶ See: hwt.hdl.statements.statement.HdlStatement._fill_enclosure()
-
_is_mergable
(other) → bool[source]¶ See: hwt.hdl.statements.statement.HdlStatement._is_mergable()
-
_iter_stms
() → Generator[hwt.hdl.statements.statement.HdlStatement, None, None][source]¶ See: hwt.hdl.statements.statement.HdlStatement._iter_stms()
-
_iter_stms_for_output
(output: hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase) → Generator[hwt.hdl.statements.statement.HdlStatement, None, None][source]¶ See: hwt.hdl.statements.statement.HdlStatement._iter_stms_for_output()
-
_merge_with_other_stm
(other: hwt.hdl.statements.switchContainer.SwitchContainer) → None[source]¶ See: hwt.hdl.statements.statement.HdlStatement._merge_with_other_stm()
-
_replace_child_statement
(stm: hwt.hdl.statements.statement.HdlStatement, replacement: hwt.hdl.statements.utils.listOfHdlStatements.ListOfHdlStatement, update_io: bool) → None[source]¶ See: hwt.hdl.statements.statement.HdlStatement._replace_child_statement()
-
_replace_input_nested
(topStm: hwt.hdl.statements.statement.HdlStatement, toReplace: Union[Tuple[hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase, hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase], Dict[hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase, hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase]]) → None[source]¶ See: hwt.hdl.statements.statement.HdlStatement._replace_input()
-
_try_reduce
() → Tuple[List[hwt.hdl.statements.statement.HdlStatement], bool][source]¶ See: hwt.hdl.statements.statement.HdlStatement._try_reduce()
-
isSame
(other: hwt.hdl.statements.statement.HdlStatement) → bool[source]¶ See: hwt.hdl.statements.statement.HdlStatement.isSame()