pyGHDL.dom.Type

This module implements derived type classes from pyVHDLModel.Type.

Classes


Classes

class pyGHDL.dom.Type.IncompleteType(node, identifier, documentation=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Type.AnonymousType.

Represents a base-class for types without a type definition of their own.

An incomplete type is the typical case: it names a type (Identifier) whose full definition follows later in the same declarative part.

Example

type node;
--   ^^^^                  <- Identifier
type ptr is access node;
type node is record
  value    : integer;
  nextNode : ptr;
end record;

Inheritance

Inheritance diagram of IncompleteType

Parameters:
  • node (Iir)

  • identifier (str)

  • documentation (str)

__init__(node, identifier, documentation=None)[source]

Initializes an incomplete type declaration.

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

  • identifier (str) – Name of the type.

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

Return type:

None

classmethod parse(node, documentation=None)[source]

Translates an IIR node to an IncompleteType.

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

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

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.

property BaseType: BaseType

Read-only property to return the base type of this type: the type itself (IEEE Std 1076-2008, 5.1).

A subtype returns the base type of the type it is derived from (BaseType).

Returns:

The base type.

DenoteBy(name, region, place, symbol)

Return this type or subtype, the model entity a name in a type mark denotes.

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:

This type or subtype.

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 identifier as declared, for the model entity’s normalized identifier.

Parameters:

normalizedIdentifier (str) – The model entity’s normalized (lower case) identifier.

Return type:

str

Returns:

The identifier 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 Identifier: str

Read-only property to access the model entity’s identifier (_identifier).

Returns:

Name of a model entity.

property IsOverloadable: bool

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

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

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

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

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

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

IterateTypeMarks(region)

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

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

Parameters:

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

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

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

property NormalizedIdentifier: str

Read-only property to access the model entity’s normalized identifier (_normalizedIdentifier).

See also

Returns:

Normalized name of a model entity.

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)

Check that a full type declaration of the same name completes this incomplete type later in its region.

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

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

Raises:

UnhandledCriticalWarningError – If no full type declaration follows in the region, and no WarningCollector collects the IncompleteTypeWarning.

Return type:

None

Visit(visitor)

Walk this incomplete type declaration 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 type declaration.

Format: type myType

Return type:

str

Returns:

Formatted type declaration.

_documentation: str | None

The associated documentation of a model entity.

_identifier: str

The identifier of a model entity.

_normalizedIdentifier: str

The normalized (lower case) identifier of a model entity.

_objectVertex: Vertex

The vertex representing this type in the design’s object graph.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

class pyGHDL.dom.Type.EnumeratedType(node, identifier, literals, documentation=None)[source]

Represents an enumerated type.

This class implements a pyGHDL.dom object derived from pyVHDLModel.Type.EnumeratedType.

Example

type integer is (lit_1, lit2, ...);

Inheritance

Inheritance diagram of EnumeratedType

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

Initializes an enumerated type definition.

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

  • identifier (str) – The enumeration type’s identifier.

  • literals (List[EnumerationLiteral]) – List of all enumeration literals, in declaration order.

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

Return type:

None

classmethod parse(typeName, typeDefinitionNode, documentation=None)[source]

Parses an enumerated type IIR and returns an EnumeratedType instance.

Parameters:
  • typeName (str) – The identifier of the type.

  • typeDefinitionNode (Iir) – The IIR node to parse.

  • documentation (str) – Optional, the documentation comment on the type declaration.

Return type:

Self

Returns:

The enumerated type instance.

_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 BaseType: BaseType

Read-only property to return the base type of this type: the type itself (IEEE Std 1076-2008, 5.1).

A subtype returns the base type of the type it is derived from (BaseType).

Returns:

The base type.

DenoteBy(name, region, place, symbol)

Return this type or subtype, the model entity a name in a type mark denotes.

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:

This type or subtype.

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 identifier as declared, for the model entity’s normalized identifier.

Parameters:

normalizedIdentifier (str) – The model entity’s normalized (lower case) identifier.

Return type:

str

Returns:

The identifier 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 Identifier: str

Read-only property to access the model entity’s identifier (_identifier).

Returns:

Name of a model entity.

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()[source]

Iterate the enumeration literals this type declaration implies.

Return type:

Generator[tuple[str, EnumerationLiteral]]

Returns:

A generator to iterate (normalized designator, enumeration literal) pairs, in declaration order.

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 Literals: list[EnumerationLiteral]

Read-only property to access the literals (_literals).

Returns:

List of literals.

property NormalizedIdentifier: str

Read-only property to access the model entity’s normalized identifier (_normalizedIdentifier).

See also

Returns:

Normalized name of a model entity.

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 enumerated type and its literals 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 enumerated type definition.

Format: state is (idle, run)

Return type:

str

Returns:

Formatted enumerated type definition.

_documentation: str | None

The associated documentation of a model entity.

_identifier: str

The identifier of a model entity.

_literals: list[EnumerationLiteral]

List of all enumeration literals, in declaration order.

_normalizedIdentifier: str

The normalized (lower case) identifier of a model entity.

_objectVertex: Vertex

The vertex representing this type in the design’s object graph.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

class pyGHDL.dom.Type.IntegerType(node, typeName, rng, documentation=None)[source]

Represents an integer type.

This class implements a pyGHDL.dom object derived from pyVHDLModel.Type.IntegerType.

Example

type integer is range -2147483648 to 2147483647;

Inheritance

Inheritance diagram of IntegerType

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

Initializes an integer type definition.

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

  • typeName (str) – The type’s identifier.

  • rng (Range | Name) – The range constraining this scalar type.

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

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 BaseType: BaseType

Read-only property to return the base type of this type: the type itself (IEEE Std 1076-2008, 5.1).

A subtype returns the base type of the type it is derived from (BaseType).

Returns:

The base type.

DenoteBy(name, region, place, symbol)

Return this type or subtype, the model entity a name in a type mark denotes.

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:

This type or subtype.

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 identifier as declared, for the model entity’s normalized identifier.

Parameters:

normalizedIdentifier (str) – The model entity’s normalized (lower case) identifier.

Return type:

str

Returns:

The identifier 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 Identifier: str

Read-only property to access the model entity’s identifier (_identifier).

Returns:

Name of a model entity.

property IsOverloadable: bool

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

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

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

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

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

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

IterateTypeMarks(region)

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

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

Parameters:

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

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

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

property NormalizedIdentifier: str

Read-only property to access the model entity’s normalized identifier (_normalizedIdentifier).

See also

Returns:

Normalized name of a model entity.

property Parent: ModelEntity

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

Returns:

Reference to the parent entity.

property Position: Position

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

If _position is None, resolve the position object from _iirNode

Returns:

The IIR’s position in the source file.

property Range: Range

Read-only property to access the type’s range (_range).

Returns:

The range.

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 integer type and its range 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 type definition.

Format: byte_count is range 0 to 7

Return type:

str

Returns:

Formatted integer type definition.

_documentation: str | None

The associated documentation of a model entity.

_identifier: str

The identifier of a model entity.

_normalizedIdentifier: str

The normalized (lower case) identifier of a model entity.

_objectVertex: Vertex

The vertex representing this type in the design’s object graph.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_range: Range

The range constraining this scalar type.

class pyGHDL.dom.Type.RealType(node, typeName, rng, documentation=None)[source]

Represents a real type (floating-point type).

This class implements a pyGHDL.dom object derived from pyVHDLModel.Type.RealType.

Example

type real is range -1.79769313486232E308 to 1.79769313486232E308;

Inheritance

Inheritance diagram of RealType

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

Initializes a real type definition.

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

  • typeName (str) – The type’s identifier.

  • rng (Range) – The range constraining this scalar type.

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

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 BaseType: BaseType

Read-only property to return the base type of this type: the type itself (IEEE Std 1076-2008, 5.1).

A subtype returns the base type of the type it is derived from (BaseType).

Returns:

The base type.

DenoteBy(name, region, place, symbol)

Return this type or subtype, the model entity a name in a type mark denotes.

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:

This type or subtype.

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 identifier as declared, for the model entity’s normalized identifier.

Parameters:

normalizedIdentifier (str) – The model entity’s normalized (lower case) identifier.

Return type:

str

Returns:

The identifier 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 Identifier: str

Read-only property to access the model entity’s identifier (_identifier).

Returns:

Name of a model entity.

property IsOverloadable: bool

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

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

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

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

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

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

IterateTypeMarks(region)

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

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

Parameters:

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

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

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

property NormalizedIdentifier: str

Read-only property to access the model entity’s normalized identifier (_normalizedIdentifier).

See also

Returns:

Normalized name of a model entity.

property Parent: ModelEntity

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

Returns:

Reference to the parent entity.

property Position: Position

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

If _position is None, resolve the position object from _iirNode

Returns:

The IIR’s position in the source file.

property Range: Range

Read-only property to access the type’s range (_range).

Returns:

The range.

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 floating-point type and its range 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 type definition.

Format: gain is range 0.0 to 1.0

Return type:

str

Returns:

Formatted floating-point type definition.

_documentation: str | None

The associated documentation of a model entity.

_identifier: str

The identifier of a model entity.

_normalizedIdentifier: str

The normalized (lower case) identifier of a model entity.

_objectVertex: Vertex

The vertex representing this type in the design’s object graph.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_range: Range

The range constraining this scalar type.

