hwt.serializer.simModel package

Sim model serializer serialize HDL objects to simulation model writen in python. For hwtSimApi.basic_rtl_simulator

class hwt.serializer.simModel.SimModelSerializer[source]

Bases: hwt.serializer.serializer_config.DummySerializerConfig

TO_HDL

alias of hdlConvertorAst.to.basic_hdl_sim_model._main.ToBasicHdlSimModel

TO_HDL_AST

alias of hwt.serializer.simModel.serializer.ToHdlAstSimModel

fileExtension = '.py'

Submodules

hwt.serializer.simModel.serializer module

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

Bases: hwt.serializer.simModel.value.ToHdlAstSimModel_value, hwt.serializer.simModel.types.ToHdlAstSimModel_types, hwt.serializer.generic.to_hdl_ast.ToHdlAst

Serializer which converts hwt.synthesizer.unit.Unit instances to simulator code

C = <HdlValueId c>
CVLD = <HdlValueId cVld>
SIM_EVAL_COND = <HdlValueId sim_eval_cond>
TMP_VAR_CONSTRUCTOR

alias of hwt.serializer.simModel.tmpVarConstructorConstOnly.TmpVarConstructorConstOnly

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

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

_as_hdl_HdlModuleDef_body(*args) → hdlConvertorAst.hdlAst._structural.HdlModuleDef[source]
_keywords_dict = {'Array3t': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'Array3val': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'BasicRtlSimModel': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'BasicRtlSimProxy': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'Bits3t': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'Bits3val': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'False': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'None': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'True': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, '__getattr__': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, '__getattribute__': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, '__init__': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, '__new__': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, '__setattr__': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, '__setattribute__': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, '_init_body': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, '_interfaces': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, '_outputs': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, '_processes': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, '_units': <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>, 'connectSimPort': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'continue': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'def': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'define_Enum3t': <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>, 'hwtSimApi': <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>, 'pyMathBitPrecise': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'raise': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'return': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'sensitivity': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'sim': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'sim_eval_cond': <hdlConvertorAst.translate.common.name_scope.LanguageKeyword object>, 'slice': <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_HdlAssignmentContainer(a: hwt.hdl.statements.assignmentContainer.HdlAssignmentContainer)[source]
as_hdl_HdlModuleDec(o: hdlConvertorAst.hdlAst._structural.HdlModuleDec)[source]
as_hdl_HdlStmCodeBlockContainer(proc: hwt.hdl.statements.codeBlockContainer.HdlStmCodeBlockContainer) → hdlConvertorAst.hdlAst._statements.HdlStmProcess[source]

Serialize HdlStmCodeBlockContainer objects as process if top statement

as_hdl_IfContainer(ifc: hwt.hdl.statements.ifContainter.IfContainer) → hdlConvertorAst.hdlAst._statements.HdlStmIf[source]
if cond:
    ...
else:
    ...

will become

c, cVld = sim_eval_cond(cond)
if not cVld:
    # ivalidate outputs
elif c:
    ... # original if true branch
else:
    ... # original if else brach
as_hdl_IfContainer_cond_eval(cond)[source]

constructs condition evaluation statement c, cVld = sim_eval_cond(cond)

as_hdl_IfContainer_out_invalidate_section(outputs: List[hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase], parent: hwt.hdl.statements.ifContainter.IfContainer)[source]
as_hdl_PortConnection(o: hwt.hdl.portItem.HdlPortItem)[source]
as_hdl_SwitchContainer(sw: hwt.hdl.statements.switchContainer.SwitchContainer) → hdlConvertorAst.hdlAst._statements.HdlStmIf[source]

switch -> if

as_hdl_extraVarsInit(extraVars)[source]
can_pop_process_wrap(statements, hasToBeVhdlProcess)[source]
has_to_be_process(proc)[source]
sensitivityListItem(item, anyEventDependent)[source]

hwt.serializer.simModel.tmpVarConstructorConstOnly module

class hwt.serializer.simModel.tmpVarConstructorConstOnly.TmpVarConstructorConstOnly(toHdlAst, name_scope: hdlConvertorAst.translate.common.name_scope.NameScope)[source]

Bases: hwt.serializer.generic.tmpVarConstructor.TmpVarConstructor

finish_var_init(var: hwt.synthesizer.rtlLevel.rtlSignal.RtlSignal)[source]
sort_hdl_declarations_first()[source]

hwt.serializer.simModel.types module

class hwt.serializer.simModel.types.ToHdlAstSimModel_types[source]

Bases: object

part of ToHdlAstSimModel responsible for type serialization

BITS3T = <HdlValueId Bits3t>
SELF = <HdlValueId self>
SLICE = <HdlValueId slice>
as_hdl_HdlType_array(typ, declaration=False)[source]
as_hdl_HdlType_bits(typ: hwt.hdl.types.bits.Bits, declaration=False)[source]
as_hdl_HdlType_enum(typ, declaration=False)[source]
as_hdl_HdlType_slice(typ: hwt.hdl.types.slice.HSlice, declaration=False)[source]

hwt.serializer.simModel.value module

class hwt.serializer.simModel.value.ToHdlAstSimModel_value[source]

Bases: hwt.serializer.generic.value.ToHdlAst_Value

ABits3t = <HdlValueId Bits3t>
Array3val = <HdlValueId Array3val>
Bits3t = <HdlValueId Bits3t>
Bits3val = <HdlValueId Bits3val>
CONCAT = <HdlValueId Concat>
FALSE = <HdlValueId False>
SELF = <HdlValueId self>
SELF_IO = {'__class__': 'HdlOp', 'fn': 'DOT', 'ops': ['self', 'io']}
SLICE = <HdlValueId slice>
TRUE = <HdlValueId True>
_cast_ops = {<OpDefinition BitsAsUnsigned>, <OpDefinition BitsAsSigned>, <OpDefinition BitsAsVec>}
as_hdl_BitsVal(val: hwt.hdl.types.bitsVal.BitsVal)[source]
as_hdl_DictVal(val)[source]
as_hdl_HArrayVal(val)[source]
as_hdl_HEnumVal(val: hwt.hdl.types.enumVal.HEnumVal)[source]
as_hdl_HSliceVal(val)[source]
as_hdl_Operator(op: hwt.hdl.operator.Operator)[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
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>}