diff --git a/doc/LanguageModel/DesignUnits.rst b/doc/LanguageModel/DesignUnits.rst index e9ab04d13..fba6298ce 100644 --- a/doc/LanguageModel/DesignUnits.rst +++ b/doc/LanguageModel/DesignUnits.rst @@ -80,7 +80,7 @@ types). An entity's list of statements is called body items. # inherited from MixinDesignUnitWithContext @property - def LibraryReferences(self) -> List[LibraryStatement]: + def LibraryReferences(self) -> List[LibraryClause]: @property def PackageReferences(self) -> List[UseClause]: @@ -128,7 +128,7 @@ Package # inherited from MixinDesignUnitWithContext @property - def LibraryReferences(self) -> List[LibraryStatement]: + def LibraryReferences(self) -> List[LibraryClause]: @property def PackageReferences(self) -> List[UseClause]: @@ -175,7 +175,7 @@ Architeture # inherited from MixinDesignUnitWithContext @property - def LibraryReferences(self) -> List[LibraryStatement]: + def LibraryReferences(self) -> List[LibraryClause]: @property def PackageReferences(self) -> List[UseClause]: @@ -220,7 +220,7 @@ Package Body # inherited from MixinDesignUnitWithContext @property - def LibraryReferences(self) -> List[LibraryStatement]: + def LibraryReferences(self) -> List[LibraryClause]: @property def PackageReferences(self) -> List[UseClause]: diff --git a/doc/LanguageModel/Miscellaneous.rst b/doc/LanguageModel/Miscellaneous.rst index 25764c60d..4bb24d728 100644 --- a/doc/LanguageModel/Miscellaneous.rst +++ b/doc/LanguageModel/Miscellaneous.rst @@ -36,7 +36,7 @@ a design has the two child nodes: ``Libraries`` and ``Documents``. Each is a # from Design @property - def Libraries(self) -> List[LibraryStatement]: + def Libraries(self) -> List[LibraryClause]: @property def Documents(self) -> List[Document]: @@ -45,24 +45,24 @@ a design has the two child nodes: ``Libraries`` and ``Documents``. Each is a .. _vhdlmodel-library: -LibraryStatement -================ +LibraryClause +============= A library contains multiple *design units*. Each design unit listed in a library is a *primary* design unit like: ``configuration``, ``entity``, ``package`` or ``context``. -**Condensed definition of class** :class:`~pyVHDLModel.VHDLModel.LibraryStatement`: +**Condensed definition of class** :class:`~pyVHDLModel.VHDLModel.LibraryClause`: .. code-block:: Python @export - class LibraryStatement(ModelEntity): + class LibraryClause(ModelEntity): # inherited from ModelEntity @property def Parent(self) -> ModelEntity: - # from LibraryStatement + # from LibraryClause @property def Contexts(self) -> List[Context]: diff --git a/doc/conf.py b/doc/conf.py index b084b32d8..e4d467e4e 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -37,7 +37,7 @@ def _LatestTagName(): # The full version, including alpha/beta/rc tags version = "0.11" # The short X.Y version. -release = "0.11.3" # The full version, including alpha/beta/rc tags. +release = "0.11.4" # The full version, including alpha/beta/rc tags. try: if _IsUnderGitControl: latestTagName = _LatestTagName()[1:] # remove prefix "v" diff --git a/pyVHDLModel/SyntaxModel.py b/pyVHDLModel/SyntaxModel.py index 21a8b3df1..3568a3ec5 100644 --- a/pyVHDLModel/SyntaxModel.py +++ b/pyVHDLModel/SyntaxModel.py @@ -42,7 +42,7 @@ """ # load dependencies from pathlib import Path -from typing import List, Tuple, Union, Dict, Iterator, Optional, Any, Iterable +from typing import List, Tuple, Union, Dict, Iterator, Optional, Any, Iterable from pydecor.decorators import export @@ -93,6 +93,11 @@ class Protocol: 'Literal', ] +Context = Union[ + 'LibraryClause' + 'UseClause' + 'ContextReference' +] @export class Name: @@ -106,8 +111,12 @@ class Name: def __init__(self, identifier: str, prefix: 'Name' = None): self._identifier = identifier - self._prefix = prefix - self._root = prefix._root + if prefix is None: + self._prefix = self + self._root = None + else: + self._prefix = prefix + self._root = prefix._root @property def Identifier(self) -> str: @@ -128,25 +137,8 @@ def Has_Prefix(self) -> bool: @export class SimpleName(Name): - def __init__(self, identifier: str): - self._name = identifier - self._root = self - self._prefix = None - - @property - def Root(self) -> 'Name': - return self - - @property - def Prefix(self) -> Nullable['Name']: - return None - - @property - def Has_Prefix(self) -> bool: - return False - def __str__(self): - return self._name + return self._identifier @export @@ -203,7 +195,16 @@ def __init__(self, prefix: Name): super().__init__("all", prefix) def __str__(self): - return "all" + return str(self._prefix) + "." + "all" + + +@export +class OpenName(Name): + def __init__(self): + super().__init__("open") + + def __str__(self): + return "open" @export @@ -1985,80 +1986,34 @@ def __init__(self, identifiers: Iterable[str], subtype: SubtypeOrSymbol): super().__init__(identifiers, subtype) ParameterInterfaceItem.__init__(self) -# class GenericItem(ModelEntity): -# def __init__(self): -# super().__init__() -# self._name = None -# self._subtype = None -# self._init = None -# -# -# class PortItem(ModelEntity): -# def __init__(self): -# super().__init__() -# self._name = None -# self._subtype = None -# self._init = None -# self._mode = None -# self._class = None - @export class Reference(ModelEntity): - pass + _names: List[Name] - -@export -class LibraryStatement(Reference): - _library: Union[None, LibraryOrSymbol] - - def __init__(self): + def __init__(self, names: Iterable[Name]): super().__init__() - self._library = None - @property - def Library(self) -> Union[None, LibraryOrSymbol]: - return self._library - - -@export -class UseClause(Reference): - _library: Union[None, LibraryOrSymbol] - _package: 'Package' - _item: str - - def __init__(self, name: Name): - super().__init__() - self._item = str(name) # FIXME: should the name be splitted? + self._names = [n for n in names] @property - def Library(self) -> Union[None, LibraryOrSymbol]: - return self._library + def Names(self) -> List[Name]: + return self._names - @property - def Package(self) -> 'Package': - return self._package - @property - def Item(self) -> str: - return self._item +@export +class LibraryClause(Reference): + pass @export -class ContextStatement(Reference): - _library: Union[None, LibraryOrSymbol] - _context: 'Context' - - def __init__(self): - super().__init__() +class UseClause(Reference): + pass - @property - def Library(self) -> Union[None, LibraryOrSymbol]: - return self._library - @property - def Context(self) -> 'Context': - return self._context +@export +class ContextReference(Reference): + pass @export @@ -2066,7 +2021,7 @@ class MixinDesignUnitWithContext: """ A ``DesignUnitWithReferences`` is a base-class for all design units with contexts. """ - _libraryReferences: List[LibraryStatement] + _libraryReferences: List[LibraryClause] _packageReferences: List[UseClause] _contextReferences: List['Context'] @@ -2076,7 +2031,7 @@ def __init__(self): self._contextReferences = [] @property - def LibraryReferences(self) -> List[LibraryStatement]: + def LibraryReferences(self) -> List[LibraryClause]: return self._libraryReferences @property @@ -2090,17 +2045,17 @@ def ContextReferences(self) -> List['Context']: @export class Context(PrimaryUnit): - _libraryReferences: List[LibraryStatement] + _libraryReferences: List[LibraryClause] _packageReferences: List[UseClause] - def __init__(self, identifier): + def __init__(self, identifier: str, libraryReferences: Iterable[LibraryClause] = None, packageReferences: Iterable[UseClause] = None): super().__init__(identifier) - self._libraryReferences = [] - self._packageReferences = [] + self._libraryReferences = [] if libraryReferences is None else [l for l in libraryReferences] + self._packageReferences = [] if packageReferences is None else [p for p in packageReferences] @property - def LibraryReferences(self) -> List[LibraryStatement]: + def LibraryReferences(self) -> List[LibraryClause]: return self._libraryReferences @property @@ -2119,6 +2074,7 @@ class Entity(PrimaryUnit, MixinDesignUnitWithContext): def __init__( self, identifier: str, + contextItems: Iterable[Context] = None, genericItems: Iterable[GenericInterfaceItem] = None, portItems: Iterable[PortInterfaceItem] = None, declaredItems: Iterable = None, @@ -2161,7 +2117,7 @@ class Architecture(SecondaryUnit, MixinDesignUnitWithContext): _declaredItems: List # FIXME: define list prefix type e.g. via Union _statements: List['ConcurrentStatement'] - def __init__(self, identifier: str, entity: Name, declaredItems: Iterable = None, statements: Iterable['ConcurrentStatement'] = None): + def __init__(self, identifier: str, entity: Name, contextItems: Iterable[Context] = None, declaredItems: Iterable = None, statements: Iterable['ConcurrentStatement'] = None): super().__init__(identifier) MixinDesignUnitWithContext.__init__(self) @@ -2212,27 +2168,36 @@ def PortItems(self) -> List[PortInterfaceItem]: @export class Configuration(PrimaryUnit, MixinDesignUnitWithContext): - def __init__(self, identifier: str): + def __init__(self, identifier: str, contextItems: Iterable[Context] = None): super().__init__(identifier) MixinDesignUnitWithContext.__init__(self) @export class AssociationItem(ModelEntity): - _formal: str # FIXME: defined type + _formal: Name _actual: Expression - def __init__(self): + def __init__(self, actual: Expression, formal: Name = None): super().__init__() + self._formal = formal + self._actual = actual + @property - def Formal(self): # FIXME: defined return type + def Formal(self) -> Name: return self._formal @property def Actual(self) -> Expression: return self._actual + def __str__(self): + if self._formal is None: + return str(self._actual) + else: + return "{formal!s} => {actual!s}".format(formal=self._formal, actual=self._actual) + @export class GenericAssociationItem(AssociationItem): @@ -2278,8 +2243,8 @@ class Package(PrimaryUnit, MixinDesignUnitWithContext): _genericItems: List[GenericInterfaceItem] _declaredItems: List - def __init__(self, identifier: str, genericItems: Iterable[GenericInterfaceItem] = None, declaredItems: Iterable = None): - super().__init__(identifier) + def __init__(self, identifier: str, contextItems: Iterable[Context] = None,genericItems: Iterable[GenericInterfaceItem] = None, declaredItems: Iterable = None): + super().__init__(identifier, contextItems) MixinDesignUnitWithContext.__init__(self) self._genericItems = [] if genericItems is None else [g for g in genericItems] @@ -2299,8 +2264,8 @@ class PackageBody(SecondaryUnit, MixinDesignUnitWithContext): _package: Package _declaredItems: List - def __init__(self, identifier: str, declaredItems: Iterable = None): - super().__init__(identifier) + def __init__(self, identifier: str, contextItems: Iterable[Context] = None, declaredItems: Iterable = None): + super().__init__(identifier, contextItems) MixinDesignUnitWithContext.__init__(self) self._declaredItems = [] if declaredItems is None else [i for i in declaredItems] @@ -2396,7 +2361,7 @@ def DeclaredItems(self) -> List: class SequentialStatements: _statements: List[SequentialStatement] - def __init__(self, statements: Iterable[SequentialStatement]): + def __init__(self, statements: Iterable[SequentialStatement] = None): self._statements = [] if statements is None else [s for s in statements] @property @@ -2406,60 +2371,67 @@ def Statements(self) -> List[SequentialStatement]: @export class Instantiation(ConcurrentStatement): - pass + _genericAssociations: List[AssociationItem] + _portAssociations: List[AssociationItem] + + def __init__(self, label: str, genericAssociations: Iterable[AssociationItem] = None, portAssociations: Iterable[AssociationItem] = None): + super().__init__(label) + + self._genericAssociations = [] if genericAssociations is None else [g for g in genericAssociations] + self._portAssociations = [] if portAssociations is None else [p for p in portAssociations] @export class ComponentInstantiation(Instantiation): - _component: Component + _component: Name - def __init__(self, label: str, componentName: Name): - super().__init__(label) + def __init__(self, label: str, componentName: Name, genericAssociations: Iterable[AssociationItem] = None, portAssociations: Iterable[AssociationItem] = None): + super().__init__(label, genericAssociations, portAssociations) self._component = componentName @property - def Component(self) -> Component: + def Component(self) -> Name: return self._component @export class EntityInstantiation(Instantiation): - _entity: Entity - _architecture: Architecture + _entity: Name + _architecture: Name - def __init__(self, label: str, entityName: Name, architectureName: Name = None): - super().__init__(label) + def __init__(self, label: str, entityName: Name, architectureName: Name = None, genericAssociations: Iterable[AssociationItem] = None, portAssociations: Iterable[AssociationItem] = None): + super().__init__(label, genericAssociations, portAssociations) self._entity = entityName self._architecture = architectureName @property - def Entity(self) -> Entity: + def Entity(self) -> Name: return self._entity @property - def Architecture(self) -> Entity: + def Architecture(self) -> Name: return self._architecture @export class ConfigurationInstantiation(Instantiation): - _configuration: Configuration + _configuration: Name - def __init__(self, label: str, configurationName: Name): - super().__init__(label) + def __init__(self, label: str, configurationName: Name, genericAssociations: Iterable[AssociationItem] = None, portAssociations: Iterable[AssociationItem] = None): + super().__init__(label, genericAssociations, portAssociations) self._configuration = configurationName @property - def Configuration(self) -> Entity: + def Configuration(self) -> Name: return self._configuration @export class ProcessStatement(ConcurrentStatement, SequentialDeclarations, SequentialStatements): - _sensitivityList: List[Signal] = None + _sensitivityList: List[Name] = None def __init__(self, label: str = None, declaredItems: Iterable = None, statements: Iterable[SequentialStatement] = None, sensitivityList: Iterable[Name] = None): super().__init__(label) @@ -2470,38 +2442,38 @@ def __init__(self, label: str = None, declaredItems: Iterable = None, statements self._sensitivityList = [s for s in sensitivityList] @property - def SensitivityList(self) -> List[Signal]: + def SensitivityList(self) -> List[Name]: return self._sensitivityList @export class ProcedureCall: _procedure: Name - _parameterMappings: List + _parameterMappings: List[ParameterAssociationItem] - def __init__(self, procedureName: Name, parameterMappings: Iterable = None): + def __init__(self, procedureName: Name, parameterMappings: Iterable[ParameterAssociationItem] = None): self._procedure = procedureName - self._parameterMappings = [] if procedureName is None else [m for m in parameterMappings] + self._parameterMappings = [] if parameterMappings is None else [m for m in parameterMappings] @property def Procedure(self) -> Name: return self._procedure @property - def ParameterMappings(self) -> List: + def ParameterMappings(self) -> List[ParameterAssociationItem]: return self._parameterMappings @export class ConcurrentProcedureCall(ConcurrentStatement, ProcedureCall): - def __init__(self, label: str, procedureName: Name, parameterMappings: Iterable = None): + def __init__(self, label: str, procedureName: Name, parameterMappings: Iterable[ParameterAssociationItem] = None): super().__init__(label) ProcedureCall.__init__(self, procedureName, parameterMappings) @export class SequentialProcedureCall(SequentialStatement, ProcedureCall): - def __init__(self, label: str, procedureName: Name, parameterMappings: Iterable = None): + def __init__(self, label: str, procedureName: Name, parameterMappings: Iterable[ParameterAssociationItem] = None): super().__init__(label) ProcedureCall.__init__(self, procedureName, parameterMappings) @@ -2552,7 +2524,7 @@ class MixinConditional: """ _condition: Expression - def __init__(self, condition: Expression): + def __init__(self, condition: Expression = None): self._condition = condition @property @@ -2684,19 +2656,27 @@ class Choice(ModelEntity): class ConcurrentChoice(Choice): """ A ``ConcurrentChoice`` is a base-class for all concurrent choices - (in for...generate statements). + (in case...generate statements). """ @export -class Case(ModelEntity): +class SequentialChoice(Choice): + """ + A ``SequentialChoice`` is a base-class for all sequential choices + (in case statements). + """ + + +@export +class BaseCase(ModelEntity): """ A ``Case`` is a base-class for all cases. """ @export -class ConcurrentCase(Case, LabeledEntity, ConcurrentDeclarations, ConcurrentStatements): +class ConcurrentCase(BaseCase, LabeledEntity, ConcurrentDeclarations, ConcurrentStatements): def __init__(self, declaredItems: Iterable = None, statements: Iterable[ConcurrentStatement] = None, alternativeLabel: str = None): super().__init__() LabeledEntity.__init__(self, alternativeLabel) @@ -2704,6 +2684,19 @@ def __init__(self, declaredItems: Iterable = None, statements: Iterable[Concurre ConcurrentStatements.__init__(self, statements) +@export +class SequentialCase(BaseCase, SequentialStatements): + _choices: List + + def __init__(self, statements: Iterable[SequentialStatement] = None): + super().__init__() + SequentialStatements.__init__(self, statements) + + @property + def Choises(self) -> List[Choice]: + return self._choices + + @export class GenerateCase(ConcurrentCase): _choices: List[ConcurrentChoice] @@ -2727,19 +2720,6 @@ def __str__(self) -> str: return "when others =>" -@export -class SequentialCase(Case, SequentialStatements): - _choices: List - - def __init__(self): - super().__init__() - SequentialStatements.__init__(self) - - @property - def Choises(self) -> List[Choice]: - return self._choices - - @export class IndexedGenerateChoice(ConcurrentChoice): _expression: Expression @@ -2779,7 +2759,7 @@ class CaseGenerateStatement(GenerateStatement): _expression: Expression _cases: List[GenerateCase] - def __init__(self, label: str, expression: Expression, cases: Iterable[GenerateCase]): + def __init__(self, label: str, expression: Expression, cases: Iterable[ConcurrentCase]): super().__init__(label) self._expression = expression @@ -2844,6 +2824,16 @@ class VariableAssignment(Assignment): """ An ``VariableAssignment`` is a base-class for all variable assignment statements. """ + _expression: Expression + + def __init__(self, target: Name, expression: Expression): + super().__init__(target) + + self._expression = expression + + @property + def Expression(self) -> Expression: + return self._expression @export @@ -2891,28 +2881,42 @@ def Waveform(self) -> List[WaveformElement]: class ConcurrentSelectedSignalAssignment(ConcurrentSignalAssignment): def __init__(self, label: str, target: Name, expression: Expression): super().__init__(label, target) - expression + @export class ConcurrentConditionalSignalAssignment(ConcurrentSignalAssignment): def __init__(self, label: str, target: Name, expression: Expression): super().__init__(label, target) - expression + @export class SequentialSignalAssignment(SequentialStatement, SignalAssignment): - def __init__(self, target: Name, expression: Expression, label: str = None): - super().__init__() - SignalAssignment.__init__(self, target, expression) + def __init__(self, target: Name, label: str = None): + super().__init__(label) + SignalAssignment.__init__(self, target) + + +@export +class SequentialSimpleSignalAssignment(SequentialSignalAssignment): + _waveform: List[WaveformElement] + + def __init__(self, target: Name, waveform: Iterable[WaveformElement], label: str = None): + super().__init__(target, label) + + self._waveform = [e for e in waveform] + + @property + def Waveform(self) -> List[WaveformElement]: + return self._waveform @export class SequentialVariableAssignment(SequentialStatement, VariableAssignment): - def __init__(self): - super().__init__() - VariableAssignment.__init__(self) + def __init__(self, target: Name, expression: Expression, label: str = None): + super().__init__(label) + VariableAssignment.__init__(self, target, expression) @export @@ -2923,8 +2927,9 @@ class MixinReportStatement: _message: Expression _severity: Expression - def __init__(self): - pass + def __init__(self, message: Expression = None, severity: Expression = None): + self._message = message + self._severity = severity @property def Message(self) -> Expression: @@ -2942,8 +2947,10 @@ class MixinAssertStatement(MixinReportStatement): """ _condition: Expression - def __init__(self): - super().__init__() + def __init__(self, condition: Expression, message: Expression = None, severity: Expression = None): + super().__init__(message, severity) + + self._condition = condition @property def Condition(self) -> Expression: @@ -2952,54 +2959,54 @@ def Condition(self) -> Expression: @export class ConcurrentAssertStatement(ConcurrentStatement, MixinAssertStatement): - def __init__(self, label: str = None): + def __init__(self, condition: Expression, message: Expression, severity: Expression = None, label: str = None): super().__init__(label) - MixinAssertStatement.__init__(self) + MixinAssertStatement.__init__(self, condition, message, severity) @export class SequentialReportStatement(SequentialStatement, MixinReportStatement): - def __init__(self): - super().__init__() - MixinReportStatement.__init__(self) + def __init__(self, message: Expression, severity: Expression = None, label: str = None): + super().__init__(label) + MixinReportStatement.__init__(self, message, severity) @export class SequentialAssertStatement(SequentialStatement, MixinAssertStatement): - def __init__(self): - super().__init__() - MixinAssertStatement.__init__(self) + def __init__(self, condition: Expression, message: Expression = None, severity: Expression = None, label: str = None): + super().__init__(label) + MixinAssertStatement.__init__(self, condition, message, severity) @export class Branch(ModelEntity, SequentialStatements): """ - A ``Branch`` is a base-class for all branches. + A ``Branch`` is a base-class for all branches in a if statement. """ - def __init__(self): + def __init__(self, statements: Iterable[ConcurrentStatement] = None): super().__init__() - SequentialStatements.__init__(self) + SequentialStatements.__init__(self, statements) @export class IfBranch(Branch, MixinIfBranch): - def __init__(self): - super().__init__() - MixinIfBranch.__init__(self) + def __init__(self, condition: Expression, statements: Iterable[ConcurrentStatement] = None): + super().__init__(statements) + MixinIfBranch.__init__(self, condition) @export class ElsifBranch(Branch, MixinElsifBranch): - def __init__(self): - super().__init__() - MixinElsifBranch.__init__(self) + def __init__(self, condition: Expression, statements: Iterable[ConcurrentStatement] = None): + super().__init__(statements) + MixinElsifBranch.__init__(self, condition) @export class ElseBranch(Branch, MixinElseBranch): - def __init__(self): - super().__init__() + def __init__(self, statements: Iterable[ConcurrentStatement] = None): + super().__init__(statements) MixinElseBranch.__init__(self) @@ -3009,9 +3016,6 @@ class CompoundStatement(SequentialStatement): A ``CompoundStatement`` is a base-class for all compound statements. """ - def __init__(self): - super().__init__() - @export class IfStatement(CompoundStatement): @@ -3019,10 +3023,12 @@ class IfStatement(CompoundStatement): _elsifBranches: List['ElsifBranch'] _elseBranch: ElseBranch - def __init__(self): - super().__init__() + def __init__(self, ifBranch: IfBranch, elsifBranches: Iterable[ElsifBranch] = None, elseBranch: ElseBranch = None, label: str = None): + super().__init__(label) - self._elsifBranches = [] + self._ifBranch = ifBranch + self._elsifBranches = [] if elsifBranches is None else [b for b in elsifBranches] + self._elseBranch = elseBranch @property def IfBranch(self) -> IfBranch: @@ -3037,14 +3043,77 @@ def ElseBranch(self) -> ElseBranch: return self._elseBranch +@export +class Case(SequentialCase): + _choices: List[SequentialChoice] + + def __init__(self, choices: Iterable[SequentialChoice], statements: Iterable[SequentialStatement] = None): + super().__init__(statements) + + self._choices = [c for c in choices] + + @property + def Choises(self) -> List[SequentialChoice]: + return self._choices + + def __str__(self) -> str: + return "when {choices} =>".format(choices=" | ".join([str(c) for c in self._choices])) + + +@export +class OthersCase(SequentialCase): + def __str__(self) -> str: + return "when others =>" + + +@export +class IndexedChoice(SequentialChoice): + _expression: Expression + + def __init__(self, expression: Expression): + super().__init__() + + self._expression = expression + + @property + def Expression(self) -> Expression: + return self._expression + + def __str__(self) -> str: + return "{expression!s}".format(expression=self._expression) + + +@export +class RangedChoice(SequentialChoice): + _range: 'Range' + + def __init__(self, rng: 'Range'): + super().__init__() + + self._range = rng + + @property + def Range(self) -> 'Range': + return self._range + + def __str__(self) -> str: + return "{range!s}".format(range=self._range) + + @export class CaseStatement(CompoundStatement): - _selectExpression: Expression - _cases: List[SequentialCase] + _expression: Expression + _cases: List[SequentialCase] + + def __init__(self, expression: Expression, cases: Iterable[SequentialCase], label: str = None): + super().__init__(label) + + self._expression = expression + self._cases = [] if cases is None else [c for c in cases] @property def SelectExpression(self) -> Expression: - return self._selectExpression + return self._expression @property def Cases(self) -> List[SequentialCase]: @@ -3057,9 +3126,9 @@ class LoopStatement(CompoundStatement, SequentialStatements): A ``LoopStatement`` is a base-class for all loop statements. """ - def __init__(self): - super().__init__() - SequentialStatements.__init__(self) + def __init__(self, statements: Iterable[ConcurrentStatement] = None, label: str = None): + super().__init__(label) + SequentialStatements.__init__(self, statements) @export @@ -3069,14 +3138,17 @@ class EndlessLoopStatement(LoopStatement): @export class ForLoopStatement(LoopStatement): - _loopIndex: Constant + _loopIndex: str _range: Range - def __init__(self): - super().__init__() + def __init__(self, loopIndex: str, range: Range, statements: Iterable[ConcurrentStatement] = None, label: str = None): + super().__init__(label, statements) + + self._loopIndex = loopIndex + self._range = range @property - def LoopIndex(self) -> Constant: + def LoopIndex(self) -> str: return self._loopIndex @property @@ -3086,9 +3158,9 @@ def Range(self) -> Range: @export class WhileLoopStatement(LoopStatement, MixinConditional): - def __init__(self): - super().__init__() - MixinConditional.__init__(self) + def __init__(self, condition: Expression, statements: Iterable[ConcurrentStatement] = None, label: str = None): + super().__init__(label, statements) + MixinConditional.__init__(self, condition) @export @@ -3098,9 +3170,9 @@ class LoopControlStatement(SequentialStatement, MixinConditional): """ _loopReference: LoopStatement - def __init__(self): + def __init__(self, condition: Expression = None, loopLabel: str = None): # TODO: is this label (currently str) a Name or a Label class? super().__init__() - MixinConditional.__init__(self) + MixinConditional.__init__(self, condition) @property def LoopReference(self) -> LoopStatement: @@ -3119,15 +3191,22 @@ class ExitStatement(LoopControlStatement): @export class WaitStatement(SequentialStatement, MixinConditional): - _sensitivityList: List[Signal] + _sensitivityList: List[Name] _timeout: Expression - def __init__(self): - super().__init__() - MixinConditional.__init__(self) + def __init__(self, sensitivityList: Iterable[Name] = None, condition: Expression = None, timeout: Expression = None, label: str = None): + super().__init__(label) + MixinConditional.__init__(self, condition) + + if sensitivityList is None: + self._sensitivityList = None + else: + self._sensitivityList = [i for i in sensitivityList] + + self._timeout = timeout @property - def SensitivityList(self) -> List[Signal]: + def SensitivityList(self) -> List[Name]: return self._sensitivityList @property @@ -3139,9 +3218,9 @@ def Timeout(self) -> Expression: class ReturnStatement(SequentialStatement, MixinConditional): _returnValue: Expression - def __init__(self): + def __init__(self, returnValue: Expression = None): super().__init__() - MixinConditional.__init__(self) + MixinConditional.__init__(self, returnValue) @property def ReturnValue(self) -> Expression: diff --git a/pyVHDLModel/__init__.py b/pyVHDLModel/__init__.py index b4f88e5b5..89976d30f 100644 --- a/pyVHDLModel/__init__.py +++ b/pyVHDLModel/__init__.py @@ -40,13 +40,13 @@ :copyright: Copyright 2007-2021 Patrick Lehmann - Bötzingen, Germany :license: Apache License, Version 2.0 """ -from enum import IntEnum, unique, Enum -from typing import List +from enum import IntEnum, unique, Enum +from typing import List, Iterable -from pydecor import export +from pydecor import export -__version__ = "0.11.3" +__version__ = "0.11.4" @export @@ -262,11 +262,18 @@ class DesignUnit(ModelEntity, NamedEntity): """ A ``DesignUnit`` is a base-class for all design units. """ + _contextItems: List['Context'] - def __init__(self, identifier: str): + def __init__(self, identifier: str, contextItems: Iterable['Context'] = None): super().__init__() NamedEntity.__init__(self, identifier) + self._contextItems = [] if contextItems is None else [c for c in contextItems] + + @property + def ContextItems(self) -> List['Context']: + return self._contextItems + @export class PrimaryUnit(DesignUnit): diff --git a/setup.py b/setup.py index 2951a1ea0..e74b69c1e 100644 --- a/setup.py +++ b/setup.py @@ -53,7 +53,7 @@ # Assemble all package information setuptools_setup( name=projectName, - version="0.11.3", + version="0.11.4", author="Patrick Lehmann", author_email="Paebbels@gmail.com",