hwt.hdl package¶
This package contains classes for representation of HDL languages (hdl types, RtlSignal, HdlAssignmentContainer, HdlStmCodeBlockContainer etc.).
It also contains classes for representation of complex HW structures like dense transaction template (TransTmpl, FrameTmpl).
Subpackages¶
- hwt.hdl.statements package
- Subpackages
- Submodules
- hwt.hdl.statements.assignmentContainer module
HdlAssignmentContainerHdlAssignmentContainer._DEEPCOPY_SHALLOW_ONLYHdlAssignmentContainer._DEEPCOPY_SKIPHdlAssignmentContainer.__init__()HdlAssignmentContainer._collect_inputs()HdlAssignmentContainer._cut_off_drivers_of()HdlAssignmentContainer._discover_enclosure()HdlAssignmentContainer._discover_sensitivity()HdlAssignmentContainer._fill_enclosure()HdlAssignmentContainer._is_mergable()HdlAssignmentContainer._iter_stms()HdlAssignmentContainer._iter_stms_for_output()HdlAssignmentContainer._nextInstId()HdlAssignmentContainer._on_parent_event_dependent()HdlAssignmentContainer._replace_input_nested()HdlAssignmentContainer._try_reduce()HdlAssignmentContainer.isSame()
- hwt.hdl.statements.codeBlockContainer module
HdlStmCodeBlockContainerHdlStmCodeBlockContainer.__init__()HdlStmCodeBlockContainer._cut_off_drivers_of()HdlStmCodeBlockContainer._iter_stms()HdlStmCodeBlockContainer._iter_stms_for_output()HdlStmCodeBlockContainer._replace_child_statement()HdlStmCodeBlockContainer._try_reduce()HdlStmCodeBlockContainer.from_known_io()
- hwt.hdl.statements.ifContainter module
- hwt.hdl.statements.statement module
HdlStatementHdlStatement._DEEPCOPY_SHALLOW_ONLYHdlStatement._DEEPCOPY_SKIPHdlStatement.__init__()HdlStatement._clean_signal_meta()HdlStatement._collect_inputs()HdlStatement._collect_io()HdlStatement._collect_outputs()HdlStatement._cut_off_drivers_of()HdlStatement._cut_off_drivers_of_regenerate_io()HdlStatement._destroy()HdlStatement._discover_enclosure()HdlStatement._discover_sensitivity()HdlStatement._fill_enclosure()HdlStatement._get_rtl_context()HdlStatement._is_enclosed()HdlStatement._is_mergable()HdlStatement._iter_stms()HdlStatement._iter_stms_for_output()HdlStatement._merge_with_other_stm()HdlStatement._on_merge()HdlStatement._on_parent_event_dependent()HdlStatement._on_reduce()HdlStatement._register_stements()HdlStatement._replace_child_statement()HdlStatement._replace_input()HdlStatement._replace_input_nested()HdlStatement._replace_input_update_sensitivity_and_inputs()HdlStatement._set_parent_stm()HdlStatement._try_cut_off_whole_stm()HdlStatement._try_reduce()HdlStatement.isSame()
HwtSyntaxError
- hwt.hdl.statements.switchContainer module
- hwt.hdl.types package
- Casting rules
- Submodules
- hwt.hdl.types.array module
- hwt.hdl.types.arrayCast module
- hwt.hdl.types.arrayConst module
HArrayConstHArrayRtlSignalHArrayRtlSignal._constHArrayRtlSignal._ctxHArrayRtlSignal._hasGenericNameHArrayRtlSignal._hdlNameHArrayRtlSignal._hwIOHArrayRtlSignal._instIdHArrayRtlSignal._isUnnamedExprHArrayRtlSignal._nop_valHArrayRtlSignal._rtlDriversHArrayRtlSignal._rtlEndpointsHArrayRtlSignal._rtlNextSigHArrayRtlSignal._rtlObjectOriginHArrayRtlSignal._usedOpsHArrayRtlSignal._usedOpsAlias
_HArrayGetitem()
- hwt.hdl.types.bitConstFunctions module
HBits_auto_cast_operands_to_same_type()HBits_common_operand_type_checks()HBits_common_operand_type_checks_for_other()HBits_common_operand_type_checks_for_self()_bitsMulModGetResultType()bitsArithOp()bitsBitOp()bitsCmp()bitsCmp_detect_useless_cmp()bitsFloordiv()bitsIsOn()bitsLshift()bitsMul()bitsRem()bitsRshift()extractNegation()
- hwt.hdl.types.bitConstFunctionsGetitem module
- hwt.hdl.types.bitConst_opReduce module
- hwt.hdl.types.bits module
HBitsHBits.__init__()HBits._constClsHBits._createMutated()HBits.differs_only_in_strictness_flags()HBits.domain_size()HBits.getAllOnesValue()HBits.getConstCls()HBits.getRtlSignalCls()HBits.get_auto_cast_HConst_fn()HBits.get_auto_cast_RtlSignal_fn()HBits.get_explicit_cast_HConst_fn()HBits.get_explicit_cast_RtlSignal_fn()HBits.get_reinterpret_cast_HConst_fn()HBits.get_reinterpret_cast_RtlSignal_fn()
- hwt.hdl.types.bitsCast module
- hwt.hdl.types.bitsCastUtils module
- hwt.hdl.types.bitsConst module
HBitsConstHBitsConst._BOOLHBitsConst._SIGNED_FOR_CONCAT_RESULTHBitsConst._SIGNED_FOR_SLICE_RESULTHBitsConst._cast_sign()HBitsConst._concat()HBitsConst._dtypeHBitsConst._eq()HBitsConst._isOn()HBitsConst._signed()HBitsConst._ternary()HBitsConst._unsigned()HBitsConst._vec()HBitsConst.from_py()HBitsConst.getMsb()HBitsConst.prettyRepr()HBitsConst.to_py()HBitsConst.valHBitsConst.vld_mask
- hwt.hdl.types.bitsRtlSignal module
HBitsRtlSignalHBitsRtlSignal._cast_sign()HBitsRtlSignal._concat()HBitsRtlSignal._constHBitsRtlSignal._ctxHBitsRtlSignal._eq()HBitsRtlSignal._ext()HBitsRtlSignal._extOrTrunc()HBitsRtlSignal._hasGenericNameHBitsRtlSignal._hdlNameHBitsRtlSignal._hwIOHBitsRtlSignal._instIdHBitsRtlSignal._isOn()HBitsRtlSignal._isUnnamedExprHBitsRtlSignal._nop_valHBitsRtlSignal._onFallingEdge()HBitsRtlSignal._onRisingEdge()HBitsRtlSignal._rtlDriversHBitsRtlSignal._rtlEndpointsHBitsRtlSignal._rtlNextSigHBitsRtlSignal._rtlObjectOriginHBitsRtlSignal._sext()HBitsRtlSignal._signed()HBitsRtlSignal._ternary()HBitsRtlSignal._trunc()HBitsRtlSignal._unsigned()HBitsRtlSignal._usedOpsHBitsRtlSignal._usedOpsAliasHBitsRtlSignal._vec()HBitsRtlSignal._zext()HBitsRtlSignal.getMsb()
- hwt.hdl.types.defs module
- hwt.hdl.types.enum module
- hwt.hdl.types.enumConst module
HEnumConstHEnumRtlSignalHEnumRtlSignal._constHEnumRtlSignal._ctxHEnumRtlSignal._eq()HEnumRtlSignal._hasGenericNameHEnumRtlSignal._hdlNameHEnumRtlSignal._hwIOHEnumRtlSignal._instIdHEnumRtlSignal._isUnnamedExprHEnumRtlSignal._nop_valHEnumRtlSignal._rtlDriversHEnumRtlSignal._rtlEndpointsHEnumRtlSignal._rtlNextSigHEnumRtlSignal._rtlObjectOriginHEnumRtlSignal._usedOpsHEnumRtlSignal._usedOpsAlias
- hwt.hdl.types.float module
- hwt.hdl.types.floatConst module
HFloatConstHFloatRtlSignalHFloatRtlSignal._constHFloatRtlSignal._ctxHFloatRtlSignal._eq()HFloatRtlSignal._hasGenericNameHFloatRtlSignal._hdlNameHFloatRtlSignal._hwIOHFloatRtlSignal._instIdHFloatRtlSignal._isUnnamedExprHFloatRtlSignal._nop_valHFloatRtlSignal._rtlDriversHFloatRtlSignal._rtlEndpointsHFloatRtlSignal._rtlNextSigHFloatRtlSignal._rtlObjectOriginHFloatRtlSignal._usedOpsHFloatRtlSignal._usedOpsAlias
_HFloatEq()
- hwt.hdl.types.function module
- hwt.hdl.types.hdlType module
HdlTypeHdlType._PRECOMPUTE_CONSTANT_SIGNALSHdlType.__init__()HdlType._as_hdl()HdlType._as_hdl_requires_def()HdlType._from_py()HdlType._reverse_auto_cast_HConst()HdlType._reverse_auto_cast_RtlSignal()HdlType._reverse_explicit_cast_HConst()HdlType._reverse_explicit_cast_RtlSignal()HdlType._reverse_reinterpret_cast_HConst()HdlType._reverse_reinterpret_cast_RtlSignal()HdlType.auto_cast_HConst()HdlType.auto_cast_RtlSignal()HdlType.explicit_cast_HConst()HdlType.explicit_cast_RtlSignal()HdlType.from_py()HdlType.getConstCls()HdlType.getRtlSignalCls()HdlType.get_auto_cast_HConst_fn()HdlType.get_auto_cast_RtlSignal_fn()HdlType.get_explicit_cast_HConst_fn()HdlType.get_explicit_cast_RtlSignal_fn()HdlType.get_reinterpret_cast_HConst_fn()HdlType.get_reinterpret_cast_RtlSignal_fn()HdlType.get_reverse_auto_cast_HConst_fn()HdlType.get_reverse_auto_cast_RtlSignal_fn()HdlType.get_reverse_explicit_cast_HConst_fn()HdlType.get_reverse_explicit_cast_RtlSignal_fn()HdlType.get_reverse_reinterpret_cast_HConst_fn()HdlType.get_reverse_reinterpret_cast_RtlSignal_fn()HdlType.isScalar()HdlType.reinterpret_cast_HConst()HdlType.reinterpret_cast_RtlSignal()
MethodNotOverloadeddefault_auto_cast_fn()default_explicit_cast_fn()default_reinterpret_cast_fn()default_reverse_auto_cast_fn()default_reverse_explicit_cast_fn()default_reverse_reinterpret_cast_fn()
- hwt.hdl.types.slice module
- hwt.hdl.types.sliceConst module
HSliceConstHSliceRtlSignalHSliceRtlSignal._constHSliceRtlSignal._ctxHSliceRtlSignal._hasGenericNameHSliceRtlSignal._hdlNameHSliceRtlSignal._hwIOHSliceRtlSignal._instIdHSliceRtlSignal._isUnnamedExprHSliceRtlSignal._nop_valHSliceRtlSignal._rtlDriversHSliceRtlSignal._rtlEndpointsHSliceRtlSignal._rtlNextSigHSliceRtlSignal._rtlObjectOriginHSliceRtlSignal._usedOpsHSliceRtlSignal._usedOpsAlias
slice_member_to_HConst()
- hwt.hdl.types.sliceUtils module
- hwt.hdl.types.stream module
- hwt.hdl.types.streamConst module
- hwt.hdl.types.string module
- hwt.hdl.types.stringConst module
HStringConstHStringRtlSignalHStringRtlSignal._constHStringRtlSignal._ctxHStringRtlSignal._eq()HStringRtlSignal._hasGenericNameHStringRtlSignal._hdlNameHStringRtlSignal._hwIOHStringRtlSignal._instIdHStringRtlSignal._isUnnamedExprHStringRtlSignal._nop_valHStringRtlSignal._rtlDriversHStringRtlSignal._rtlEndpointsHStringRtlSignal._rtlNextSigHStringRtlSignal._rtlObjectOriginHStringRtlSignal._usedOpsHStringRtlSignal._usedOpsAlias
- hwt.hdl.types.struct module
- hwt.hdl.types.structCast module
- hwt.hdl.types.structUtils module
- hwt.hdl.types.structValBase module
- hwt.hdl.types.typeCast module
- hwt.hdl.types.union module
- hwt.hdl.types.utils module
Submodules¶
hwt.hdl.commonConstants module¶
hwt.hdl.const module¶
- class hwt.hdl.const.HConst(dtype: HdlType, val, vld_mask)[source]¶
Bases:
Generic[T]Wrap around hdl value with overloaded operators
operators are overloaded in every type separately
- __init__(dtype: HdlType, val, vld_mask)[source]¶
- Parameters:
val – pythonic value representing this value
dtype – data type object from which this value was derived from
vld_mask – validity mask for value
- _auto_cast(toType: HdlType)[source]¶
Cast value or signal of this type to another compatible type.
- Parameters:
toType – instance of HdlType to cast into
- _dtype¶
- _explicit_cast(toType: HdlType)[source]¶
Cast value or signal of this type to another friendly type.
- Parameters:
toType – instance of HdlType to cast into
- classmethod _from_py(typeObj, val, vld_mask) Self[source]¶
from_py without value normalization and type checking
- _reinterpret_cast(toType: HdlType)[source]¶
Cast value or signal of this type to another type of same size.
- Parameters:
toType – instance of HdlType to cast into
- _walk_sensitivity(casualSensitivity: Set[RtlSignalBase], seen: Set[RtlSignalBase], ctx: SensitivityCtx)[source]¶
- val¶
- vld_mask¶
hwt.hdl.constUtils module¶
hwt.hdl.frameTmpl module¶
hwt.hdl.frameTmplUtils module¶
hwt.hdl.hdlObject module¶
hwt.hdl.operator module¶
- class hwt.hdl.operator.HOperatorNode(operator: HOperatorDef, operands: Tuple[RtlSignalBase | HConst])[source]¶
Bases:
HdlObjectClass of operator in expression tree
- Variables:
~.operands – list of operands
~.evalFn – function to evaluate this operator
~.operator – HOperatorDef instance
~.result – result signal of this operator
- __init__(operator: HOperatorDef, operands: Tuple[RtlSignalBase | HConst])[source]¶
- _replace_input(inp: RtlSignal, replacement: RtlSignal)[source]¶
Replace operand signal (non-recursively)
- Attention:
costly operation because all records in operand cache for all inputs may be potentially updated
- _walk_public_drivers(seen: set) Generator[RtlSignal, None, None][source]¶
Walk all non hidden signals in an expression
- _walk_sensitivity(casualSensitivity: Set[RtlSignal], seen: Set[RtlSignal], ctx: SensitivityCtx)[source]¶
- static withRes(opDef: HOperatorDef, operands: Sequence[RtlSignalBase | HConst], resT: HdlType)[source]¶
Create operator with result signal
- Variables:
~.resT – data type of result signal
~.outputs – iterable of signals which are outputs from this operator
- hwt.hdl.operator.isConst(item: HConst | RtlSignalBase)[source]¶
- Returns:
True if expression is constant
hwt.hdl.operatorDefs module¶
- class hwt.hdl.operatorDefs.HOperatorDef(evalFn, allowsAssignTo=False, idStr: str | None = None, hdlConvertoAstOp: HdlOpType | None = None)[source]¶
Bases:
objectOperator definition
- Variables:
~.id – name of operator
~._evalFn – function which evaluates operands
~.hdlConvertoAstOp – an operator which is used for export to hdlConvertoAst library
- class hwt.hdl.operatorDefs.HwtOps[source]¶
Bases:
object- Attention:
Remember that and operator “and” is & and “or” is |, “and” and “or” can not be used because they can not be overloaded
- Attention:
These are operators of internal AST, they are not equal to verilog or vhdl operators
- ADD = <HOperatorDef ADD>¶
- AND = <HOperatorDef AND>¶
- BitsAsSigned = <HOperatorDef BitsAsSigned>¶
- BitsAsUnsigned = <HOperatorDef BitsAsUnsigned>¶
- BitsAsVec = <HOperatorDef BitsAsVec>¶
- BitsFlagCast = <HOperatorDef BitsFlagCast>¶
- CALL = <HOperatorDef CALL>¶
- CONCAT = <HOperatorDef CONCAT>¶
- DIV = <HOperatorDef DIV>¶
- DOT = <HOperatorDef DOT>¶
- DOWNTO = <HOperatorDef DOWNTO>¶
- EQ = <HOperatorDef EQ>¶
- FALLING_EDGE = <HOperatorDef FALLING_EDGE>¶
- GE = <HOperatorDef GE>¶
- GT = <HOperatorDef GT>¶
- INDEX = <HOperatorDef INDEX>¶
- LE = <HOperatorDef LE>¶
- LT = <HOperatorDef LT>¶
- MINUS_UNARY = <HOperatorDef MINUS_UNARY>¶
- MUL = <HOperatorDef MUL>¶
- NE = <HOperatorDef NE>¶
- NOT = <HOperatorDef NOT>¶
- OR = <HOperatorDef OR>¶
- POW = <HOperatorDef POW>¶
- RISING_EDGE = <HOperatorDef RISING_EDGE>¶
- SDIV = <HOperatorDef SDIV>¶
- SEXT = <HOperatorDef SEXT>¶
- SGE = <HOperatorDef SGE>¶
- SGT = <HOperatorDef SGT>¶
- SLE = <HOperatorDef SLE>¶
- SLT = <HOperatorDef SLT>¶
- SREM = <HOperatorDef SREM>¶
- SUB = <HOperatorDef SUB>¶
- TERNARY = <HOperatorDef TERNARY>¶
- TO = <HOperatorDef TO>¶
- TRUNC = <HOperatorDef TRUNC>¶
- UDIV = <HOperatorDef UDIV>¶
- UGE = <HOperatorDef UGE>¶
- UGT = <HOperatorDef UGT>¶
- ULE = <HOperatorDef ULE>¶
- ULT = <HOperatorDef ULT>¶
- UREM = <HOperatorDef UREM>¶
- XOR = <HOperatorDef XOR>¶
- ZEXT = <HOperatorDef ZEXT>¶
hwt.hdl.operatorUtils module¶
- hwt.hdl.operatorUtils._replace_input_in_expr(expr: RtlSignalBase | HConst, toReplace: Tuple[RtlSignalBase, RtlSignalBase] | Dict[RtlSignalBase, RtlSignalBase]) RtlSignalBase[source]¶
- Returns:
newly rewritten expression with the subexpression replaced, True if changed else False
- hwt.hdl.operatorUtils.replace_input_in_expr(topStatement: HdlStatement, parentStm: HdlStatement, expr: RtlSignalBase | HConst, toReplace: Tuple[RtlSignalBase, RtlSignalBase] | Dict[RtlSignalBase, RtlSignalBase]) Tuple[RtlSignalBase, bool][source]¶
- Returns:
tuple (newExpression, True if expr is toReplace and should be replaced else False)
hwt.hdl.portItem module¶
- class hwt.hdl.portItem.HdlPortItem(name: str, direction: DIRECTION, dtype: HdlType, module: HwModule)[source]¶
Bases:
objectHDL entity/module/component port item Used to split signal paths on component boundary.
- Note:
src/dst are named based on input output signal direction both dst and src can be parent/component signal, it depends on direction
- _walk_sensitivity(casualSensitivity: set, seen: set, ctx: SensitivityCtx)[source]¶
- connectInternSig(signal)[source]¶
Connect signal from internal side of of this component to this port.
- connectOuterSig(signal: RtlSignalBase)[source]¶
Connect to port item on submodule
- classmethod fromSignal(s: HdlSignalItem, component, d: DIRECTION)[source]¶
hwt.hdl.sensitivityCtx module¶
hwt.hdl.transPart module¶
hwt.hdl.transTmpl module¶
hwt.hdl.variables module¶
- class hwt.hdl.variables.HdlSignalItem(name: str, dtype: HdlType, def_val=None, virtual_only=False)[source]¶
Bases:
HdlObjectBasic hdl signal used to design circuits
- __init__(name: str, dtype: HdlType, def_val=None, virtual_only=False)[source]¶
- Parameters:
_name – name for better orientation in netlists (used only in serialization)
dtype – data type of this signal
def_val – value for initialization
virtual_only – flag indicates that this assignments is only virtual and should not be added into netlist, because it is only for internal notation
- _dtype¶
- _name¶
- def_val¶
- virtual_only¶