pyGHDL.dom.Name

This module implements derived name classes from pyVHDLModel.Name.

Classes


Classes

class pyGHDL.dom.Name.SimpleName(node, identifier)[source]

Represents a single name (identifier) to a language entity.

This class implements a pyGHDL.dom object derived from pyVHDLModel.Name.SimpleName.

Example

ieee

Inheritance

Inheritance diagram of SimpleName

Parameters:
__init__(node, identifier)[source]

Initializes a simple name.

Parameters:
  • node (Iir) – The IIR node this object was translated from.

  • identifier (str) – The name’s identifier.

Return type:

None

_iirNode: Iir

The IIR node in libghdl’s tree this DOM object was translated from.

_position: Position

The IIR node’s position in the source file, resolved on first access and then cached.

Copy()

Create a copy of this name.

The copy has no parent. Its prefix, if any, is a copy of this name’s prefix.

Return type:

Self

Returns:

The new name.

Denote(region, place, symbol)[source]

Determine the model entity this simple name denotes as a part of a type mark, which is an attribute name.

The type mark is an attribute name like s'subtype. The logical name of a library visible in the design unit containing the place (work or a library clause, IsLibraryVisible()) denotes the library; the dependency analysis (LinkLibraryReferences()) ensured it exists in the design. Otherwise, the name is looked up at the place (LookupName()) and the declaration says what it denotes (DenoteBy()).

Parameters:
Return type:

ModelEntity | None

Returns:

The denoted model entity, or None if it can’t be resolved (reported as a warning).

Raises:

UnhandledCriticalWarningError – If the name isn’t visible, is ambiguous, or denotes neither an object, a type nor a package, and no WarningCollector collects the UnresolvedTypeMarkWarning.

DenoteBy(name, region, place, symbol)

Determine the model entity a name denoting this declaration denotes, as a part of a type mark (Name.Denote).

A declaration, which a name in a type mark can denote, overrides this method and returns itself: an object, an alias, a type or subtype, a record element, a package. Any other declaration (e.g. a subprogram) is reported.

Parameters:
  • name (Name) – The name denoting this declaration, a part of the type mark.

  • region (DeclarativeRegionMixin) – The declarative region containing the type mark.

  • place (ModelEntity) – The declaration containing the type mark.

  • symbol (Symbol) – The type mark.

Return type:

ModelEntity | None

Returns:

None, as a name in a type mark can’t denote this declaration (reported as a warning).

Raises:

UnhandledCriticalWarningError – Always, if no WarningCollector collects the UnresolvedTypeMarkWarning.

GetAncestor(type)

Return the closest ancestor of the given type found by walking the parent chain upwards.

Iterates the parent chain - starting at this model entity - upwards (toward the root of the model) until an ancestor of the requested type is found.

Parameters:

type (Type) – Class (type) of the ancestor to find.

Return type:

ModelEntity

Returns:

The closest ancestor of the requested type.

Raises:

AncestorNotFoundError – If the root of the model is reached without finding an ancestor of the requested type.

classmethod GetMethodsWithAttributes(predicate=None)

Return the class’ methods that carry at least one matching attribute.

Parameters:

predicate (type[TAttr] | Iterable[type[TAttr]] | None) – Optional, an attribute class, an iterable of attribute classes, or None to accept every attribute.

Return type:

dict[Callable[..., Any], tuple[Attribute, ...]]

Returns:

Dictionary of methods and the matching attributes attached to them.

Raises:
  • ValueError – If an element of parameter ‘predicate’ is not a sub-class of Attribute.

  • ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.

property HasPrefix: bool

Check if the name has a prefix, i.e. _prefix is set.

This is true for all names except simple names.

Returns:

True, if the name has a prefix.

property Identifier: str

Read-only property to access the identifier this name references (_identifier).

Returns:

The referenced identifier.

property IsExpandedName: bool

Check if the name is an expanded name library.package.item.

A selected name x.y may also select an element of a record object, so only a selected name, whose prefix is a selected name of a simple name, is an expanded name here. Selected names override this property.

Returns:

True, if the name is an expanded name library.package.item.

property IsOperatorSymbol: bool

Check if the name is an operator symbol (_identifier in quotation marks).

An operator symbol names an operator function, e.g. "and" in an alias declaration.

Returns:

True, if the name is an operator symbol.

property IsOverloadable: bool

Check if this model entity is an overloadable declaration: it may share its designator with other overloadable declarations.

Subprograms, enumeration literals and aliases, which may denote one of them, are overloadable; they override this property.

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

An enumerated type implies its enumeration literals, a physical type its units; they override this method.

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

A generator to iterate (normalized designator, declaration) pairs, in declaration order: none.

IterateTypeMarks(region)

Iterate the type marks of this declaration, each with the region and the place to look it up.

The place of a type mark is the declaration containing it. Declarations with type marks override this method, e.g. an object yields the type mark of its subtype indication, an array type its index and element subtypes.

Parameters:

region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

A generator to iterate (region, place, type mark) tuples, in declaration order: none.

property NormalizedIdentifier: str

Read-only property to access the normalized identifier this name references (_normalizedIdentifier).

See also

Returns:

The referenced identifier (normalized).

property Parent: ModelEntity

Property to access the model entity’s parent element reference in a logical hierarchy (_parent).

Returns:

Reference to the parent entity.

property Position: Position

Cached read-only property to access an IIR’s position in source code (_position).

If _position is None, resolve the position object from _iirNode

Returns:

The IIR’s position in the source file.

property Prefix: Name | None

Read-only property to access the name’s prefix in a chain of names (_prefix).

Returns:

The name left from current name, if not a simple name, otherwise None.

ResetReferences(designUnit, region)

Reset the references ResolveReferences() derived: the references of this declaration’s type marks.

A use clause, an alias and a subtype extend this method.

Parameters:
  • designUnit (DesignUnit) – The design unit containing this declaration.

  • region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Return type:

None

ResolveReferences(designUnit, region)

Resolve the references of this declaration: its type marks (IterateTypeMarks()).

Each type mark is resolved at its place by the region it is looked up in (ResolveTypeMark()). An incomplete type, an alias and a subtype extend this method.

Parameters:
  • designUnit (DesignUnit) – The design unit containing this declaration.

  • region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Raises:

UnhandledCriticalWarningError – If a type mark can’t be resolved, and no WarningCollector collects the UnresolvedTypeMarkWarning.

Return type:

None

property Root: Name

Read-only property to access the root (left-most) element in a chain of names (_root).

In case the name is a simple name, the root points to the name itself.

Returns:

The name’s root element.

Visit(visitor)[source]

Walk this simple name with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

Return the object’s state for pickling, collecting every slot of the class hierarchy.

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If a slot was never assigned, so it has no value to serialize.

__new__(**kwargs)
__repr__()

Formats a representation of the name.

Format: Name: 'sig'

Return type:

str

Returns:

String representation of the name.

__setstate__(state)

Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.

Parameters:

state (dict[str, Any]) – Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If the given state misses a slot or carries an unexpected one.

Return type:

None

__str__()

Formats the name.

Format: sig

Return type:

str

Returns:

Formatted name.

_identifier: str

The name’s identifier.

_normalizedIdentifier: str

The normalized (lower case) identifier.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_prefix: Name | None

Reference to the name’s prefix, or None for a simple name.

_root: Name | None

Reference to the root of the name chain.

class pyGHDL.dom.Name.ParenthesisName(node, prefix, associations)[source]

Represents a parenthesis (index access or function call) following a name.