class pyGHDL.dom.Type.PhysicalUnit(node, identifier, value=None, documentation=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Type.PhysicalUnit.

Represents a unit declaration of a physical type: its primary unit or one of its secondary units.

A unit name is declared by the physical type’s declaration in the declarative region enclosing the type, so it’s visible like the type itself, e.g. imported by a use clause. The unit’s parent is its physical type; the unit is the parent of its value.

Example

type distance is range 0 to 1000000 units
  um;
--^^                                        <- Identifier (primary unit)
  mm = 1000 um;
--^^                                        <- Identifier (secondary unit)
--   ^^^^^^^                                <- Value
end units;

Inheritance

Inheritance diagram of PhysicalUnit

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

Initializes a unit declaration of a physical type.

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

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

  • value (PhysicalIntegerLiteral) – Optional, the unit’s value in a smaller unit, None for the primary unit.

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

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.

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 identifier as declared, for the model entity’s normalized identifier.

Parameters:

normalizedIdentifier (str) – The model entity’s normalized (lower case) identifier.

Return type:

str

Returns:

The identifier 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 Identifier: str

Read-only property to access the model entity’s identifier (_identifier).

Returns:

Name of a model entity.

property IsOverloadable: bool

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

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

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

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

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

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

IterateTypeMarks(region)

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

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

Parameters:

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

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

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

property NormalizedIdentifier: str

Read-only property to access the model entity’s normalized identifier (_normalizedIdentifier).

See also

Returns:

Normalized name of a model entity.

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: PhysicalIntegerLiteral | None

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

Returns:

The unit’s value in a smaller unit, or None for the primary unit.

Visit(visitor)

Walk this model element with a visitor.

A model class implements its walk; a class without one raises.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Raises:

NotImplementedError – Always, because the element’s class has no walk of its own.

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

Format: mm = 1000 um, or um for the primary unit

Return type:

str

Returns:

Formatted unit declaration.

_documentation: str | None

The associated documentation of a model entity.

_identifier: str

The identifier of a model entity.

_normalizedIdentifier: str

The normalized (lower case) identifier of a model entity.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_value: PhysicalIntegerLiteral | None

The unit’s value in a smaller unit, or None for the primary unit.

class pyGHDL.dom.Type.PhysicalType(node, typeName, rng, primaryUnit, secondaryUnits, documentation=None)[source]

Represents a physical type.

This class implements a pyGHDL.dom object derived from pyVHDLModel.Type.PhysicalType.

Example

type time is range integer'low to integer'high units
  fs;
  ps = 1000 fs;
  -- ...
end units;

Inheritance

Inheritance diagram of PhysicalType

Parameters:
__init__(node, typeName, rng, primaryUnit, secondaryUnits, documentation=None)[source]

Initializes a physical type definition.

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

  • typeName (str) – The type’s identifier.

  • rng (Range | Name) – The range constraining this scalar type.

  • primaryUnit (PhysicalUnit) – The type’s primary unit.

  • secondaryUnits (List[PhysicalUnit]) – The type’s secondary units.

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

Return type:

None

classmethod parse(typeName, typeDefinitionNode, documentation=None)[source]

Parses an physical type IIR and returns an PhysicalType instance.

Parameters:
  • typeName (str) – The identifier of the type.

  • typeDefinitionNode (Iir) – The IIR node to parse.

  • documentation (str) – Optional, the documentation comment on the type declaration.

Return type:

Self

Returns:

The physical type instance.

_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 BaseType: BaseType

Read-only property to return the base type of this type: the type itself (IEEE Std 1076-2008, 5.1).

A subtype returns the base type of the type it is derived from (BaseType).

Returns:

The base type.

DenoteBy(name, region, place, symbol)

Return this type or subtype, the model entity a name in a type mark denotes.

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:

This type or subtype.

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 identifier as declared, for the model entity’s normalized identifier.

Parameters:

normalizedIdentifier (str) – The model entity’s normalized (lower case) identifier.

Return type:

str

Returns:

The identifier 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 Identifier: str

Read-only property to access the model entity’s identifier (_identifier).

Returns:

Name of a model entity.

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()[source]

Iterate the units this type declaration implies: the primary unit, then the secondary units.

Return type:

Generator[tuple[str, PhysicalUnit]]

Returns:

A generator to iterate (normalized identifier, unit) pairs, in declaration order.

IterateTypeMarks(region)

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

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

Parameters:

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

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

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

property NormalizedIdentifier: str

Read-only property to access the model entity’s normalized identifier (_normalizedIdentifier).

See also

Returns:

Normalized name of a model entity.

property Parent: ModelEntity

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

Returns:

Reference to the parent entity.

property Position: Position

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

If _position is None, resolve the position object from _iirNode

Returns:

The IIR’s position in the source file.

property PrimaryUnit: PhysicalUnit

Read-only property to access the primary unit (_primaryUnit).

The primary unit has no value. Formatted, it’s the unit’s name.

Returns:

The primary unit.

property Range: Range

Read-only property to access the type’s range (_range).

Returns:

The range.

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 SecondaryUnits: list[PhysicalUnit]

Read-only property to access the secondary units (_secondaryUnits).

Returns:

List of secondary units, in declaration order.

Visit(visitor)[source]

Walk this physical type, its range and its secondary units with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_END_KEYWORDS: ClassVar[tuple[ReservedWord, ...]] = (ReservedWord.Units,)

Reserved words after end.

_END_KEYWORDS_OPTIONAL: ClassVar[bool] = False

The reserved words after end are optional.

__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 physical type definition.

Format: distance is range 0 to 1000 units um; mm = 1000 um;

Return type:

str

Returns:

Formatted physical type definition.

_documentation: str | None

The associated documentation of a model entity.

_identifier: str

The identifier of a model entity.

_normalizedIdentifier: str

The normalized (lower case) identifier of a model entity.

_objectVertex: Vertex

The vertex representing this type in the design’s object graph.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_primaryUnit: PhysicalUnit

The type’s primary unit, which has no value.

_range: Range

The range constraining this scalar type.

_secondaryUnits: list[PhysicalUnit]

List of the type’s secondary units, in declaration order.

class pyGHDL.dom.Type.ArrayType(node, identifier, indices, elementSubtype, documentation=None)[source]

Represents an array type.

This class implements a pyGHDL.dom object derived from pyVHDLModel.Type.ArrayType.

Example

type bit_vector is array(natural range <>) of bit;

Inheritance

Inheritance diagram of ArrayType

Parameters:
  • node (Iir)

  • identifier (str)

  • indices (List)

  • elementSubtype (Symbol)

  • documentation (str)

__init__(node, identifier, indices, elementSubtype, documentation=None)[source]

Initializes an array type definition.

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

  • identifier (str) – The array type’s identifier.

  • indices (List) – List of all index ranges, one per dimension.

  • elementSubtype (Symbol) – Reference to the subtype of the array’s elements.

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

Return type:

None

classmethod parse(typeName, typeDefinitionNode, documentation=None)[source]

Parses an array type IIR and returns an ArrayType instance.

An unconstrained array type (array (natural range <>) of bit) is an Array_Type_Definition; a constrained array type (array (0 to 3) of bit) is an Array_Subtype_Definition carrying an index constraint per dimension.

Parameters:
  • typeName (str) – The identifier of the type.

  • typeDefinitionNode (Iir) – The IIR node to parse.

  • documentation (str) – Optional, the documentation comment on the type declaration.

Return type:

Self

Returns:

The array type instance.

Raises:

DOMException – If an index of an unconstrained array type is not a type mark.

_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 BaseType: BaseType

Read-only property to return the base type of this type: the type itself (IEEE Std 1076-2008, 5.1).

A subtype returns the base type of the type it is derived from (BaseType).

Returns:

The base type.

DenoteBy(name, region, place, symbol)

Return this type or subtype, the model entity a name in a type mark denotes.

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:

This type or subtype.

property Dimensions: list[Range]

Read-only property to access the dimensions (_dimensions).

Returns:

List of dimensions.

property Documentation: str | None

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

Returns:

Associated documentation of a model entity.

property ElementType: Symbol

Read-only property to access the element type (_elementType).

Returns:

The element type.

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 identifier as declared, for the model entity’s normalized identifier.

Parameters:

normalizedIdentifier (str) – The model entity’s normalized (lower case) identifier.

Return type:

str

Returns:

The identifier 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 Identifier: str

Read-only property to access the model entity’s identifier (_identifier).

Returns:

Name of a model entity.

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)[source]

Iterate the type marks of this array type: its index subtypes, then its element subtype.

Parameters:

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

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

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

property NormalizedIdentifier: str

Read-only property to access the model entity’s normalized identifier (_normalizedIdentifier).

See also

Returns:

Normalized name of a model entity.

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 array type, its index ranges and its element subtype 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 array type definition.

Format: memory is array(0 to 7) of bit

Return type:

str

Returns:

Formatted array type definition.

_dimensions: list[Range]

List of all index ranges, one per dimension.

_documentation: str | None

The associated documentation of a model entity.

_elementType: Symbol

Reference to the subtype of the array’s elements.

_identifier: str

The identifier of a model entity.

_normalizedIdentifier: str

The normalized (lower case) identifier of a model entity.

_objectVertex: Vertex

The vertex representing this type in the design’s object graph.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

class pyGHDL.dom.Type.RecordTypeElement(node, identifiers, subtype, documentation=None)[source]

Represents a record element.

This class implements a pyGHDL.dom object derived from pyVHDLModel.Type.RecordTypeElement.

