pyGHDL.dom.Literal

This module implements derived literal classes from pyVHDLModel.Expression.

Classes


Classes

class pyGHDL.dom.Literal.NullLiteral(node)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Expression.NullLiteral.

Represents a null literal.

A null literal denotes the null value of an access type.

Example

p := null;
--   ^^^^    <- the literal

Inheritance

Inheritance diagram of NullLiteral

Parameters:

node (Iir)

__init__(node)[source]

Initializes a null literal.

Parameters:

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

Return type:

None

classmethod parse(node)[source]

Translates an IIR node to a NullLiteral.

Parameters:

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

Return type:

Self

Returns:

The translated object.

_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 null literal.

The copy has no parent.

Return type:

Self

Returns:

The new null literal.

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 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 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.

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

Visit(visitor)[source]

Walk this null literal 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)
__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 null literal.

Format: null

Return type:

str

Returns:

Formatted null literal.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

class pyGHDL.dom.Literal.EnumerationLiteral(node, value, documentation=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Expression.EnumerationLiteral.

Represents an enumeration literal.

The literal’s name is available as Value.

Example

st <= Idle;
--    ^^^^    <- Value

Inheritance

Inheritance diagram of EnumerationLiteral

Parameters:
__init__(node, value, documentation=None)[source]

Initializes an enumeration literal.

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

  • value (str) – The enumeration literal’s name.

  • documentation (str) – Optional, the documentation comment associated with this declaration.

Return type:

None

classmethod parse(literalNode)[source]

Translates the IIR node of the literal to an EnumerationLiteral.

Parameters:

literalNode (Iir) – The IIR node of the literal.

Return type:

Self

Returns:

The translated literal.

_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 enumeration literal.

The copy has no parent.

Return type:

Self

Returns:

The new enumeration literal.

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.

property Documentation: str | None

Read-only property to access the model entity’s documentation (_documentation).

Returns:

Associated documentation of a model entity.

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.

GetIdentifier(normalizedIdentifier)[source]

Return the literal as declared, for its normalized designator.

Parameters:

normalizedIdentifier (str) – The literal’s normalized designator.

Return type:

str

Returns:

The literal in its declared spelling.

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 IsOverloadable: bool

Check if this enumeration literal is overloadable: always, it may share its designator with other enumeration literals and subprograms.

Returns:

True.

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 NormalizedDesignator: str

Read-only property to return the normalized designator, the key the literal is indexed by in a namespace.

See also

Returns:

The literal’s name in lower case.

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.

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 Value: str

Read-only property to access the value (_value).

Returns:

The value.

Visit(visitor)[source]

Walk this enumeration literal 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)
__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 enumeration literal.

Format: idle

Return type:

str

Returns:

Formatted enumeration literal.

_documentation: str | None

The associated documentation of a model entity.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_value: str

The enumeration literal’s name.

class pyGHDL.dom.Literal.CharacterEnumerationLiteral(node, value, documentation=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Expression.CharacterEnumerationLiteral.

Represents an enumeration literal that is a character literal.

The literal’s character is available as Value. It is the bare character without the enclosing apostrophes: 0 for the enumeration literal '0' of type bit is ('0', '1');. This distinguishes it from an enumeration literal named by an identifier with the same text.

Example

type logic is ('0', '1', 'Z');
--              ^  <- Value

Inheritance

Inheritance diagram of CharacterEnumerationLiteral

Parameters:
__init__(node, value, documentation=None)[source]

Initializes a character enumeration literal.

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

  • value (str) – The enumeration literal’s character, without quotes.

  • documentation (str) – Optional, the documentation comment associated with this declaration.

Return type:

None

classmethod parse(literalNode)[source]

Translates the IIR node of the literal to a CharacterEnumerationLiteral.

Parameters:

literalNode (Iir) – The IIR node of the literal.

Return type:

Self

Returns:

The translated literal.

_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 character enumeration literal.

The copy has no parent.

Return type:

Self

Returns:

The new character enumeration literal.

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.

property Documentation: str | None

Read-only property to access the model entity’s documentation (_documentation).

Returns:

Associated documentation of a model entity.

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.

GetIdentifier(normalizedIdentifier)

Return the literal as declared, for its normalized designator.

Parameters:

normalizedIdentifier (str) – The literal’s normalized designator.

Return type:

str

Returns:

The literal in its declared spelling.

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 IsOverloadable: bool

Check if this enumeration literal is overloadable: always, it may share its designator with other enumeration literals and subprograms.

Returns:

True.

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 NormalizedDesignator: str

Read-only property to return the normalized designator, the key the literal is indexed by in a namespace.

A character literal keeps its case and is enclosed in apostrophes, so the literal 'a' doesn’t clash with an identifier a.

See also

Returns:

The character enclosed in apostrophes.

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.

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 Value: str

Read-only property to access the value (_value).

Returns:

The value.

Visit(visitor)[source]

Walk this character enumeration literal 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)
__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 character enumeration literal.