This class implements a pyGHDL.dom object derived from pyVHDLModel.Name.ParenthesisName.

Example

arr(0)
-- ^^^

Inheritance

Inheritance diagram of ParenthesisName

Parameters:
  • node (Iir)

  • prefix (VHDLModel_Name)

  • associations (List)

__init__(node, prefix, associations)[source]

Initializes a name followed by a parenthesized association list.

Parameters:
  • node (Iir) – The IIR node this object was translated from.

  • prefix (Name) – Reference to the name’s prefix, or None for a simple name.

  • associations (List) – List of all associations in the parenthesis.

Return type:

None

_iirNode: Iir

The IIR node in libghdl’s tree this DOM object was translated from.

_position: Position

The IIR node’s position in the source file, resolved on first access and then cached.

property Associations: list

Read-only property to access the associations (_associations).

Returns:

List of associations.

Copy()[source]

Create a copy of this parenthesis name.

The copy has no parent. Its prefix and associations are copies of this name’s prefix and associations.

Return type:

Self

Returns:

The new parenthesis name.

Denote(region, place, symbol)

Determine the model entity this name denotes as a part of a type mark, which is an attribute name.

The type mark is an attribute name like rec.f'subtype. A name resolves its prefix first and applies itself to the entity the prefix denotes, which must be of a kind the name can be applied to. A kind of name, which denotes no declaration (e.g. an indexed name m(0) or ptr.all), isn’t supported and is reported.

Parameters:
Return type:

ModelEntity | None

Returns:

The denoted model entity, or None if it can’t be resolved (reported as a warning).

Raises:

UnhandledCriticalWarningError – If this kind of name isn’t supported as a part of a type mark, and no WarningCollector collects the UnresolvedTypeMarkWarning.

DenoteBy(name, region, place, symbol)

Determine the model entity a name denoting this declaration denotes, as a part of a type mark (Name.Denote).

A declaration, which a name in a type mark can denote, overrides this method and returns itself: an object, an alias, a type or subtype, a record element, a package. Any other declaration (e.g. a subprogram) is reported.

Parameters:
  • name (Name) – The name denoting this declaration, a part of the type mark.

  • region (DeclarativeRegionMixin) – The declarative region containing the type mark.

  • place (ModelEntity) – The declaration containing the type mark.

  • symbol (Symbol) – The type mark.

Return type:

ModelEntity | None

Returns:

None, as a name in a type mark can’t denote this declaration (reported as a warning).

Raises:

UnhandledCriticalWarningError – Always, if no WarningCollector collects the UnresolvedTypeMarkWarning.

GetAncestor(type)

Return the closest ancestor of the given type found by walking the parent chain upwards.

Iterates the parent chain - starting at this model entity - upwards (toward the root of the model) until an ancestor of the requested type is found.

Parameters:

type (Type) – Class (type) of the ancestor to find.

Return type:

ModelEntity

Returns:

The closest ancestor of the requested type.

Raises:

AncestorNotFoundError – If the root of the model is reached without finding an ancestor of the requested type.

classmethod GetMethodsWithAttributes(predicate=None)

Return the class’ methods that carry at least one matching attribute.

Parameters:

predicate (type[TAttr] | Iterable[type[TAttr]] | None) – Optional, an attribute class, an iterable of attribute classes, or None to accept every attribute.

Return type:

dict[Callable[..., Any], tuple[Attribute, ...]]

Returns:

Dictionary of methods and the matching attributes attached to them.

Raises:
  • ValueError – If an element of parameter ‘predicate’ is not a sub-class of Attribute.

  • ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.

property HasPrefix: bool

Check if the name has a prefix, i.e. _prefix is set.

This is true for all names except simple names.

Returns:

True, if the name has a prefix.

property Identifier: str

Read-only property to access the identifier this name references (_identifier).

Returns:

The referenced identifier.

property IsExpandedName: bool

Check if the name is an expanded name library.package.item.

A selected name x.y may also select an element of a record object, so only a selected name, whose prefix is a selected name of a simple name, is an expanded name here. Selected names override this property.

Returns:

True, if the name is an expanded name library.package.item.

property IsOperatorSymbol: bool

Check if the name is an operator symbol (_identifier in quotation marks).

An operator symbol names an operator function, e.g. "and" in an alias declaration.

Returns:

True, if the name is an operator symbol.

property IsOverloadable: bool

Check if this model entity is an overloadable declaration: it may share its designator with other overloadable declarations.

Subprograms, enumeration literals and aliases, which may denote one of them, are overloadable; they override this property.

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

An enumerated type implies its enumeration literals, a physical type its units; they override this method.

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

A generator to iterate (normalized designator, declaration) pairs, in declaration order: none.

IterateTypeMarks(region)

Iterate the type marks of this declaration, each with the region and the place to look it up.

The place of a type mark is the declaration containing it. Declarations with type marks override this method, e.g. an object yields the type mark of its subtype indication, an array type its index and element subtypes.

Parameters:

region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

A generator to iterate (region, place, type mark) tuples, in declaration order: none.

property NormalizedIdentifier: str

Read-only property to access the normalized identifier this name references (_normalizedIdentifier).

See also

Returns:

The referenced identifier (normalized).

property Parent: ModelEntity

Property to access the model entity’s parent element reference in a logical hierarchy (_parent).

Returns:

Reference to the parent entity.

property Position: Position

Cached read-only property to access an IIR’s position in source code (_position).

If _position is None, resolve the position object from _iirNode

Returns:

The IIR’s position in the source file.

property Prefix: Name | None

Read-only property to access the name’s prefix in a chain of names (_prefix).

Returns:

The name left from current name, if not a simple name, otherwise None.

ResetReferences(designUnit, region)

Reset the references ResolveReferences() derived: the references of this declaration’s type marks.

A use clause, an alias and a subtype extend this method.

Parameters:
  • designUnit (DesignUnit) – The design unit containing this declaration.

  • region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Return type:

None

ResolveReferences(designUnit, region)

Resolve the references of this declaration: its type marks (IterateTypeMarks()).

Each type mark is resolved at its place by the region it is looked up in (ResolveTypeMark()). An incomplete type, an alias and a subtype extend this method.

Parameters:
  • designUnit (DesignUnit) – The design unit containing this declaration.

  • region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Raises:

UnhandledCriticalWarningError – If a type mark can’t be resolved, and no WarningCollector collects the UnresolvedTypeMarkWarning.

Return type:

None

property Root: Name

Read-only property to access the root (left-most) element in a chain of names (_root).

In case the name is a simple name, the root points to the name itself.

Returns:

The name’s root element.

Visit(visitor)[source]

Walk this parenthesis name, its prefix and its associations with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

Return the object’s state for pickling, collecting every slot of the class hierarchy.

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If a slot was never assigned, so it has no value to serialize.

__new__(**kwargs)
__repr__()

Formats a representation of the name.

Format: Name: 'sig'

Return type:

str

Returns:

String representation of the name.

__setstate__(state)

Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.

Parameters:

state (dict[str, Any]) – Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If the given state misses a slot or carries an unexpected one.

Return type:

None

__str__()[source]

Formats the parenthesis name.

Format: func(a, b)

Return type:

str

Returns:

Formatted parenthesis name.

_associations: list

List of all associations in the parenthesis.

_identifier: str

The name’s identifier.

_normalizedIdentifier: str

The normalized (lower case) identifier.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_prefix: Name | None

Reference to the name’s prefix, or None for a simple name.