Example

-- type pt is record
  element : std_logic;
  -- ...
-- end record;

Inheritance

Inheritance diagram of RecordTypeElement

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

Initializes a record type element.

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

  • identifiers (List[str]) – A list of identifiers.

  • subtype (Symbol) – Reference to the subtype shared by all identifiers of this element declaration.

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

Return type:

None

classmethod parse(elementDeclarationNode, furtherIdentifiers=None)[source]

Parses a record element IIR and returns an RecordTypeElement instance.

Parameters:
  • elementDeclarationNode (Iir) – The IIR node to parse.

  • furtherIdentifiers (Iterable[str]) – Optional, the list of record element identifiers.

Return type:

Self

Returns:

The record element instance.

_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 record type element.

The copy has no parent. Its subtype is a copy of this element’s subtype.

Return type:

Self

Returns:

The new record type element.

DenoteBy(name, region, place, symbol)[source]

Return this record element, the model entity a name in a type mark denotes.

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:

This record element.

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 identifier as declared, for one of the model entity’s normalized identifiers.

Parameters:

normalizedIdentifier (str) – One of the model entity’s normalized (lower case) identifiers.

Return type:

str

Returns:

The identifier 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 Identifiers: tuple[str]

Read-only property to access the model entity’s identifiers (_identifiers).

Returns:

Tuple of identifiers.

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 NormalizedIdentifiers: tuple[str]

Read-only property to access the model entity’s normalized identifiers (_normalizedIdentifiers).

See also

Returns:

Tuple of normalized identifiers.

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

Split()

Split this declaration into one declaration per identifier.

IEEE Std 1076 defines a declaration with an identifier list as equivalent to a sequence of single declarations, one per identifier, in list order: signal a, b : bit; declares the same as signal a : bit; signal b : bit;. This declaration keeps its first identifier. For every other identifier, a new declaration is created by Copy(): it has its own copy of the subtype indication and of the default expression, and the same documentation. Single declarations created before are dropped.

Without a parent, the new declarations have no parent either: the caller places them. With a parent, the parent’s mutator splits the declaration and inserts the new declarations right after it, e.g. WithPortsMixin.SplitPortItem for a port.

A declaration with one identifier is unchanged.

Return type:

tuple[Self, ...]

Returns:

Tuple of declarations, one per identifier in list order, starting with this declaration.

Raises:
  • NotAChildError – If this declaration’s parent doesn’t list it.

  • NotInNamespaceError – If the parent is an indexed declarative region, and an identifier of this declaration refers to another element, e.g. a duplicate declaration.

property Subtype: Symbol

Read-only property to access the subtype (_subtype).

Returns:

The subtype.

Visit(visitor)[source]

Walk this record element declaration and its subtype with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_KeepIdentifier(position)

Reduce the identifier list to the identifier at a position and drop the single declarations.

Parameters:

position (int) – The position of the identifier to keep.

Return type:

None

_SplitCopies()

Create one parentless copy of this declaration per identifier after the first, each keeping its identifier.

Return type:

list[Self]

Returns:

List of new declarations, in list order.

_SplitInParent()[source]

Split this element declaration by the mutator of its parent (SplitElement()).

Return type:

tuple[Self, ...]

Returns:

Tuple of element declarations, one per identifier in list order, starting with this element declaration.

__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 record element declaration.

Format: a, b : bit

Return type:

str

Returns:

Formatted record element declaration.

_documentation: str | None

The associated documentation of a model entity.

_identifiers: tuple[str]

A list of identifiers.

_normalizedIdentifiers: tuple[str]

A list of normalized (lower case) identifiers.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_singleDeclarations: list[SingleDeclarationMixin] | None

Cached single declarations, or None.

_subtype: Symbol

Reference to the subtype shared by all identifiers of this element declaration.

class pyGHDL.dom.Type.RecordType(node, identifier, elements=None, documentation=None)[source]

Represents a record type.

This class implements a pyGHDL.dom object derived from pyVHDLModel.Type.RecordType.

Example

type pt is record
  -- elements
end record;

Inheritance

Inheritance diagram of RecordType

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

Initializes a record type definition.

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

  • identifier (str) – The record type’s identifier.

  • elements (List[RecordTypeElement]) – Optional, list of all element declarations, in declaration order.

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

Return type:

None

classmethod parse(typeName, typeDefinitionNode, documentation=None)[source]

Parses a record type IIR and returns an RecordType instance.

Parameters:
  • typeName (str) – The identifier of the type.

  • typeDefinitionNode (Iir) – The IIR node to parse.

  • documentation (str) – Optional, the documentation comment on the type declaration.

Return type:

Self

Returns:

The record type instance.

_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 BaseType: BaseType

Read-only property to return the base type of this type: the type itself (IEEE Std 1076-2008, 5.1).

A subtype returns the base type of the type it is derived from (BaseType).

Returns:

The base type.

DenoteBy(name, region, place, symbol)

Return this type or subtype, the model entity a name in a type mark denotes.

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:

This type or subtype.

property Documentation: str | None

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

Returns:

Associated documentation of a model entity.

property Elements: list[RecordTypeElement]

Read-only property to access the elements (_elements).

Returns:

List of elements.

property ElementsByIdentifier: dict[str, RecordTypeElement]

Read-only property to access the elements by identifier (_elementsByIdentifier).

An element declaring several identifiers (a, b : bit) is indexed by each of them.

Returns:

Dictionary of elements, indexed by normalized identifier.

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 identifier as declared, for the model entity’s normalized identifier.

Parameters:

normalizedIdentifier (str) – The model entity’s normalized (lower case) identifier.

Return type:

str

Returns:

The identifier 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 Identifier: str

Read-only property to access the model entity’s identifier (_identifier).

Returns:

Name of a model entity.

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)[source]

Iterate the type marks of this record type: the element subtypes.

Parameters:

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

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

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

property NormalizedIdentifier: str

Read-only property to access the model entity’s normalized identifier (_normalizedIdentifier).

See also

Returns:

Normalized name of a model entity.

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

SplitElement(element)[source]

Split an element with an identifier list into one element per identifier.

The element keeps its first identifier. For every other identifier, a new element is created by its Copy() and inserted right after it, in list order; its parent is set to this record type. An element declaring one identifier is unchanged.

Parameters:

element (RecordTypeElement) – The element to split.

Return type:

tuple[RecordTypeElement, ...]

Returns:

Tuple of elements, one per identifier in list order, starting with the split element.

Raises:
  • ValueError – If parameter ‘element’ is None.

  • TypeError – If parameter ‘element’ is not of type RecordTypeElement.

  • NotAChildError – If parameter ‘element’ is not an element of this record type.

See also

Split()

→ Split a declaration with an identifier list.

Visit(visitor)[source]

Walk this record type and its element declarations with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_END_KEYWORDS: ClassVar[tuple[ReservedWord, ...]] = (ReservedWord.Record,)

Reserved words after end.

_END_KEYWORDS_OPTIONAL: ClassVar[bool] = False

The reserved words after end are optional.

__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 record type definition.

Format: frame is record a : bit;

Return type:

str

Returns:

Formatted record type definition.

_documentation: str | None

The associated documentation of a model entity.

_elements: list[RecordTypeElement]

List of all element declarations, in declaration order.

_elementsByIdentifier: dict[str, RecordTypeElement]

All element declarations, indexed by normalized identifier.

_identifier: str

The identifier of a model entity.

_normalizedIdentifier: str

The normalized (lower case) identifier of a model entity.

_objectVertex: Vertex

The vertex representing this type in the design’s object graph.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

class pyGHDL.dom.Type.ProtectedType(node, identifier, methods=None, documentation=None)[source]

Represents a protected type.

This class implements a pyGHDL.dom object derived from pyVHDLModel.Type.ProtectedType.

Example

type pt is protected
  -- public interface
end protected;

Inheritance

Inheritance diagram of ProtectedType

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

Initializes a protected type declaration.

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

  • identifier (str) – The protected type’s identifier.

  • methods (List | Iterator) – Optional, list of the protected type’s methods, in declaration order.

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

Return type:

None

classmethod parse(typeName, typeDefinitionNode, documentation=None)[source]

Parses a protected type IIR and returns an ProtectedType instance.

Parameters:
  • typeName (str) – The identifier of the type.

  • typeDefinitionNode (Iir) – The IIR node to parse.

  • documentation (str) – Optional, the documentation comment on the type declaration.

Return type:

Self

Returns:

The protected type instance.

_iirNode

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

_position

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

AddDeclaredItem(declaredItem)

Add a declared item at the end of the declarative region.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

Parameters:

declaredItem (ModelEntity) – The declared item to add.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

property BaseType: BaseType

Read-only property to return the base type of this type: the type itself (IEEE Std 1076-2008, 5.1).

A subtype returns the base type of the type it is derived from (BaseType).

Returns:

The base type.

property DeclaredItems: list

Read-only property to access the declared items (_declaredItems).

Returns:

List of all declared items.

DenoteBy(name, region, place, symbol)

Return this type or subtype, the model entity a name in a type mark denotes.

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:

This type or subtype.

property Documentation: str | None

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

Returns:

Associated documentation of a model entity.

property Functions: dict[str, list[Function]]

Read-only property to access the declared functions (_functions).

Returns:

Dictionary of all functions, indexed by name; each entry is a list of overloads.

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 identifier as declared, for the model entity’s normalized identifier.