Format: '0'

Return type:

str

Returns:

Formatted character enumeration literal.

_documentation: str | None

The associated documentation of a model entity.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_value: str

The enumeration literal’s name.

class pyGHDL.dom.Literal.IntegerLiteral(node, value)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Expression.IntegerLiteral.

Represents an integer literal.

The literal’s value is available as Value.

Example

res := a + 42;
--         ^^    <- Value

Inheritance

Inheritance diagram of IntegerLiteral

Parameters:
__init__(node, value)[source]

Initializes an integer literal.

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

  • value (int) – The literal’s integer value.

Return type:

None

classmethod parse(literalNode)[source]

Translates the IIR node of the literal to an IntegerLiteral.

Parameters:

literalNode (Iir) – The IIR node of the literal.

Return type:

Self

Returns:

The translated literal.

_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 integer literal.

The copy has no parent.

Return type:

Self

Returns:

The new integer literal.

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 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 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.

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 Value: int

Read-only property to access the value (_value).

Returns:

The value.

Visit(visitor)[source]

Walk this integer literal 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)
__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 integer literal.

Format: 42

Return type:

str

Returns:

Formatted integer literal.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_value: int

The literal’s integer value.

class pyGHDL.dom.Literal.FloatingPointLiteral(node, value)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Expression.FloatingPointLiteral.

Represents a floating-point literal.

The literal’s value is available as Value.

Example

r <= 3.14;
--   ^^^^    <- Value

Inheritance

Inheritance diagram of FloatingPointLiteral

Parameters:
__init__(node, value)[source]

Initializes a floating-point literal.

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

  • value (float) – The literal’s floating-point value.

Return type:

None

classmethod parse(literalNode)[source]

Translates the IIR node of the literal to a FloatingPointLiteral.

Parameters:

literalNode (Iir) – The IIR node of the literal.

Return type:

Self

Returns:

The translated literal.

_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 floating-point literal.

The copy has no parent.

Return type:

Self

Returns:

The new floating-point literal.

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 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 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.

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 Value: float

Read-only property to access the value (_value).

Returns:

The value.

Visit(visitor)[source]

Walk this floating-point literal 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)
__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 floating-point literal.

Format: 3.5

Return type:

str

Returns:

Formatted floating-point literal.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_value: float

The literal’s floating-point value.

class pyGHDL.dom.Literal.PhysicalIntegerLiteral(node, value, unitName)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Expression.PhysicalIntegerLiteral.

Represents a physical literal with an integer value.

Value (Value) and unit name (UnitName) are available separately.

Example

t <= 10 ns;
--   ^^       <- Value
--      ^^    <- UnitName

Inheritance

Inheritance diagram of PhysicalIntegerLiteral

Parameters:
__init__(node, value, unitName)[source]

Initializes a physical literal with an integer value.

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

  • value (int) – The literal’s integer value, in units of _unitName.

  • unitName (str) – The name of the physical unit the value is given in.

Return type:

None

classmethod parse(literalNode)[source]