_root: Name | None

Reference to the root of the name chain.

class pyGHDL.dom.Name.IndexedName(node, identifier)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Name.IndexedName.

Represents a name indexing an array by one or more values.

Example

s <= v(0);
--   ^^^^    <- the indexed name

Inheritance

Inheritance diagram of IndexedName

Parameters:
__init__(node, identifier)[source]

Initializes a name indexing an array by one or more values.

Parameters:
  • node (Iir) – The IIR node this object was translated from.

  • identifier (str) – The identifier of the indexed name.

Return type:

None

_iirNode

The IIR node in libghdl’s tree this DOM object was translated from.

_position

The IIR node’s position in the source file, resolved on first access and then cached.

Copy()[source]

Create a copy of this indexed name.

The copy has no parent. Its prefix and indices are copies of this name’s prefix and indices.

Return type:

Self

Returns:

The new indexed name.

Denote(region, place, symbol)

Determine the model entity this name denotes as a part of a type mark, which is an attribute name.

The type mark is an attribute name like rec.f'subtype. A name resolves its prefix first and applies itself to the entity the prefix denotes, which must be of a kind the name can be applied to. A kind of name, which denotes no declaration (e.g. an indexed name m(0) or ptr.all), isn’t supported and is reported.

Parameters:
Return type:

ModelEntity | None

Returns:

The denoted model entity, or None if it can’t be resolved (reported as a warning).

Raises:

UnhandledCriticalWarningError – If this kind of name isn’t supported as a part of a type mark, and no WarningCollector collects the UnresolvedTypeMarkWarning.

DenoteBy(name, region, place, symbol)

Determine the model entity a name denoting this declaration denotes, as a part of a type mark (Name.Denote).

A declaration, which a name in a type mark can denote, overrides this method and returns itself: an object, an alias, a type or subtype, a record element, a package. Any other declaration (e.g. a subprogram) is reported.

Parameters:
  • name (Name) – The name denoting this declaration, a part of the type mark.

  • region (DeclarativeRegionMixin) – The declarative region containing the type mark.

  • place (ModelEntity) – The declaration containing the type mark.

  • symbol (Symbol) – The type mark.

Return type:

ModelEntity | None

Returns:

None, as a name in a type mark can’t denote this declaration (reported as a warning).

Raises:

UnhandledCriticalWarningError – Always, if no WarningCollector collects the UnresolvedTypeMarkWarning.

GetAncestor(type)

Return the closest ancestor of the given type found by walking the parent chain upwards.

Iterates the parent chain - starting at this model entity - upwards (toward the root of the model) until an ancestor of the requested type is found.

Parameters:

type (Type) – Class (type) of the ancestor to find.

Return type:

ModelEntity

Returns:

The closest ancestor of the requested type.

Raises:

AncestorNotFoundError – If the root of the model is reached without finding an ancestor of the requested type.

classmethod GetMethodsWithAttributes(predicate=None)

Return the class’ methods that carry at least one matching attribute.

Parameters:

predicate (type[TAttr] | Iterable[type[TAttr]] | None) – Optional, an attribute class, an iterable of attribute classes, or None to accept every attribute.

Return type:

dict[Callable[..., Any], tuple[Attribute, ...]]

Returns:

Dictionary of methods and the matching attributes attached to them.

Raises:
  • ValueError – If an element of parameter ‘predicate’ is not a sub-class of Attribute.

  • ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.

property HasPrefix: bool

Check if the name has a prefix, i.e. _prefix is set.

This is true for all names except simple names.

Returns:

True, if the name has a prefix.

property Identifier: str

Read-only property to access the identifier this name references (_identifier).

Returns:

The referenced identifier.

property Indices: list[BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal]

Read-only property to access the indices (_indices).

Returns:

List of indices.

property IsExpandedName: bool

Check if the name is an expanded name library.package.item.

A selected name x.y may also select an element of a record object, so only a selected name, whose prefix is a selected name of a simple name, is an expanded name here. Selected names override this property.

Returns:

True, if the name is an expanded name library.package.item.

property IsOperatorSymbol: bool

Check if the name is an operator symbol (_identifier in quotation marks).

An operator symbol names an operator function, e.g. "and" in an alias declaration.

Returns:

True, if the name is an operator symbol.

property IsOverloadable: bool

Check if this model entity is an overloadable declaration: it may share its designator with other overloadable declarations.

Subprograms, enumeration literals and aliases, which may denote one of them, are overloadable; they override this property.

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

An enumerated type implies its enumeration literals, a physical type its units; they override this method.

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

A generator to iterate (normalized designator, declaration) pairs, in declaration order: none.

IterateTypeMarks(region)

Iterate the type marks of this declaration, each with the region and the place to look it up.

The place of a type mark is the declaration containing it. Declarations with type marks override this method, e.g. an object yields the type mark of its subtype indication, an array type its index and element subtypes.

Parameters:

region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

A generator to iterate (region, place, type mark) tuples, in declaration order: none.

property NormalizedIdentifier: str

Read-only property to access the normalized identifier this name references (_normalizedIdentifier).

See also

Returns:

The referenced identifier (normalized).

property Parent: ModelEntity

Property to access the model entity’s parent element reference in a logical hierarchy (_parent).

Returns:

Reference to the parent entity.

property Position: Position

Cached read-only property to access an IIR’s position in source code (_position).

If _position is None, resolve the position object from _iirNode

Returns:

The IIR’s position in the source file.

property Prefix: Name | None

Read-only property to access the name’s prefix in a chain of names (_prefix).

Returns:

The name left from current name, if not a simple name, otherwise None.

ResetReferences(designUnit, region)

Reset the references ResolveReferences() derived: the references of this declaration’s type marks.

A use clause, an alias and a subtype extend this method.

Parameters:
  • designUnit (DesignUnit) – The design unit containing this declaration.

  • region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Return type:

None

ResolveReferences(designUnit, region)

Resolve the references of this declaration: its type marks (IterateTypeMarks()).

Each type mark is resolved at its place by the region it is looked up in (ResolveTypeMark()). An incomplete type, an alias and a subtype extend this method.

Parameters:
  • designUnit (DesignUnit) – The design unit containing this declaration.

  • region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Raises:

UnhandledCriticalWarningError – If a type mark can’t be resolved, and no WarningCollector collects the UnresolvedTypeMarkWarning.

Return type:

None

property Root: Name

Read-only property to access the root (left-most) element in a chain of names (_root).

In case the name is a simple name, the root points to the name itself.

Returns:

The name’s root element.

Visit(visitor)[source]

Walk this indexed name, its prefix and its indices with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

Return the object’s state for pickling, collecting every slot of the class hierarchy.

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If a slot was never assigned, so it has no value to serialize.

__new__(**kwargs)
__repr__()

Formats a representation of the name.

Format: Name: 'sig'

Return type:

str

Returns:

String representation of the name.

__setstate__(state)

Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.

Parameters:

state (dict[str, Any]) – Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If the given state misses a slot or carries an unexpected one.

Return type:

None

__str__()[source]

Formats the indexed name.

Format: arr(0)

Return type:

str

Returns:

Formatted indexed name.

_identifier

The name’s identifier.

_indices: list[ExpressionUnion]

List of all index expressions, one per dimension.

_normalizedIdentifier

The normalized (lower case) identifier.

_parent

Reference to a parent entity in the logical model hierarchy.

_prefix

Reference to the name’s prefix, or None for a simple name.

_root

Reference to the root of the name chain.