Parameters:

normalizedIdentifier (str) – The model entity’s normalized (lower case) identifier.

Return type:

str

Returns:

The identifier 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 Identifier: str

Read-only property to access the model entity’s identifier (_identifier).

Returns:

Name of a model entity.

IndexDeclaredItems()

Index declared items listed in the protected type declaration.

Both lookup tables are cleared and all declared items are removed from _namespace first. Only subprogram declarations are legal here, so anything else is passed to _IndexOtherDeclaredItem(). Indexing again yields the same lookup tables and namespace.

See also

IndexDeclaredItems()

The same algorithm for the protected type’s body.

Raises:

UnhandledCriticalWarningError – If an identifier is declared twice in a declarative region and no WarningCollector collects the DuplicateDeclarationWarning.

Return type:

None

InsertDeclaredItem(index, declaredItem)

Insert a declared item at a position of the declarative region.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

An identifier is declared once per declarative region: interface items and declared items count, including those of the language construct sharing the declarative region (an entity and its architecture, a package and its body). Subprograms are overloadable: a subprogram may share its identifier with other subprograms. A protected type body may share its identifier with its protected type, a full type with its incomplete type declaration, and a constant with its deferred constant. Items imported into the namespace (e.g. by a use clause) are hidden.

Parameters:
  • index (int) – Position, from 0 (first) to the number of declared items (append). A negative index counts from the end, as for list.insert(): -1 inserts before the last declared item.

  • declaredItem (ModelEntity) – The declared item to insert.

Raises:
  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

AddDeclaredItem()

→ Add a declared item at the end of the declarative region.

InsertDeclaredItemBefore()

→ Insert a declared item before another declared item.

InsertDeclaredItemAfter()

→ Insert a declared item after another declared item.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

InsertDeclaredItemAfter(declaredItem, after)

Insert a declared item after another declared item.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

Parameters:
  • declaredItem (ModelEntity) – The declared item to insert.

  • after (ModelEntity) – The declared item of this declarative region to insert after.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a declared item of this declarative region.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

InsertDeclaredItemBefore()

→ Insert a declared item before another declared item.

InsertDeclaredItemBefore(declaredItem, before)

Insert a declared item before another declared item.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

Parameters:
  • declaredItem (ModelEntity) – The declared item to insert.

  • before (ModelEntity) – The declared item of this declarative region to insert before.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a declared item of this declarative region.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

InsertDeclaredItemAfter()

→ Insert a declared item after another declared item.

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.

IterateDeclarationRegions()

Iterate this declarative region and all declarative regions nested in it.

Nested regions are declarations (e.g. subprograms, generic subprograms, protected types, packages) and concurrent statements (blocks, processes, generate statements and their branches), each followed by the regions nested in it.

Return type:

Generator[DeclarativeRegionMixin]

Returns:

A generator to iterate the declarative regions, this region first.

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.

LookupName(place, symbol, name, warningType)

Look up the declarations a simple name or an expanded name denotes at a place in this region.

A simple name is looked up at the place (Lookup()). An expanded name pkg.T or lib.pkg.T resolves its prefix: pkg to a package visible at the place, else to an enclosing declarative region of that name (e.g. the package or entity containing the place); lib.pkg by the library (work or a library whose name is visible in the design unit containing the place, IsLibraryVisible()) and the package’s name. Then the suffix is searched among the declarations of the package or region (FindDeclarations()).