Translates the IIR node of the literal to a PhysicalIntegerLiteral.

Parameters:

literalNode (Iir) – The IIR node of the literal.

Return type:

Self

Returns:

The translated literal.

_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 physical literal.

The copy has no parent.

Return type:

Self

Returns:

The new physical literal.

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 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 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.

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 UnitName: str

Read-only property to access the unit name (_unitName).

Returns:

The unit name.

property Value: int

Read-only property to access the value (_value).

Returns:

The value.

Visit(visitor)[source]

Walk this physical literal with an integer value 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)
__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 physical literal.

Format: 10 ns

Return type:

str

Returns:

Formatted physical literal.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_unitName: str

The name of the physical unit the value is given in.

_value: int

The literal’s integer value, in units of _unitName.

class pyGHDL.dom.Literal.PhysicalFloatingLiteral(node, value, unitName)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Expression.PhysicalFloatingLiteral.

Represents a physical literal with a floating-point value.

Value (Value) and unit name (UnitName) are available separately.

Example

t <= 1.5 ns;
--   ^^^       <- Value
--       ^^    <- UnitName

Inheritance

Inheritance diagram of PhysicalFloatingLiteral

Parameters:
__init__(node, value, unitName)[source]

Initializes a physical literal with a floating-point value.

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

  • value (int) – The literal’s floating-point value, in units of _unitName.

  • unitName (float) – The name of the physical unit the value is given in.

Return type:

None

classmethod parse(literalNode)[source]

Translates the IIR node of the literal to a PhysicalFloatingLiteral.

Parameters:

literalNode (Iir) – The IIR node of the literal.

Return type:

Self

Returns:

The translated literal.

_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 physical literal.

The copy has no parent.

Return type:

Self

Returns:

The new physical literal.

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 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 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.

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 UnitName: str

Read-only property to access the unit name (_unitName).

Returns:

The unit name.

property Value: float

Read-only property to access the value (_value).

Returns:

The value.

Visit(visitor)[source]

Walk this physical literal with a floating-point value 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)
__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 physical literal.

Format: 10 ns

Return type:

str

Returns:

Formatted physical literal.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_unitName: str

The name of the physical unit the value is given in.

_value: float

The literal’s floating-point value, in units of _unitName.

class pyGHDL.dom.Literal.CharacterLiteral(node, value)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Expression.CharacterLiteral.

Represents a character literal.

The literal’s character is available as Value. It is the bare character without the enclosing apostrophes: a for the character literal 'a'.

Example

ch <= 'a';
--     ^     <- Value

Inheritance

Inheritance diagram of CharacterLiteral

Parameters:
__init__(node, value)[source]

Initializes a character literal.

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

  • value (str) – The literal’s character value.

Return type:

None

classmethod parse(literalNode)[source]

Translates the IIR node of the literal to a CharacterLiteral.

Parameters:

literalNode (Iir) – The IIR node of the literal.

Return type:

Self

Returns:

The translated literal.

_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 character literal.

The copy has no parent.

Return type:

Self

Returns:

The new character literal.

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 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 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.

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 Value: str

Read-only property to access the value (_value).

Returns:

The value.

Visit(visitor)[source]

Walk this character literal 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)
__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 character literal.

Format: a

Return type:

str

Returns:

Formatted character literal.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_value: str

The literal’s character value without apostrophes.

