hwt.serializer.generic package

This package contains common parts of serializers.

Submodules

hwt.serializer.generic.constant_cache module

class hwt.serializer.generic.constant_cache.ConstantCache(toHdlAst, tmpVars: hwt.serializer.generic.tmpVarConstructor.TmpVarConstructor)[source]

Bases: object

Container of constants for serializer. Used to extract constants as constant variables.

__init__(toHdlAst, tmpVars: hwt.serializer.generic.tmpVarConstructor.TmpVarConstructor)[source]

Initialize self. See help(type(self)) for accurate signature.

extract_const_val_as_const_var(val) → hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase[source]

Create a constant variable with a value specified or use existitng variable with same value

hwt.serializer.generic.indent module

hwt.serializer.generic.indent.getIndent(indentNum)[source]

Cached indent getter function

hwt.serializer.generic.ops module

hwt.serializer.generic.tmpVarConstructor module

class hwt.serializer.generic.tmpVarConstructor.NoTmpVars[source]

Bases: object

create_cached(suggestedName, dtype, *args, **kwargs)[source]
create_var_cached(suggestedName, dtype, *args, **kwargs)[source]
class hwt.serializer.generic.tmpVarConstructor.TmpVarConstructor(toHdlAst, name_scope: hdlConvertorAst.translate.common.name_scope.NameScope)[source]

Bases: object

__init__(toHdlAst, name_scope: hdlConvertorAst.translate.common.name_scope.NameScope)[source]

Initialize self. See help(type(self)) for accurate signature.

create_var(suggestedName: str, dtype: hwt.hdl.types.hdlType.HdlType, const=False, def_val: Union[hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase, hwt.hdl.value.HValue, None] = None, postponed_init=False) → hwt.synthesizer.rtlLevel.rtlSignal.RtlSignal[source]
create_var_cached(suggestedName: str, dtype: hwt.hdl.types.hdlType.HdlType, const=False, def_val: Union[hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase, hwt.hdl.value.HValue, None] = None, postponed_init=False, extra_args=None) → Tuple[bool, hwt.synthesizer.rtlLevel.rtlSignal.RtlSignal][source]
finish_var_init(var: hwt.synthesizer.rtlLevel.rtlSignal.RtlSignal)[source]
sort_hdl_declarations_first()[source]

hwt.serializer.generic.to_hdl_ast module

class hwt.serializer.generic.to_hdl_ast.ToHdlAst(name_scope: Optional[hdlConvertorAst.translate.common.name_scope.NameScope] = None)[source]

Bases: object

Base class for translators which translates hwt AST to a HDL ast

Variables:
  • name_scope – name scope for resolution of hdl names for objects and for name colision checking for newly generated objects
  • tmpVars – A object which is used to create a tmp variable in current scope. It is set if it is possible to create a tmp variable.
  • constCache – A ConstCache instance used o extract values as a constants.
ALL_STATEMENT_CLASSES = [<class 'hdlConvertorAst.hdlAst._statements.HdlStmNop'>, <class 'hdlConvertorAst.hdlAst._statements.HdlStmBlock'>, <class 'hdlConvertorAst.hdlAst._statements.HdlStmAssign'>, <class 'hdlConvertorAst.hdlAst._statements.HdlStmIf'>, <class 'hdlConvertorAst.hdlAst._statements.HdlStmProcess'>, <class 'hdlConvertorAst.hdlAst._statements.HdlStmCase'>, <class 'hdlConvertorAst.hdlAst._statements.HdlStmFor'>, <class 'hdlConvertorAst.hdlAst._statements.HdlStmForIn'>, <class 'hdlConvertorAst.hdlAst._statements.HdlStmWhile'>, <class 'hdlConvertorAst.hdlAst._statements.HdlStmRepeat'>, <class 'hdlConvertorAst.hdlAst._statements.HdlStmReturn'>, <class 'hdlConvertorAst.hdlAst._statements.HdlStmWait'>, <class 'hdlConvertorAst.hdlAst._statements.HdlStmBreak'>, <class 'hdlConvertorAst.hdlAst._statements.HdlStmContinue'>, <class 'hdlConvertorAst.hdlAst._statements.HdlStmThrow'>, <class 'hwt.hdl.statements.codeBlockContainer.HdlStmCodeBlockContainer'>]
TMP_VAR_CONSTRUCTOR

alias of hwt.serializer.generic.tmpVarConstructor.TmpVarConstructor

__init__(name_scope: Optional[hdlConvertorAst.translate.common.name_scope.NameScope] = None)[source]

Initialize self. See help(type(self)) for accurate signature.

_as_hdl_HdlAssignmentContainer_auto_conversions(a: hwt.hdl.statements.assignmentContainer.HdlAssignmentContainer)[source]
_as_hdl_HdlModuleDef(new_m: hdlConvertorAst.hdlAst._structural.HdlModuleDef) → hdlConvertorAst.hdlAst._structural.HdlModuleDef[source]
_as_hdl_HdlModuleDef_body(new_m, types, hdl_types, hdl_variables, extraVars: hwt.serializer.generic.tmpVarConstructor.TmpVarConstructor, processes: List[hdlConvertorAst.hdlAst._bases.iHdlStatement], component_insts: List[hdlConvertorAst.hdlAst._structural.HdlCompInst], others: List[Union[hdlConvertorAst.hdlAst._expr.HdlOp, hdlConvertorAst.hdlAst._bases.iHdlStatement]])[source]
_as_hdl_HdlModuleDef_param_asserts(new_m: hdlConvertorAst.hdlAst._structural.HdlModuleDec) → List[hdlConvertorAst.hdlAst._bases.iHdlStatement][source]
_as_hdl_HdlModuleDef_param_asserts_real(new_m: hdlConvertorAst.hdlAst._structural.HdlModuleDec) → List[hdlConvertorAst.hdlAst._bases.iHdlStatement][source]
_keywords_dict = {}
_static_assert_false(msg: str)[source]
_static_assert_symbol_eq(symbol_name: str, v)[source]
as_hdl(obj) → hdlConvertorAst.hdlAst._bases.iHdlObj[source]

