pyGHDL.dom.Sequential

This module implements derived sequential statement classes from pyVHDLModel.Sequential.

Classes


Classes

class pyGHDL.dom.Sequential.IfBranch(branchNode, condition, statements=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Sequential.IfBranch.

Represents the if branch of an if statement.

The branch’s condition is available as Condition, its body as Statements.

Example

The whole if statement is shown; the bracket marks the part this class represents.

if sel = '0' then     -- ┐ IfBranch
-- ^^^^^^^^^          -- │   <- Condition
  s <= '0';           -- │
--^^^^^^^^^           -- ┘   <- Statements
elsif sel = '1' then
  s <= '1';
else
  s <= '0';
end if;

Inheritance

Inheritance diagram of IfBranch

Parameters:
  • branchNode (Iir)

  • condition (ExpressionUnion)

  • statements (Iterable[SequentialStatement])

__init__(branchNode, condition, statements=None)[source]

Initializes an if branch.

Parameters:
  • branchNode (Iir) – The IIR node of the branch this object represents.

  • condition (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – The condition under which this branch’s statements are executed.

  • statements (Iterable[SequentialStatement]) – Optional, list of all sequential statements in this construct.

Return type:

None

classmethod parse(branchNode, label)[source]

Translates the IIR node of the branch to an IfBranch.

Parameters:
  • branchNode (Iir) – The IIR node of the branch.

  • label (str) – The statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated branch.

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

AddStatement(statement)

Add a sequential statement at the end of this construct.

The statement’s parent is set to this construct.

Parameters:

statement (SequentialStatement) – The sequential statement to add.

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

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

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

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

InsertStatement()

→ Insert a sequential statement at a position of this construct.

RemoveStatement()

→ Remove a sequential statement from this construct.

property Condition: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

Read-only property to access the condition of a statement (_condition).

Returns:

The expression representing the condition of a statement.

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.

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.

InsertStatement(index, statement)

Insert a sequential statement at a position of this construct.

The statement’s parent is set to this construct.

Every label of a process or subprogram body is declared in the process’ or subprogram’s declarative region: the statement’s label and the labels of statements nested in it (in branches, case alternatives and loops) may neither repeat another label of the body, nor an identifier declared in the region. A construct not in a process or subprogram (yet) checks the labels of its own statements. An unlabeled statement declares nothing.

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

  • statement (SequentialStatement) – The sequential statement 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 ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

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

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

AddStatement()

→ Add a sequential statement at the end of this construct.

InsertStatementBefore()

→ Insert a sequential statement before another statement.

InsertStatementAfter()

→ Insert a sequential statement after another statement.

RemoveStatement()

→ Remove a sequential statement from this construct.

MoveStatement()

→ Move a sequential statement to a position of this construct.

InsertStatementAfter(statement, after)

Insert a sequential statement after another statement of this construct.

The statement’s parent is set to this construct.

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

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

  • AlreadyInDesignError – If parameter ‘statement’ 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 statement of this construct.

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

InsertStatement()

→ Insert a sequential statement at a position of this construct.

InsertStatementBefore()

→ Insert a sequential statement before another statement.

InsertStatementBefore(statement, before)

Insert a sequential statement before another statement of this construct.

The statement’s parent is set to this construct.

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

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

  • AlreadyInDesignError – If parameter ‘statement’ 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 statement of this construct.

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

InsertStatement()

→ Insert a sequential statement at a position of this construct.

InsertStatementAfter()

→ Insert a sequential statement after another statement.

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.

MoveStatement(statement, index)

Move a sequential statement to a position of this construct.

The statement stays a statement of this construct: only the order of the statements changes.

Parameters:
  • statement (SequentialStatement) – The sequential statement to move.

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

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

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

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • 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

MoveStatementBefore()

→ Move a sequential statement before another statement.

MoveStatementAfter()

→ Move a sequential statement after another statement.

InsertStatement()

→ Insert a sequential statement at a position of this construct.

RemoveStatement()

→ Remove a sequential statement from this construct.

MoveStatementAfter(statement, after)

Move a sequential statement after another statement of this construct.

The statement stays a statement of this construct: only the order of the statements changes, as for MoveStatement(). Moving a statement after itself keeps it in place.

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

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

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘after’ is None.

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

  • NotAChildError – If parameter ‘after’ is not a statement of this construct.

Return type:

None

See also

MoveStatement()

→ Move a sequential statement to a position of this construct.

MoveStatementBefore()

→ Move a sequential statement before another statement.

MoveStatementBefore(statement, before)

Move a sequential statement before another statement of this construct.

The statement stays a statement of this construct: only the order of the statements changes, as for MoveStatement(). Moving a statement before itself keeps it in place.

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

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

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘before’ is None.

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

  • NotAChildError – If parameter ‘before’ is not a statement of this construct.

Return type:

None

See also

MoveStatement()

→ Move a sequential statement to a position of this construct.

MoveStatementAfter()

→ Move a sequential statement after another statement.

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.

RemoveStatement(statement)

Remove a sequential statement from this construct.

The statement is detached: its parent is cleared. The statement itself is unchanged and can be added to another construct, or inserted at another position; its labels are free again in this construct’s declarative region.

Parameters:

statement (SequentialStatement) – The sequential statement to remove.

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

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

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

Return type:

None

See also

AddStatement()

→ Add a sequential statement at the end of this construct.

InsertStatement()

→ Insert a sequential statement at a position of this construct.

MoveStatement()

→ Move a sequential statement to a position of this construct.

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 Statements: list[SequentialStatement]

Read-only property to access the list of sequential statements (_statements).

Returns:

A list of sequential statements.

Visit(visitor)[source]

Walk this if branch, its condition and its statements with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_IterateStatementRegions()

Iterate the declarative regions nested in the sequential statements of this construct.

Return type:

Generator[DeclarativeRegionMixin]

Returns:

An empty generator: a sequential statement has no declarative region.

_LabelRegion()

Return the process or subprogram declaring the labels of this branch’s statements.

It’s the region of the construct holding the if statement.

Return type:

ModelEntity | None

Returns:

The process or subprogram, or None if the branch isn’t part of one (yet).

_Labels()

Return the labeled statements of this construct, including the statements nested in compound statements.

Every label of a process or subprogram body is declared in the process’ or subprogram’s declarative region, also a label inside an if branch, a case alternative or a loop.

Return type:

tuple[SequentialStatement, ...]

Returns:

Tuple of labeled statements, depth-first in statement order.

static _LabelsOf(statement)

Return a statement, if it’s labeled, and the labeled statements nested in it.

Parameters:

statement (SequentialStatement) – The sequential statement.

Return type:

tuple[SequentialStatement, ...]

Returns:

Tuple of labeled statements, depth-first in statement order.

_VisitStatements(visitor)

Walk the sequential statements in statement 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

_condition

The condition guarding this statement.

_documentation

The associated documentation of a model entity.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_statements

List of all sequential statements in this construct.

class pyGHDL.dom.Sequential.ElsifBranch(branchNode, condition, statements=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Sequential.ElsifBranch.

Represents an elsif branch of an if statement.

The branch’s condition is available as Condition, its body as Statements. An if statement may have any number of them.

Example

The whole if statement is shown; the bracket marks the part this class represents.

if sel = '0' then
  s <= '0';
elsif sel = '1' then  -- ┐ ElsifBranch
--    ^^^^^^^^^       -- │   <- Condition
  s <= '1';           -- │
--^^^^^^^^^           -- ┘   <- Statements
else
  s <= '0';
end if;

Inheritance

Inheritance diagram of ElsifBranch

Parameters:
  • branchNode (Iir)

  • condition (ExpressionUnion)

  • statements (Iterable[SequentialStatement])

__init__(branchNode, condition, statements=None)[source]

Initializes an elsif branch of an if statement.

Parameters:
  • branchNode (Iir) – The IIR node of the branch this object represents.

  • condition (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – The condition under which this branch’s statements are executed.

  • statements (Iterable[SequentialStatement]) – Optional, list of all sequential statements in this construct.

Return type:

None

classmethod parse(branchNode, condition, label)[source]

Translates the IIR node of the branch to an ElsifBranch.

Parameters:
  • branchNode (Iir) – The IIR node of the branch.

  • condition (Iir) – The condition guarding the branch.

  • label (str) – The statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated branch.

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

AddStatement(statement)

Add a sequential statement at the end of this construct.

The statement’s parent is set to this construct.

Parameters:

statement (SequentialStatement) – The sequential statement to add.

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

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

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

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

InsertStatement()

→ Insert a sequential statement at a position of this construct.

RemoveStatement()

→ Remove a sequential statement from this construct.

property Condition: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

Read-only property to access the condition of a statement (_condition).

Returns:

The expression representing the condition of a statement.

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.

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.

InsertStatement(index, statement)

Insert a sequential statement at a position of this construct.

The statement’s parent is set to this construct.

Every label of a process or subprogram body is declared in the process’ or subprogram’s declarative region: the statement’s label and the labels of statements nested in it (in branches, case alternatives and loops) may neither repeat another label of the body, nor an identifier declared in the region. A construct not in a process or subprogram (yet) checks the labels of its own statements. An unlabeled statement declares nothing.

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

  • statement (SequentialStatement) – The sequential statement 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 ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

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

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

AddStatement()

→ Add a sequential statement at the end of this construct.

InsertStatementBefore()

→ Insert a sequential statement before another statement.

InsertStatementAfter()

→ Insert a sequential statement after another statement.

RemoveStatement()

→ Remove a sequential statement from this construct.

MoveStatement()

→ Move a sequential statement to a position of this construct.

InsertStatementAfter(statement, after)

Insert a sequential statement after another statement of this construct.

The statement’s parent is set to this construct.

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

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

  • AlreadyInDesignError – If parameter ‘statement’ 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 statement of this construct.

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

InsertStatement()

→ Insert a sequential statement at a position of this construct.

InsertStatementBefore()

→ Insert a sequential statement before another statement.

InsertStatementBefore(statement, before)

Insert a sequential statement before another statement of this construct.

The statement’s parent is set to this construct.

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

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

  • AlreadyInDesignError – If parameter ‘statement’ 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 statement of this construct.

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

InsertStatement()

→ Insert a sequential statement at a position of this construct.

InsertStatementAfter()

→ Insert a sequential statement after another statement.

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.

MoveStatement(statement, index)

Move a sequential statement to a position of this construct.

The statement stays a statement of this construct: only the order of the statements changes.

Parameters:
  • statement (SequentialStatement) – The sequential statement to move.

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

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

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

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • 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

MoveStatementBefore()

→ Move a sequential statement before another statement.

MoveStatementAfter()

→ Move a sequential statement after another statement.

InsertStatement()

→ Insert a sequential statement at a position of this construct.

RemoveStatement()

→ Remove a sequential statement from this construct.

MoveStatementAfter(statement, after)

Move a sequential statement after another statement of this construct.

The statement stays a statement of this construct: only the order of the statements changes, as for MoveStatement(). Moving a statement after itself keeps it in place.

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

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

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘after’ is None.

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

  • NotAChildError – If parameter ‘after’ is not a statement of this construct.

Return type:

None

See also

MoveStatement()

→ Move a sequential statement to a position of this construct.

MoveStatementBefore()

→ Move a sequential statement before another statement.

MoveStatementBefore(statement, before)

Move a sequential statement before another statement of this construct.

The statement stays a statement of this construct: only the order of the statements changes, as for MoveStatement(). Moving a statement before itself keeps it in place.

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

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

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘before’ is None.

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

  • NotAChildError – If parameter ‘before’ is not a statement of this construct.

Return type:

None

See also

MoveStatement()

→ Move a sequential statement to a position of this construct.

MoveStatementAfter()

→ Move a sequential statement after another statement.

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.

RemoveStatement(statement)

Remove a sequential statement from this construct.

The statement is detached: its parent is cleared. The statement itself is unchanged and can be added to another construct, or inserted at another position; its labels are free again in this construct’s declarative region.

Parameters:

statement (SequentialStatement) – The sequential statement to remove.

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

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

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

Return type:

None

See also

AddStatement()

→ Add a sequential statement at the end of this construct.

InsertStatement()

→ Insert a sequential statement at a position of this construct.

MoveStatement()

→ Move a sequential statement to a position of this construct.

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 Statements: list[SequentialStatement]

Read-only property to access the list of sequential statements (_statements).

Returns:

A list of sequential statements.

Visit(visitor)[source]

Walk this elsif branch, its condition and its statements with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_IterateStatementRegions()

Iterate the declarative regions nested in the sequential statements of this construct.

Return type:

Generator[DeclarativeRegionMixin]

Returns:

An empty generator: a sequential statement has no declarative region.

_LabelRegion()

Return the process or subprogram declaring the labels of this branch’s statements.

It’s the region of the construct holding the if statement.

Return type:

ModelEntity | None

Returns:

The process or subprogram, or None if the branch isn’t part of one (yet).

_Labels()

Return the labeled statements of this construct, including the statements nested in compound statements.

Every label of a process or subprogram body is declared in the process’ or subprogram’s declarative region, also a label inside an if branch, a case alternative or a loop.

Return type:

tuple[SequentialStatement, ...]

Returns:

Tuple of labeled statements, depth-first in statement order.

static _LabelsOf(statement)

Return a statement, if it’s labeled, and the labeled statements nested in it.

Parameters:

statement (SequentialStatement) – The sequential statement.

Return type:

tuple[SequentialStatement, ...]

Returns:

Tuple of labeled statements, depth-first in statement order.

_VisitStatements(visitor)

Walk the sequential statements in statement 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

_condition

The condition guarding this statement.

_documentation

The associated documentation of a model entity.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_statements

List of all sequential statements in this construct.

class pyGHDL.dom.Sequential.ElseBranch(branchNode, statements=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Sequential.ElseBranch.

Represents the else branch of an if statement.

Unlike the other branches, an else branch has no condition; it only has a body (Statements). An if statement has at most one.

Example

The whole if statement is shown; the bracket marks the part this class represents.

if sel = '0' then
  s <= '0';
elsif sel = '1' then
  s <= '1';
else                  -- ┐ ElseBranch
  s <= '0';           -- │
--^^^^^^^^^           -- ┘   <- Statements
end if;

Inheritance

Inheritance diagram of ElseBranch

Parameters:
  • branchNode (Iir)

  • statements (Iterable[SequentialStatement])

__init__(branchNode, statements=None)[source]

Initializes an else branch.

Parameters:
  • branchNode (Iir) – The IIR node of the branch this object represents.

  • statements (Iterable[SequentialStatement]) – Optional, list of all sequential statements in this construct.

Return type:

None

classmethod parse(branchNode, label)[source]

Translates the IIR node of the branch to an ElseBranch.

Parameters:
  • branchNode (Iir) – The IIR node of the branch.

  • label (str) – The statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated branch.

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

AddStatement(statement)

Add a sequential statement at the end of this construct.

The statement’s parent is set to this construct.

Parameters:

statement (SequentialStatement) – The sequential statement to add.

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

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

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

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

InsertStatement()

→ Insert a sequential statement at a position of this construct.

RemoveStatement()

→ Remove a sequential statement from this construct.

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.

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.

InsertStatement(index, statement)

Insert a sequential statement at a position of this construct.

The statement’s parent is set to this construct.

Every label of a process or subprogram body is declared in the process’ or subprogram’s declarative region: the statement’s label and the labels of statements nested in it (in branches, case alternatives and loops) may neither repeat another label of the body, nor an identifier declared in the region. A construct not in a process or subprogram (yet) checks the labels of its own statements. An unlabeled statement declares nothing.

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

  • statement (SequentialStatement) – The sequential statement 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 ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

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

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

AddStatement()

→ Add a sequential statement at the end of this construct.

InsertStatementBefore()

→ Insert a sequential statement before another statement.

InsertStatementAfter()

→ Insert a sequential statement after another statement.

RemoveStatement()

→ Remove a sequential statement from this construct.

MoveStatement()

→ Move a sequential statement to a position of this construct.

InsertStatementAfter(statement, after)

Insert a sequential statement after another statement of this construct.

The statement’s parent is set to this construct.

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

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

  • AlreadyInDesignError – If parameter ‘statement’ 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 statement of this construct.

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

InsertStatement()

→ Insert a sequential statement at a position of this construct.

InsertStatementBefore()

→ Insert a sequential statement before another statement.

InsertStatementBefore(statement, before)

Insert a sequential statement before another statement of this construct.

The statement’s parent is set to this construct.

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

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

  • AlreadyInDesignError – If parameter ‘statement’ 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 statement of this construct.

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

InsertStatement()

→ Insert a sequential statement at a position of this construct.

InsertStatementAfter()

→ Insert a sequential statement after another statement.

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.

MoveStatement(statement, index)

Move a sequential statement to a position of this construct.

The statement stays a statement of this construct: only the order of the statements changes.

Parameters:
  • statement (SequentialStatement) – The sequential statement to move.

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

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

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

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • 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

MoveStatementBefore()

→ Move a sequential statement before another statement.

MoveStatementAfter()

→ Move a sequential statement after another statement.

InsertStatement()

→ Insert a sequential statement at a position of this construct.

RemoveStatement()

→ Remove a sequential statement from this construct.

MoveStatementAfter(statement, after)

Move a sequential statement after another statement of this construct.

The statement stays a statement of this construct: only the order of the statements changes, as for MoveStatement(). Moving a statement after itself keeps it in place.

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

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

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘after’ is None.

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

  • NotAChildError – If parameter ‘after’ is not a statement of this construct.

Return type:

None

See also

MoveStatement()

→ Move a sequential statement to a position of this construct.

MoveStatementBefore()

→ Move a sequential statement before another statement.

MoveStatementBefore(statement, before)

Move a sequential statement before another statement of this construct.

The statement stays a statement of this construct: only the order of the statements changes, as for MoveStatement(). Moving a statement before itself keeps it in place.

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

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

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘before’ is None.

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

  • NotAChildError – If parameter ‘before’ is not a statement of this construct.

Return type:

None

See also

MoveStatement()

→ Move a sequential statement to a position of this construct.

MoveStatementAfter()

→ Move a sequential statement after another statement.

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.

RemoveStatement(statement)

Remove a sequential statement from this construct.

The statement is detached: its parent is cleared. The statement itself is unchanged and can be added to another construct, or inserted at another position; its labels are free again in this construct’s declarative region.

Parameters:

statement (SequentialStatement) – The sequential statement to remove.

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

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

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

Return type:

None

See also

AddStatement()

→ Add a sequential statement at the end of this construct.

InsertStatement()

→ Insert a sequential statement at a position of this construct.

MoveStatement()

→ Move a sequential statement to a position of this construct.

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 Statements: list[SequentialStatement]

Read-only property to access the list of sequential statements (_statements).

Returns:

A list of sequential statements.

Visit(visitor)[source]

Walk this else branch and its statements with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_IterateStatementRegions()

Iterate the declarative regions nested in the sequential statements of this construct.

Return type:

Generator[DeclarativeRegionMixin]

Returns:

An empty generator: a sequential statement has no declarative region.

_LabelRegion()

Return the process or subprogram declaring the labels of this branch’s statements.

It’s the region of the construct holding the if statement.

Return type:

ModelEntity | None

Returns:

The process or subprogram, or None if the branch isn’t part of one (yet).

_Labels()

Return the labeled statements of this construct, including the statements nested in compound statements.

Every label of a process or subprogram body is declared in the process’ or subprogram’s declarative region, also a label inside an if branch, a case alternative or a loop.

Return type:

tuple[SequentialStatement, ...]

Returns:

Tuple of labeled statements, depth-first in statement order.

static _LabelsOf(statement)

Return a statement, if it’s labeled, and the labeled statements nested in it.

Parameters:

statement (SequentialStatement) – The sequential statement.

Return type:

tuple[SequentialStatement, ...]

Returns:

Tuple of labeled statements, depth-first in statement order.

_VisitStatements(visitor)

Walk the sequential statements in statement 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

_documentation: str | None

The associated documentation of a model entity.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_statements: list[SequentialStatement]

List of all sequential statements in this construct.

class pyGHDL.dom.Sequential.IfStatement(ifNode, ifBranch, elsifBranches=None, elseBranch=None, label=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Sequential.IfStatement.

Represents an if statement.

An if statement has one if branch (IfBranch), any number of elsif branches (ElsIfBranches) and an optional else branch (ElseBranch).

Example

Only an if branch:

  lbl : if sel = '0' then
--^^^                       <- optional Label
    s <= '0';
  end if;

With elsif and else branches:

  lbl : if sel = '0' then
--^^^                       <- optional Label
--      ^^^^^^^^^^^^^^^^^   <- IfBranch
    s <= '0';
  elsif sel = '1' then
--^^^^^^^^^^^^^^^^^^^^      <- ElsIfBranches[0]
    s <= '1';
  else
--^^^^                      <- ElseBranch
    s <= '0';
  end if;

Inheritance

Inheritance diagram of IfStatement

Parameters:
__init__(ifNode, ifBranch, elsifBranches=None, elseBranch=None, label=None)[source]

Initializes an if statement.

Parameters:
  • ifNode (Iir) – The IIR node of the if statement.

  • ifBranch (IfBranch) – The mandatory if branch.

  • elsifBranches (Iterable[ElsifBranch]) – Optional, list of all elsif branches, in the order they were written.

  • elseBranch (ElseBranch) – Optional, the else branch, or None if none was given.

  • label (str) – Optional, the label of the if statement, or None if it has none.

Return type:

None

classmethod parse(ifNode, label)[source]

Translates the IIR node of the if statement to an IfStatement.

Parameters:
  • ifNode (Iir) – The IIR node of the if statement.

  • label (str) – The statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated if statement.

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

property ElsIfBranches: list[ElsifBranch]

Read-only property to access the elsif-branches of the if-statement (_elsifBranches).

Returns:

List of elsif-branches, in the order they were written.

property ElseBranch: ElseBranch | None

Read-only property to access the else-branch of the if-statement (_elseBranch).

Returns:

The else-branch.

GetAncestor(type)

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

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

Parameters:

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

Return type:

ModelEntity

Returns:

The closest ancestor of the requested type.

Raises:

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

classmethod GetMethodsWithAttributes(predicate=None)

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

Parameters:

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

Return type:

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

Returns:

Dictionary of methods and the matching attributes attached to them.

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

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

property IfBranch: IfBranch

Read-only property to access the if-branch of the if-statement (_ifBranch).

Returns:

The if-branch.

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 Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

See also

Returns:

Normalized label 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 if statement and its branches with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

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

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

_documentation: str | None

The associated documentation of a model entity.

_elseBranch: ElseBranch | None

The optional else branch, or None if none was given.

_elsifBranches: list[ElsifBranch]

List of all elsif branches, in the order they were written.

_ifBranch: IfBranch

The mandatory if branch.

_label: str | None

The label of a model entity.

_normalizedLabel: str | None

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

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

class pyGHDL.dom.Sequential.IndexedChoice(node, expression)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Sequential.IndexedChoice.

Represents a case choice given by a single value.

The value is available as Expression.

Example

when 0      => v := '1';
--   ^                     <- Expression

Inheritance

Inheritance diagram of IndexedChoice

Parameters:
  • node (Iir)

  • expression (ExpressionUnion)

__init__(node, expression)[source]

Initializes a case choice given by a single value.

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

  • expression (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – The expression this choice selects on.

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.

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 Expression: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

Read-only property to access the expression (_expression).

Returns:

The expression.

GetAncestor(type)

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

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

Parameters:

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

Return type:

ModelEntity

Returns:

The closest ancestor of the requested type.

Raises:

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

classmethod GetMethodsWithAttributes(predicate=None)

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

Parameters:

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

Return type:

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

Returns:

Dictionary of methods and the matching attributes attached to them.

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

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

property IsOverloadable: bool

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

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

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

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

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

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

IterateTypeMarks(region)

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

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

Parameters:

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

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

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

property Parent: ModelEntity

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

Returns:

Reference to the parent entity.

property Position: Position

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

If _position is None, resolve the position object from _iirNode

Returns:

The IIR’s position in the source file.

ResetReferences(designUnit, region)

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

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

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

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

Return type:

None

ResolveReferences(designUnit, region)

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

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

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

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

Raises:

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

Return type:

None

Visit(visitor)[source]

Walk this choice and its value with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

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

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

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

__new__(**kwargs)
__setstate__(state)

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

Parameters:

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

Raises:

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

Return type:

None

__str__()[source]

Formats the indexed case choice.

Format: 0

Return type:

str

Returns:

Formatted indexed case choice.

_expression: ExpressionUnion

The expression this choice selects on.

_parent

Reference to a parent entity in the logical model hierarchy.

class pyGHDL.dom.Sequential.RangedChoice(node, rng)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Sequential.RangedChoice.

Represents a case choice given by a range.

The range is available as Range.

Example

when 1 to 2 => v := '0';
--   ^^^^^^                <- Range

Inheritance

Inheritance diagram of RangedChoice

Parameters:
__init__(node, rng)[source]

Initializes a case choice given by a range.

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

  • rng (Range) – The range this choice selects on.

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.

GetAncestor(type)

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

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

Parameters:

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

Return type:

ModelEntity

Returns:

The closest ancestor of the requested type.

Raises:

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

classmethod GetMethodsWithAttributes(predicate=None)

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

Parameters:

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

Return type:

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

Returns:

Dictionary of methods and the matching attributes attached to them.

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

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

property IsOverloadable: bool

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

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

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

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

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

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

IterateTypeMarks(region)

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

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

Parameters:

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

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

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

property Parent: ModelEntity

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

Returns:

Reference to the parent entity.

property Position: Position

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

If _position is None, resolve the position object from _iirNode

Returns:

The IIR’s position in the source file.

property Range: Range

Read-only property to access the 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 choice 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 ranged case choice.

Format: 0 to 3

Return type:

str

Returns:

Formatted ranged case choice.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_range: Range

The range this choice selects on.

class pyGHDL.dom.Sequential.Case(node, choices, statements=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Sequential.Case.

Represents one alternative of a case statement, selected by its choices.

Example

when 1 to 2 => v := '0';
--   ^^^^^^                <- Choices
--             ^^^^^^^^^   <- the statements

Inheritance

Inheritance diagram of Case

Parameters:
  • node (Iir)

  • choices (Iterable[SequentialChoice])

  • statements (Iterable[SequentialStatement])

__init__(node, choices, statements=None)[source]

Initializes a case.

Parameters:
Return type:

None

classmethod parse(caseNode, choices, label)[source]

Translates the IIR node of the alternative to a Case.

Parameters:
  • caseNode (Iir) – The IIR node of the alternative.

  • choices (Iterable[SequentialChoice]) – List of all choices selecting this alternative.

  • label (str) – The statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated alternative.

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

AddStatement(statement)

Add a sequential statement at the end of this construct.

The statement’s parent is set to this construct.

Parameters:

statement (SequentialStatement) – The sequential statement to add.

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

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

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

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

InsertStatement()

→ Insert a sequential statement at a position of this construct.

RemoveStatement()

→ Remove a sequential statement from this construct.

property Choices: list[BaseChoice]

Read-only property to access the choices (_choices).

Returns:

List of choices.

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.

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.

InsertStatement(index, statement)

Insert a sequential statement at a position of this construct.

The statement’s parent is set to this construct.

Every label of a process or subprogram body is declared in the process’ or subprogram’s declarative region: the statement’s label and the labels of statements nested in it (in branches, case alternatives and loops) may neither repeat another label of the body, nor an identifier declared in the region. A construct not in a process or subprogram (yet) checks the labels of its own statements. An unlabeled statement declares nothing.

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

  • statement (SequentialStatement) – The sequential statement 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 ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

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

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

AddStatement()

→ Add a sequential statement at the end of this construct.

InsertStatementBefore()

→ Insert a sequential statement before another statement.

InsertStatementAfter()

→ Insert a sequential statement after another statement.

RemoveStatement()

→ Remove a sequential statement from this construct.

MoveStatement()

→ Move a sequential statement to a position of this construct.

InsertStatementAfter(statement, after)

Insert a sequential statement after another statement of this construct.

The statement’s parent is set to this construct.

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

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

  • AlreadyInDesignError – If parameter ‘statement’ 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 statement of this construct.

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

InsertStatement()

→ Insert a sequential statement at a position of this construct.

InsertStatementBefore()

→ Insert a sequential statement before another statement.

InsertStatementBefore(statement, before)

Insert a sequential statement before another statement of this construct.

The statement’s parent is set to this construct.

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

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

  • AlreadyInDesignError – If parameter ‘statement’ 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 statement of this construct.

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

InsertStatement()

→ Insert a sequential statement at a position of this construct.

InsertStatementAfter()

→ Insert a sequential statement after another statement.

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.

MoveStatement(statement, index)

Move a sequential statement to a position of this construct.

The statement stays a statement of this construct: only the order of the statements changes.

Parameters:
  • statement (SequentialStatement) – The sequential statement to move.

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

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

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

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • 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

MoveStatementBefore()

→ Move a sequential statement before another statement.

MoveStatementAfter()

→ Move a sequential statement after another statement.

InsertStatement()

→ Insert a sequential statement at a position of this construct.

RemoveStatement()

→ Remove a sequential statement from this construct.

MoveStatementAfter(statement, after)

Move a sequential statement after another statement of this construct.

The statement stays a statement of this construct: only the order of the statements changes, as for MoveStatement(). Moving a statement after itself keeps it in place.

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

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

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘after’ is None.

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

  • NotAChildError – If parameter ‘after’ is not a statement of this construct.

Return type:

None

See also

MoveStatement()

→ Move a sequential statement to a position of this construct.

MoveStatementBefore()

→ Move a sequential statement before another statement.

MoveStatementBefore(statement, before)

Move a sequential statement before another statement of this construct.

The statement stays a statement of this construct: only the order of the statements changes, as for MoveStatement(). Moving a statement before itself keeps it in place.

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

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

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘before’ is None.

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

  • NotAChildError – If parameter ‘before’ is not a statement of this construct.

Return type:

None

See also

MoveStatement()

→ Move a sequential statement to a position of this construct.

MoveStatementAfter()

→ Move a sequential statement after another statement.

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.

RemoveStatement(statement)

Remove a sequential statement from this construct.

The statement is detached: its parent is cleared. The statement itself is unchanged and can be added to another construct, or inserted at another position; its labels are free again in this construct’s declarative region.

Parameters:

statement (SequentialStatement) – The sequential statement to remove.

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

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

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

Return type:

None

See also

AddStatement()

→ Add a sequential statement at the end of this construct.

InsertStatement()

→ Insert a sequential statement at a position of this construct.

MoveStatement()

→ Move a sequential statement to a position of this construct.

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 Statements: list[SequentialStatement]

Read-only property to access the list of sequential statements (_statements).

Returns:

A list of sequential statements.

Visit(visitor)[source]

Walk this case alternative, its choices and its statements with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_IterateStatementRegions()

Iterate the declarative regions nested in the sequential statements of this construct.

Return type:

Generator[DeclarativeRegionMixin]

Returns:

An empty generator: a sequential statement has no declarative region.

_LabelRegion()

Return the process or subprogram declaring the labels of this case alternative’s statements.

It’s the region of the construct holding the case statement.

Return type:

ModelEntity | None

Returns:

The process or subprogram, or None if the case alternative isn’t part of one (yet).

_Labels()

Return the labeled statements of this construct, including the statements nested in compound statements.

Every label of a process or subprogram body is declared in the process’ or subprogram’s declarative region, also a label inside an if branch, a case alternative or a loop.

Return type:

tuple[SequentialStatement, ...]

Returns:

Tuple of labeled statements, depth-first in statement order.

static _LabelsOf(statement)

Return a statement, if it’s labeled, and the labeled statements nested in it.

Parameters:

statement (SequentialStatement) – The sequential statement.

Return type:

tuple[SequentialStatement, ...]

Returns:

Tuple of labeled statements, depth-first in statement order.

_VisitStatements(visitor)

Walk the sequential statements in statement 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__()[source]

Formats the case alternative.

Format: when 0 | 1 =>

Return type:

str

Returns:

Formatted case alternative.

_choices: list[BaseChoice]

List of all choices selecting this alternative.

_documentation: str | None

The associated documentation of a model entity.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_statements: list[SequentialStatement]

List of all sequential statements in this construct.

class pyGHDL.dom.Sequential.OthersCase(caseNode, statements=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Sequential.OthersCase.

Represents the others alternative of a case statement.

It covers every choice not named explicitly.

Example

when others => null;
--   ^^^^^^            <- the choice

Inheritance

Inheritance diagram of OthersCase

Parameters:
  • caseNode (Iir)

  • statements (Iterable[SequentialStatement])

__init__(caseNode, statements=None)[source]

Initializes an others alternative.

Parameters:
  • caseNode (Iir) – The IIR node of the case statement.

  • statements (Iterable[SequentialStatement]) – Optional, list of all sequential statements in this construct.

Return type:

None

classmethod parse(caseNode, label=None)[source]

Translates the IIR node of the alternative to an OthersCase.

Parameters:
  • caseNode (Iir) – The IIR node of the alternative.

  • label (str) – Optional, the statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated alternative.

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

AddStatement(statement)

Add a sequential statement at the end of this construct.

The statement’s parent is set to this construct.

Parameters:

statement (SequentialStatement) – The sequential statement to add.

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

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

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

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

InsertStatement()

→ Insert a sequential statement at a position of this construct.

RemoveStatement()

→ Remove a sequential statement from this construct.

property Choices: list[BaseChoice]

Read-only property to access the choices (_choices).

Returns:

List of choices.

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.

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.

InsertStatement(index, statement)

Insert a sequential statement at a position of this construct.

The statement’s parent is set to this construct.

Every label of a process or subprogram body is declared in the process’ or subprogram’s declarative region: the statement’s label and the labels of statements nested in it (in branches, case alternatives and loops) may neither repeat another label of the body, nor an identifier declared in the region. A construct not in a process or subprogram (yet) checks the labels of its own statements. An unlabeled statement declares nothing.

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

  • statement (SequentialStatement) – The sequential statement 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 ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

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

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

AddStatement()

→ Add a sequential statement at the end of this construct.

InsertStatementBefore()

→ Insert a sequential statement before another statement.

InsertStatementAfter()

→ Insert a sequential statement after another statement.

RemoveStatement()

→ Remove a sequential statement from this construct.

MoveStatement()

→ Move a sequential statement to a position of this construct.

InsertStatementAfter(statement, after)

Insert a sequential statement after another statement of this construct.

The statement’s parent is set to this construct.

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

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

  • AlreadyInDesignError – If parameter ‘statement’ 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 statement of this construct.

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

InsertStatement()

→ Insert a sequential statement at a position of this construct.

InsertStatementBefore()

→ Insert a sequential statement before another statement.

InsertStatementBefore(statement, before)

Insert a sequential statement before another statement of this construct.

The statement’s parent is set to this construct.

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

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

  • AlreadyInDesignError – If parameter ‘statement’ 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 statement of this construct.

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

InsertStatement()

→ Insert a sequential statement at a position of this construct.

InsertStatementAfter()

→ Insert a sequential statement after another statement.

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.

MoveStatement(statement, index)

Move a sequential statement to a position of this construct.

The statement stays a statement of this construct: only the order of the statements changes.

Parameters:
  • statement (SequentialStatement) – The sequential statement to move.

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

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

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

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • 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

MoveStatementBefore()

→ Move a sequential statement before another statement.

MoveStatementAfter()

→ Move a sequential statement after another statement.

InsertStatement()

→ Insert a sequential statement at a position of this construct.

RemoveStatement()

→ Remove a sequential statement from this construct.

MoveStatementAfter(statement, after)

Move a sequential statement after another statement of this construct.

The statement stays a statement of this construct: only the order of the statements changes, as for MoveStatement(). Moving a statement after itself keeps it in place.

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

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

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘after’ is None.

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

  • NotAChildError – If parameter ‘after’ is not a statement of this construct.

Return type:

None

See also

MoveStatement()

→ Move a sequential statement to a position of this construct.

MoveStatementBefore()

→ Move a sequential statement before another statement.

MoveStatementBefore(statement, before)

Move a sequential statement before another statement of this construct.

The statement stays a statement of this construct: only the order of the statements changes, as for MoveStatement(). Moving a statement before itself keeps it in place.

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

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

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘before’ is None.

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

  • NotAChildError – If parameter ‘before’ is not a statement of this construct.

Return type:

None

See also

MoveStatement()

→ Move a sequential statement to a position of this construct.

MoveStatementAfter()

→ Move a sequential statement after another statement.

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.

RemoveStatement(statement)

Remove a sequential statement from this construct.

The statement is detached: its parent is cleared. The statement itself is unchanged and can be added to another construct, or inserted at another position; its labels are free again in this construct’s declarative region.

Parameters:

statement (SequentialStatement) – The sequential statement to remove.

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

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

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

Return type:

None

See also

AddStatement()

→ Add a sequential statement at the end of this construct.

InsertStatement()

→ Insert a sequential statement at a position of this construct.

MoveStatement()

→ Move a sequential statement to a position of this construct.

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 Statements: list[SequentialStatement]

Read-only property to access the list of sequential statements (_statements).

Returns:

A list of sequential statements.

Visit(visitor)[source]

Walk this others case alternative and its statements with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_IterateStatementRegions()

Iterate the declarative regions nested in the sequential statements of this construct.

Return type:

Generator[DeclarativeRegionMixin]

Returns:

An empty generator: a sequential statement has no declarative region.

_LabelRegion()

Return the process or subprogram declaring the labels of this case alternative’s statements.

It’s the region of the construct holding the case statement.

Return type:

ModelEntity | None

Returns:

The process or subprogram, or None if the case alternative isn’t part of one (yet).

_Labels()

Return the labeled statements of this construct, including the statements nested in compound statements.

Every label of a process or subprogram body is declared in the process’ or subprogram’s declarative region, also a label inside an if branch, a case alternative or a loop.

Return type:

tuple[SequentialStatement, ...]

Returns:

Tuple of labeled statements, depth-first in statement order.

static _LabelsOf(statement)

Return a statement, if it’s labeled, and the labeled statements nested in it.

Parameters:

statement (SequentialStatement) – The sequential statement.

Return type:

tuple[SequentialStatement, ...]

Returns:

Tuple of labeled statements, depth-first in statement order.

_VisitStatements(visitor)

Walk the sequential statements in statement 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__()[source]

Formats the others case alternative.

Format: when others =>

Return type:

str

Returns:

Formatted others case alternative.

_choices: list[BaseChoice]

List of all choices selecting this alternative.

_documentation: str | None

The associated documentation of a model entity.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_statements: list[SequentialStatement]

List of all sequential statements in this construct.

class pyGHDL.dom.Sequential.CaseStatement(caseNode, label, expression, cases)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Sequential.CaseStatement.

Represents a case statement.

The expression being tested is available as SelectExpression, the alternatives as Cases.

Example

  lbl : case sel is
--^^^                          <- optional Label
--           ^^^               <- SelectExpression
    when '0'    => s <= '1';
--  ^^^^^^^^^^^^^^^^^^^^^^^^   <- Cases[0]
    when others => null;
--  ^^^^^^^^^^^^^^^^^^^^       <- Cases[1]
  end case;

Inheritance

Inheritance diagram of CaseStatement

Parameters:
  • caseNode (Iir)

  • label (str)

  • expression (ExpressionUnion)

  • cases (Iterable[SequentialCase])

__init__(caseNode, label, expression, cases)[source]

Initializes a case statement.

Parameters:
  • caseNode (Iir) – The IIR node of the case statement.

  • label (str) – The label of the case statement, or None if it has none.

  • expression (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – The expression being tested.

  • cases (Iterable[SequentialCase]) – List of all alternatives, in the order they were written.

Return type:

None

classmethod parse(caseNode, label)[source]

Translates the IIR node of the alternative to a CaseStatement.

Parameters:
  • caseNode (Iir) – The IIR node of the alternative.

  • label (str) – The statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated alternative.

_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 Cases: list[SequentialCase]

Read-only property to access the cases (_cases).

Returns:

List of cases.

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.

classmethod GetMethodsWithAttributes(predicate=None)

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

Parameters:

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

Return type:

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

Returns:

Dictionary of methods and the matching attributes attached to them.

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

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

property IsOverloadable: bool

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

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

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

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

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

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

IterateTypeMarks(region)

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

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

Parameters:

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

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

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

property Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

See also

Returns:

Normalized label 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 SelectExpression: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

Read-only property to access the select expression (_expression).

Returns:

The select expression.

Visit(visitor)[source]

Walk this case statement, its selector and its alternatives with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

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

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

_cases: list[SequentialCase]

List of all alternatives, in the order they were written.

_documentation

The associated documentation of a model entity.

_expression: ExpressionUnion

The expression being tested.

_label

The label of a model entity.

_normalizedLabel

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

_parent

Reference to a parent entity in the logical model hierarchy.

class pyGHDL.dom.Sequential.EndlessLoopStatement(loopNode, statements=None, label=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Sequential.EndlessLoopStatement.

Represents an endless loop statement.

The loop body is available as Statements. The loop has no iteration scheme, so it is left with an exit or return statement.

Example

  lbl : loop
--^^^          <- optional Label
    exit;
--  ^^^^^      <- Statements
  end loop;

Inheritance

Inheritance diagram of EndlessLoopStatement

Parameters:
  • loopNode (Iir)

  • statements (Iterable[SequentialStatement])

  • label (str)

__init__(loopNode, statements=None, label=None)[source]

Initializes a loop statement without iteration scheme.

Parameters:
  • loopNode (Iir) – The IIR node of the loop statement.

  • statements (Iterable[SequentialStatement]) – Optional, list of all sequential statements in this construct.

  • label (str) – Optional, the label of the loop statement, or None if it has none.

Return type:

None

classmethod parse(loopNode, label)[source]

Translates the IIR node of the loop statement to an EndlessLoopStatement.

libghdl represents a loop statement without iteration scheme as a While_Loop_Statement without condition.

Parameters:
  • loopNode (Iir) – The IIR node of the loop statement.

  • label (str) – The statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated loop statement.

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

AddStatement(statement)

Add a sequential statement at the end of this construct.

The statement’s parent is set to this construct.

Parameters:

statement (SequentialStatement) – The sequential statement to add.

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

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

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

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

InsertStatement()

→ Insert a sequential statement at a position of this construct.

RemoveStatement()

→ Remove a sequential statement from this construct.

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.

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.

InsertStatement(index, statement)

Insert a sequential statement at a position of this construct.

The statement’s parent is set to this construct.

Every label of a process or subprogram body is declared in the process’ or subprogram’s declarative region: the statement’s label and the labels of statements nested in it (in branches, case alternatives and loops) may neither repeat another label of the body, nor an identifier declared in the region. A construct not in a process or subprogram (yet) checks the labels of its own statements. An unlabeled statement declares nothing.

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

  • statement (SequentialStatement) – The sequential statement 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 ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

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

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

AddStatement()

→ Add a sequential statement at the end of this construct.

InsertStatementBefore()

→ Insert a sequential statement before another statement.

InsertStatementAfter()

→ Insert a sequential statement after another statement.

RemoveStatement()

→ Remove a sequential statement from this construct.

MoveStatement()

→ Move a sequential statement to a position of this construct.

InsertStatementAfter(statement, after)

Insert a sequential statement after another statement of this construct.

The statement’s parent is set to this construct.

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

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

  • AlreadyInDesignError – If parameter ‘statement’ 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 statement of this construct.

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

InsertStatement()

→ Insert a sequential statement at a position of this construct.

InsertStatementBefore()

→ Insert a sequential statement before another statement.

InsertStatementBefore(statement, before)

Insert a sequential statement before another statement of this construct.

The statement’s parent is set to this construct.

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

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

  • AlreadyInDesignError – If parameter ‘statement’ 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 statement of this construct.

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

InsertStatement()

→ Insert a sequential statement at a position of this construct.

InsertStatementAfter()

→ Insert a sequential statement after another statement.

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 Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

MoveStatement(statement, index)

Move a sequential statement to a position of this construct.

The statement stays a statement of this construct: only the order of the statements changes.

Parameters:
  • statement (SequentialStatement) – The sequential statement to move.

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

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

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

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • 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

MoveStatementBefore()

→ Move a sequential statement before another statement.

MoveStatementAfter()

→ Move a sequential statement after another statement.

InsertStatement()

→ Insert a sequential statement at a position of this construct.

RemoveStatement()

→ Remove a sequential statement from this construct.

MoveStatementAfter(statement, after)

Move a sequential statement after another statement of this construct.

The statement stays a statement of this construct: only the order of the statements changes, as for MoveStatement(). Moving a statement after itself keeps it in place.

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

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

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘after’ is None.

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

  • NotAChildError – If parameter ‘after’ is not a statement of this construct.

Return type:

None

See also

MoveStatement()

→ Move a sequential statement to a position of this construct.

MoveStatementBefore()

→ Move a sequential statement before another statement.

MoveStatementBefore(statement, before)

Move a sequential statement before another statement of this construct.

The statement stays a statement of this construct: only the order of the statements changes, as for MoveStatement(). Moving a statement before itself keeps it in place.

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

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

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘before’ is None.

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

  • NotAChildError – If parameter ‘before’ is not a statement of this construct.

Return type:

None

See also

MoveStatement()

→ Move a sequential statement to a position of this construct.

MoveStatementAfter()

→ Move a sequential statement after another statement.

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

See also

Returns:

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

RemoveStatement(statement)

Remove a sequential statement from this construct.

The statement is detached: its parent is cleared. The statement itself is unchanged and can be added to another construct, or inserted at another position; its labels are free again in this construct’s declarative region.

Parameters:

statement (SequentialStatement) – The sequential statement to remove.

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

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

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

Return type:

None

See also

AddStatement()

→ Add a sequential statement at the end of this construct.

InsertStatement()

→ Insert a sequential statement at a position of this construct.

MoveStatement()

→ Move a sequential statement to a position of this construct.

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 Statements: list[SequentialStatement]

Read-only property to access the list of sequential statements (_statements).

Returns:

A list of sequential statements.

Visit(visitor)[source]

Walk this loop and its statements with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

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

Reserved words after end.

_END_KEYWORDS_OPTIONAL: ClassVar[bool] = False

The reserved words after end are optional.

_IterateStatementRegions()

Iterate the declarative regions nested in the sequential statements of this construct.

Return type:

Generator[DeclarativeRegionMixin]

Returns:

An empty generator: a sequential statement has no declarative region.

_LabelRegion()

Return the process or subprogram declaring the labels of this loop’s statements.

It’s the region of the construct holding the loop.

Return type:

ModelEntity | None

Returns:

The process or subprogram, or None if the loop isn’t part of one (yet).

_Labels()

Return the labeled statements of this construct, including the statements nested in compound statements.

Every label of a process or subprogram body is declared in the process’ or subprogram’s declarative region, also a label inside an if branch, a case alternative or a loop.

Return type:

tuple[SequentialStatement, ...]

Returns:

Tuple of labeled statements, depth-first in statement order.

static _LabelsOf(statement)

Return a statement, if it’s labeled, and the labeled statements nested in it.

Parameters:

statement (SequentialStatement) – The sequential statement.

Return type:

tuple[SequentialStatement, ...]

Returns:

Tuple of labeled statements, depth-first in statement order.

_VisitStatements(visitor)

Walk the sequential statements in statement 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

_documentation: str | None

The associated documentation of a model entity.

_label: str | None

The label of a model entity.

_normalizedLabel: str | None

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

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_statements: list[SequentialStatement]

List of all sequential statements in this construct.

class pyGHDL.dom.Sequential.ForLoopStatement(loopNode, loopIndex, rng, statements=None, label=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Sequential.ForLoopStatement.

Represents a for-loop statement.

The loop index is available as LoopIndex, the iteration range as Range and the loop body as Statements.

Example

  lbl : for k in 0 to 3 loop
--^^^                          <- optional Label
--          ^                  <- LoopIndex
--               ^^^^^^        <- Range
    null;
--  ^^^^^                      <- Statements
  end loop;

Inheritance

Inheritance diagram of ForLoopStatement

Parameters:
  • loopNode (Iir)

  • loopIndex (str)

  • rng (Range)

  • statements (Iterable[SequentialStatement])

  • label (str)

__init__(loopNode, loopIndex, rng, statements=None, label=None)[source]

Initializes a for..loop statement.

Parameters:
  • loopNode (Iir) – The IIR node of the loop statement.

  • loopIndex (str) – The name of the loop’s index.

  • rng (Range) – The range the loop iterates over.

  • statements (Iterable[SequentialStatement]) – Optional, list of all sequential statements in this construct.

  • label (str) – Optional, the label of the for..loop statement, or None if it has none.

Return type:

None

classmethod parse(loopNode, label)[source]

Translates the IIR node of the loop statement to a ForLoopStatement.

Parameters:
  • loopNode (Iir) – The IIR node of the loop statement.

  • label (str) – The statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated loop statement.

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

AddStatement(statement)

Add a sequential statement at the end of this construct.

The statement’s parent is set to this construct.

Parameters:

statement (SequentialStatement) – The sequential statement to add.

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

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

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

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

InsertStatement()

→ Insert a sequential statement at a position of this construct.

RemoveStatement()

→ Remove a sequential statement from this construct.

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.

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.

InsertStatement(index, statement)

Insert a sequential statement at a position of this construct.

The statement’s parent is set to this construct.

Every label of a process or subprogram body is declared in the process’ or subprogram’s declarative region: the statement’s label and the labels of statements nested in it (in branches, case alternatives and loops) may neither repeat another label of the body, nor an identifier declared in the region. A construct not in a process or subprogram (yet) checks the labels of its own statements. An unlabeled statement declares nothing.

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

  • statement (SequentialStatement) – The sequential statement 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 ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

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

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

AddStatement()

→ Add a sequential statement at the end of this construct.

InsertStatementBefore()

→ Insert a sequential statement before another statement.

InsertStatementAfter()

→ Insert a sequential statement after another statement.

RemoveStatement()

→ Remove a sequential statement from this construct.

MoveStatement()

→ Move a sequential statement to a position of this construct.

InsertStatementAfter(statement, after)

Insert a sequential statement after another statement of this construct.

The statement’s parent is set to this construct.

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

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

  • AlreadyInDesignError – If parameter ‘statement’ 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 statement of this construct.

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

InsertStatement()

→ Insert a sequential statement at a position of this construct.

InsertStatementBefore()

→ Insert a sequential statement before another statement.

InsertStatementBefore(statement, before)

Insert a sequential statement before another statement of this construct.

The statement’s parent is set to this construct.

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

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

  • AlreadyInDesignError – If parameter ‘statement’ 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 statement of this construct.

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

InsertStatement()

→ Insert a sequential statement at a position of this construct.

InsertStatementAfter()

→ Insert a sequential statement after another statement.

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 Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

property LoopIndex: str

Read-only property to access the loop index (_loopIndex).

Returns:

The loop index.

MoveStatement(statement, index)

Move a sequential statement to a position of this construct.

The statement stays a statement of this construct: only the order of the statements changes.

Parameters:
  • statement (SequentialStatement) – The sequential statement to move.

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

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

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

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • 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

MoveStatementBefore()

→ Move a sequential statement before another statement.

MoveStatementAfter()

→ Move a sequential statement after another statement.

InsertStatement()

→ Insert a sequential statement at a position of this construct.

RemoveStatement()

→ Remove a sequential statement from this construct.

MoveStatementAfter(statement, after)

Move a sequential statement after another statement of this construct.

The statement stays a statement of this construct: only the order of the statements changes, as for MoveStatement(). Moving a statement after itself keeps it in place.

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

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

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘after’ is None.

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

  • NotAChildError – If parameter ‘after’ is not a statement of this construct.

Return type:

None

See also

MoveStatement()

→ Move a sequential statement to a position of this construct.

MoveStatementBefore()

→ Move a sequential statement before another statement.

MoveStatementBefore(statement, before)

Move a sequential statement before another statement of this construct.

The statement stays a statement of this construct: only the order of the statements changes, as for MoveStatement(). Moving a statement before itself keeps it in place.

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

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

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘before’ is None.

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

  • NotAChildError – If parameter ‘before’ is not a statement of this construct.

Return type:

None

See also

MoveStatement()

→ Move a sequential statement to a position of this construct.

MoveStatementAfter()

→ Move a sequential statement after another statement.

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

See also

Returns:

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

RemoveStatement(statement)

Remove a sequential statement from this construct.

The statement is detached: its parent is cleared. The statement itself is unchanged and can be added to another construct, or inserted at another position; its labels are free again in this construct’s declarative region.

Parameters:

statement (SequentialStatement) – The sequential statement to remove.

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

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

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

Return type:

None

See also

AddStatement()

→ Add a sequential statement at the end of this construct.

InsertStatement()

→ Insert a sequential statement at a position of this construct.

MoveStatement()

→ Move a sequential statement to a position of this construct.

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 Statements: list[SequentialStatement]

Read-only property to access the list of sequential statements (_statements).

Returns:

A list of sequential statements.

Visit(visitor)[source]

Walk this for-loop, its range and its statements with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

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

Reserved words after end.

_END_KEYWORDS_OPTIONAL: ClassVar[bool] = False

The reserved words after end are optional.

_IterateStatementRegions()

Iterate the declarative regions nested in the sequential statements of this construct.

Return type:

Generator[DeclarativeRegionMixin]

Returns:

An empty generator: a sequential statement has no declarative region.

_LabelRegion()

Return the process or subprogram declaring the labels of this loop’s statements.

It’s the region of the construct holding the loop.

Return type:

ModelEntity | None

Returns:

The process or subprogram, or None if the loop isn’t part of one (yet).

_Labels()

Return the labeled statements of this construct, including the statements nested in compound statements.

Every label of a process or subprogram body is declared in the process’ or subprogram’s declarative region, also a label inside an if branch, a case alternative or a loop.

Return type:

tuple[SequentialStatement, ...]

Returns:

Tuple of labeled statements, depth-first in statement order.

static _LabelsOf(statement)

Return a statement, if it’s labeled, and the labeled statements nested in it.

Parameters:

statement (SequentialStatement) – The sequential statement.

Return type:

tuple[SequentialStatement, ...]

Returns:

Tuple of labeled statements, depth-first in statement order.

_VisitStatements(visitor)

Walk the sequential statements in statement 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

_documentation: str | None

The associated documentation of a model entity.

_label: str | None

The label of a model entity.

_loopIndex: str

The name of the loop’s index.

_normalizedLabel: str | None

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

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_range: Range

The range the loop iterates over.

_statements: list[SequentialStatement]

List of all sequential statements in this construct.

class pyGHDL.dom.Sequential.WhileLoopStatement(loopNode, condition, statements=None, label=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Sequential.WhileLoopStatement.

Represents a while-loop statement.

The loop condition is available as Condition, the loop body as Statements.

Example

  lbl : while i < 4 loop
--^^^                      <- optional Label
--            ^^^^^        <- Condition
    null;
--  ^^^^^                  <- Statements
  end loop;

Inheritance

Inheritance diagram of WhileLoopStatement

Parameters:
  • loopNode (Iir)

  • condition (ExpressionUnion)

  • statements (Iterable[SequentialStatement])

  • label (str)

__init__(loopNode, condition, statements=None, label=None)[source]

Initializes a while..loop statement.

Parameters:
  • loopNode (Iir) – The IIR node of the loop statement.

  • condition (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – The condition tested before each iteration; the loop ends when it is false.

  • statements (Iterable[SequentialStatement]) – Optional, list of all sequential statements in this construct.

  • label (str) – Optional, the label of the while..loop statement, or None if it has none.

Return type:

None

classmethod parse(loopNode, label)[source]

Translates the IIR node of the loop statement to a WhileLoopStatement.

Parameters:
  • loopNode (Iir) – The IIR node of the loop statement.

  • label (str) – The statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated loop statement.

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

AddStatement(statement)

Add a sequential statement at the end of this construct.

The statement’s parent is set to this construct.

Parameters:

statement (SequentialStatement) – The sequential statement to add.

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

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

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

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

InsertStatement()

→ Insert a sequential statement at a position of this construct.

RemoveStatement()

→ Remove a sequential statement from this construct.

property Condition: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

Read-only property to access the condition of a statement (_condition).

Returns:

The expression representing the condition of a statement.

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.

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.

InsertStatement(index, statement)

Insert a sequential statement at a position of this construct.

The statement’s parent is set to this construct.

Every label of a process or subprogram body is declared in the process’ or subprogram’s declarative region: the statement’s label and the labels of statements nested in it (in branches, case alternatives and loops) may neither repeat another label of the body, nor an identifier declared in the region. A construct not in a process or subprogram (yet) checks the labels of its own statements. An unlabeled statement declares nothing.

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

  • statement (SequentialStatement) – The sequential statement 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 ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

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

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

AddStatement()

→ Add a sequential statement at the end of this construct.

InsertStatementBefore()

→ Insert a sequential statement before another statement.

InsertStatementAfter()

→ Insert a sequential statement after another statement.

RemoveStatement()

→ Remove a sequential statement from this construct.

MoveStatement()

→ Move a sequential statement to a position of this construct.

InsertStatementAfter(statement, after)

Insert a sequential statement after another statement of this construct.

The statement’s parent is set to this construct.

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

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

  • AlreadyInDesignError – If parameter ‘statement’ 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 statement of this construct.

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

InsertStatement()

→ Insert a sequential statement at a position of this construct.

InsertStatementBefore()

→ Insert a sequential statement before another statement.

InsertStatementBefore(statement, before)

Insert a sequential statement before another statement of this construct.

The statement’s parent is set to this construct.

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

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

  • AlreadyInDesignError – If parameter ‘statement’ 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 statement of this construct.

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

InsertStatement()

→ Insert a sequential statement at a position of this construct.

InsertStatementAfter()

→ Insert a sequential statement after another statement.

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 Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

MoveStatement(statement, index)

Move a sequential statement to a position of this construct.

The statement stays a statement of this construct: only the order of the statements changes.

Parameters:
  • statement (SequentialStatement) – The sequential statement to move.

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

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

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

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • 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

MoveStatementBefore()

→ Move a sequential statement before another statement.

MoveStatementAfter()

→ Move a sequential statement after another statement.

InsertStatement()

→ Insert a sequential statement at a position of this construct.

RemoveStatement()

→ Remove a sequential statement from this construct.

MoveStatementAfter(statement, after)

Move a sequential statement after another statement of this construct.

The statement stays a statement of this construct: only the order of the statements changes, as for MoveStatement(). Moving a statement after itself keeps it in place.

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

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

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘after’ is None.

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

  • NotAChildError – If parameter ‘after’ is not a statement of this construct.

Return type:

None

See also

MoveStatement()

→ Move a sequential statement to a position of this construct.

MoveStatementBefore()

→ Move a sequential statement before another statement.

MoveStatementBefore(statement, before)

Move a sequential statement before another statement of this construct.

The statement stays a statement of this construct: only the order of the statements changes, as for MoveStatement(). Moving a statement before itself keeps it in place.

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

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

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘before’ is None.

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

  • NotAChildError – If parameter ‘before’ is not a statement of this construct.

Return type:

None

See also

MoveStatement()

→ Move a sequential statement to a position of this construct.

MoveStatementAfter()

→ Move a sequential statement after another statement.

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

See also

Returns:

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

RemoveStatement(statement)

Remove a sequential statement from this construct.

The statement is detached: its parent is cleared. The statement itself is unchanged and can be added to another construct, or inserted at another position; its labels are free again in this construct’s declarative region.

Parameters:

statement (SequentialStatement) – The sequential statement to remove.

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

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

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

Return type:

None

See also

AddStatement()

→ Add a sequential statement at the end of this construct.

InsertStatement()

→ Insert a sequential statement at a position of this construct.

MoveStatement()

→ Move a sequential statement to a position of this construct.

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 Statements: list[SequentialStatement]

Read-only property to access the list of sequential statements (_statements).

Returns:

A list of sequential statements.

Visit(visitor)[source]

Walk this while-loop, its condition and its statements with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

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

Reserved words after end.

_END_KEYWORDS_OPTIONAL: ClassVar[bool] = False

The reserved words after end are optional.

_IterateStatementRegions()

Iterate the declarative regions nested in the sequential statements of this construct.

Return type:

Generator[DeclarativeRegionMixin]

Returns:

An empty generator: a sequential statement has no declarative region.

_LabelRegion()

Return the process or subprogram declaring the labels of this loop’s statements.

It’s the region of the construct holding the loop.

Return type:

ModelEntity | None

Returns:

The process or subprogram, or None if the loop isn’t part of one (yet).

_Labels()

Return the labeled statements of this construct, including the statements nested in compound statements.

Every label of a process or subprogram body is declared in the process’ or subprogram’s declarative region, also a label inside an if branch, a case alternative or a loop.

Return type:

tuple[SequentialStatement, ...]

Returns:

Tuple of labeled statements, depth-first in statement order.

static _LabelsOf(statement)

Return a statement, if it’s labeled, and the labeled statements nested in it.

Parameters:

statement (SequentialStatement) – The sequential statement.

Return type:

tuple[SequentialStatement, ...]

Returns:

Tuple of labeled statements, depth-first in statement order.

_VisitStatements(visitor)

Walk the sequential statements in statement 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

_condition

The condition guarding this statement.

_documentation

The associated documentation of a model entity.

_label

The label of a model entity.

_normalizedLabel

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

_parent

Reference to a parent entity in the logical model hierarchy.

_statements

List of all sequential statements in this construct.

class pyGHDL.dom.Sequential.SequentialSimpleSignalAssignment(assignmentNode, target, waveform, label=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Sequential.SequentialSimpleSignalAssignment.

Represents a simple sequential signal assignment.

The assignment’s destination is available as Target, its value as Waveform.

Example

  lbl : s <= '1';
--^^^               <- optional Label
--      ^           <- Target
--           ^^^    <- Waveform

Inheritance

Inheritance diagram of SequentialSimpleSignalAssignment

Parameters:
__init__(assignmentNode, target, waveform, label=None)[source]

Initializes a simple sequential signal assignment.

Parameters:
  • assignmentNode (Iir) – The IIR node of the assignment statement.

  • target (SignalSymbol) – Reference to the assignment’s destination.

  • waveform (Iterable[WaveformElement]) – List of all waveform elements, in the order they were written.

  • label (str) – Optional, the label of the sequential signal assignment, or None if it has none.

Return type:

None

classmethod parse(assignmentNode, label=None)[source]

Translates the IIR node of the assignment statement to a SequentialSimpleSignalAssignment.

Parameters:
  • assignmentNode (Iir) – The IIR node of the assignment statement.

  • label (str) – Optional, the statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated assignment statement.

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

classmethod GetMethodsWithAttributes(predicate=None)

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

Parameters:

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

Return type:

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

Returns:

Dictionary of methods and the matching attributes attached to them.

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

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

property IsOverloadable: bool

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

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

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

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

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

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

IterateTypeMarks(region)

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

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

Parameters:

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

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

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

property Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

See also

Returns:

Normalized label 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 Target: SignalSymbol

Read-only property to access the target (_target).

Returns:

The target.

Visit(visitor)[source]

Walk this signal assignment, its target and its waveform with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

property Waveform: list[WaveformElement]

Read-only property to access the waveform (_waveform).

Returns:

List of waveform.

_VisitWaveform(visitor)

Walk the waveform elements, separated by commas, 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

_documentation: str | None

The associated documentation of a model entity.

_label: str | None

The label of a model entity.

_normalizedLabel: str | None

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

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_target: Symbol

Reference to the assignment’s destination.

_waveform: list[WaveformElement]

List of all waveform elements, in the order they were written.

class pyGHDL.dom.Sequential.ConditionalExpression(node, expression, condition=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Common.ConditionalExpression.

Represents one branch of a conditional variable assignment.

Each branch pairs an expression (Expression) with a condition (Condition). The final branch has no when, so its condition is None.

Example

v := '1' when cond else '0';
--   ^^^^^^^^^^^^^             <- this branch: Expression='1', Condition=cond
--                      ^^^    <- final branch (no ``when``): Expression='0', Condition=None

Inheritance

Inheritance diagram of ConditionalExpression

Parameters:
  • node (Iir)

  • expression (ExpressionUnion)

  • condition (ExpressionUnion)

__init__(node, expression, condition=None)[source]

Initializes a conditional expression.

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

  • expression (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – The value assigned when the condition holds.

  • condition (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – Optional, the condition selecting this alternative.

Return type:

None

classmethod parse(node)[source]

Translates an IIR node to a ConditionalExpression.

Parameters:

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

Return type:

Self

Returns:

The translated object.

_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 Condition: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

Read-only property to access the condition of a statement (_condition).

Returns:

The expression representing the condition of a statement.

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 Expression: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

Read-only property to access the expression (_expression).

Returns:

The expression.

GetAncestor(type)

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

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

Parameters:

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

Return type:

ModelEntity

Returns:

The closest ancestor of the requested type.

Raises:

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

classmethod GetMethodsWithAttributes(predicate=None)

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

Parameters:

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

Return type:

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

Returns:

Dictionary of methods and the matching attributes attached to them.

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

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

property IsOverloadable: bool

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

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

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

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

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

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

IterateTypeMarks(region)

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

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

Parameters:

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

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

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

property Parent: ModelEntity

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

Returns:

Reference to the parent entity.

property Position: Position

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

If _position is None, resolve the position object from _iirNode

Returns:

The IIR’s position in the source file.

ResetReferences(designUnit, region)

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

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

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

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

Return type:

None

ResolveReferences(designUnit, region)

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

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

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

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

Raises:

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

Return type:

None

Visit(visitor)[source]

Walk this conditional expression, its value and its condition (if any) with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

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

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

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

__new__(**kwargs)
__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

_condition

The condition guarding this statement.

_expression

The expression held by this construct.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

class pyGHDL.dom.Sequential.SelectedExpression(node, choices, expression)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Common.SelectedExpression.

Represents one alternative of a selected variable assignment.

Each alternative pairs an expression (Expression) with the choices selecting it (Choices).

Example

with sel select v := '1' when '0', '0' when others;
--                   ^^^^^^^^^^^^                     <- this alternative: Choices=['0'], Expression='1'

Inheritance

Inheritance diagram of SelectedExpression

Parameters:
  • node (Iir)

  • choices (Iterable)

  • expression (ExpressionUnion)

__init__(node, choices, expression)[source]

Initializes a selected expression.

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

  • choices (Iterable) – List of all choices selecting this alternative.

  • expression (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – The value assigned for the matching choices.

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 Choices: list[BaseChoice]

Read-only property to access the choices (_choices).

Returns:

List of choices.

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 Expression: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

Read-only property to access the expression (_expression).

Returns:

The expression.

GetAncestor(type)

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

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

Parameters:

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

Return type:

ModelEntity

Returns:

The closest ancestor of the requested type.

Raises:

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

classmethod GetMethodsWithAttributes(predicate=None)

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

Parameters:

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

Return type:

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

Returns:

Dictionary of methods and the matching attributes attached to them.

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

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

property IsOverloadable: bool

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

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

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

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

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

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

IterateTypeMarks(region)

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

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

Parameters:

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

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

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

property Parent: ModelEntity

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

Returns:

Reference to the parent entity.

property Position: Position

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

If _position is None, resolve the position object from _iirNode

Returns:

The IIR’s position in the source file.

ResetReferences(designUnit, region)

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

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

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

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

Return type:

None

ResolveReferences(designUnit, region)

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

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

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

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

Raises:

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

Return type:

None

Visit(visitor)[source]

Walk this selected expression, its value and its choices 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

_choices: list[BaseChoice]

List of all choices selecting this alternative.

_expression: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

The expression held by this construct.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

class pyGHDL.dom.Sequential.OthersSelectedExpression(node, expression)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Common.OthersSelectedExpression.

Represents the others alternative of a selected variable assignment.

It supplies the expression (Expression) for every choice not named explicitly.

Example

with sel select v := '1' when '0', '0' when others;
--                                 ^^^^^^^^^^^^^^^    <- the others alternative

Inheritance

Inheritance diagram of OthersSelectedExpression

Parameters:
  • node (Iir)

  • expression (ExpressionUnion)

__init__(node, expression)[source]

Initializes an others selected expression.

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

  • expression (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – The value assigned for every unnamed choice.

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 Expression: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

Read-only property to access the expression (_expression).

Returns:

The expression.

GetAncestor(type)

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

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

Parameters:

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

Return type:

ModelEntity

Returns:

The closest ancestor of the requested type.

Raises:

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

classmethod GetMethodsWithAttributes(predicate=None)

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

Parameters:

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

Return type:

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

Returns:

Dictionary of methods and the matching attributes attached to them.

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

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

property IsOverloadable: bool

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

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

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

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

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

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

IterateTypeMarks(region)

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

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

Parameters:

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

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

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

property Parent: ModelEntity

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

Returns:

Reference to the parent entity.

property Position: Position

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

If _position is None, resolve the position object from _iirNode

Returns:

The IIR’s position in the source file.

ResetReferences(designUnit, region)

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

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

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

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

Return type:

None

ResolveReferences(designUnit, region)

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

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

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

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

Raises:

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

Return type:

None

Visit(visitor)[source]

Walk this others selected expression and its value with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

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

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

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

__new__(**kwargs)
__setstate__(state)

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

Parameters:

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

Raises:

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

Return type:

None

_expression: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

The expression held by this construct.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

class pyGHDL.dom.Sequential.SequentialVariableAssignment(assignmentNode, target, expression, label=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Sequential.SequentialVariableAssignment.

Represents a simple sequential variable assignment.

The assignment’s destination is available as Target, its value as Expression.

Example

  lbl : v := '1';
--^^^               <- optional Label
--      ^           <- Target
--           ^^^    <- Expression

Inheritance

Inheritance diagram of SequentialVariableAssignment

Parameters:
__init__(assignmentNode, target, expression, label=None)[source]

Initializes a simple sequential variable assignment.

Parameters:
  • assignmentNode (Iir) – The IIR node of the assignment statement.

  • target (VariableSymbol) – Reference to the assignment’s destination.

  • expression (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – The assigned expression.

  • label (str) – Optional, the label of the variable assignment, or None if it has none.

Return type:

None

classmethod parse(assignmentNode, label=None)[source]

Translates the IIR node of the assignment statement to a SequentialVariableAssignment.

Parameters:
  • assignmentNode (Iir) – The IIR node of the assignment statement.

  • label (str) – Optional, the statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated assignment statement.

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

property Expression: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

Read-only property to access the expression (_expression).

Returns:

The expression.

GetAncestor(type)

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

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

Parameters:

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

Return type:

ModelEntity

Returns:

The closest ancestor of the requested type.

Raises:

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

classmethod GetMethodsWithAttributes(predicate=None)

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

Parameters:

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

Return type:

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

Returns:

Dictionary of methods and the matching attributes attached to them.

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

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

property IsOverloadable: bool

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

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

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

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

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

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

IterateTypeMarks(region)

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

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

Parameters:

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

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

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

property Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

See also

Returns:

Normalized label 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 Target: VariableSymbol

Read-only property to access the target (_target).

Returns:

The target.

Visit(visitor)[source]

Walk this variable assignment, its target and its expression 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

_documentation: str | None

The associated documentation of a model entity.

_expression: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

The assigned expression.

_label: str | None

The label of a model entity.

_normalizedLabel: str | None

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

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_target: Symbol

Reference to the assignment’s destination.

class pyGHDL.dom.Sequential.SequentialConditionalVariableAssignment(assignmentNode, target, conditionalExpressions, label=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Sequential.SequentialConditionalVariableAssignment.

Represents a conditional sequential variable assignment.

The alternatives are available as ConditionalExpressions, a list of ConditionalExpression. The model holds them in a list and has no distinct field per alternative, so the markers below name list elements.

Example

  lbl : v := '1' when sel = '0' else '0';
--^^^                                       <- optional Label
--      ^                                   <- Target
--           ^^^^^^^^^^^^^^^^^^             <- ConditionalExpressions[0]
--                                   ^^^    <- ConditionalExpressions[1]

Inheritance

Inheritance diagram of SequentialConditionalVariableAssignment

Parameters:
__init__(assignmentNode, target, conditionalExpressions, label=None)[source]

Initializes a conditional sequential variable assignment.

Parameters:
  • assignmentNode (Iir) – The IIR node of the assignment statement.

  • target (VariableSymbol) – Reference to the assignment’s destination.

  • conditionalExpressions (Iterable[ConditionalExpression]) – List of all alternatives, in the order they were written.

  • label (str) – Optional, the label of the conditional variable assignment, or None if it has none.

Return type:

None

classmethod parse(assignmentNode, label=None)[source]

Translates the IIR node of the assignment statement to a SequentialConditionalVariableAssignment.

Parameters:
  • assignmentNode (Iir) – The IIR node of the assignment statement.

  • label (str) – Optional, the statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated assignment statement.

_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 ConditionalExpressions: list[ConditionalExpression]

Read-only property to access the conditional expressions (_conditionalExpressions).

Returns:

List of conditional expressions.

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.

classmethod GetMethodsWithAttributes(predicate=None)

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

Parameters:

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

Return type:

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

Returns:

Dictionary of methods and the matching attributes attached to them.

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

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

property IsOverloadable: bool

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

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

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

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

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

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

IterateTypeMarks(region)

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

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

Parameters:

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

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

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

property Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

See also

Returns:

Normalized label 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 Target: Symbol

Read-only property to access the target (_target).

Returns:

The target.

Visit(visitor)[source]

Walk this conditional variable assignment, its target and its alternatives 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

_conditionalExpressions: list[ConditionalExpression]

List of all alternatives, in the order they were written.

_documentation: str | None

The associated documentation of a model entity.

_label: str | None

The label of a model entity.

_normalizedLabel: str | None

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

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_target: Symbol

Reference to the assignment’s destination.

class pyGHDL.dom.Sequential.SequentialConditionalSignalAssignment(assignmentNode, target, conditionalWaveforms, label=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Sequential.SequentialConditionalSignalAssignment.

Represents a conditional sequential signal assignment.

The alternatives are available as ConditionalWaveforms, a list of ConditionalWaveform. The model holds them in a list and has no distinct field per alternative, so the markers below name list elements.

Example

  lbl : s <= '1' when sel = '0' else '0';
--^^^                                       <- optional Label
--      ^                                   <- Target
--           ^^^^^^^^^^^^^^^^^^             <- ConditionalWaveforms[0]
--                                   ^^^    <- ConditionalWaveforms[1]

Inheritance

Inheritance diagram of SequentialConditionalSignalAssignment

Parameters:
__init__(assignmentNode, target, conditionalWaveforms, label=None)[source]

Initializes a conditional sequential signal assignment.

Parameters:
  • assignmentNode (Iir) – The IIR node of the assignment statement.

  • target (SignalSymbol) – Reference to the assignment’s destination.

  • conditionalWaveforms (Iterable) – All alternatives, in order.

  • label (str) – Optional, the label of the conditional sequential signal assignment, or None if it has none.

Return type:

None

classmethod parse(assignmentNode, label=None)[source]

Translates the IIR node of the assignment statement to a SequentialConditionalSignalAssignment.

Parameters:
  • assignmentNode (Iir) – The IIR node of the assignment statement.

  • label (str) – Optional, the statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated assignment statement.

_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 ConditionalWaveforms: list[ConditionalWaveform]

Read-only property to access the conditional waveforms (_conditionalWaveforms).

Returns:

List of conditional waveforms.

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.

classmethod GetMethodsWithAttributes(predicate=None)

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

Parameters:

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

Return type:

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

Returns:

Dictionary of methods and the matching attributes attached to them.

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

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

property IsOverloadable: bool

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

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

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

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

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

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

IterateTypeMarks(region)

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

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

Parameters:

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

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

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

property Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

See also

Returns:

Normalized label 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 Target: SignalSymbol

Read-only property to access the target (_target).

Returns:

The target.

Visit(visitor)[source]

Walk this conditional signal assignment, its target and its alternatives with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_VisitConditionalWaveforms(visitor)

Walk the conditional waveforms, separated by the reserved word else, 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

_conditionalWaveforms: list[ConditionalWaveform]

All alternatives, in order.

_documentation: str | None

The associated documentation of a model entity.

_label: str | None

The label of a model entity.

_normalizedLabel: str | None

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

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_target: Symbol

Reference to the assignment’s destination.

class pyGHDL.dom.Sequential.SequentialSelectedVariableAssignment(assignmentNode, target, expression, selectedExpressions, label=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Sequential.SequentialSelectedVariableAssignment.

Represents a selected sequential variable assignment.

The selector is available as Expression, the alternatives as SelectedExpressions, a list of SelectedExpression. The model holds them in a list and has no distinct field per alternative, so the markers below name list elements.

Example

  lbl : with sel select v := '1' when '0', '0' when others;
--^^^                                                         <- optional Label
--           ^^^                                              <- Expression
--                      ^                                     <- Target
--                           ^^^^^^^^^^^^                     <- SelectedExpressions[0]
--                                         ^^^^^^^^^^^^^^^    <- SelectedExpressions[1]

Inheritance

Inheritance diagram of SequentialSelectedVariableAssignment

Parameters:
  • assignmentNode (Iir)

  • target (VariableSymbol)

  • expression (ExpressionUnion)

  • selectedExpressions (Iterable)

  • label (str)

__init__(assignmentNode, target, expression, selectedExpressions, label=None)[source]

Initializes a selected sequential variable assignment.

Parameters:
  • assignmentNode (Iir) – The IIR node of the assignment statement.

  • target (VariableSymbol) – Reference to the assignment’s destination.

  • expression (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – The selector expression.

  • selectedExpressions (Iterable) – All alternatives, in order.

  • label (str) – Optional, the label of the selected variable assignment, or None if it has none.

Return type:

None

classmethod parse(assignmentNode, label=None)[source]

Translates the IIR node of the assignment statement to a SequentialSelectedVariableAssignment.

Parameters:
  • assignmentNode (Iir) – The IIR node of the assignment statement.

  • label (str) – Optional, the statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated assignment statement.

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

property Expression: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

Read-only property to access the expression (_expression).

Returns:

The expression.

GetAncestor(type)

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

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

Parameters:

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

Return type:

ModelEntity

Returns:

The closest ancestor of the requested type.

Raises:

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

classmethod GetMethodsWithAttributes(predicate=None)

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

Parameters:

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

Return type:

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

Returns:

Dictionary of methods and the matching attributes attached to them.

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

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

property IsOverloadable: bool

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

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

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

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

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

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

IterateTypeMarks(region)

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

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

Parameters:

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

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

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

property Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

See also

Returns:

Normalized label 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 SelectedExpressions: list[SelectedExpression | OthersSelectedExpression]

Read-only property to access the selected expressions (_selectedExpressions).

Returns:

List of selected expressions.

property Target: Symbol

Read-only property to access the target (_target).

Returns:

The target.

Visit(visitor)[source]

Walk this selected variable assignment, its selector, its target and its alternatives with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_VisitSelectedExpressions(visitor)

Walk the selected expressions, separated by commas, 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

_documentation: str | None

The associated documentation of a model entity.

_expression: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

The expression held by this construct.

_label: str | None

The label of a model entity.

_normalizedLabel: str | None

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

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_selectedExpressions: list[SelectedExpression | OthersSelectedExpression]

All alternatives, in order.

_target: Symbol

Reference to the assignment’s destination.

class pyGHDL.dom.Sequential.SequentialSelectedSignalAssignment(assignmentNode, target, expression, selectedWaveforms, label=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Sequential.SequentialSelectedSignalAssignment.

Represents a selected sequential signal assignment.

The selector is available as Expression, the alternatives as SelectedWaveforms, a list of SelectedWaveform. The model holds them in a list and has no distinct field per alternative, so the markers below name list elements.

Example

  lbl : with sel select s <= '1' when '0', '0' when others;
--^^^                                                         <- optional Label
--           ^^^                                              <- Expression
--                      ^                                     <- Target
--                           ^^^^^^^^^^^^                     <- SelectedWaveforms[0]
--                                         ^^^^^^^^^^^^^^^    <- SelectedWaveforms[1]

Inheritance

Inheritance diagram of SequentialSelectedSignalAssignment

Parameters:
  • assignmentNode (Iir)

  • target (SignalSymbol)

  • expression (ExpressionUnion)

  • selectedWaveforms (Iterable)

  • label (str)

__init__(assignmentNode, target, expression, selectedWaveforms, label=None)[source]

Initializes a selected sequential signal assignment.

Parameters:
  • assignmentNode (Iir) – The IIR node of the assignment statement.

  • target (SignalSymbol) – Reference to the assignment’s destination.

  • expression (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – The selector expression.

  • selectedWaveforms (Iterable) – All alternatives, in order.

  • label (str) – Optional, the label of the selected sequential signal assignment, or None if it has none.

Return type:

None

classmethod parse(assignmentNode, label=None)[source]

Translates the IIR node of the assignment statement to a SequentialSelectedSignalAssignment.

Parameters:
  • assignmentNode (Iir) – The IIR node of the assignment statement.

  • label (str) – Optional, the statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated assignment statement.

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

property Expression: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

Read-only property to access the expression (_expression).

Returns:

The expression.

GetAncestor(type)

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

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

Parameters:

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

Return type:

ModelEntity

Returns:

The closest ancestor of the requested type.

Raises:

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

classmethod GetMethodsWithAttributes(predicate=None)

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

Parameters:

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

Return type:

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

Returns:

Dictionary of methods and the matching attributes attached to them.

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

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

property IsOverloadable: bool

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

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

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

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

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

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

IterateTypeMarks(region)

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

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

Parameters:

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

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

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

property Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

See also

Returns:

Normalized label 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 SelectedWaveforms: list[SelectedWaveform | OthersSelectedWaveform]

Read-only property to access the selected waveforms (_selectedWaveforms).

Returns:

List of selected waveforms.

property Target: SignalSymbol

Read-only property to access the target (_target).

Returns:

The target.

Visit(visitor)[source]

Walk this selected signal assignment, its selector, its target and its alternatives with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_VisitSelectedWaveforms(visitor)

Walk the selected waveforms, separated by commas, 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

_documentation: str | None

The associated documentation of a model entity.

_expression: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

The expression held by this construct.

_label: str | None

The label of a model entity.

_normalizedLabel: str | None

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

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_selectedWaveforms: list[SelectedWaveform | OthersSelectedWaveform]

All alternatives, in order.

_target: Symbol

Reference to the assignment’s destination.

class pyGHDL.dom.Sequential.SignalForceAssignment(assignmentNode, target, expression, label=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Sequential.SignalForceAssignment.

Represents a signal force assignment.

A force assignment overrides a signal’s driver until it is released.

Example

  lbl : s <= force '1';
--^^^                     <- optional Label
--      ^                 <- Target
--                 ^^^    <- Expression

Inheritance

Inheritance diagram of SignalForceAssignment

Parameters:
__init__(assignmentNode, target, expression, label=None)[source]

Initializes a signal force assignment.

Parameters:
  • assignmentNode (Iir) – The IIR node of the assignment statement.

  • target (SignalSymbol) – Reference to the assignment’s destination.

  • expression (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – The value forced onto the signal.

  • label (str) – Optional, the label of the signal force assignment, or None if it has none.

Return type:

None

classmethod parse(assignmentNode, label=None)[source]

Translates the IIR node of the assignment statement to a SignalForceAssignment.

Parameters:
  • assignmentNode (Iir) – The IIR node of the assignment statement.

  • label (str) – Optional, the statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated assignment statement.

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

property Expression: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

Read-only property to access the expression (_expression).

Returns:

The expression.

GetAncestor(type)

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

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

Parameters:

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

Return type:

ModelEntity

Returns:

The closest ancestor of the requested type.

Raises:

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

classmethod GetMethodsWithAttributes(predicate=None)

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

Parameters:

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

Return type:

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

Returns:

Dictionary of methods and the matching attributes attached to them.

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

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

property IsOverloadable: bool

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

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

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

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

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

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

IterateTypeMarks(region)

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

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

Parameters:

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

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

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

property Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

See also

Returns:

Normalized label 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 Target: SignalSymbol

Read-only property to access the target (_target).

Returns:

The target.

Visit(visitor)[source]

Walk this force assignment, its target and its expression 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

_documentation: str | None

The associated documentation of a model entity.

_expression: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

The expression held by this construct.

_label: str | None

The label of a model entity.

_normalizedLabel: str | None

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

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_target: Symbol

Reference to the assignment’s destination.

class pyGHDL.dom.Sequential.SignalReleaseAssignment(assignmentNode, target, label=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Sequential.SignalReleaseAssignment.

Represents a signal release assignment.

A release assignment ends a previously applied force.

Example

  lbl : s <= release;
--^^^                   <- optional Label
--      ^               <- Target

Inheritance

Inheritance diagram of SignalReleaseAssignment

Parameters:
__init__(assignmentNode, target, label=None)[source]

Initializes a signal release assignment.

Parameters:
  • assignmentNode (Iir) – The IIR node of the assignment statement.

  • target (SignalSymbol) – Reference to the assignment’s destination.

  • label (str) – Optional, the label of the signal release assignment, or None if it has none.

Return type:

None

classmethod parse(assignmentNode, label=None)[source]

Translates the IIR node of the assignment statement to a SignalReleaseAssignment.

Parameters:
  • assignmentNode (Iir) – The IIR node of the assignment statement.

  • label (str) – Optional, the statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated assignment statement.

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

classmethod GetMethodsWithAttributes(predicate=None)

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

Parameters:

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

Return type:

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

Returns:

Dictionary of methods and the matching attributes attached to them.

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

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

property IsOverloadable: bool

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

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

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

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

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

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

IterateTypeMarks(region)

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

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

Parameters:

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

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

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

property Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

See also

Returns:

Normalized label 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 Target: SignalSymbol

Read-only property to access the target (_target).

Returns:

The target.

Visit(visitor)[source]

Walk this release assignment and its target 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

_documentation: str | None

The associated documentation of a model entity.

_label: str | None

The label of a model entity.

_normalizedLabel: str | None

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

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_target: Symbol

Reference to the assignment’s destination.

class pyGHDL.dom.Sequential.SequentialProcedureCall(callNode, procedureName, parameterAssociationItems, label=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Sequential.SequentialProcedureCall.

Represents a procedure call as a sequential statement.

Like every sequential statement, it can carry an optional label (Label).

Example

  lbl : log("hello");
--^^^                   <- optional Label
--      ^^^^^^^^^^^^    <- the call

Inheritance

Inheritance diagram of SequentialProcedureCall

Parameters:
__init__(callNode, procedureName, parameterAssociationItems, label=None)[source]

Initializes a procedure call as a sequential statement.

Parameters:
  • callNode (Iir) – The IIR node of the subprogram call.

  • procedureName (Symbol) – Reference to the called procedure.

  • parameterAssociationItems (Iterable[ParameterAssociationItem]) – List of all parameter associations of the call.

  • label (str) – Optional, the label of the procedure call, or None if it has none.

Return type:

None

classmethod parse(callNode, label)[source]

Translates the IIR node of the procedure call to a SequentialProcedureCall.

Parameters:
  • callNode (Iir) – The IIR node of the procedure call.

  • label (str) – The statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated procedure call.

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

AddParameterAssociationItem(parameterAssociationItem)

Add a parameter association at the end of the parameter association list.

The association’s parent is set to this procedure call.

Parameters:

parameterAssociationItem (ParameterAssociationItem) – The parameter association to add.

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

  • TypeError – If parameter ‘parameterAssociationItem’ is not of type ParameterAssociationItem.

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

  • DuplicateParameterAssociationError – If the association is named, and another named association of the parameter association list has the same formal.

  • AssociationOrderError – If the association is positional, and the parameter association list has a named association.

Return type:

None

See also

InsertParameterAssociationItem()

→ Insert a parameter association at a position of the parameter association list.

RemoveParameterAssociationItem()

→ Remove a parameter association from the parameter association list.

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.

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.

InsertParameterAssociationItem(index, parameterAssociationItem)

Insert a parameter association at a position of the parameter association list.

The association’s parent is set to this procedure call.

A named association (formal => actual) can’t repeat the formal of another named association of the parameter association list. Only formals given as a simple name are compared: a partial association (a(0) => x) or a conversion function (to_integer(a) => x) is accepted. All positional associations precede the named associations.

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

  • parameterAssociationItem (ParameterAssociationItem) – The parameter association 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 ‘parameterAssociationItem’ is None.

  • TypeError – If parameter ‘parameterAssociationItem’ is not of type ParameterAssociationItem.

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

  • DuplicateParameterAssociationError – If the association is named, and another named association of the parameter association list has the same formal.

  • AssociationOrderError – If the association is positional, and a named association precedes the position.

  • AssociationOrderError – If the association is named, and a positional association follows the position.

Return type:

None

See also

AddParameterAssociationItem()

→ Add a parameter association at the end of the parameter association list.

RemoveParameterAssociationItem()

→ Remove a parameter association from the parameter association list.

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 Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

See also

Returns:

Normalized label of a model entity.

property ParameterAssociationItems: list[ParameterAssociationItem]

Read-only property to access the parameter association items (_parameterAssociationItems).

Returns:

List of parameter association items.

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

Read-only property to access the procedure (_procedure).

Returns:

The procedure.

RemoveParameterAssociationItem(parameterAssociationItem)

Remove a parameter association from the parameter association list.

The association is detached: its parent is cleared. The association itself is unchanged and can be added to another procedure call, or inserted at another position.

Parameters:

parameterAssociationItem (ParameterAssociationItem) – The parameter association to remove.

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

  • TypeError – If parameter ‘parameterAssociationItem’ is not of type ParameterAssociationItem.

  • NotAChildError – If parameter ‘parameterAssociationItem’ is not a parameter association of this procedure call.

Return type:

None

See also

AddParameterAssociationItem()

→ Add a parameter association at the end of the parameter association list.

InsertParameterAssociationItem()

→ Insert a parameter association at a position of the parameter association list.

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 procedure call, its procedure and its parameters with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_VisitProcedureCall(visitor)

Walk the called procedure and the actual parameter part, if there are parameters, 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

_documentation: str | None

The associated documentation of a model entity.

_label: str | None

The label of a model entity.

_normalizedLabel: str | None

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

_parameterAssociationItems: list[ParameterAssociationItem]

List of all parameter associations of the call.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_procedure: Symbol

Reference to the called procedure.

class pyGHDL.dom.Sequential.SequentialAssertStatement(assertNode, condition, message=None, severity=None, label=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Sequential.SequentialAssertStatement.

Represents a sequential assertion statement.

The checked condition is available as Condition, the optional report string as Message and the optional severity as Severity.

Example

  lbl : assert sel = '0' report "bad" severity error;
--^^^                                                   <- optional Label
--             ^^^^^^^^^                                <- Condition
--                              ^^^^^                   <- optional Message
--                                             ^^^^^    <- optional Severity

Inheritance

Inheritance diagram of SequentialAssertStatement

Parameters:
  • assertNode (Iir)

  • condition (ExpressionUnion)

  • message (ExpressionUnion)

  • severity (ExpressionUnion)

  • label (str)

__init__(assertNode, condition, message=None, severity=None, label=None)[source]

Initializes a sequential assertion statement.

Parameters:
  • assertNode (Iir) – The IIR node of the assertion.

  • condition (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – The condition that must hold; the report is issued when it is false.

  • message (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – Optional, the reported message, or None if none was given.

  • severity (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – Optional, the reported severity level, or None if none was given.

  • label (str) – Optional, the label of the assertion statement, or None if it has none.

Return type:

None

classmethod parse(assertNode, label)[source]

Translates the IIR node of the assertion to a SequentialAssertStatement.

Parameters:
  • assertNode (Iir) – The IIR node of the assertion.

  • label (str) – The statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated assertion.

_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 Condition: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

Read-only property to access the condition of a statement (_condition).

Returns:

The expression representing the condition of a statement.

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.

classmethod GetMethodsWithAttributes(predicate=None)

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

Parameters:

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

Return type:

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

Returns:

Dictionary of methods and the matching attributes attached to them.

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

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

property IsOverloadable: bool

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

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

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

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

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

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

IterateTypeMarks(region)

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

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

Parameters:

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

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

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

property Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

property Message: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal | None

Read-only property to access the message (_message).

Returns:

The message, or None if not set.

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

See also

Returns:

Normalized label 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 Severity: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal | None

Read-only property to access the severity (_severity).

Returns:

The severity, or None if not set.

Visit(visitor)[source]

Walk this assertion, its condition, its message and its severity with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_VisitAssertion(visitor)

Walk the condition, the message and the severity of an assertion with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_VisitReportAndSeverity(visitor)

Walk the message and the severity, if given, each after its reserved word, 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

_condition

The condition guarding this statement.

_documentation

The associated documentation of a model entity.

_label

The label of a model entity.

_message

The reported message, or None if none was given.

_normalizedLabel

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

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_severity

The reported severity level, or None if none was given.

class pyGHDL.dom.Sequential.SequentialReportStatement(reportNode, message, severity=None, label=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Sequential.SequentialReportStatement.

Represents a sequential report statement.

The report string is available as Message, the optional severity as Severity.

Example

  lbl : report "message" severity note;
--^^^                                     <- optional Label
--             ^^^^^^^^^                  <- Message
--                                ^^^^    <- optional Severity

Inheritance

Inheritance diagram of SequentialReportStatement

Parameters:
  • reportNode (Iir)

  • message (ExpressionUnion)

  • severity (ExpressionUnion)

  • label (str)

__init__(reportNode, message, severity=None, label=None)[source]

Initializes a sequential report statement.

Parameters:
  • reportNode (Iir) – The IIR node of the report statement.

  • message (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – The reported message, or None if none was given.

  • severity (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – Optional, the reported severity level, or None if none was given.

  • label (str) – Optional, the label of the report statement, or None if it has none.

Return type:

None

classmethod parse(reportNode, label)[source]

Translates the IIR node of the report statement to a SequentialReportStatement.

Parameters:
  • reportNode (Iir) – The IIR node of the report statement.

  • label (str) – The statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated report statement.

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

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.

classmethod GetMethodsWithAttributes(predicate=None)

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

Parameters:

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

Return type:

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

Returns:

Dictionary of methods and the matching attributes attached to them.

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

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

property IsOverloadable: bool

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

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

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

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

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

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

IterateTypeMarks(region)

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

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

Parameters:

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

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

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

property Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

property Message: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal | None

Read-only property to access the message (_message).

Returns:

The message, or None if not set.

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

See also

Returns:

Normalized label 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 Severity: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal | None

Read-only property to access the severity (_severity).

Returns:

The severity, or None if not set.

Visit(visitor)[source]

Walk this report statement, its message and its severity with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_VisitReportAndSeverity(visitor)

Walk the message and the severity, if given, each after its reserved word, 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

_documentation

The associated documentation of a model entity.

_label

The label of a model entity.

_message

The reported message, or None if none was given.

_normalizedLabel

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

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_severity

The reported severity level, or None if none was given.

class pyGHDL.dom.Sequential.ReturnStatement(returnNode, returnValue=None, label=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Sequential.ReturnStatement.

Represents a return statement.

The optionally returned value is available as ReturnValue; a procedure returns nothing.

Example

  lbl : return x;
--^^^               <- optional Label
--             ^    <- optional ReturnValue

Inheritance

Inheritance diagram of ReturnStatement

Parameters:
  • returnNode (Iir)

  • returnValue (ExpressionUnion)

  • label (str)

__init__(returnNode, returnValue=None, label=None)[source]

Initializes a return statement.

Parameters:
  • returnNode (Iir) – The IIR node of the return statement.

  • returnValue (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – Optional, the returned expression, or None for a procedure.

  • label (str) – Optional, the label of the return statement, or None if it has none.

Return type:

None

classmethod parse(returnNode, label)[source]

Translates the IIR node of the return statement to a ReturnStatement.

Parameters:
  • returnNode (Iir) – The IIR node of the return statement.

  • label (str) – The statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated return statement.

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

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.

classmethod GetMethodsWithAttributes(predicate=None)

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

Parameters:

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

Return type:

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

Returns:

Dictionary of methods and the matching attributes attached to them.

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

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

property IsOverloadable: bool

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

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

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

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

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

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

IterateTypeMarks(region)

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

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

Parameters:

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

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

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

property Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

See also

Returns:

Normalized label 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 ReturnValue: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal | None

Read-only property to access the return value (_returnValue).

Returns:

The return value, or None if not set.

Visit(visitor)[source]

Walk this return statement and its value (if any) with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

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

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

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

__new__(**kwargs)
__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

_documentation

The associated documentation of a model entity.

_label

The label of a model entity.

_normalizedLabel

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

_parent

Reference to a parent entity in the logical model hierarchy.

_returnValue: Nullable[ExpressionUnion]

The returned expression, or None for a procedure.

class pyGHDL.dom.Sequential.NullStatement(waitNode, label=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Sequential.NullStatement.

Represents a null statement.

A null statement does nothing. Like every sequential statement, it can carry an optional label (Label).

Example

  lbl : null;
--^^^           <- optional Label
--      ^^^^    <- the statement

Inheritance

Inheritance diagram of NullStatement

Parameters:
__init__(waitNode, label=None)[source]

Initializes a null statement.

Parameters:
  • waitNode (Iir) – The IIR node of the wait statement.

  • label (str) – Optional, the label of the null statement, or None if it has none.

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.

classmethod GetMethodsWithAttributes(predicate=None)

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

Parameters:

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

Return type:

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

Returns:

Dictionary of methods and the matching attributes attached to them.

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

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

property IsOverloadable: bool

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

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

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

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

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

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

IterateTypeMarks(region)

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

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

Parameters:

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

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

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

property Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

See also

Returns:

Normalized label 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 null statement 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

_documentation: str | None

The associated documentation of a model entity.

_label: str | None

The label of a model entity.

_normalizedLabel: str | None

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

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

class pyGHDL.dom.Sequential.NextStatement(node, condition=None, loopLabel=None, label=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Sequential.NextStatement.

Represents a next statement.

A next statement skips to the next iteration of the named loop (LoopReference), optionally only when a condition (Condition) holds.

Example

  lbl : next outer when k = 1;
--^^^                            <- optional Label
--           ^^^^^               <- optional LoopReference
--                      ^^^^^    <- optional Condition

Inheritance

Inheritance diagram of NextStatement

Parameters:
__init__(node, condition=None, loopLabel=None, label=None)[source]

Initializes a next statement.

Parameters:
  • node (Iir) – The IIR node of the next statement.

  • condition (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – Optional, the condition under which the iteration is skipped, or None if unconditional.

  • loopLabel (LoopSymbol) – Optional, the label of the loop this statement applies to, or None for the enclosing loop.

  • label (str) – Optional, the statement’s own label.

Return type:

None

classmethod parse(exitNode, label)[source]

Translates the IIR node of the exit statement to a NextStatement.

Parameters:
  • exitNode (Iir) – The IIR node of the exit statement.

  • label (str) – The statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated exit statement.

_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 Condition: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

Read-only property to access the condition of a statement (_condition).

Returns:

The expression representing the condition of a statement.

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.

classmethod GetMethodsWithAttributes(predicate=None)

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

Parameters:

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

Return type:

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

Returns:

Dictionary of methods and the matching attributes attached to them.

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

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

property IsOverloadable: bool

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

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

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

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

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

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

IterateTypeMarks(region)

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

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

Parameters:

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

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

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

property Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

property LoopReference: LoopSymbol | None

Read-only property to access the reference to the controlled loop (_loopReference).

Returns:

The reference to the controlled loop, or None if not set (the innermost loop).

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

See also

Returns:

Normalized label 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 next statement, its loop label (if any) and its condition (if any) with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

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

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

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

__new__(**kwargs)
__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

_condition

The condition guarding this statement.

_documentation

The associated documentation of a model entity.

_label

The label of a model entity.

_loopReference: Nullable[LoopSymbol]

Reference to the controlled loop, or None for the innermost loop.

_normalizedLabel

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

_parent

Reference to a parent entity in the logical model hierarchy.

class pyGHDL.dom.Sequential.ExitStatement(node, condition=None, loopLabel=None, label=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Sequential.ExitStatement.

Represents an exit statement.

An exit statement leaves the named loop (LoopReference), optionally only when a condition (Condition) holds.

Example

  lbl : exit outer when k = 1;
--^^^                            <- optional Label
--           ^^^^^               <- optional LoopReference
--                      ^^^^^    <- optional Condition

Inheritance

Inheritance diagram of ExitStatement

Parameters:
__init__(node, condition=None, loopLabel=None, label=None)[source]

Initializes an exit statement.

Parameters:
  • node (Iir) – The IIR node of the exit statement.

  • condition (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – Optional, the condition under which the loop is left, or None if unconditional.

  • loopLabel (LoopSymbol) – Optional, the label of the loop this statement applies to, or None for the enclosing loop.

  • label (str) – Optional, the statement’s own label.

Return type:

None

classmethod parse(exitNode, label)[source]

Translates the IIR node of the exit statement to an ExitStatement.

Parameters:
  • exitNode (Iir) – The IIR node of the exit statement.

  • label (str) – The statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated exit statement.

_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 Condition: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

Read-only property to access the condition of a statement (_condition).

Returns:

The expression representing the condition of a statement.

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.

classmethod GetMethodsWithAttributes(predicate=None)

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

Parameters:

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

Return type:

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

Returns:

Dictionary of methods and the matching attributes attached to them.

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

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

property IsOverloadable: bool

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

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

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

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

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

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

IterateTypeMarks(region)

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

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

Parameters:

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

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

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

property Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

property LoopReference: LoopSymbol | None

Read-only property to access the reference to the controlled loop (_loopReference).

Returns:

The reference to the controlled loop, or None if not set (the innermost loop).

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

See also

Returns:

Normalized label 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 exit statement, its loop label (if any) and its condition (if any) with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

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

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

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

__new__(**kwargs)
__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

_condition

The condition guarding this statement.

_documentation

The associated documentation of a model entity.

_label

The label of a model entity.

_loopReference: Nullable[LoopSymbol]

Reference to the controlled loop, or None for the innermost loop.

_normalizedLabel

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

_parent

Reference to a parent entity in the logical model hierarchy.

class pyGHDL.dom.Sequential.WaitStatement(waitNode, sensitivityList=None, condition=None, timeout=None, label=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Sequential.WaitStatement.

Represents a wait statement.

A wait statement may name a sensitivity list (SensitivityList), a condition (Condition) and a timeout (Timeout); all three are optional.

Example

  lbl : wait until clock = '1' for 10 ns;
--^^^                                       <- optional Label
--                 ^^^^^^^^^^^              <- optional Condition
--                                 ^^^^^    <- optional Timeout

Inheritance

Inheritance diagram of WaitStatement

Parameters:
  • waitNode (Iir)

  • sensitivityList (Iterable[Symbol])

  • condition (ExpressionUnion)

  • timeout (ExpressionUnion)

  • label (str)

__init__(waitNode, sensitivityList=None, condition=None, timeout=None, label=None)[source]

Initializes a wait statement.

Parameters:
  • waitNode (Iir) – The IIR node of the wait statement.

  • sensitivityList (Iterable[Symbol]) – Optional, list of all signal names of the on clause, or None if none was given.

  • condition (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – Optional, the condition of the until clause, or None if none was given.

  • timeout (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – Optional, the timeout expression of the for clause, or None if none was given.

  • label (str) – Optional, the label of the wait statement, or None if it has none.

Return type:

None

classmethod parse(waitNode, label)[source]

Translates the IIR node of the wait statement to a WaitStatement.

Parameters:
  • waitNode (Iir) – The IIR node of the wait statement.

  • label (str) – The statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated wait statement.

_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 Condition: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

Read-only property to access the condition of a statement (_condition).

Returns:

The expression representing the condition of a statement.

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.

classmethod GetMethodsWithAttributes(predicate=None)

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

Parameters:

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

Return type:

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

Returns:

Dictionary of methods and the matching attributes attached to them.

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

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

property IsOverloadable: bool

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

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

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

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

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

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

IterateTypeMarks(region)

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

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

Parameters:

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

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

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

property Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

See also

Returns:

Normalized label 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 SensitivityList: list[Symbol]

Read-only property to access the sensitivity list (_sensitivityList).

Returns:

List of sensitivity list.

property Timeout: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

Read-only property to access the timeout (_timeout).

Returns:

The timeout.

Visit(visitor)[source]

Walk this wait statement, its sensitivity clause, its condition clause and its timeout clause 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

_condition

The condition guarding this statement.

_documentation

The associated documentation of a model entity.

_label

The label of a model entity.

_normalizedLabel

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

_parent

Reference to a parent entity in the logical model hierarchy.

_sensitivityList: Nullable[list[Symbol]]

List of all signal names to wait on, or None if none was given.

_timeout: ExpressionUnion

The timeout expression, or None if none was given.