class pyGHDL.dom.Literal.BinaryBitStringLiteral(node, value, length=None, isSigned=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Expression.BinaryBitStringLiteral.

Represents a bit string literal written in base 2.

Example

res := b"10100000";
--     ^^^^^^^^^^^    <- Value

Inheritance

Inheritance diagram of BinaryBitStringLiteral

Parameters:
  • node (Iir)

  • value (str)

  • length (Nullable[int])

  • isSigned (Nullable[bool])

__init__(node, value, length=None, isSigned=None)[source]

Initializes a binary bit string literal.

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

  • value (str) – The literal as written in the source, without the enclosing double quotes.

  • length (int | None) – Optional, the explicitly given length, or None if the literal has no length specification.

  • isSigned (bool | None) – Optional, True if signed, False if unsigned, None if unspecified.

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 BinaryValue: str

Read-only property to return the literal’s string value, one character per bit (_binaryValue).

The value follows IEEE Std 1076-2008, clause 15.8. It is computed from Value, the base, Length and IsSigned on first access and cached:

  1. Underscores are removed.

  2. Expansion:

    • Binary, octal and hexadecimal: each digit valid for the base is replaced by its 1, 3 or 4 bits; hexadecimal digits are case-insensitive. Each other graphic character, e.g. X, Z or -, is repeated 1, 3 or 4 times, keeping its case.

    • Decimal: the digits are converted to binary with the minimal number of bits (none for 0).

  3. With a length larger than the expanded value, the value is padded on the left: with 0 if unsigned or unspecified, with the leftmost character if signed.

  4. With a length smaller than the expanded value, leftmost characters are deleted: only 0 if unsigned or unspecified, only copies of the leftmost remaining character if signed.

Example: 12sx"F5" → 111111110101.

Returns:

The literal’s string value, one character per bit.

Raises:
  • LiteralError – If the value starts or ends with an underscore or contains two consecutive underscores.

  • LiteralError – If a decimal literal is signed or unsigned.

  • LiteralError – If a decimal literal contains a character other than a digit or an underscore.

  • LiteralError – If a digit is not allowed in the base, e.g. 2 in a binary literal.

  • LiteralError – If the value contains a non-graphic character.

  • LiteralError – If a signed literal with an empty expanded value has a non-zero length.

  • LiteralError – If the length of an unsigned or unspecified literal truncates a character other than 0.
    Only leading ‘0’ characters can be truncated.

  • LiteralError – If the length of a signed literal truncates a character other than the sign.
    Only copies of the leftmost remaining character can be truncated.

property Bits: int

Read-only property to return the number of bits the literal represents.

This is the length of BinaryValue, computed the same way, so the same exceptions apply.

Returns:

The number of bits.

Copy()

Create a copy of this bit string literal.

The copy has no parent.

Return type:

Self

Returns:

The new bit string literal.

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 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.

property IsSigned: bool | None

Check if the bit string literal is signed (_isSigned).

Returns:

True, if the literal is signed; False, if unsigned; None, if unspecified.

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 Length: int | None

Read-only property to access the length (_length).

Returns:

The length, or None if not set.

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.

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 Value: str

Read-only property to access the value (_value).

Returns:

The value.

Visit(visitor)

Walk this bit string literal with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_BASE: ClassVar[BitStringBase] = 2

The base this literal is written in.

__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)
__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 bit string literal.

Format: 8ub"10100000"

The length and the signedness marker (s/u) are omitted when unspecified.

Return type:

str

Returns:

Formatted bit string literal.

_binaryValue: str | None

The literal’s string value, one character per bit, or None until computed.

_isSigned: bool | None

True if signed, False if unsigned, None if unspecified.

_length: int | None

The explicitly given length, or None if the literal has no length specification.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_value: str

The literal as written in the source, without the enclosing double quotes.

