hwt.serializer.hwt package

Hwt serializer converts HDL objects back to code in python for hwt.

class hwt.serializer.hwt.HwtDebugSerializer[source]

Bases: hwt.serializer.serializer_config.DummySerializerConfig

TO_HDL

alias of hdlConvertorAst.to.hwt._main.ToHwt

TO_HDL_AST

alias of ToHdlAstDebugHwt

fileExtension = '.py'
class hwt.serializer.hwt.HwtSerializer[source]

Bases: hwt.serializer.serializer_config.DummySerializerConfig

TO_HDL

alias of hdlConvertorAst.to.hwt._main.ToHwt

TO_HDL_AST

alias of hwt.serializer.hwt.serializer.ToHdlAstHwt

fileExtension = '.py'
class hwt.serializer.hwt.ToHdlAstDebugHwt(name_scope: Optional[hdlConvertorAst.translate.common.name_scope.NameScope] = None)[source]

Bases: hwt.serializer.hwt.serializer.ToHdlAstHwt

as_hdl(obj) → hdlConvertorAst.hdlAst._bases.iHdlObj[source]

Convert any object to HDL AST

Parameters:obj – object to convert

Submodules

hwt.serializer.hwt.context module

class hwt.serializer.hwt.context.ValueWidthRequirementScope(ctx, val)[source]

Bases: object

Context manager which temporarily swaps the _valueWidthRequired on specified context

with ValueWidthRequirementScope(ctx, True):
    #...
__init__(ctx, val)[source]

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

hwt.serializer.hwt.ops module

class hwt.serializer.hwt.ops.ToHdlAstHwt_ops[source]

Bases: object

CONCAT = <HdlValueId Concat>
_cast_ops = {<OpDefinition BitsAsUnsigned>, <OpDefinition BitsAsSigned>, <OpDefinition BitsAsVec>}
as_hdl_Operator(op: hwt.hdl.operator.Operator)[source]
op_transl_dict = {<OpDefinition AND>: <HdlOpType.AND: 18>, <OpDefinition OR>: <HdlOpType.OR: 19>, <OpDefinition XOR>: <HdlOpType.XOR: 22>, <OpDefinition CONCAT>: <HdlOpType.CONCAT: 51>, <OpDefinition DIV>: <HdlOpType.DIV: 4>, <OpDefinition DOWNTO>: <HdlOpType.DOWNTO: 78>, <OpDefinition TO>: <HdlOpType.TO: 79>, <OpDefinition EQ>: <HdlOpType.EQ: 36>, <OpDefinition GT>: <HdlOpType.GT: 42>, <OpDefinition GE>: <HdlOpType.GE: 43>, <OpDefinition LE>: <HdlOpType.LE: 41>, <OpDefinition POW>: <HdlOpType.POW: 8>, <OpDefinition LT>: <HdlOpType.LT: 40>, <OpDefinition SUB>: <HdlOpType.SUB: 2>, <OpDefinition MUL>: <HdlOpType.MUL: 5>, <OpDefinition NE>: <HdlOpType.NE: 37>, <OpDefinition ADD>: <HdlOpType.ADD: 3>, <OpDefinition NOT>: <HdlOpType.NEG: 15>, <OpDefinition MINUS_UNARY>: <HdlOpType.MINUS_UNARY: 0>, <OpDefinition RISING_EDGE>: <HdlOpType.RISING: 76>, <OpDefinition FALLING_EDGE>: <HdlOpType.FALLING: 77>, <OpDefinition INDEX>: <HdlOpType.INDEX: 50>}

hwt.serializer.hwt.serializer module

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

Bases: hwt.serializer.hwt.value.ToHdlAstHwt_value, hwt.serializer.hwt.ops.ToHdlAstHwt_ops, hwt.serializer.hwt.types.ToHdlAstHwt_types, hwt.serializer.generic.to_hdl_ast.ToHdlAst

Serializer which converts Hwt objects back to Hwt code for debugging purposes/code ports

Variables:_valueWidthRequired – flag which tells if the values are required to have the width specified
__init__(name_scope: Optional[hdlConvertorAst.translate.common.name_scope.NameScope] = None)[source]

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

_as_hdl_HdlModuleDef(new_m: hdlConvertorAst.hdlAst._structural.HdlModuleDef) → hdlConvertorAst.hdlAst._structural.HdlModuleDef[source]
_keywords_dict = {'BIT': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'Bits': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'Concat': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'FLOAT64': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'False': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'HArray': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'HEnum': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'INT': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'If': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'None': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'Param': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'SLICE': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'STR': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'Signal': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'Switch': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'True': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'Unit': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, '_': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'and': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'as': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'assert': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'async': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'await': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'break': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'class': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'continue': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'def': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'del': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'elif': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'else': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'except': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'finally': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'for': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'from': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'global': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'hwt': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'if': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'import': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'in': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'is': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'lambda': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'nonlocal': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'not': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'or': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'pass': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'raise': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'rename_signal': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'return': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'try': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'while': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'with': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'yield': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>}
as_hdl_CodeBlock(o: hwt.code.CodeBlock)[source]
can_pop_process_wrap(statements, hasToBeVhdlProcess)[source]
has_to_be_process(proc)[source]
sensitivityListItem(item, anyIsEventDependnt)[source]

hwt.serializer.hwt.types module

class hwt.serializer.hwt.types.ToHdlAstHwt_types[source]

Bases: object

part of ToHdlAstSimModel responsible for type serialization

BITS = <HdlValueId Bits>
BOOL = <HdlValueId BOOL>
INT = <HdlValueId INT>
as_hdl_HdlType_array(typ: hwt.hdl.types.array.HArray, declaration=False)[source]
as_hdl_HdlType_bits(typ: hwt.hdl.types.bits.Bits, declaration=False)[source]
as_hdl_HdlType_float(typ: hwt.hdl.types.float.HFloat, declaration=False)[source]
does_type_requires_extra_def(t, other_types)[source]

hwt.serializer.hwt.value module

class hwt.serializer.hwt.value.ToHdlAstHwt_value[source]

Bases: hwt.serializer.generic.value.ToHdlAst_Value

NONE = <HdlValueId None>
SLICE = <HdlValueId SLICE>
as_hdl_BitsVal(val: hwt.hdl.types.bitsVal.BitsVal)[source]
as_hdl_DictVal(val)[source]
as_hdl_HArrayVal(val: hwt.hdl.types.arrayVal.HArrayVal)[source]
as_hdl_HEnumVal(val: hwt.hdl.types.enumVal.HEnumVal)[source]
as_hdl_HSliceVal(val: hwt.hdl.types.sliceVal.HSliceVal)[source]
as_hdl_SignalItem(si: Union[hwt.hdl.variables.SignalItem, hdlConvertorAst.hdlAst._defs.HdlIdDef], declaration=False)[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