A failure is reported as a warning of the given type, whose label names the kind of name in the message (e.g. Type mark); then no declaration is returned. A name, which is a part of the symbol’s name (e.g. the prefix s of the type mark s'subtype), is reported as a prefix of the symbol’s name.

Parameters:
  • place (ModelEntity) – The declaration containing the name.

  • symbol (Symbol) – The symbol containing the name.

  • name (Name) – The simple name or expanded name: the symbol’s name or a part of it.

  • warningType (type[UnresolvedNameWarning]) – The warning class reporting a failure.

Return type:

tuple[ModelEntity, ...]

Returns:

Tuple of the directly visible declarations, empty if none is.

Raises:

UnhandledCriticalWarningError – If the name isn’t visible, is ambiguous, or has a prefix, which isn’t a visible package or an enclosing region, and no WarningCollector collects the warning.

property Methods: list[Procedure | Function]

Read-only property to return the declared methods, in declaration order.

A protected type declares nothing but subprograms, so this is every declared item (_declaredItems). It is kept as a named view because “method” is the VHDL term for a protected type’s subprograms.

Returns:

List of methods, in declaration order.

MoveDeclaredItem(declaredItem, index)

Move a declared item to a position of the declarative region.

The declared item stays a declared item of this declarative region: only the order of the declared items changes.

If the region is indexed, the lookup tables and the namespace follow the new order: a list of overloads (e.g. in Functions) follows the declaration order, and the namespace refers to the overload declared last. If another declaration shares an identifier with the declared item (e.g. a duplicate declaration read by a parser), the region is indexed again (IndexDeclaredItems()) after the move.

Parameters:
  • declaredItem (ModelEntity) – The declared item to move.

  • index (int) – Position of the declared item after the move, from 0 (first) to the number of declared items minus one (last). A negative index counts from the end, as for a list index: -1 moves the declared item to the end.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

Return type:

None

See also

MoveDeclaredItemBefore()

→ Move a declared item before another declared item.

MoveDeclaredItemAfter()

→ Move a declared item after another declared item.

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

MoveDeclaredItemAfter(declaredItem, after)

Move a declared item after another declared item.

The declared item stays a declared item of this declarative region: only the order of the declared items changes, as for MoveDeclaredItem(). Moving a declared item after itself keeps it in place.

Parameters:
  • declaredItem (ModelEntity) – The declared item to move.

  • after (ModelEntity) – The declared item of this declarative region to move after.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a declared item of this declarative region.

Return type:

None

See also

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

MoveDeclaredItemBefore()

→ Move a declared item before another declared item.

MoveDeclaredItemBefore(declaredItem, before)

Move a declared item before another declared item.

The declared item stays a declared item of this declarative region: only the order of the declared items changes, as for MoveDeclaredItem(). Moving a declared item before itself keeps it in place.

Parameters:
  • declaredItem (ModelEntity) – The declared item to move.

  • before (ModelEntity) – The declared item of this declarative region to move before.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a declared item of this declarative region.

Return type:

None

See also

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

MoveDeclaredItemAfter()

→ Move a declared item after another declared item.

property NormalizedIdentifier: str

Read-only property to access the model entity’s normalized identifier (_normalizedIdentifier).

See also

Returns:

Normalized name of a model entity.

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.

Precedes(item, anchor, inclusive)

Check if an item precedes an anchor in this declarative region.

An item, which isn’t a declaration of this region (e.g. a use clause of the context clause), precedes every anchor.

Parameters:
  • item (ModelEntity | None) – The item in declaration order, or None for the implicit use clause.

  • anchor (ModelEntity) – A declaration of this region, e.g. the one containing the place of a lookup.

  • inclusive (bool) – True, if the anchor precedes itself, i.e. the place is nested inside the anchor.

Return type:

bool

Returns:

True, if the item precedes the anchor.

property Procedures: dict[str, list[Procedure]]

Read-only property to access the declared procedures (_procedures).

Returns:

Dictionary of all procedures, indexed by name; each entry is a list of overloads.

RemoveDeclaredItem(declaredItem)

Remove a declared item from the declarative region.

The declared item is detached: its parent is cleared. If the region is indexed, the declared item’s identifiers are removed from the region’s namespace and from the lookup table matching its kind first; they are checked before anything is changed. The declared item itself is unchanged and can be added to another declarative region, or inserted at another position.

The namespace refers to the overload declared last: removing it, the namespace refers to the remaining overload declared last. If another declaration shares an identifier with the declared item (e.g. a duplicate declaration read by a parser), the region is indexed again (IndexDeclaredItems()) after the removal.

Parameters:

declaredItem (ModelEntity) – The declared item to remove.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • NotInNamespaceError – If the region is indexed, and an identifier of the declared item isn’t declared in its namespace.

  • NotInNamespaceError – If the region is indexed, and an identifier of the declared item refers to another declaration, e.g. a duplicate declaration.

Return type:

None

See also

AddDeclaredItem()

→ Add a declared item at the end of the declarative region.

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

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

ResolveTypeMark(place, symbol)

Resolve a type mark at its place in this region and set the symbol’s reference.

Algorithm

  1. Clear the symbol’s reference.

  2. Look up the type mark’s name (LookupName()).

  3. An alias of a type is replaced by the type its name references.

  4. If the declaration is a type, a subtype or a generic type, it becomes the symbol’s reference. A full type, which follows the place in the same region, is visible by its incomplete type declaration only to an access type.

An attribute name denoting a type (e.g. s'subtype, A'element) is resolved part by part (Denote()); the type it denotes becomes the symbol’s reference.

Parameters:
Raises:

UnhandledCriticalWarningError – If the type mark isn’t visible, is ambiguous, has a prefix, which isn’t a visible package, denotes no type, or denotes an incomplete type outside of an access type, and no WarningCollector collects the UnresolvedTypeMarkWarning.

Return type:

None

SplitDeclaredItem(declaredItem)

Split a declared item with an identifier list into one declaration per identifier.

The declared item keeps its first identifier. For every other identifier, a new declaration is created by its Copy() and inserted right after it, in list order; its parent is set to this declarative region. If the region is indexed, the namespace and lookup table entries of the other identifiers refer to the new declarations; they are checked before anything is changed. A declared item declaring one identifier is unchanged.

Parameters:

declaredItem (ModelEntity) – The declared item to split.

Return type:

tuple[ModelEntity, ...]

Returns:

Tuple of declarations, one per identifier in list order, starting with the split declared item.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • NotInNamespaceError – If the region is indexed, and an identifier of the declared item refers to another declaration, e.g. a duplicate declaration.

See also

Split()

→ Split a declaration with an identifier list.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

Visit(visitor)[source]

Walk this protected type declaration and its methods with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_AddOverloadToNamespace(item)

Add a function or procedure to the namespace, if it’s the overload declared last.

The namespace keeps one entry per identifier: the overload declared last, as after IndexDeclaredItems(), which adds interface items first, then declared items (_Declarations()).

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The function or procedure, already an interface item or declared item of this region.

Return type:

None

_AddToNamespace(element)

Add an element’s identifiers to this region’s namespace.

Nothing is added to a region not indexed yet: IndexDeclaredItems() adds the element later. A generic subprogram is an overload (_AddOverloadToNamespace()).

Parameters:

element (NamedEntityMixin | MultipleNamedEntityMixin) – The named element to add, e.g. an interface item.

Return type:

None

_ClashingDeclarations(item)

Return the declarations sharing an identifier with the given item, which may not share it.

The declarations (_Declarations()) and the labeled statements (_Labels()) of this declarative region and of the language constructs sharing it (_SharedRegions()) are searched: a statement label is declared implicitly. Items imported into the namespace (e.g. by a use clause) are no declarations.

Parameters:

item (ModelEntity) – The new declaration, or the new labeled statement.

Return type:

tuple[ModelEntity, ...]

Returns:

Tuple of clashing declarations, interface items first, then declared items in declaration order, then labeled statements.

_ConnectParentNamespace(parent)

Connect this region’s namespace to the namespace of the enclosing declarative region.

A declaration of this region then hides a same-named declaration of the enclosing region. A parent, which isn’t a declarative region (e.g. a subprogram of an interface list), has no namespace to connect to.

Parameters:

parent (ModelEntity) – The new parent of this region.

Return type:

None

_DECLARED_ITEM_TYPES = (<class 'pyVHDLModel.Subprogram.Subprogram'>,)

Accepted classes of declared items (pyVHDLModel).

_Declarations()

Return all declarations of this declarative region.

A host class with interface items extends the list by its interface items, listed first.

Return type:

tuple[ModelEntity, ...]

Returns:

Tuple of declarations: the declared items, in declaration order.

_DeclaredItemsSharingIdentifiers(declaredItem)

Return the other declared items of this region sharing an identifier with the given declared item.

Parameters:

declaredItem (ModelEntity) – The declared item.

Return type:

list[ModelEntity]

Returns:

List of declared items, in declaration order.

_END_KEYWORDS: ClassVar[tuple[ReservedWord, ...]] = (ReservedWord.Protected,)

Reserved words after end.

_END_KEYWORDS_OPTIONAL: ClassVar[bool] = False

The reserved words after end are optional.

_IndexDeclaredItem(item)

Add a declared item to the namespace and to the lookup table matching its kind.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_IndexOtherDeclaredItem(item)

Hook for declared items the region doesn’t handle itself. Derived classes may override it.

An alias, an attribute declaration and a package (also a package instantiation) declared in the region are added to the namespace, without a lookup table.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_IndexOverload(item)

Add an inserted function or procedure to its lookup table and to the namespace.

The list of overloads follows the declaration order. The namespace is updated by _AddOverloadToNamespace().

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The inserted function or procedure.

Return type:

None

_IterateStatementRegions()

Iterate the declarative regions nested in the statements of this declarative region.

Return type:

Generator[DeclarativeRegionMixin]

Returns:

An empty generator.

_Labels()

Return the labeled statements, whose labels are declared in this declarative region.

Return type:

tuple[ModelEntity, ...]

Returns:

An empty tuple.

_MayShareIdentifier(item, existing)

Check if two declarations may share an identifier in one declarative region.

Subprograms are overloadable. A protected type body completes its protected type, a full type completes its incomplete type, and a constant completes its deferred constant.

Parameters:
Return type:

bool

Returns:

True, if both declarations may share an identifier.

_RemoveDeclaredItemEntries(lookupTable, item)

Remove a declared item’s entries from a lookup table and from the namespace.

Every identifier is checked before anything is removed.

Parameters:
Raises:
  • NotInNamespaceError – If an identifier of the declared item isn’t declared in the namespace.

  • NotInNamespaceError – If an identifier of the declared item refers to another element, e.g. a duplicate declaration.

Return type:

None

_RemoveDeclaredItemsFromNamespace()

Remove all declared items of this region from its namespace.

Interface items of this region and items imported from elsewhere (e.g. by a use clause) are kept.

Return type:

None

_RemoveFromNamespace(element)

Remove an element’s identifiers from this region’s namespace.

Nothing is removed from a region not indexed yet, as its namespace doesn’t contain the element. A generic subprogram is an overload (_RemoveOverloadFromNamespace()).

Parameters:

element (NamedEntityMixin | MultipleNamedEntityMixin) – The named element to remove, e.g. an interface item.

Raises:
  • NotInNamespaceError – If the region is indexed, and an identifier of the element isn’t declared in the namespace.

  • NotInNamespaceError – If the region is indexed, and an identifier of the element refers to another element, e.g. a duplicate declaration.

Return type:

None

_RemoveOverloadFromNamespace(item)

Remove a function or procedure from the namespace.

Removing the overload the namespace refers to, the namespace refers to the remaining overload declared last (_Declarations()), or the identifier is removed, if no overload remains. Removing another overload leaves the namespace unchanged. The namespace is checked before it’s changed.

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The function or procedure, still an interface item or declared item of this region.

Raises:
  • NotInNamespaceError – If the identifier isn’t declared in the namespace.

  • NotInNamespaceError – If the identifier refers to an element, which is no overload, e.g. a duplicate declaration.

Return type:

None

_SharedRegions()

Return the other language constructs forming one declarative region with this one.

An entity and each of its architectures form one declarative region, as do a package and its body. Derived classes override it.

Return type:

tuple[DeclarativeRegionMixin, ...]

Returns:

Tuple of declarative regions.

_UnindexDeclaredItem(item)

Remove a declared item from the namespace and from the lookup table matching its kind.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_UnindexOtherDeclaredItem(item)

Hook to remove declared items the region doesn’t handle itself. Derived classes may override it.

An alias, an attribute declaration and a package are removed from the namespace.

Parameters:

item (ModelEntity) – The declared item.

Raises:

NotInNamespaceError – If the item is an alias, an attribute declaration or a package, which isn’t declared in the namespace.

Return type:

None

_UnindexOverload(item)

Remove a function or procedure from its lookup table and from the namespace.

The namespace is updated first, by _RemoveOverloadFromNamespace().

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The function or procedure to remove, still a declared item of this region.

Raises:
  • NotInNamespaceError – If the identifier isn’t declared in the namespace.

  • NotInNamespaceError – If the identifier refers to an element, which is no overload, e.g. a duplicate declaration.

Return type:

None

_VisitDeclaredItems(visitor)

Walk the declared items in declaration order 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 type declaration.

Format: type myType

Return type:

str

Returns:

Formatted type declaration.

_areDeclaredItemsIndexed

True if IndexDeclaredItems() filled the namespace.

_declaredItems

List of all declared items in this protected type declaration.

_documentation

The associated documentation of a model entity.

_functions

All declared functions, indexed by name; each is a list of overloads.

_identifier

The identifier of a model entity.

_namespace

The namespace of this protected type declaration.

_normalizedIdentifier

The normalized (lower case) identifier of a model entity.

_objectVertex

The vertex representing this type in the design’s object graph.

_parent

Reference to a parent entity in the logical model hierarchy.

_procedures

All declared procedures by name; each is a list of overloads.

class pyGHDL.dom.Type.ProtectedTypeBody(node, identifier, declaredItems=None, documentation=None)[source]

Represents a protected type body.

This class implements a pyGHDL.dom object derived from pyVHDLModel.Type.ProtectedTypeBody.

Example

type pt is protected body
  -- implementations
end protected body;

Inheritance

Inheritance diagram of ProtectedTypeBody

Parameters:
  • node (Iir)

  • identifier (str)

  • declaredItems (Union[List, Iterator])

  • documentation (str)

__init__(node, identifier, declaredItems=None, documentation=None)[source]

Initializes a protected type body.

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

  • identifier (str) – The protected type body’s identifier.

  • declaredItems (List | Iterator) – Optional, iterable of all items declared in this body.

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

Return type:

None

classmethod parse(protectedBodyNode)[source]

Parses a protected type body IIR and returns an ProtectedTypeBody instance.

Parameters:

protectedBodyNode (Iir) – The IIR node to parse.

Return type:

Self

Returns:

The protected type body instance.

_iirNode

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

_position

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

AddDeclaredItem(declaredItem)

Add a declared item at the end of the declarative region.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

Parameters:

declaredItem (ModelEntity) – The declared item to add.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

property BaseType: BaseType

Read-only property to return the base type of this type: the type itself (IEEE Std 1076-2008, 5.1).

A subtype returns the base type of the type it is derived from (BaseType).

Returns:

The base type.

property Constants: dict[str, Constant]

Read-only property to access the declared constants (_constants).

Returns:

Dictionary of constants, indexed by normalized identifier.

property DeclaredItems: list

Read-only property to access the declared items (_declaredItems).

Returns:

List of declared items.

DenoteBy(name, region, place, symbol)

Return this type or subtype, the model entity a name in a type mark denotes.

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:

This type or subtype.

property Documentation: str | None

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

Returns:

Associated documentation of a model entity.

property Files: dict[str, File]

Read-only property to access the declared files (_files).

Returns:

Dictionary of files, indexed by normalized identifier.

property Functions: dict[str, list[Function]]

Read-only property to access the declared functions (_functions).

Returns:

Dictionary of functions, indexed by normalized identifier; each entry is a list of overloads.

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 identifier as declared, for the model entity’s normalized identifier.

Parameters:

normalizedIdentifier (str) – The model entity’s normalized (lower case) identifier.

Return type:

str

Returns:

The identifier 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 Identifier: str

Read-only property to access the model entity’s identifier (_identifier).

Returns:

Name of a model entity.

IndexDeclaredItems()

Index declared items listed in the sequential declaration region.

All lookup tables are cleared and all declared items are removed from _namespace first. Then every declared item is added to _namespace, and additionally to the lookup table matching its kind. Items of an unhandled kind are passed to _IndexOtherDeclaredItem(). A protected type body completes its protected type, so it’s skipped. Indexing again yields the same lookup tables and namespace.

See also

IndexDeclaredItems()

The same algorithm for a concurrent declaration region.

Raises:

UnhandledCriticalWarningError – If an identifier is declared twice in a declarative region and no WarningCollector collects the DuplicateDeclarationWarning.

Return type:

None

InsertDeclaredItem(index, declaredItem)

Insert a declared item at a position of the declarative region.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

An identifier is declared once per declarative region: interface items and declared items count, including those of the language construct sharing the declarative region (an entity and its architecture, a package and its body). Subprograms are overloadable: a subprogram may share its identifier with other subprograms. A protected type body may share its identifier with its protected type, a full type with its incomplete type declaration, and a constant with its deferred constant. Items imported into the namespace (e.g. by a use clause) are hidden.

Parameters:
  • index (int) – Position, from 0 (first) to the number of declared items (append). A negative index counts from the end, as for list.insert(): -1 inserts before the last declared item.

  • declaredItem (ModelEntity) – The declared item to insert.

Raises:
  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

AddDeclaredItem()

→ Add a declared item at the end of the declarative region.

InsertDeclaredItemBefore()

→ Insert a declared item before another declared item.

InsertDeclaredItemAfter()

→ Insert a declared item after another declared item.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

InsertDeclaredItemAfter(declaredItem, after)

Insert a declared item after another declared item.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

Parameters:
  • declaredItem (ModelEntity) – The declared item to insert.

  • after (ModelEntity) – The declared item of this declarative region to insert after.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a declared item of this declarative region.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

InsertDeclaredItemBefore()

→ Insert a declared item before another declared item.

InsertDeclaredItemBefore(declaredItem, before)

Insert a declared item before another declared item.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

Parameters:
  • declaredItem (ModelEntity) – The declared item to insert.

  • before (ModelEntity) – The declared item of this declarative region to insert before.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a declared item of this declarative region.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

InsertDeclaredItemAfter()

→ Insert a declared item after another declared item.

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.

IterateDeclarationRegions()

Iterate this declarative region and all declarative regions nested in it.

Nested regions are declarations (e.g. subprograms, generic subprograms, protected types, packages) and concurrent statements (blocks, processes, generate statements and their branches), each followed by the regions nested in it.

Return type:

Generator[DeclarativeRegionMixin]

Returns:

A generator to iterate the declarative regions, this region first.

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.

LookupName(place, symbol, name, warningType)

Look up the declarations a simple name or an expanded name denotes at a place in this region.

A simple name is looked up at the place (Lookup()). An expanded name pkg.T or lib.pkg.T resolves its prefix: pkg to a package visible at the place, else to an enclosing declarative region of that name (e.g. the package or entity containing the place); lib.pkg by the library (work or a library whose name is visible in the design unit containing the place, IsLibraryVisible()) and the package’s name. Then the suffix is searched among the declarations of the package or region (FindDeclarations()).

A failure is reported as a warning of the given type, whose label names the kind of name in the message (e.g. Type mark); then no declaration is returned. A name, which is a part of the symbol’s name (e.g. the prefix s of the type mark s'subtype), is reported as a prefix of the symbol’s name.

Parameters:
  • place (ModelEntity) – The declaration containing the name.

  • symbol (Symbol) – The symbol containing the name.

  • name (Name) – The simple name or expanded name: the symbol’s name or a part of it.

  • warningType (type[UnresolvedNameWarning]) – The warning class reporting a failure.

Return type:

tuple[ModelEntity, ...]

Returns:

Tuple of the directly visible declarations, empty if none is.

Raises:

UnhandledCriticalWarningError – If the name isn’t visible, is ambiguous, or has a prefix, which isn’t a visible package or an enclosing region, and no WarningCollector collects the warning.

property Methods: list[Procedure | Function]

Read-only property to return the implemented methods, in declaration order.

A protected type body may also declare variables, types, subtypes, aliases and files, so this is the subprogram subset of _declaredItems rather than all of them.

Returns:

List of methods, in declaration order.

MoveDeclaredItem(declaredItem, index)

Move a declared item to a position of the declarative region.

The declared item stays a declared item of this declarative region: only the order of the declared items changes.

If the region is indexed, the lookup tables and the namespace follow the new order: a list of overloads (e.g. in Functions) follows the declaration order, and the namespace refers to the overload declared last. If another declaration shares an identifier with the declared item (e.g. a duplicate declaration read by a parser), the region is indexed again (IndexDeclaredItems()) after the move.

Parameters:
  • declaredItem (ModelEntity) – The declared item to move.

  • index (int) – Position of the declared item after the move, from 0 (first) to the number of declared items minus one (last). A negative index counts from the end, as for a list index: -1 moves the declared item to the end.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

Return type:

None

See also

MoveDeclaredItemBefore()

→ Move a declared item before another declared item.

MoveDeclaredItemAfter()

→ Move a declared item after another declared item.

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

MoveDeclaredItemAfter(declaredItem, after)

Move a declared item after another declared item.

The declared item stays a declared item of this declarative region: only the order of the declared items changes, as for MoveDeclaredItem(). Moving a declared item after itself keeps it in place.

Parameters:
  • declaredItem (ModelEntity) – The declared item to move.

  • after (ModelEntity) – The declared item of this declarative region to move after.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a declared item of this declarative region.

Return type:

None

See also

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

MoveDeclaredItemBefore()

→ Move a declared item before another declared item.

MoveDeclaredItemBefore(declaredItem, before)

Move a declared item before another declared item.

The declared item stays a declared item of this declarative region: only the order of the declared items changes, as for MoveDeclaredItem(). Moving a declared item before itself keeps it in place.

Parameters:
  • declaredItem (ModelEntity) – The declared item to move.

  • before (ModelEntity) – The declared item of this declarative region to move before.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a declared item of this declarative region.

Return type:

None

See also

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

MoveDeclaredItemAfter()

→ Move a declared item after another declared item.

property Namespace: Namespace

Read-only property to access this region’s namespace (_namespace).

Returns:

The namespace.

property NormalizedIdentifier: str

Read-only property to access the model entity’s normalized identifier (_normalizedIdentifier).

See also

Returns:

Normalized name of a model entity.

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.

Precedes(item, anchor, inclusive)

Check if an item precedes an anchor in this declarative region.

An item, which isn’t a declaration of this region (e.g. a use clause of the context clause), precedes every anchor.

Parameters:
  • item (ModelEntity | None) – The item in declaration order, or None for the implicit use clause.

  • anchor (ModelEntity) – A declaration of this region, e.g. the one containing the place of a lookup.

  • inclusive (bool) – True, if the anchor precedes itself, i.e. the place is nested inside the anchor.

Return type:

bool

Returns:

True, if the item precedes the anchor.

property Procedures: dict[str, list[Procedure]]

Read-only property to access the declared procedures (_procedures).

Returns:

Dictionary of procedures, indexed by normalized identifier; each entry is a list of overloads.

RemoveDeclaredItem(declaredItem)

Remove a declared item from the declarative region.

The declared item is detached: its parent is cleared. If the region is indexed, the declared item’s identifiers are removed from the region’s namespace and from the lookup table matching its kind first; they are checked before anything is changed. The declared item itself is unchanged and can be added to another declarative region, or inserted at another position.

The namespace refers to the overload declared last: removing it, the namespace refers to the remaining overload declared last. If another declaration shares an identifier with the declared item (e.g. a duplicate declaration read by a parser), the region is indexed again (IndexDeclaredItems()) after the removal.

Parameters:

declaredItem (ModelEntity) – The declared item to remove.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • NotInNamespaceError – If the region is indexed, and an identifier of the declared item isn’t declared in its namespace.

  • NotInNamespaceError – If the region is indexed, and an identifier of the declared item refers to another declaration, e.g. a duplicate declaration.

Return type:

None

See also

AddDeclaredItem()

→ Add a declared item at the end of the declarative region.

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

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

ResolveTypeMark(place, symbol)

Resolve a type mark at its place in this region and set the symbol’s reference.

Algorithm

  1. Clear the symbol’s reference.

  2. Look up the type mark’s name (LookupName()).

  3. An alias of a type is replaced by the type its name references.

  4. If the declaration is a type, a subtype or a generic type, it becomes the symbol’s reference. A full type, which follows the place in the same region, is visible by its incomplete type declaration only to an access type.

An attribute name denoting a type (e.g. s'subtype, A'element) is resolved part by part (Denote()); the type it denotes becomes the symbol’s reference.

Parameters:
Raises:

UnhandledCriticalWarningError – If the type mark isn’t visible, is ambiguous, has a prefix, which isn’t a visible package, denotes no type, or denotes an incomplete type outside of an access type, and no WarningCollector collects the UnresolvedTypeMarkWarning.

Return type:

None

SplitDeclaredItem(declaredItem)

Split a declared item with an identifier list into one declaration per identifier.

The declared item keeps its first identifier. For every other identifier, a new declaration is created by its Copy() and inserted right after it, in list order; its parent is set to this declarative region. If the region is indexed, the namespace and lookup table entries of the other identifiers refer to the new declarations; they are checked before anything is changed. A declared item declaring one identifier is unchanged.

Parameters:

declaredItem (ModelEntity) – The declared item to split.

Return type:

tuple[ModelEntity, ...]

Returns:

Tuple of declarations, one per identifier in list order, starting with the split declared item.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • NotInNamespaceError – If the region is indexed, and an identifier of the declared item refers to another declaration, e.g. a duplicate declaration.

See also

Split()

→ Split a declaration with an identifier list.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

property Subtypes: dict[str, Subtype]

Read-only property to access the declared subtypes (_subtypes).

Returns:

Dictionary of subtypes, indexed by normalized identifier.

property Types: dict[str, FullType]

Read-only property to access the declared types (_types).

Returns:

Dictionary of types, indexed by normalized identifier.

property Variables: dict[str, Variable]

Read-only property to access the declared variables (_variables).

Returns:

Dictionary of variables, indexed by normalized identifier.

Visit(visitor)[source]

Walk this protected type body and its declared items with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_AddOverloadToNamespace(item)

Add a function or procedure to the namespace, if it’s the overload declared last.

The namespace keeps one entry per identifier: the overload declared last, as after IndexDeclaredItems(), which adds interface items first, then declared items (_Declarations()).

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The function or procedure, already an interface item or declared item of this region.

Return type:

None

_AddToNamespace(element)

Add an element’s identifiers to this region’s namespace.

Nothing is added to a region not indexed yet: IndexDeclaredItems() adds the element later. A generic subprogram is an overload (_AddOverloadToNamespace()).

Parameters:

element (NamedEntityMixin | MultipleNamedEntityMixin) – The named element to add, e.g. an interface item.

Return type:

None

_ClashingDeclarations(item)

Return the declarations sharing an identifier with the given item, which may not share it.

The declarations (_Declarations()) and the labeled statements (_Labels()) of this declarative region and of the language constructs sharing it (_SharedRegions()) are searched: a statement label is declared implicitly. Items imported into the namespace (e.g. by a use clause) are no declarations.

Parameters:

item (ModelEntity) – The new declaration, or the new labeled statement.

Return type:

tuple[ModelEntity, ...]

Returns:

Tuple of clashing declarations, interface items first, then declared items in declaration order, then labeled statements.

_ConnectParentNamespace(parent)

Connect this region’s namespace to the namespace of the enclosing declarative region.

A declaration of this region then hides a same-named declaration of the enclosing region. A parent, which isn’t a declarative region (e.g. a subprogram of an interface list), has no namespace to connect to.

Parameters:

parent (ModelEntity) – The new parent of this region.

Return type:

None

_DECLARED_ITEM_TYPES = (<class 'pyVHDLModel.Type.BaseType'>, <class 'pyVHDLModel.Subprogram.Subprogram'>, <class 'pyVHDLModel.DesignUnit.Package'>, <class 'pyVHDLModel.DesignUnit.PackageBody'>, <class 'pyVHDLModel.Object.Constant'>, <class 'pyVHDLModel.Object.Variable'>, <class 'pyVHDLModel.Object.File'>, <class 'pyVHDLModel.Declaration.Alias'>, <class 'pyVHDLModel.Declaration.Attribute'>, <class 'pyVHDLModel.Declaration.AttributeSpecification'>, <class 'pyVHDLModel.DesignUnit.UseClause'>)

Accepted classes of declared items (pyVHDLModel).

_Declarations()

Return all declarations of this declarative region.

A host class with interface items extends the list by its interface items, listed first.

Return type:

tuple[ModelEntity, ...]

Returns:

Tuple of declarations: the declared items, in declaration order.

_DeclaredItemsSharingIdentifiers(declaredItem)

Return the other declared items of this region sharing an identifier with the given declared item.

Parameters:

declaredItem (ModelEntity) – The declared item.

Return type:

list[ModelEntity]

Returns:

List of declared items, in declaration order.

_END_KEYWORDS: ClassVar[tuple[ReservedWord, ...]] = (ReservedWord.Protected, ReservedWord.Body)

Reserved words after end.

_END_KEYWORDS_OPTIONAL: ClassVar[bool] = False

The reserved words after end are optional.

_IndexDeclaredItem(item)

Add a declared item to the namespace and to the lookup table matching its kind.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_IndexOtherDeclaredItem(item)

Hook for declared items the region doesn’t handle itself. Derived classes may override it.

An alias, an attribute declaration and a package (also a package instantiation) declared in the region are added to the namespace, without a lookup table.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_IndexOverload(item)

Add an inserted function or procedure to its lookup table and to the namespace.

The list of overloads follows the declaration order. The namespace is updated by _AddOverloadToNamespace().

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The inserted function or procedure.

Return type:

None

_IterateStatementRegions()

Iterate the declarative regions nested in the statements of this declarative region.

Return type:

Generator[DeclarativeRegionMixin]

Returns:

An empty generator.

_Labels()

Return the labeled statements, whose labels are declared in this declarative region.

Return type:

tuple[ModelEntity, ...]

Returns:

An empty tuple.

_MayShareIdentifier(item, existing)

Check if two declarations may share an identifier in one declarative region.

Subprograms are overloadable. A protected type body completes its protected type, a full type completes its incomplete type, and a constant completes its deferred constant.

Parameters:
Return type:

bool

Returns:

True, if both declarations may share an identifier.

_RemoveDeclaredItemEntries(lookupTable, item)

Remove a declared item’s entries from a lookup table and from the namespace.

Every identifier is checked before anything is removed.

Parameters:
Raises:
  • NotInNamespaceError – If an identifier of the declared item isn’t declared in the namespace.

  • NotInNamespaceError – If an identifier of the declared item refers to another element, e.g. a duplicate declaration.

Return type:

None

_RemoveDeclaredItemsFromNamespace()

Remove all declared items of this region from its namespace.

Interface items of this region and items imported from elsewhere (e.g. by a use clause) are kept.

Return type:

None

_RemoveFromNamespace(element)

Remove an element’s identifiers from this region’s namespace.

Nothing is removed from a region not indexed yet, as its namespace doesn’t contain the element. A generic subprogram is an overload (_RemoveOverloadFromNamespace()).

Parameters:

element (NamedEntityMixin | MultipleNamedEntityMixin) – The named element to remove, e.g. an interface item.

Raises:
  • NotInNamespaceError – If the region is indexed, and an identifier of the element isn’t declared in the namespace.

  • NotInNamespaceError – If the region is indexed, and an identifier of the element refers to another element, e.g. a duplicate declaration.

Return type:

None

_RemoveOverloadFromNamespace(item)

Remove a function or procedure from the namespace.

Removing the overload the namespace refers to, the namespace refers to the remaining overload declared last (_Declarations()), or the identifier is removed, if no overload remains. Removing another overload leaves the namespace unchanged. The namespace is checked before it’s changed.

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The function or procedure, still an interface item or declared item of this region.

Raises:
  • NotInNamespaceError – If the identifier isn’t declared in the namespace.

  • NotInNamespaceError – If the identifier refers to an element, which is no overload, e.g. a duplicate declaration.

Return type:

None

_SharedRegions()

Return the other language constructs forming one declarative region with this one.

An entity and each of its architectures form one declarative region, as do a package and its body. Derived classes override it.

Return type:

tuple[DeclarativeRegionMixin, ...]

Returns:

Tuple of declarative regions.

_UnindexDeclaredItem(item)

Remove a declared item from the namespace and from the lookup table matching its kind.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_UnindexOtherDeclaredItem(item)

Hook to remove declared items the region doesn’t handle itself. Derived classes may override it.

An alias, an attribute declaration and a package are removed from the namespace.

Parameters:

item (ModelEntity) – The declared item.

Raises:

NotInNamespaceError – If the item is an alias, an attribute declaration or a package, which isn’t declared in the namespace.

Return type:

None

_UnindexOverload(item)

Remove a function or procedure from its lookup table and from the namespace.

The namespace is updated first, by _RemoveOverloadFromNamespace().

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The function or procedure to remove, still a declared item of this region.

Raises:
  • NotInNamespaceError – If the identifier isn’t declared in the namespace.

  • NotInNamespaceError – If the identifier refers to an element, which is no overload, e.g. a duplicate declaration.

Return type:

None

_VisitDeclaredItems(visitor)

Walk the declared items in declaration order 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 type declaration.

Format: type myType

Return type:

str

Returns:

Formatted type declaration.

_areDeclaredItemsIndexed

True if IndexDeclaredItems() filled the namespace.

_constants

Dictionary of all constants declared in this sequential declaration region.

_declaredItems

List of all declared items in this sequential declaration region.

_documentation

The associated documentation of a model entity.

_files

Dictionary of all files declared in this sequential declaration region.

_functions

Dictionary of all functions declared in this sequential declaration region, indexed by name; each entry is a list of overloads.

_identifier

The identifier of a model entity.

_namespace

The namespace of this sequential declaration region.

_normalizedIdentifier

The normalized (lower case) identifier of a model entity.

_objectVertex

The vertex representing this type in the design’s object graph.

_parent

Reference to a parent entity in the logical model hierarchy.

_procedures

Dictionary of all procedures declared in this sequential declaration region, indexed by name; each entry is a list of overloads.

_subtypes

Dictionary of all subtypes declared in this sequential declaration region.

_types

Dictionary of all types declared in this sequential declaration region.

_variables

Dictionary of all variables declared in this sequential declaration region.

class pyGHDL.dom.Type.AccessType(node, identifier, designatedSubtype, documentation=None)[source]

Represents an access type.

This class implements a pyGHDL.dom object derived from pyVHDLModel.Type.AccessType.

Example

type line is access string;

Inheritance

Inheritance diagram of AccessType

Parameters:
  • node (Iir)

  • identifier (str)

  • designatedSubtype (Symbol)

  • documentation (str)

__init__(node, identifier, designatedSubtype, documentation=None)[source]

Initializes an access type definition.

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

  • identifier (str) – The access type’s identifier.

  • designatedSubtype (Symbol) – Reference to the subtype the access values designate.

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

Return type:

None

classmethod parse(typeName, typeDefinitionNode, documentation=None)[source]

Parses an access type IIR and returns an AccessType instance.

Parameters:
  • typeName (str) – The identifier of the type.

  • typeDefinitionNode (Iir) – The IIR node to parse.

  • documentation (str) – Optional, the documentation comment on the type declaration.

Return type:

Self

Returns:

The access type instance.

_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 BaseType: BaseType

Read-only property to return the base type of this type: the type itself (IEEE Std 1076-2008, 5.1).

A subtype returns the base type of the type it is derived from (BaseType).

Returns:

The base type.

DenoteBy(name, region, place, symbol)

Return this type or subtype, the model entity a name in a type mark denotes.

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:

This type or subtype.

property DesignatedSubtype: Symbol

Read-only property to access the designated subtype (_designatedSubtype).

Returns:

The designated subtype.

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 identifier as declared, for the model entity’s normalized identifier.

Parameters:

normalizedIdentifier (str) – The model entity’s normalized (lower case) identifier.

Return type:

str

Returns:

The identifier 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 Identifier: str

Read-only property to access the model entity’s identifier (_identifier).

Returns:

Name of a model entity.

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)[source]

Iterate the type marks of this access type: the subtype its values designate.

Parameters:

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

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

A generator to iterate (region, place, type mark) tuples: the designated subtype.

property NormalizedIdentifier: str

Read-only property to access the model entity’s normalized identifier (_normalizedIdentifier).

See also

Returns:

Normalized name of a model entity.

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 access type and its designated subtype 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 access type definition.

Format: ptr is access node

Return type:

str

Returns:

Formatted access type definition.

_designatedSubtype: Symbol

Reference to the subtype the access values designate.

_documentation: str | None

The associated documentation of a model entity.

_identifier: str

The identifier of a model entity.

_normalizedIdentifier: str

The normalized (lower case) identifier of a model entity.

_objectVertex: Vertex

The vertex representing this type in the design’s object graph.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

class pyGHDL.dom.Type.FileType(node, identifier, designatedSubtype, documentation=None)[source]

Represents a file type.

This class implements a pyGHDL.dom object derived from pyVHDLModel.Type.FileType.

Example

type text is file of string;

Inheritance

Inheritance diagram of FileType

Parameters:
  • node (Iir)

  • identifier (str)

  • designatedSubtype (Symbol)

  • documentation (str)

__init__(node, identifier, designatedSubtype, documentation=None)[source]

Initializes a file type definition.

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

  • identifier (str) – The file type’s identifier.

  • designatedSubtype (Symbol) – Reference to the subtype of the values stored in the file.

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

Return type:

None

classmethod parse(typeName, typeDefinitionNode, documentation=None)[source]

Parses a file type IIR and returns an FileType instance.

Parameters:
  • typeName (str) – The identifier of the type.

  • typeDefinitionNode (Iir) – The IIR node to parse.

  • documentation (str) – Optional, the documentation comment on the type declaration.

Return type:

Self

Returns:

The file type instance.

_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 BaseType: BaseType

Read-only property to return the base type of this type: the type itself (IEEE Std 1076-2008, 5.1).

A subtype returns the base type of the type it is derived from (BaseType).

Returns:

The base type.

DenoteBy(name, region, place, symbol)

Return this type or subtype, the model entity a name in a type mark denotes.

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:

This type or subtype.

property DesignatedSubtype: Symbol

Read-only property to access the designated subtype (_designatedSubtype).

Returns:

The designated subtype.

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 identifier as declared, for the model entity’s normalized identifier.

Parameters:

normalizedIdentifier (str) – The model entity’s normalized (lower case) identifier.

Return type:

str

Returns:

The identifier 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 Identifier: str

Read-only property to access the model entity’s identifier (_identifier).

Returns:

Name of a model entity.

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)[source]

