hdlConvertorAst.translate.common package

Submodules

hdlConvertorAst.translate.common.add_call_operator_for_call_without_parenthesis module

class hdlConvertorAst.translate.common.add_call_operator_for_call_without_parenthesis.AddCallOperatorForCallWithoutParenthesis[source]

Bases: hdlConvertorAst.to.hdl_ast_modifier.HdlAstModifier

Verilog function call does not need to have () and it can be called just by its id. To simplify handling we decorete each such a call with a call operator in this transformation.

__init__()[source]

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

visit_iHdlExpr(o)[source]
Returns:iHdlExpr

hdlConvertorAst.translate.common.discover_declarations module

class hdlConvertorAst.translate.common.discover_declarations.BuiltIn(name)[source]

Bases: object

__init__(name)[source]

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

class hdlConvertorAst.translate.common.discover_declarations.DiscoverDeclarations(name_scope)[source]

Bases: hdlConvertorAst.to.hdl_ast_visitor.HdlAstVisitor

__init__(name_scope)[source]
_discover_declarations(o)[source]
discover_declarations(objs)[source]
visit_HdlCompInst(o)[source]
visit_HdlFunctionDef(o)[source]
visit_HdlIdDef(o)[source]
visit_HdlModuleDec(o)[source]
visit_HdlModuleDef(o)[source]

hdlConvertorAst.translate.common.name_scope module

class hdlConvertorAst.translate.common.name_scope.LanguageKeyword[source]

Bases: object

Base class for keywords of target language. Used to notify that the name represents a language keyword and thus shall not be modified.

exception hdlConvertorAst.translate.common.name_scope.NameOccupiedErr(nameScope, name, usedOn)[source]

Bases: Exception

An exception which is rised if the symbol name is used by a different object in current scope

__init__(nameScope, name, usedOn)[source]

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

class hdlConvertorAst.translate.common.name_scope.NameScope(parent, name, ignorecase, debug=False)[source]

Bases: dict

Scope of used names in hdl (node of hierarchical symbol table). Used to find an object for a HdlValueId or HdlValueId for an object and to resolve collision between different object of a same name if required.

Contains mapping {name: obj}

if name is discovered in scope it is converted to name_id where id is sequential number for prefix name_

Variables:
  • level – describes how deeply nested is this NameScopeItem in name hierarchy
  • cntrsForPrefixNames – counters for prefix names (for each name which has to be renamed there is a counter which is used to find a non occupied name faster)
  • reversed – a reverse dict to this dict ({obj: name})
  • serializer_ctx – an object with metainformations private to a current serializer
  • children – a dictionary {object which caused a NameScope fork: new NameScope}
RE_LETTER = re.compile('[A-Za-z]')
RE_NON_ID_CHAR = re.compile('[^A-Za-z_$0-9]', re.MULTILINE)
_NameScope__discard_prefix_cntrs_from_children(prefix)

Discard all prefix counters from all childrens in order to prevent children from looping trought all occupied names.

_NameScope__incrPrefixCntr(prefix, currentVal)
Returns:str
__init__(parent, name, ignorecase, debug=False)[source]
Parameters:
  • name (Optional[str]) – name of object which this namescope belongs to
  • ignorecase – if True the name comparison does not care about lowercase/uppercase
  • debug – If True name scopes are not required to have forward declarations and for any object some name is always resolved without raising definition errors
Note:

parent=None, name=None for global namescope

classmethod _sanitize_name(suggested_name: str) → str[source]
checked_name(suggested_name, obj)[source]

Get a non occupied name in current scope if name is occupied or name ends with _ the new name is generated.

Returns:str
get_child(name)[source]
get_object_and_scope_by_name(name)[source]
get_object_name(obj)[source]
Returns:str
level_pop()[source]
level_push(name)[source]
classmethod make_top(ignorecase)[source]

Syntax shugar, call constructor with argument prefilled for a top NameScope

Returns:NameScope
register_name(name, obj)[source]
update([E, ]**F) → None. Update D from dict/iterable E and F.[source]

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

exception hdlConvertorAst.translate.common.name_scope.ObjectForNameNotFound[source]

Bases: KeyError

And exception which is rised if the name is not registered at all.

class hdlConvertorAst.translate.common.name_scope.WithNameScope(obj, name_scope)[source]

Bases: object

A syntax shugar, context manager which temporarly swaps the name_scope property on object

__init__(obj, name_scope)[source]
class hdlConvertorAst.translate.common.name_scope._INVALID[source]

Bases: object

__init__()[source]

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

hdlConvertorAst.translate.common.resolve_names module

Use declarations collected from resolve_names and use them to associate HdlValueIds to a HdlObjects.

class hdlConvertorAst.translate.common.resolve_names.ResolveNames(name_scope)[source]

Bases: hdlConvertorAst.to.hdl_ast_visitor.HdlAstVisitor

__init__(name_scope)[source]
visit_HdlCompInst(o)[source]
visit_HdlFunctionDef(o)[source]
visit_HdlIdDef(o)[source]
visit_HdlModuleDec(o)[source]
visit_HdlModuleDef(o)[source]
visit_iHdlExpr(o)[source]
visit_port_param_map(mod_name_scope, pmap)[source]