class pyGHDL.dom.Literal.OctalBitStringLiteral(node, value, length=None, isSigned=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Expression.OctalBitStringLiteral.

Represents a bit string literal written in base 8.

Each digit contributes three bits.

Example

res := o"240";
--     ^^^^^^    <- Value

Inheritance

Inheritance diagram of OctalBitStringLiteral

Parameters:
  • node (Iir)

  • value (str)

  • length (Nullable[int])

  • isSigned (Nullable[bool])

__init__(node, value, length=None, isSigned=None)[source]

Initializes an octal bit string literal.

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

  • value (str) – The literal as written in the source, without the enclosing double quotes.

  • length (int | None) – Optional, the explicitly given length, or None if the literal has no length specification.

  • isSigned (bool | None) – Optional, True if signed, False if unsigned, None if unspecified.

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 BinaryValue: str

Read-only property to return the literal’s string value, one character per bit (_binaryValue).

The value follows IEEE Std 1076-2008, clause 15.8. It is computed from Value, the base, Length and IsSigned on first access and cached:

  1. Underscores are removed.

  2. Expansion:

    • Binary, octal and hexadecimal: each digit valid for the base is replaced by its 1, 3 or 4 bits; hexadecimal digits are case-insensitive. Each other graphic character, e.g. X, Z or -, is repeated 1, 3 or 4 times, keeping its case.

    • Decimal: the digits are converted to binary with the minimal number of bits (none for 0).

  3. With a length larger than the expanded value, the value is padded on the left: with 0 if unsigned or unspecified, with the leftmost character if signed.

  4. With a length smaller than the expanded value, leftmost characters are deleted: only 0 if unsigned or unspecified, only copies of the leftmost remaining character if signed.

Example: 12sx"F5" → 111111110101.

Returns:

The literal’s string value, one character per bit.

Raises:
  • LiteralError – If the value starts or ends with an underscore or contains two consecutive underscores.

  • LiteralError – If a decimal literal is signed or unsigned.

  • LiteralError – If a decimal literal contains a character other than a digit or an underscore.

  • LiteralError – If a digit is not allowed in the base, e.g. 2 in a binary literal.

  • LiteralError – If the value contains a non-graphic character.

  • LiteralError – If a signed literal with an empty expanded value has a non-zero length.

  • LiteralError – If the length of an unsigned or unspecified literal truncates a character other than 0.
    Only leading ‘0’ characters can be truncated.

  • LiteralError – If the length of a signed literal truncates a character other than the sign.
    Only copies of the leftmost remaining character can be truncated.

property Bits: int

Read-only property to return the number of bits the literal represents.

This is the length of BinaryValue, computed the same way, so the same exceptions apply.

Returns:

The number of bits.

Copy()

Create a copy of this bit string literal.

The copy has no parent.

Return type:

Self

Returns:

The new bit string literal.

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 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.

property IsSigned: bool | None

Check if the bit string literal is signed (_isSigned).

Returns:

True, if the literal is signed; False, if unsigned; None, if unspecified.

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 Length: int | None

Read-only property to access the length (_length).

Returns:

The length, or None if not set.

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.

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 Value: str

Read-only property to access the value (_value).

Returns:

The value.

Visit(visitor)

Walk this bit string literal with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_BASE: ClassVar[BitStringBase] = 8

The base this literal is written in.

__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)
__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 bit string literal.

Format: 8ub"10100000"

The length and the signedness marker (s/u) are omitted when unspecified.

Return type:

str

Returns:

Formatted bit string literal.

_binaryValue: str | None

The literal’s string value, one character per bit, or None until computed.

_isSigned: bool | None

True if signed, False if unsigned, None if unspecified.

_length: int | None

The explicitly given length, or None if the literal has no length specification.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_value: str

The literal as written in the source, without the enclosing double quotes.