class pyGHDL.dom.Name.SlicedName(node, identifier)[source]

Represents a slice following a name.

This class implements a pyGHDL.dom object derived from pyVHDLModel.Name.SlicedName.

Example

arr(7 downto 0)
-- ^^^^^^^^^^^^

Inheritance

Inheritance diagram of SlicedName

Parameters:
__init__(node, identifier)[source]

Initializes a sliced name.

Parameters:
  • node (Iir) – The IIR node this object was translated from.

  • identifier (str) – The name’s identifier.

Return type:

None

_iirNode: Iir

The IIR node in libghdl’s tree this DOM object was translated from.

_position: Position

The IIR node’s position in the source file, resolved on first access and then cached.

Copy()

Create a copy of this name.

The copy has no parent. Its prefix, if any, is a copy of this name’s prefix.

Return type:

Self

Returns:

The new name.

Denote(region, place, symbol)

Determine the model entity this name denotes as a part of a type mark, which is an attribute name.

The type mark is an attribute name like rec.f'subtype. A name resolves its prefix first and applies itself to the entity the prefix denotes, which must be of a kind the name can be applied to. A kind of name, which denotes no declaration (e.g. an indexed name m(0) or ptr.all), isn’t supported and is reported.

Parameters:
Return type:

ModelEntity | None

Returns:

The denoted model entity, or None if it can’t be resolved (reported as a warning).

Raises:

UnhandledCriticalWarningError – If this kind of name isn’t supported as a part of a type mark, and no WarningCollector collects the UnresolvedTypeMarkWarning.

DenoteBy(name, region, place, symbol)

Determine the model entity a name denoting this declaration denotes, as a part of a type mark (Name.Denote).

A declaration, which a name in a type mark can denote, overrides this method and returns itself: an object, an alias, a type or subtype, a record element, a package. Any other declaration (e.g. a subprogram) is reported.

Parameters:
  • name (Name) – The name denoting this declaration, a part of the type mark.

  • region (DeclarativeRegionMixin) – The declarative region containing the type mark.

  • place (ModelEntity) – The declaration containing the type mark.

  • symbol (Symbol) – The type mark.

Return type:

ModelEntity | None

Returns:

None, as a name in a type mark can’t denote this declaration (reported as a warning).

Raises:

UnhandledCriticalWarningError – Always, if no WarningCollector collects the UnresolvedTypeMarkWarning.

GetAncestor(type)

Return the closest ancestor of the given type found by walking the parent chain upwards.

Iterates the parent chain - starting at this model entity - upwards (toward the root of the model) until an ancestor of the requested type is found.

Parameters:

type (Type) – Class (type) of the ancestor to find.

Return type:

ModelEntity

Returns:

The closest ancestor of the requested type.

Raises:

AncestorNotFoundError – If the root of the model is reached without finding an ancestor of the requested type.

classmethod GetMethodsWithAttributes(predicate=None)

Return the class’ methods that carry at least one matching attribute.

Parameters:

predicate (type[TAttr] | Iterable[type[TAttr]] | None) – Optional, an attribute class, an iterable of attribute classes, or None to accept every attribute.

Return type:

dict[Callable[..., Any], tuple[Attribute, ...]]

Returns:

Dictionary of methods and the matching attributes attached to them.

Raises:
  • ValueError – If an element of parameter ‘predicate’ is not a sub-class of Attribute.

  • ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.

property HasPrefix: bool

Check if the name has a prefix, i.e. _prefix is set.

This is true for all names except simple names.

Returns:

True, if the name has a prefix.

property Identifier: str

Read-only property to access the identifier this name references (_identifier).

Returns:

The referenced identifier.

property IsExpandedName: bool

Check if the name is an expanded name library.package.item.

A selected name x.y may also select an element of a record object, so only a selected name, whose prefix is a selected name of a simple name, is an expanded name here. Selected names override this property.

Returns:

True, if the name is an expanded name library.package.item.

property IsOperatorSymbol: bool

Check if the name is an operator symbol (_identifier in quotation marks).

An operator symbol names an operator function, e.g. "and" in an alias declaration.

Returns:

True, if the name is an operator symbol.

property IsOverloadable: bool

Check if this model entity is an overloadable declaration: it may share its designator with other overloadable declarations.

Subprograms, enumeration literals and aliases, which may denote one of them, are overloadable; they override this property.

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

An enumerated type implies its enumeration literals, a physical type its units; they override this method.

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

A generator to iterate (normalized designator, declaration) pairs, in declaration order: none.

IterateTypeMarks(region)

Iterate the type marks of this declaration, each with the region and the place to look it up.

The place of a type mark is the declaration containing it. Declarations with type marks override this method, e.g. an object yields the type mark of its subtype indication, an array type its index and element subtypes.

Parameters:

region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

A generator to iterate (region, place, type mark) tuples, in declaration order: none.

property NormalizedIdentifier: str

Read-only property to access the normalized identifier this name references (_normalizedIdentifier).

See also

Returns:

The referenced identifier (normalized).

property Parent: ModelEntity

Property to access the model entity’s parent element reference in a logical hierarchy (_parent).

Returns:

Reference to the parent entity.

property Position: Position

Cached read-only property to access an IIR’s position in source code (_position).

If _position is None, resolve the position object from _iirNode

Returns:

The IIR’s position in the source file.

property Prefix: Name | None

Read-only property to access the name’s prefix in a chain of names (_prefix).

Returns:

The name left from current name, if not a simple name, otherwise None.

ResetReferences(designUnit, region)

Reset the references ResolveReferences() derived: the references of this declaration’s type marks.

A use clause, an alias and a subtype extend this method.

Parameters:
  • designUnit (DesignUnit) – The design unit containing this declaration.

  • region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Return type:

None

ResolveReferences(designUnit, region)

Resolve the references of this declaration: its type marks (IterateTypeMarks()).

Each type mark is resolved at its place by the region it is looked up in (ResolveTypeMark()). An incomplete type, an alias and a subtype extend this method.

Parameters:
  • designUnit (DesignUnit) – The design unit containing this declaration.

  • region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Raises:

UnhandledCriticalWarningError – If a type mark can’t be resolved, and no WarningCollector collects the UnresolvedTypeMarkWarning.

Return type:

None

property Root: Name

Read-only property to access the root (left-most) element in a chain of names (_root).

In case the name is a simple name, the root points to the name itself.

Returns:

The name’s root element.

Visit(visitor)[source]

Walk this sliced name and its prefix with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

Return the object’s state for pickling, collecting every slot of the class hierarchy.

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If a slot was never assigned, so it has no value to serialize.

__new__(**kwargs)
__repr__()

Formats a representation of the name.

Format: Name: 'sig'

Return type:

str

Returns:

String representation of the name.

__setstate__(state)

Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.

Parameters:

state (dict[str, Any]) – Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If the given state misses a slot or carries an unexpected one.

Return type:

None

__str__()

Formats the name.

Format: sig

Return type:

str

Returns:

Formatted name.

_identifier: str

The name’s identifier.

_normalizedIdentifier: str

The normalized (lower case) identifier.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_prefix: Name | None

Reference to the name’s prefix, or None for a simple name.

_root: Name | None

Reference to the root of the name chain.

class pyGHDL.dom.Name.SelectedName(node, identifier, prefix)[source]

Represents a name following a name in dot-notation.

This class implements a pyGHDL.dom object derived from pyVHDLModel.Name.SelectedName.

Example

rec.elem
-- ^^^^^

Inheritance

Inheritance diagram of SelectedName