Iterate the type marks of this file type: the subtype of its values.

Parameters:

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

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

A generator to iterate (region, place, type mark) tuples: the designated subtype.

property NormalizedIdentifier: str

Read-only property to access the model entity’s normalized identifier (_normalizedIdentifier).

See also

Returns:

Normalized name of a model entity.

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 file type and its designated subtype 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 file type definition.

Format: ft is file of character

Return type:

str

Returns:

Formatted file type definition.

_designatedSubtype: Symbol

Reference to the subtype of the values stored in the file.

_documentation: str | None

The associated documentation of a model entity.

_identifier: str

The identifier of a model entity.

_normalizedIdentifier: str

The normalized (lower case) identifier of a model entity.

_objectVertex: Vertex

The vertex representing this type in the design’s object graph.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

class pyGHDL.dom.Type.Subtype(node, subtypeName, symbol, documentation=None)[source]

Represents a subtype.

This class implements a pyGHDL.dom object derived from pyVHDLModel.Type.Subtype.

Inheritance

Inheritance diagram of Subtype

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

Initializes a subtype declaration.

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

  • subtypeName (str) – The subtype’s identifier.

  • symbol (Symbol) – Reference to the type or subtype this subtype is derived from.

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

Return type:

None

_iirNode

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

_position

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