class pyGHDL.dom.Literal.DecimalBitStringLiteral(node, value, length=None, isSigned=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Expression.DecimalBitStringLiteral.

Represents a bit string literal written in base 10.

Example

res := d"160";
--     ^^^^^^    <- Value

Inheritance

Inheritance diagram of DecimalBitStringLiteral

Parameters:
  • node (Iir)

  • value (str)

  • length (Nullable[int])

  • isSigned (Nullable[bool])

__init__(node, value, length=None, isSigned=None)[source]

Initializes a decimal bit string literal.

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

  • value (str) – The literal as written in the source, without the enclosing double quotes.

  • length (int | None) – Optional, the explicitly given length, or None if the literal has no length specification.

  • isSigned (bool | None) – Optional, True if signed, False if unsigned, None if unspecified.

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 BinaryValue: str

Read-only property to return the literal’s string value, one character per bit (_binaryValue).

The value follows IEEE Std 1076-2008, clause 15.8. It is computed from Value, the base, Length and IsSigned on first access and cached:

  1. Underscores are removed.

  2. Expansion:

    • Binary, octal and hexadecimal: each digit valid for the base is replaced by its 1, 3 or 4 bits; hexadecimal digits are case-insensitive. Each other graphic character, e.g. X, Z or -, is repeated 1, 3 or 4 times, keeping its case.

    • Decimal: the digits are converted to binary with the minimal number of bits (none for 0).

  3. With a length larger than the expanded value, the value is padded on the left: with 0 if unsigned or unspecified, with the leftmost character if signed.

  4. With a length smaller than the expanded value, leftmost characters are deleted: only 0 if unsigned or unspecified, only copies of the leftmost remaining character if signed.

Example: 12sx"F5" → 111111110101.

Returns:

The literal’s string value, one character per bit.

Raises:
  • LiteralError – If the value starts or ends with an underscore or contains two consecutive underscores.

  • LiteralError – If a decimal literal is signed or unsigned.

  • LiteralError – If a decimal literal contains a character other than a digit or an underscore.

  • LiteralError – If a digit is not allowed in the base, e.g. 2 in a binary literal.

  • LiteralError – If the value contains a non-graphic character.

  • LiteralError – If a signed literal with an empty expanded value has a non-zero length.

  • LiteralError – If the length of an unsigned or unspecified literal truncates a character other than 0.
    Only leading ‘0’ characters can be truncated.

  • LiteralError – If the length of a signed literal truncates a character other than the sign.
    Only copies of the leftmost remaining character can be truncated.

property Bits: int

Read-only property to return the number of bits the literal represents.

This is the length of BinaryValue, computed the same way, so the same exceptions apply.

Returns:

The number of bits.

Copy()

Create a copy of this bit string literal.

The copy has no parent.

Return type:

Self

Returns:

The new bit string literal.

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 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.

property IsSigned: bool | None

Check if the bit string literal is signed (_isSigned).

Returns:

True, if the literal is signed; False, if unsigned; None, if unspecified.

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 Length: int | None

Read-only property to access the length (_length).

Returns:

The length, or None if not set.

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.

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 Value: str

Read-only property to access the value (_value).

Returns:

The value.

Visit(visitor)

Walk this bit string literal with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_BASE: ClassVar[BitStringBase] = 10

The base this literal is written in.

__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)
__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 bit string literal.

Format: 8ub"10100000"

The length and the signedness marker (s/u) are omitted when unspecified.

Return type:

str

Returns:

Formatted bit string literal.

_binaryValue: str | None

The literal’s string value, one character per bit, or None until computed.

_isSigned: bool | None

True if signed, False if unsigned, None if unspecified.

_length: int | None

The explicitly given length, or None if the literal has no length specification.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_value: str

The literal as written in the source, without the enclosing double quotes.