Convert any object to HDL AST

Parameters:obj – object to convert
as_hdl_FsmBuilder(*args, **kwargs) → hdlConvertorAst.hdlAst._statements.HdlStmCase[source]
as_hdl_GenericItem(o: hdlConvertorAst.hdlAst._defs.HdlIdDef)[source]
as_hdl_HdlAssignmentContainer(a: hwt.hdl.statements.assignmentContainer.HdlAssignmentContainer)[source]
as_hdl_HdlCompInst(o: hdlConvertorAst.hdlAst._structural.HdlCompInst) → hdlConvertorAst.hdlAst._structural.HdlCompInst[source]
as_hdl_HdlModuleDec(o: hdlConvertorAst.hdlAst._structural.HdlModuleDec)[source]
as_hdl_HdlModuleDef(o: hdlConvertorAst.hdlAst._structural.HdlModuleDef) → hdlConvertorAst.hdlAst._structural.HdlModuleDef[source]
as_hdl_HdlModuleDef_variable(v, types, hdl_types, hdl_variables, processes, component_insts)[source]
as_hdl_HdlPortItem(o: hwt.hdl.portItem.HdlPortItem)[source]
as_hdl_HdlStmCodeBlockContainer(proc: hwt.hdl.statements.codeBlockContainer.HdlStmCodeBlockContainer) → hdlConvertorAst.hdlAst._bases.iHdlStatement[source]

Serialize HdlStmCodeBlockContainer objects as process if top statement

as_hdl_HdlType(typ: hwt.hdl.types.hdlType.HdlType, declaration=False)[source]
as_hdl_HdlType_array(typ: hwt.hdl.types.array.HArray, declaration=False)[source]
as_hdl_HdlType_enum(typ: hwt.hdl.types.enum.HEnum, declaration=False)[source]
as_hdl_HdlType_slice(typ: hwt.hdl.types.slice.HSlice, declaration=False)[source]
as_hdl_If(*args, **kwargs) → hdlConvertorAst.hdlAst._statements.HdlStmIf[source]
as_hdl_IfContainer(ifc: hwt.hdl.statements.ifContainter.IfContainer) → hdlConvertorAst.hdlAst._statements.HdlStmIf[source]
as_hdl_PortConnection(o: hwt.hdl.portItem.HdlPortItem)[source]
as_hdl_Switch(*args, **kwargs) → hdlConvertorAst.hdlAst._statements.HdlStmCase[source]
as_hdl_SwitchContainer(sw: hwt.hdl.statements.switchContainer.SwitchContainer) → hdlConvertorAst.hdlAst._statements.HdlStmCase[source]
as_hdl_cond(v, force_bool) → Union[hdlConvertorAst.hdlAst._expr.HdlValueId, hdlConvertorAst.hdlAst._expr.HdlValueInt, float, str, None, List[Union[hdlConvertorAst.hdlAst._expr.HdlValueId, hdlConvertorAst.hdlAst._expr.HdlValueInt, float, str, None, List[iHdlExpr], hdlConvertorAst.hdlAst._expr.HdlAll, hdlConvertorAst.hdlAst._expr.HdlOp]], hdlConvertorAst.hdlAst._expr.HdlAll, hdlConvertorAst.hdlAst._expr.HdlOp][source]
as_hdl_statements(stm_list) → hdlConvertorAst.hdlAst._bases.iHdlStatement[source]
can_pop_process_wrap(statements, hasToBeVhdlProcess)[source]
does_type_requires_extra_def(t: hwt.hdl.types.hdlType.HdlType, other_types: list)[source]
classmethod getBaseNameScope()[source]

Get root of name space

has_to_be_process(proc: hdlConvertorAst.hdlAst._bases.iHdlStatement)[source]

hwt.serializer.generic.utils module

class hwt.serializer.generic.utils.TmpVarsSwap(ctx, tmpVars)[source]

Bases: object

An object which is used as a context manager for tmpVars inside of ToHdlAst

__init__(ctx, tmpVars)[source]

Initialize self. See help(type(self)) for accurate signature.

hwt.serializer.generic.value module

class hwt.serializer.generic.value.ToHdlAst_Value[source]

Bases: object

Value_try_extract_as_const(val)[source]
as_hdl_BitsVal(val)[source]
as_hdl_HFloatVal(val)[source]
as_hdl_HStringVal(val)[source]
as_hdl_IntegerVal(val)[source]
as_hdl_SignalItem(si: Union[hwt.hdl.variables.SignalItem, hdlConvertorAst.hdlAst._defs.HdlIdDef], declaration=False)[source]
as_hdl_Value(val)[source]
Parameters:
  • dst – is signal connected with value
  • val – value object, can be instance of Signal or HValue
as_hdl_int(val: int)[source]
is_suitable_for_const_extract(val: hwt.hdl.value.HValue)[source]
Returns:True if an value should be extracted as a constant if possible