property BaseType: BaseType

Read-only property to access the base type (_baseType).

It is set, when the subtype’s type mark is resolved (ResolveReferences()).

Returns:

The base type, or None if the type mark isn’t resolved.

DenoteBy(name, region, place, symbol)

Return this type or subtype, the model entity a name in a type mark denotes.

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:

This type or subtype.

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 identifier as declared, for the model entity’s normalized identifier.

Parameters:

normalizedIdentifier (str) – The model entity’s normalized (lower case) identifier.

Return type:

str

Returns:

The identifier 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 Identifier: str

Read-only property to access the model entity’s identifier (_identifier).

Returns:

Name of a model entity.

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)[source]

Iterate the type marks of this subtype declaration: the type mark it is derived from.

Parameters:

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

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

A generator to iterate (region, place, type mark) tuples: the subtype’s type mark.

property NormalizedIdentifier: str

Read-only property to access the model entity’s normalized identifier (_normalizedIdentifier).

See also

Returns:

Normalized name of a model entity.

property Parent: ModelEntity

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

Returns:

Reference to the parent entity.

property Position: Position

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

If _position is None, resolve the position object from _iirNode

Returns:

The IIR’s position in the source file.

property Range: Range

Read-only property to access the range (_range).

Returns:

The range.

ResetReferences(designUnit, region)[source]