Parameters:
  • node (Iir)

  • identifier (str)

  • prefix (VHDLModel_Name)

__init__(node, identifier, prefix)[source]

Initializes a selected name.

Parameters:
  • node (Iir) – The IIR node this object was translated from.

  • identifier (str) – The name’s identifier.

  • prefix (Name) – Reference to the name’s prefix, or None for a simple name.

Return type:

None

_iirNode: Iir

The IIR node in libghdl’s tree this DOM object was translated from.

_position: Position

The IIR node’s position in the source file, resolved on first access and then cached.

Copy()[source]

Create a copy of this selected name.

The copy has no parent. Its prefix is a copy of this name’s prefix.

Return type:

Self

Returns:

The new selected name.

Denote(region, place, symbol)[source]

Determine the model entity this selected name denotes as a part of a type mark, which is an attribute name.

The type mark is an attribute name like p.c'subtype or rec.f'subtype. Depending on the entity the prefix denotes, this name denotes:

  • a library: the package of this name in the library.

  • a package: the declaration of this name in the package (FindDeclarations()); the declaration says what it denotes (DenoteBy()).

  • an object of a record type: the record element of this name (ElementsByIdentifier).

Parameters:
Return type:

ModelEntity | None

Returns:

The denoted model entity, or None if it can’t be resolved (reported as a warning).

Raises:
  • UnhandledCriticalWarningError – If the library has no package of this name, and no WarningCollector collects the UnresolvedTypeMarkWarning.

  • UnhandledCriticalWarningError – If the package declares nothing of this name, and no WarningCollector collects the UnresolvedTypeMarkWarning.

  • UnhandledCriticalWarningError – If the prefix isn’t an object of a record type with an element of this name, and no WarningCollector collects the UnresolvedTypeMarkWarning.

DenoteBy(name, region, place, symbol)

Determine the model entity a name denoting this declaration denotes, as a part of a type mark (Name.Denote).

A declaration, which a name in a type mark can denote, overrides this method and returns itself: an object, an alias, a type or subtype, a record element, a package. Any other declaration (e.g. a subprogram) is reported.

Parameters:
  • name (Name) – The name denoting this declaration, a part of the type mark.

  • region (DeclarativeRegionMixin) – The declarative region containing the type mark.

  • place (ModelEntity) – The declaration containing the type mark.

  • symbol (Symbol) – The type mark.

Return type:

ModelEntity | None

Returns:

None, as a name in a type mark can’t denote this declaration (reported as a warning).

Raises:

UnhandledCriticalWarningError – Always, if no WarningCollector collects the UnresolvedTypeMarkWarning.

GetAncestor(type)

Return the closest ancestor of the given type found by walking the parent chain upwards.

Iterates the parent chain - starting at this model entity - upwards (toward the root of the model) until an ancestor of the requested type is found.

Parameters:

type (Type) – Class (type) of the ancestor to find.

Return type:

ModelEntity

Returns:

The closest ancestor of the requested type.

Raises:

AncestorNotFoundError – If the root of the model is reached without finding an ancestor of the requested type.

classmethod GetMethodsWithAttributes(predicate=None)

Return the class’ methods that carry at least one matching attribute.

Parameters:

predicate (type[TAttr] | Iterable[type[TAttr]] | None) – Optional, an attribute class, an iterable of attribute classes, or None to accept every attribute.

Return type:

dict[Callable[..., Any], tuple[Attribute, ...]]

Returns:

Dictionary of methods and the matching attributes attached to them.

Raises:
  • ValueError – If an element of parameter ‘predicate’ is not a sub-class of Attribute.

  • ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.

property HasPrefix: bool

Check if the name has a prefix, i.e. _prefix is set.

This is true for all names except simple names.

Returns:

True, if the name has a prefix.

property Identifier: str

Read-only property to access the identifier this name references (_identifier).

Returns:

The referenced identifier.

property IsExpandedName: bool

Check if the name is an expanded name library.package.item: its prefix is a selected name of a simple name.

Returns:

True, if the name is an expanded name library.package.item.

property IsOperatorSymbol: bool

Check if the name is an operator symbol (_identifier in quotation marks).

An operator symbol names an operator function, e.g. "and" in an alias declaration.

Returns:

True, if the name is an operator symbol.

property IsOverloadable: bool

Check if this model entity is an overloadable declaration: it may share its designator with other overloadable declarations.

Subprograms, enumeration literals and aliases, which may denote one of them, are overloadable; they override this property.

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

An enumerated type implies its enumeration literals, a physical type its units; they override this method.

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

A generator to iterate (normalized designator, declaration) pairs, in declaration order: none.

IterateTypeMarks(region)

Iterate the type marks of this declaration, each with the region and the place to look it up.

The place of a type mark is the declaration containing it. Declarations with type marks override this method, e.g. an object yields the type mark of its subtype indication, an array type its index and element subtypes.

Parameters:

region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

A generator to iterate (region, place, type mark) tuples, in declaration order: none.

property NormalizedIdentifier: str

Read-only property to access the normalized identifier this name references (_normalizedIdentifier).

See also

Returns:

The referenced identifier (normalized).

property Parent: ModelEntity

Property to access the model entity’s parent element reference in a logical hierarchy (_parent).

Returns:

Reference to the parent entity.

property Position: Position

Cached read-only property to access an IIR’s position in source code (_position).

If _position is None, resolve the position object from _iirNode

Returns:

The IIR’s position in the source file.

property Prefix: Name | None

Read-only property to access the name’s prefix in a chain of names (_prefix).

Returns:

The name left from current name, if not a simple name, otherwise None.

ResetReferences(designUnit, region)

Reset the references ResolveReferences() derived: the references of this declaration’s type marks.

A use clause, an alias and a subtype extend this method.

Parameters:
  • designUnit (DesignUnit) – The design unit containing this declaration.

  • region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Return type:

None

ResolveReferences(designUnit, region)

Resolve the references of this declaration: its type marks (IterateTypeMarks()).

Each type mark is resolved at its place by the region it is looked up in (ResolveTypeMark()). An incomplete type, an alias and a subtype extend this method.

Parameters:
  • designUnit (DesignUnit) – The design unit containing this declaration.

  • region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Raises:

UnhandledCriticalWarningError – If a type mark can’t be resolved, and no WarningCollector collects the UnresolvedTypeMarkWarning.

Return type:

None

property Root: Name

Read-only property to access the root (left-most) element in a chain of names (_root).

In case the name is a simple name, the root points to the name itself.

Returns:

The name’s root element.

Visit(visitor)[source]

Walk this selected name and its prefix with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

Return the object’s state for pickling, collecting every slot of the class hierarchy.

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If a slot was never assigned, so it has no value to serialize.

__new__(**kwargs)
__repr__()

Formats a representation of the name.

Format: Name: 'sig'

Return type:

str

Returns:

String representation of the name.

__setstate__(state)

Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.

Parameters:

state (dict[str, Any]) – Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If the given state misses a slot or carries an unexpected one.

Return type:

None

__str__()[source]

Formats the selected name.

Format: rec.elem

Return type:

str

Returns:

Formatted selected name.

_identifier: str

The name’s identifier.

_normalizedIdentifier: str

The normalized (lower case) identifier.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_prefix: Name | None

Reference to the name’s prefix, or None for a simple name.

_root: Name | None

Reference to the root of the name chain.

class pyGHDL.dom.Name.AttributeName(node, identifier, prefix)[source]

Represents a name following a name in tick-notation.