class pyGHDL.dom.Literal.HexadecimalBitStringLiteral(node, value, length=None, isSigned=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Expression.HexadecimalBitStringLiteral.

Represents a bit string literal written in base 16.

Each digit contributes four bits.

Example

res := x"A0";
--     ^^^^^    <- Value

Inheritance

Inheritance diagram of HexadecimalBitStringLiteral

Parameters:
  • node (Iir)

  • value (str)

  • length (Nullable[int])

  • isSigned (Nullable[bool])

__init__(node, value, length=None, isSigned=None)[source]

Initializes a hexadecimal bit string literal.

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

  • value (str) – The literal as written in the source, without the enclosing double quotes.

  • length (int | None) – Optional, the explicitly given length, or None if the literal has no length specification.

  • isSigned (bool | None) – Optional, True if signed, False if unsigned, None if unspecified.

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 BinaryValue: str

Read-only property to return the literal’s string value, one character per bit (_binaryValue).

The value follows IEEE Std 1076-2008, clause 15.8. It is computed from Value, the base, Length and IsSigned on first access and cached:

  1. Underscores are removed.

  2. Expansion:

    • Binary, octal and hexadecimal: each digit valid for the base is replaced by its 1, 3 or 4 bits; hexadecimal digits are case-insensitive. Each other graphic character, e.g. X, Z or -, is repeated 1, 3 or 4 times, keeping its case.

    • Decimal: the digits are converted to binary with the minimal number of bits (none for 0).

  3. With a length larger than the expanded value, the value is padded on the left: with 0 if unsigned or unspecified, with the leftmost character if signed.

  4. With a length smaller than the expanded value, leftmost characters are deleted: only 0 if unsigned or unspecified, only copies of the leftmost remaining character if signed.

Example: 12sx"F5" → 111111110101.

Returns:

The literal’s string value, one character per bit.

Raises:
  • LiteralError – If the value starts or ends with an underscore or contains two consecutive underscores.

  • LiteralError – If a decimal literal is signed or unsigned.

  • LiteralError – If a decimal literal contains a character other than a digit or an underscore.

  • LiteralError – If a digit is not allowed in the base, e.g. 2 in a binary literal.

  • LiteralError – If the value contains a non-graphic character.

  • LiteralError – If a signed literal with an empty expanded value has a non-zero length.

  • LiteralError – If the length of an unsigned or unspecified literal truncates a character other than 0.
    Only leading ‘0’ characters can be truncated.

  • LiteralError – If the length of a signed literal truncates a character other than the sign.
    Only copies of the leftmost remaining character can be truncated.

property Bits: int

Read-only property to return the number of bits the literal represents.

This is the length of BinaryValue, computed the same way, so the same exceptions apply.

Returns:

The number of bits.

Copy()

Create a copy of this bit string literal.

The copy has no parent.

Return type:

Self

Returns:

The new bit string literal.

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 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.

property IsSigned: bool | None

Check if the bit string literal is signed (_isSigned).

Returns:

True, if the literal is signed; False, if unsigned; None, if unspecified.

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 Length: int | None

Read-only property to access the length (_length).

Returns:

The length, or None if not set.

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.

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 Value: str

Read-only property to access the value (_value).

Returns:

The value.

Visit(visitor)

Walk this bit string literal with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_BASE: ClassVar[BitStringBase] = 16

The base this literal is written in.

__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)
__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 bit string literal.

Format: 8ub"10100000"

The length and the signedness marker (s/u) are omitted when unspecified.

Return type:

str

Returns:

Formatted bit string literal.

_binaryValue: str | None

The literal’s string value, one character per bit, or None until computed.

_isSigned: bool | None

True if signed, False if unsigned, None if unspecified.

_length: int | None

The explicitly given length, or None if the literal has no length specification.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_value: str

The literal as written in the source, without the enclosing double quotes.

class pyGHDL.dom.Literal.StringLiteral(node, value)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Expression.StringLiteral.

Represents a string literal.

The literal’s text is available as Value.

Example

txt <= "text";
--     ^^^^^^    <- Value

Inheritance

Inheritance diagram of StringLiteral

Parameters:
__init__(node, value)[source]

Initializes a string literal.

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

  • value (str) – The literal’s string value, without the enclosing double quotes.

Return type:

None

classmethod parse(literalNode)[source]

Translates the IIR node of the literal to a StringLiteral.

A bit string literal’s value is the literal as written in the source, without length, signedness, base specifier and delimiters (x"A_5" has the value A_5).

Parameters:

literalNode (Iir) – The IIR node of the literal.

Return type:

StringLiteral | BinaryBitStringLiteral | OctalBitStringLiteral | DecimalBitStringLiteral | HexadecimalBitStringLiteral

Returns:

The translated literal.

Raises:
_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 string literal.

The copy has no parent.

Return type:

Self

Returns:

The new string literal.

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 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 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.

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 Value: str

Read-only property to access the value (_value).

Returns:

The value.

Visit(visitor)[source]

Walk this string literal 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)
__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 string literal.

Format: "hello"

Return type:

str

Returns:

Formatted string literal.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_value: str

The literal’s string value, without the enclosing double quotes.