38
38
39
39
from pyTooling .Decorators import export
40
40
41
- from pyVHDLModel .Base import ModelEntity , LabeledEntityMixin , DocumentedEntityMixin , ExpressionUnion , Range , BaseChoice , BaseCase , IfBranchMixin , \
42
- ElsifBranchMixin , ElseBranchMixin , AssertStatementMixin , BlockStatementMixin , WaveformElement
43
- from pyVHDLModel .Namespace import Namespace
41
+ from pyVHDLModel .Base import ModelEntity , LabeledEntityMixin , DocumentedEntityMixin , ExpressionUnion , Range , BaseChoice , BaseCase , IfBranchMixin
42
+ from pyVHDLModel .Base import ElsifBranchMixin , ElseBranchMixin , AssertStatementMixin , BlockStatementMixin , WaveformElement
43
+ from pyVHDLModel .Regions import ConcurrentDeclarationRegionMixin
44
+ from pyVHDLModel .Namespace import Namespace
44
45
from pyVHDLModel .Symbol import ComponentInstantiationSymbol , EntityInstantiationSymbol , ArchitectureSymbol , ConfigurationInstantiationSymbol
45
46
from pyVHDLModel .Association import AssociationItem , ParameterAssociationItem
46
47
from pyVHDLModel .Interface import PortInterfaceItem
@@ -90,26 +91,16 @@ def IterateInstantiations(self) -> Generator['Instantiation', None, None]:
90
91
yield from generate .IterateInstantiations ()
91
92
92
93
# TODO: move into _init__
93
- def Index (self ):
94
+ def IndexStatements (self ):
94
95
for statement in self ._statements :
95
- if isinstance (statement , EntityInstantiation ):
96
+ if isinstance (statement , ( EntityInstantiation , ComponentInstantiation , ConfigurationInstantiation ) ):
96
97
self ._instantiations [statement .NormalizedLabel ] = statement
97
- elif isinstance (statement , ComponentInstantiation ):
98
- self ._instantiations [statement .NormalizedLabel ] = statement
99
- elif isinstance (statement , ConfigurationInstantiation ):
100
- self ._instantiations [statement .NormalizedLabel ] = statement
101
- elif isinstance (statement , ForGenerateStatement ):
102
- self ._generates [statement .NormalizedLabel ] = statement
103
- statement .Index ()
104
- elif isinstance (statement , IfGenerateStatement ):
105
- self ._generates [statement .NormalizedLabel ] = statement
106
- statement .Index ()
107
- elif isinstance (statement , CaseGenerateStatement ):
98
+ elif isinstance (statement , (ForGenerateStatement , IfGenerateStatement , CaseGenerateStatement )):
108
99
self ._generates [statement .NormalizedLabel ] = statement
109
- statement .Index ()
100
+ statement .IndexStatement ()
110
101
elif isinstance (statement , ConcurrentBlockStatement ):
111
102
self ._hierarchy [statement .NormalizedLabel ] = statement
112
- statement .Index ()
103
+ statement .IndexStatements ()
113
104
114
105
115
106
@export
@@ -234,26 +225,8 @@ def __init__(self, label: str, procedureName: 'Name', parameterMappings: Iterabl
234
225
ProcedureCall .__init__ (self , procedureName , parameterMappings )
235
226
236
227
237
- # FIXME: Why not used in package, package body
238
- @export
239
- class ConcurrentDeclarations :
240
- _declaredItems : List # FIXME: define list prefix type e.g. via Union
241
-
242
- def __init__ (self , declaredItems : Iterable = None ):
243
- # TODO: extract to mixin
244
- self ._declaredItems = [] # TODO: convert to dict
245
- if declaredItems is not None :
246
- for item in declaredItems :
247
- self ._declaredItems .append (item )
248
- item ._parent = self
249
-
250
- @property
251
- def DeclaredItems (self ) -> List :
252
- return self ._declaredItems
253
-
254
-
255
228
@export
256
- class ConcurrentBlockStatement (ConcurrentStatement , BlockStatementMixin , LabeledEntityMixin , ConcurrentDeclarations , ConcurrentStatements , DocumentedEntityMixin ):
229
+ class ConcurrentBlockStatement (ConcurrentStatement , BlockStatementMixin , LabeledEntityMixin , ConcurrentDeclarationRegionMixin , ConcurrentStatements , DocumentedEntityMixin ):
257
230
_portItems : List [PortInterfaceItem ]
258
231
259
232
def __init__ (
@@ -267,7 +240,7 @@ def __init__(
267
240
super ().__init__ (label )
268
241
BlockStatementMixin .__init__ (self )
269
242
LabeledEntityMixin .__init__ (self , label )
270
- ConcurrentDeclarations .__init__ (self , declaredItems )
243
+ ConcurrentDeclarationRegionMixin .__init__ (self , declaredItems )
271
244
ConcurrentStatements .__init__ (self , statements )
272
245
DocumentedEntityMixin .__init__ (self , documentation )
273
246
@@ -284,7 +257,7 @@ def PortItems(self) -> List[PortInterfaceItem]:
284
257
285
258
286
259
@export
287
- class GenerateBranch (ModelEntity , ConcurrentDeclarations , ConcurrentStatements ):
260
+ class GenerateBranch (ModelEntity , ConcurrentDeclarationRegionMixin , ConcurrentStatements ):
288
261
"""A ``GenerateBranch`` is a base-class for all branches in a generate statements."""
289
262
290
263
_alternativeLabel : Nullable [str ]
@@ -294,7 +267,7 @@ class GenerateBranch(ModelEntity, ConcurrentDeclarations, ConcurrentStatements):
294
267
295
268
def __init__ (self , declaredItems : Iterable = None , statements : Iterable [ConcurrentStatement ] = None , alternativeLabel : str = None ):
296
269
super ().__init__ ()
297
- ConcurrentDeclarations .__init__ (self , declaredItems )
270
+ ConcurrentDeclarationRegionMixin .__init__ (self , declaredItems )
298
271
ConcurrentStatements .__init__ (self , statements )
299
272
300
273
self ._alternativeLabel = alternativeLabel
@@ -348,7 +321,7 @@ def IterateInstantiations(self) -> Generator[Instantiation, None, None]:
348
321
raise NotImplementedError ()
349
322
350
323
# @mustoverride
351
- def Index (self ) -> None :
324
+ def IndexStatement (self ) -> None :
352
325
raise NotImplementedError ()
353
326
354
327
@@ -395,12 +368,12 @@ def IterateInstantiations(self) -> Generator[Instantiation, None, None]:
395
368
if self ._elseBranch is not None :
396
369
yield from self ._ifBranch .IterateInstantiations ()
397
370
398
- def Index (self ) -> None :
399
- self ._ifBranch .Index ()
371
+ def IndexStatement (self ) -> None :
372
+ self ._ifBranch .IndexStatements ()
400
373
for branch in self ._elsifBranches :
401
- branch .Index ()
374
+ branch .IndexStatements ()
402
375
if self ._elseBranch is not None :
403
- self ._elseBranch .Index ()
376
+ self ._elseBranch .IndexStatements ()
404
377
405
378
406
379
@export
@@ -409,11 +382,11 @@ class ConcurrentChoice(BaseChoice):
409
382
410
383
411
384
@export
412
- class ConcurrentCase (BaseCase , LabeledEntityMixin , ConcurrentDeclarations , ConcurrentStatements ):
385
+ class ConcurrentCase (BaseCase , LabeledEntityMixin , ConcurrentDeclarationRegionMixin , ConcurrentStatements ):
413
386
def __init__ (self , declaredItems : Iterable = None , statements : Iterable [ConcurrentStatement ] = None , alternativeLabel : str = None ):
414
387
super ().__init__ ()
415
388
LabeledEntityMixin .__init__ (self , alternativeLabel )
416
- ConcurrentDeclarations .__init__ (self , declaredItems )
389
+ ConcurrentDeclarationRegionMixin .__init__ (self , declaredItems )
417
390
ConcurrentStatements .__init__ (self , statements )
418
391
419
392
@@ -476,19 +449,19 @@ def IterateInstantiations(self) -> Generator[Instantiation, None, None]:
476
449
for case in self ._cases :
477
450
yield from case .IterateInstantiations ()
478
451
479
- def Index (self ):
452
+ def IndexStatement (self ):
480
453
for case in self ._cases :
481
- case .Index ()
454
+ case .IndexStatements ()
482
455
483
456
484
457
@export
485
- class ForGenerateStatement (GenerateStatement , ConcurrentDeclarations , ConcurrentStatements ):
458
+ class ForGenerateStatement (GenerateStatement , ConcurrentDeclarationRegionMixin , ConcurrentStatements ):
486
459
_loopIndex : str
487
460
_range : Range
488
461
489
462
def __init__ (self , label : str , loopIndex : str , rng : Range , declaredItems : Iterable = None , statements : Iterable [ConcurrentStatement ] = None ):
490
463
super ().__init__ (label )
491
- ConcurrentDeclarations .__init__ (self , declaredItems )
464
+ ConcurrentDeclarationRegionMixin .__init__ (self , declaredItems )
492
465
ConcurrentStatements .__init__ (self , statements )
493
466
494
467
self ._loopIndex = loopIndex
@@ -506,13 +479,15 @@ def Range(self) -> Range:
506
479
507
480
IterateInstantiations = ConcurrentStatements .IterateInstantiations
508
481
509
- Index = ConcurrentStatements .Index
482
+ # IndexDeclaredItems = ConcurrentStatements.IndexDeclaredItems
483
+
484
+ def IndexStatement (self ) -> None :
485
+ self .IndexStatements ()
486
+
487
+ IndexStatements = ConcurrentStatements .IndexStatements
510
488
511
489
# def IterateInstantiations(self) -> Generator[Instantiation, None, None]:
512
490
# return ConcurrentStatements.IterateInstantiations(self)
513
- #
514
- # def Index(self) -> None:
515
- # return ConcurrentStatements.Index(self)
516
491
517
492
518
493
@export
0 commit comments