This class implements a pyGHDL.dom object derived from pyVHDLModel.Name.AttributeName.

Example

arr'length
-- ^^^^^^^

Inheritance

Inheritance diagram of AttributeName

Parameters:
  • node (Iir)

  • identifier (str)

  • prefix (VHDLModel_Name)

__init__(node, identifier, prefix)[source]

Initializes a name selecting an attribute of its prefix.

Parameters:
  • node (Iir) – The IIR node this object was translated from.

  • identifier (str) – The name’s identifier.

  • prefix (Name) – Reference to the name’s prefix, or None for a simple name.

Return type:

None

_iirNode: Iir

The IIR node in libghdl’s tree this DOM object was translated from.

_position: Position

The IIR node’s position in the source file, resolved on first access and then cached.

Copy()[source]

Create a copy of this attribute name.

The copy has no parent. Its prefix is a copy of this name’s prefix.

Return type:

Self

Returns:

The new attribute name.

Denote(region, place, symbol)[source]

Determine the type or subtype this attribute name denotes as a type mark or as a part of one (IEEE Std 1076-2008, 16.2).

Depending on the predefined attribute (PredefinedAttribute), this name denotes:

  • 'subtype: the subtype of the object its prefix denotes.

  • 'element: the element subtype of the array type or subtype, or of the array object, its prefix denotes.

  • 'base: the base type of the type or subtype its prefix denotes; only allowed as the prefix of another attribute.

An object is an object declaration, a record element or an object alias (an alias with a subtype indication); a type is a type or subtype declaration. The constraint of a subtype indication isn’t represented: s'subtype of signal s : bit_vector(3 downto 0) denotes bit_vector.

Parameters:
Return type:

ModelEntity | None

Returns:

The denoted type or subtype, or None if it can’t be resolved (reported as a warning).

Raises:
  • UnhandledCriticalWarningError – If the prefix of 'subtype isn’t an object, or the object’s subtype isn’t resolved, and no WarningCollector collects the UnresolvedTypeMarkWarning.

  • UnhandledCriticalWarningError – If the prefix of 'element isn’t an array, or the array’s element type isn’t resolved, and no WarningCollector collects the UnresolvedTypeMarkWarning.

  • UnhandledCriticalWarningError – If 'base is the type mark itself, or its prefix isn’t a type, or its base type isn’t resolved, and no WarningCollector collects the UnresolvedTypeMarkWarning.

  • UnhandledCriticalWarningError – If the attribute denotes no type, and no WarningCollector collects the UnresolvedTypeMarkWarning.

DenoteBy(name, region, place, symbol)

Determine the model entity a name denoting this declaration denotes, as a part of a type mark (Name.Denote).

A declaration, which a name in a type mark can denote, overrides this method and returns itself: an object, an alias, a type or subtype, a record element, a package. Any other declaration (e.g. a subprogram) is reported.

Parameters:
  • name (Name) – The name denoting this declaration, a part of the type mark.

  • region (DeclarativeRegionMixin) – The declarative region containing the type mark.

  • place (ModelEntity) – The declaration containing the type mark.

  • symbol (Symbol) – The type mark.

Return type:

ModelEntity | None

Returns:

None, as a name in a type mark can’t denote this declaration (reported as a warning).

Raises:

UnhandledCriticalWarningError – Always, if no WarningCollector collects the UnresolvedTypeMarkWarning.

GetAncestor(type)

Return the closest ancestor of the given type found by walking the parent chain upwards.

Iterates the parent chain - starting at this model entity - upwards (toward the root of the model) until an ancestor of the requested type is found.

Parameters:

type (Type) – Class (type) of the ancestor to find.

Return type:

ModelEntity

Returns:

The closest ancestor of the requested type.

Raises:

AncestorNotFoundError – If the root of the model is reached without finding an ancestor of the requested type.

classmethod GetMethodsWithAttributes(predicate=None)

Return the class’ methods that carry at least one matching attribute.

Parameters:

predicate (type[TAttr] | Iterable[type[TAttr]] | None) – Optional, an attribute class, an iterable of attribute classes, or None to accept every attribute.

Return type:

dict[Callable[..., Any], tuple[Attribute, ...]]

Returns:

Dictionary of methods and the matching attributes attached to them.

Raises:
  • ValueError – If an element of parameter ‘predicate’ is not a sub-class of Attribute.

  • ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.

property HasPrefix: bool

Check if the name has a prefix, i.e. _prefix is set.

This is true for all names except simple names.

Returns:

True, if the name has a prefix.

property Identifier: str

Read-only property to access the identifier this name references (_identifier).

Returns:

The referenced identifier.

property IsExpandedName: bool

Check if the name is an expanded name library.package.item.

A selected name x.y may also select an element of a record object, so only a selected name, whose prefix is a selected name of a simple name, is an expanded name here. Selected names override this property.

Returns:

True, if the name is an expanded name library.package.item.

property IsOperatorSymbol: bool

Check if the name is an operator symbol (_identifier in quotation marks).

An operator symbol names an operator function, e.g. "and" in an alias declaration.

Returns:

True, if the name is an operator symbol.

property IsOverloadable: bool

Check if this model entity is an overloadable declaration: it may share its designator with other overloadable declarations.

Subprograms, enumeration literals and aliases, which may denote one of them, are overloadable; they override this property.

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

An enumerated type implies its enumeration literals, a physical type its units; they override this method.

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

A generator to iterate (normalized designator, declaration) pairs, in declaration order: none.

IterateTypeMarks(region)

Iterate the type marks of this declaration, each with the region and the place to look it up.

The place of a type mark is the declaration containing it. Declarations with type marks override this method, e.g. an object yields the type mark of its subtype indication, an array type its index and element subtypes.

Parameters:

region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

A generator to iterate (region, place, type mark) tuples, in declaration order: none.

property NormalizedIdentifier: str

Read-only property to access the normalized identifier this name references (_normalizedIdentifier).

See also

Returns:

The referenced identifier (normalized).

property Parent: ModelEntity

Property to access the model entity’s parent element reference in a logical hierarchy (_parent).

Returns:

Reference to the parent entity.

property Position: Position

Cached read-only property to access an IIR’s position in source code (_position).

If _position is None, resolve the position object from _iirNode

Returns:

The IIR’s position in the source file.

property PredefinedAttribute: PredefinedAttribute | None

Read-only property to access the predefined attribute this name selects (_predefinedAttribute).

Returns:

The predefined attribute, or None for a user-defined attribute.

property Prefix: Name | None

Read-only property to access the name’s prefix in a chain of names (_prefix).

Returns:

The name left from current name, if not a simple name, otherwise None.

ResetReferences(designUnit, region)

Reset the references ResolveReferences() derived: the references of this declaration’s type marks.

A use clause, an alias and a subtype extend this method.

Parameters:
  • designUnit (DesignUnit) – The design unit containing this declaration.

  • region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Return type:

None

ResolveReferences(designUnit, region)

Resolve the references of this declaration: its type marks (IterateTypeMarks()).

Each type mark is resolved at its place by the region it is looked up in (ResolveTypeMark()). An incomplete type, an alias and a subtype extend this method.

Parameters:
  • designUnit (DesignUnit) – The design unit containing this declaration.

  • region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Raises:

UnhandledCriticalWarningError – If a type mark can’t be resolved, and no WarningCollector collects the UnresolvedTypeMarkWarning.

Return type:

None

property Root: Name

Read-only property to access the root (left-most) element in a chain of names (_root).