Reset the reference of this subtype’s type mark and its base type; a subtype of a predefined library (IsPredefined) keeps its base type.

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

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

Return type:

None

property ResolutionFunction: Function

Read-only property to access the resolution function (_resolutionFunction).

Returns:

The resolution function.

ResolveReferences(designUnit, region)[source]

Resolve the type mark of this subtype and set its base type (BaseType): the resolved type, or the base type of the resolved subtype; None, if the type mark isn’t resolved.

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 Type: Symbol

Read-only property to access the type (_type).

Returns:

The type.

Visit(visitor)[source]

Walk this subtype declaration and its subtype indication 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 subtype declaration.

Format: subtype byte is bit_vector

The base type is rendered, so an unlinked subtype shows None.

Return type:

str

Returns:

Formatted subtype declaration.

_baseType: BaseType

The resolved base type of this subtype.

_documentation

The associated documentation of a model entity.

_identifier

The identifier of a model entity.

_normalizedIdentifier

The normalized (lower case) identifier of a model entity.

_objectVertex

The vertex representing this type in the design’s object graph.

_parent

Reference to a parent entity in the logical model hierarchy.

_range: Range

The constraint narrowing the base type, or None if unconstrained.

_resolutionFunction: Function

The resolution function, or None if the subtype is unresolved.

_type: Symbol

Reference to the type or subtype this subtype is derived from.