In case the name is a simple name, the root points to the name itself.

Returns:

The name’s root element.

Visit(visitor)[source]

Walk this attribute name and its prefix with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

Return the object’s state for pickling, collecting every slot of the class hierarchy.

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If a slot was never assigned, so it has no value to serialize.

__new__(**kwargs)
__repr__()

Formats a representation of the name.

Format: Name: 'sig'

Return type:

str

Returns:

String representation of the name.

__setstate__(state)

Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.

Parameters:

state (dict[str, Any]) – Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If the given state misses a slot or carries an unexpected one.

Return type:

None

__str__()[source]

Formats the attribute name.

Format: v'range

Return type:

str

Returns:

Formatted attribute name.

_identifier: str

The name’s identifier.

_normalizedIdentifier: str

The normalized (lower case) identifier.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_predefinedAttribute: PredefinedAttribute | None

The predefined attribute, or None if user-defined.

_prefix: Name | None

Reference to the name’s prefix, or None for a simple name.

_root: Name | None

Reference to the root of the name chain.

class pyGHDL.dom.Name.AllName(node, prefix)[source]

Represents a keyword all following a name in dot-notation.

This class implements a pyGHDL.dom object derived from pyVHDLModel.Name.AllName.

Example

ptr.all
-- ^^^^

Inheritance

Inheritance diagram of AllName

Parameters:
  • node (Iir)

  • prefix (VHDLModel_Name)

__init__(node, prefix)[source]

Initializes an all name.

Parameters:
  • node (Iir) – The IIR node this object was translated from.

  • prefix (Name) – Reference to the name’s prefix, or None for a simple name.

Return type:

None

_iirNode: Iir

The IIR node in libghdl’s tree this DOM object was translated from.

_position: Position

The IIR node’s position in the source file, resolved on first access and then cached.

Copy()[source]

Create a copy of this all name.

The copy has no parent. Its prefix is a copy of this name’s prefix.

Return type:

Self

Returns:

The new all name.

Denote(region, place, symbol)[source]

Report an all name as a part of a type mark as unsupported.

The type mark is an attribute name like ptr.all'subtype: ptr.all denotes the object an access value designates, which has no declaration.

Parameters:
Return type:

ModelEntity | None

Returns:

None, as the name isn’t supported (reported as a warning).

Raises:

UnhandledCriticalWarningError – Always, if no WarningCollector collects the UnresolvedTypeMarkWarning.

DenoteBy(name, region, place, symbol)

Determine the model entity a name denoting this declaration denotes, as a part of a type mark (Name.Denote).

A declaration, which a name in a type mark can denote, overrides this method and returns itself: an object, an alias, a type or subtype, a record element, a package. Any other declaration (e.g. a subprogram) is reported.

Parameters:
  • name (Name) – The name denoting this declaration, a part of the type mark.

  • region (DeclarativeRegionMixin) – The declarative region containing the type mark.

  • place (ModelEntity) – The declaration containing the type mark.

  • symbol (Symbol) – The type mark.

Return type:

ModelEntity | None

Returns:

None, as a name in a type mark can’t denote this declaration (reported as a warning).

Raises:

UnhandledCriticalWarningError – Always, if no WarningCollector collects the UnresolvedTypeMarkWarning.

GetAncestor(type)

Return the closest ancestor of the given type found by walking the parent chain upwards.

Iterates the parent chain - starting at this model entity - upwards (toward the root of the model) until an ancestor of the requested type is found.

Parameters:

type (Type) – Class (type) of the ancestor to find.

Return type:

ModelEntity

Returns:

The closest ancestor of the requested type.

Raises:

AncestorNotFoundError – If the root of the model is reached without finding an ancestor of the requested type.

classmethod GetMethodsWithAttributes(predicate=None)

Return the class’ methods that carry at least one matching attribute.

Parameters:

predicate (type[TAttr] | Iterable[type[TAttr]] | None) – Optional, an attribute class, an iterable of attribute classes, or None to accept every attribute.

Return type:

dict[Callable[..., Any], tuple[Attribute, ...]]

Returns:

Dictionary of methods and the matching attributes attached to them.

Raises:
  • ValueError – If an element of parameter ‘predicate’ is not a sub-class of Attribute.

  • ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.

property HasPrefix: bool

Check if the name has a prefix, i.e. _prefix is set.

This is true for all names except simple names.

Returns:

True, if the name has a prefix.

property Identifier: str

Read-only property to access the identifier this name references (_identifier).

Returns:

The referenced identifier.

property IsExpandedName: bool

Check if the name is an expanded name library.package.item: a name ending in all isn’t one.

Returns:

False

property IsOperatorSymbol: bool

Check if the name is an operator symbol (_identifier in quotation marks).

An operator symbol names an operator function, e.g. "and" in an alias declaration.

Returns:

True, if the name is an operator symbol.

property IsOverloadable: bool

Check if this model entity is an overloadable declaration: it may share its designator with other overloadable declarations.

Subprograms, enumeration literals and aliases, which may denote one of them, are overloadable; they override this property.

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

An enumerated type implies its enumeration literals, a physical type its units; they override this method.

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

A generator to iterate (normalized designator, declaration) pairs, in declaration order: none.

IterateTypeMarks(region)

Iterate the type marks of this declaration, each with the region and the place to look it up.

The place of a type mark is the declaration containing it. Declarations with type marks override this method, e.g. an object yields the type mark of its subtype indication, an array type its index and element subtypes.

Parameters:

region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

A generator to iterate (region, place, type mark) tuples, in declaration order: none.

property NormalizedIdentifier: str

Read-only property to access the normalized identifier this name references (_normalizedIdentifier).

See also

Returns:

The referenced identifier (normalized).

property Parent: ModelEntity

Property to access the model entity’s parent element reference in a logical hierarchy (_parent).

Returns:

Reference to the parent entity.

property Position: Position

Cached read-only property to access an IIR’s position in source code (_position).

If _position is None, resolve the position object from _iirNode

Returns:

The IIR’s position in the source file.

property Prefix: Name | None

Read-only property to access the name’s prefix in a chain of names (_prefix).

Returns:

The name left from current name, if not a simple name, otherwise None.

ResetReferences(designUnit, region)

Reset the references ResolveReferences() derived: the references of this declaration’s type marks.

A use clause, an alias and a subtype extend this method.

Parameters:
  • designUnit (DesignUnit) – The design unit containing this declaration.

  • region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Return type:

None

ResolveReferences(designUnit, region)

Resolve the references of this declaration: its type marks (IterateTypeMarks()).

Each type mark is resolved at its place by the region it is looked up in (ResolveTypeMark()). An incomplete type, an alias and a subtype extend this method.

Parameters:
  • designUnit (DesignUnit) – The design unit containing this declaration.

  • region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Raises:

UnhandledCriticalWarningError – If a type mark can’t be resolved, and no WarningCollector collects the UnresolvedTypeMarkWarning.

Return type:

None

property Root: Name

Read-only property to access the root (left-most) element in a chain of names (_root).

In case the name is a simple name, the root points to the name itself.

Returns:

The name’s root element.

Visit(visitor)[source]

Walk this all name and its prefix (if any) with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

Return the object’s state for pickling, collecting every slot of the class hierarchy.

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If a slot was never assigned, so it has no value to serialize.

__new__(**kwargs)
__repr__()

Formats a representation of the name.

Format: Name: 'sig'

Return type:

str

Returns:

String representation of the name.

__setstate__(state)

Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.

Parameters:

state (dict[str, Any]) – Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If the given state misses a slot or carries an unexpected one.

Return type:

None

__str__()

Formats the selected name.

Format: rec.elem

Return type:

str

Returns:

Formatted selected name.

_identifier: str

The name’s identifier.

_normalizedIdentifier: str

The normalized (lower case) identifier.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_prefix: Name | None

Reference to the name’s prefix, or None for a simple name.

_root: Name | None

Reference to the root of the name chain.

class pyGHDL.dom.Name.OpenName(node)[source]

Represents the keyword open used as a special name.

This class implements a pyGHDL.dom object derived from pyVHDLModel.Name.OpenName.

Example

open

Inheritance

Inheritance diagram of OpenName

Parameters:

node (Iir)

__init__(node)[source]

Initializes an open name.

Parameters:

node (Iir) – The IIR node this object was translated from.

Return type:

None

_iirNode: Iir

The IIR node in libghdl’s tree this DOM object was translated from.

_position: Position

The IIR node’s position in the source file, resolved on first access and then cached.

Copy()[source]

Create a copy of this open name.

The copy has no parent.

Return type:

Self

Returns:

The new open name.

Denote(region, place, symbol)

Determine the model entity this name denotes as a part of a type mark, which is an attribute name.

The type mark is an attribute name like rec.f'subtype. A name resolves its prefix first and applies itself to the entity the prefix denotes, which must be of a kind the name can be applied to. A kind of name, which denotes no declaration (e.g. an indexed name m(0) or ptr.all), isn’t supported and is reported.

Parameters:
Return type:

ModelEntity | None

Returns:

The denoted model entity, or None if it can’t be resolved (reported as a warning).

Raises:

UnhandledCriticalWarningError – If this kind of name isn’t supported as a part of a type mark, and no WarningCollector collects the UnresolvedTypeMarkWarning.

DenoteBy(name, region, place, symbol)

Determine the model entity a name denoting this declaration denotes, as a part of a type mark (Name.Denote).

A declaration, which a name in a type mark can denote, overrides this method and returns itself: an object, an alias, a type or subtype, a record element, a package. Any other declaration (e.g. a subprogram) is reported.

Parameters:
  • name (Name) – The name denoting this declaration, a part of the type mark.

  • region (DeclarativeRegionMixin) – The declarative region containing the type mark.

  • place (ModelEntity) – The declaration containing the type mark.

  • symbol (Symbol) – The type mark.

Return type:

ModelEntity | None

Returns:

None, as a name in a type mark can’t denote this declaration (reported as a warning).

Raises:

UnhandledCriticalWarningError – Always, if no WarningCollector collects the UnresolvedTypeMarkWarning.

GetAncestor(type)

Return the closest ancestor of the given type found by walking the parent chain upwards.

Iterates the parent chain - starting at this model entity - upwards (toward the root of the model) until an ancestor of the requested type is found.

Parameters:

type (Type) – Class (type) of the ancestor to find.

Return type:

ModelEntity

Returns:

The closest ancestor of the requested type.

Raises:

AncestorNotFoundError – If the root of the model is reached without finding an ancestor of the requested type.

classmethod GetMethodsWithAttributes(predicate=None)

Return the class’ methods that carry at least one matching attribute.

Parameters:

predicate (type[TAttr] | Iterable[type[TAttr]] | None) – Optional, an attribute class, an iterable of attribute classes, or None to accept every attribute.

Return type:

dict[Callable[..., Any], tuple[Attribute, ...]]

Returns:

Dictionary of methods and the matching attributes attached to them.

Raises:
  • ValueError – If an element of parameter ‘predicate’ is not a sub-class of Attribute.

  • ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.

property HasPrefix: bool

Check if the name has a prefix, i.e. _prefix is set.

This is true for all names except simple names.

Returns:

True, if the name has a prefix.

property Identifier: str

Read-only property to access the identifier this name references (_identifier).

Returns:

The referenced identifier.

property IsExpandedName: bool

Check if the name is an expanded name library.package.item.

A selected name x.y may also select an element of a record object, so only a selected name, whose prefix is a selected name of a simple name, is an expanded name here. Selected names override this property.

Returns:

True, if the name is an expanded name library.package.item.

property IsOperatorSymbol: bool

Check if the name is an operator symbol (_identifier in quotation marks).

An operator symbol names an operator function, e.g. "and" in an alias declaration.

Returns:

True, if the name is an operator symbol.

property IsOverloadable: bool

Check if this model entity is an overloadable declaration: it may share its designator with other overloadable declarations.

Subprograms, enumeration literals and aliases, which may denote one of them, are overloadable; they override this property.

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

An enumerated type implies its enumeration literals, a physical type its units; they override this method.

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

A generator to iterate (normalized designator, declaration) pairs, in declaration order: none.

IterateTypeMarks(region)

Iterate the type marks of this declaration, each with the region and the place to look it up.

The place of a type mark is the declaration containing it. Declarations with type marks override this method, e.g. an object yields the type mark of its subtype indication, an array type its index and element subtypes.

Parameters:

region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

A generator to iterate (region, place, type mark) tuples, in declaration order: none.

property NormalizedIdentifier: str

Read-only property to access the normalized identifier this name references (_normalizedIdentifier).

See also

Returns:

The referenced identifier (normalized).

property Parent: ModelEntity

Property to access the model entity’s parent element reference in a logical hierarchy (_parent).

Returns:

Reference to the parent entity.

property Position: Position

Cached read-only property to access an IIR’s position in source code (_position).

If _position is None, resolve the position object from _iirNode

Returns:

The IIR’s position in the source file.

property Prefix: Name | None

Read-only property to access the name’s prefix in a chain of names (_prefix).

Returns:

The name left from current name, if not a simple name, otherwise None.

ResetReferences(designUnit, region)

Reset the references ResolveReferences() derived: the references of this declaration’s type marks.

A use clause, an alias and a subtype extend this method.

Parameters:
  • designUnit (DesignUnit) – The design unit containing this declaration.

  • region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Return type:

None

ResolveReferences(designUnit, region)

Resolve the references of this declaration: its type marks (IterateTypeMarks()).

Each type mark is resolved at its place by the region it is looked up in (ResolveTypeMark()). An incomplete type, an alias and a subtype extend this method.

Parameters:
  • designUnit (DesignUnit) – The design unit containing this declaration.

  • region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Raises:

UnhandledCriticalWarningError – If a type mark can’t be resolved, and no WarningCollector collects the UnresolvedTypeMarkWarning.

Return type:

None

property Root: Name

Read-only property to access the root (left-most) element in a chain of names (_root).

In case the name is a simple name, the root points to the name itself.

Returns:

The name’s root element.

Visit(visitor)[source]

Walk this open name with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

Return the object’s state for pickling, collecting every slot of the class hierarchy.

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If a slot was never assigned, so it has no value to serialize.

__new__(**kwargs)
__repr__()

Formats a representation of the name.

Format: Name: 'sig'

Return type:

str

Returns:

String representation of the name.

__setstate__(state)

Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.

Parameters:

state (dict[str, Any]) – Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If the given state misses a slot or carries an unexpected one.

Return type:

None

__str__()[source]

Formats the open name.

Format: open

Return type:

str

Returns:

Formatted open name.

_identifier: str

The name’s identifier.

_normalizedIdentifier: str

The normalized (lower case) identifier.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_prefix: Name | None

Reference to the name’s prefix, or None for a simple name.

_root: Name | None

Reference to the root of the name chain.