Skip to content

Commit 9fdd14c

Browse files
committed
Added doc-strings.
1 parent 0dc02dc commit 9fdd14c

File tree

1 file changed

+175
-4
lines changed

1 file changed

+175
-4
lines changed

pyVHDLModel/Concurrent.py

Lines changed: 175 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,19 @@
5151

5252
@export
5353
class ConcurrentStatement(Statement):
54-
"""A ``ConcurrentStatement`` is a base-class for all concurrent statements."""
54+
"""A base-class for all concurrent statements."""
5555

5656

5757
@export
5858
class ConcurrentStatementsMixin:
59+
"""
60+
A mixin-class for all language constructs supporting concurrent statements.
61+
62+
.. seealso::
63+
64+
.. todo:: concurrent declaration region
65+
"""
66+
5967
_statements: List[ConcurrentStatement]
6068

6169
_instantiations: Dict[str, 'Instantiation'] # TODO: add another instantiation class level for entity/configuration/component inst.
@@ -105,6 +113,10 @@ def IndexStatements(self):
105113

106114
@export
107115
class Instantiation(ConcurrentStatement):
116+
"""
117+
A base-class for all (component) instantiations.
118+
"""
119+
108120
_genericAssociations: List[AssociationItem]
109121
_portAssociations: List[AssociationItem]
110122

@@ -136,6 +148,16 @@ def PortAssociations(self) -> List[AssociationItem]:
136148

137149
@export
138150
class ComponentInstantiation(Instantiation):
151+
"""
152+
Represents a component instantiation by referring to a component name.
153+
154+
.. admonition:: Example
155+
156+
.. code-block:: VHDL
157+
158+
inst : component Counter;
159+
"""
160+
139161
_component: ComponentInstantiationSymbol
140162

141163
def __init__(self, label: str, componentSymbol: ComponentInstantiationSymbol, genericAssociations: Iterable[AssociationItem] = None, portAssociations: Iterable[AssociationItem] = None):
@@ -151,6 +173,16 @@ def Component(self) -> ComponentInstantiationSymbol:
151173

152174
@export
153175
class EntityInstantiation(Instantiation):
176+
"""
177+
Represents an entity instantiation by referring to an entity name with optional architecture name.
178+
179+
.. admonition:: Example
180+
181+
.. code-block:: VHDL
182+
183+
inst : entity work. Counter;
184+
"""
185+
154186
_entity: EntityInstantiationSymbol
155187
_architecture: ArchitectureSymbol
156188

@@ -175,6 +207,16 @@ def Architecture(self) -> ArchitectureSymbol:
175207

176208
@export
177209
class ConfigurationInstantiation(Instantiation):
210+
"""
211+
Represents a configuration instantiation by referring to a configuration name.
212+
213+
.. admonition:: Example
214+
215+
.. code-block:: VHDL
216+
217+
inst : configuration Counter;
218+
"""
219+
178220
_configuration: ConfigurationInstantiationSymbol
179221

180222
def __init__(self, label: str, configurationSymbol: ConfigurationInstantiationSymbol, genericAssociations: Iterable[AssociationItem] = None, portAssociations: Iterable[AssociationItem] = None):
@@ -190,6 +232,20 @@ def Configuration(self) -> ConfigurationInstantiationSymbol:
190232

191233
@export
192234
class ProcessStatement(ConcurrentStatement, SequentialDeclarations, SequentialStatements, DocumentedEntityMixin):
235+
"""
236+
Represents a process statement with sensitivity list, sequential declaration region and sequential statements.
237+
238+
.. admonition:: Example
239+
240+
.. code-block:: VHDL
241+
242+
proc: process(Clock)
243+
-- sequential declarations
244+
begin
245+
-- sequential statements
246+
end process;
247+
"""
248+
193249
_sensitivityList: List['Name'] # TODO: implement a SignalSymbol
194250

195251
def __init__(
@@ -258,7 +314,15 @@ def PortItems(self) -> List[PortInterfaceItem]:
258314

259315
@export
260316
class GenerateBranch(ModelEntity, ConcurrentDeclarationRegionMixin, ConcurrentStatementsMixin):
261-
"""A ``GenerateBranch`` is a base-class for all branches in a generate statements."""
317+
"""
318+
A base-class for all branches in a generate statements.
319+
320+
.. seealso::
321+
322+
* :class:`If-generate branch <pyVHDLModel.Concurrent.IfGenerateBranch>`
323+
* :class:`Elsif-generate branch <pyVHDLModel.Concurrent.ElsifGenerateBranch>`
324+
* :class:`Else-generate branch <pyVHDLModel.Concurrent.ElseGenerateBranch>`
325+
"""
262326

263327
_alternativeLabel: Nullable[str]
264328
_normalizedAlternativeLabel: Nullable[str]
@@ -286,28 +350,90 @@ def NormalizedAlternativeLabel(self) -> Nullable[str]:
286350

287351
@export
288352
class IfGenerateBranch(GenerateBranch, IfBranchMixin):
353+
"""
354+
Represents if-generate branch in a generate statement with a concurrent declaration region and concurrent statements.
355+
356+
.. admonition:: Example
357+
358+
.. code-block:: VHDL
359+
360+
gen: if condition generate
361+
-- concurrent declarations
362+
begin
363+
-- concurrent statements
364+
elsif condition generate
365+
-- ...
366+
else generate
367+
-- ...
368+
end generate;
369+
"""
370+
289371
def __init__(self, condition: ExpressionUnion, declaredItems: Iterable = None, statements: Iterable[ConcurrentStatement] = None, alternativeLabel: str = None):
290372
super().__init__(declaredItems, statements, alternativeLabel)
291373
IfBranchMixin.__init__(self, condition)
292374

293375

294376
@export
295377
class ElsifGenerateBranch(GenerateBranch, ElsifBranchMixin):
378+
"""
379+
Represents elsif-generate branch in a generate statement with a concurrent declaration region and concurrent statements.
380+
381+
.. admonition:: Example
382+
383+
.. code-block:: VHDL
384+
385+
gen: if condition generate
386+
-- ...
387+
elsif condition generate
388+
-- concurrent declarations
389+
begin
390+
-- concurrent statements
391+
else generate
392+
-- ...
393+
end generate;
394+
"""
395+
296396
def __init__(self, condition: ExpressionUnion, declaredItems: Iterable = None, statements: Iterable[ConcurrentStatement] = None, alternativeLabel: str = None):
297397
super().__init__(declaredItems, statements, alternativeLabel)
298398
ElsifBranchMixin.__init__(self, condition)
299399

300400

301401
@export
302402
class ElseGenerateBranch(GenerateBranch, ElseBranchMixin):
403+
"""
404+
Represents else-generate branch in a generate statement with a concurrent declaration region and concurrent statements.
405+
406+
.. admonition:: Example
407+
408+
.. code-block:: VHDL
409+
410+
gen: if condition generate
411+
-- ...
412+
elsif condition generate
413+
-- ...
414+
else generate
415+
-- concurrent declarations
416+
begin
417+
-- concurrent statements
418+
end generate;
419+
"""
420+
303421
def __init__(self, declaredItems: Iterable = None, statements: Iterable[ConcurrentStatement] = None, alternativeLabel: str = None):
304422
super().__init__(declaredItems, statements, alternativeLabel)
305423
ElseBranchMixin.__init__(self)
306424

307425

308426
@export
309427
class GenerateStatement(ConcurrentStatement):
310-
"""A ``GenerateStatement`` is a base-class for all generate statements."""
428+
"""
429+
A base-class for all generate statements.
430+
431+
.. seealso::
432+
433+
* :class:`If...generate statement <pyVHDLModel.Concurrent.IfGenerateStatement>`
434+
* :class:`Case...generate statement <pyVHDLModel.Concurrent.CaseGenerateStatement>`
435+
* :class:`For...generate statement <pyVHDLModel.Concurrent.ForGenerateStatement>`
436+
"""
311437

312438
_namespace: Namespace
313439

@@ -327,6 +453,22 @@ def IndexStatement(self) -> None:
327453

328454
@export
329455
class IfGenerateStatement(GenerateStatement):
456+
"""
457+
Represents an if...generate statement.
458+
459+
.. admonition:: Example
460+
461+
.. code-block:: VHDL
462+
463+
gen: if condition generate
464+
-- ...
465+
elsif condition generate
466+
-- ...
467+
else generate
468+
-- ...
469+
end generate;
470+
"""
471+
330472
_ifBranch: IfGenerateBranch
331473
_elsifBranches: List[ElsifGenerateBranch]
332474
_elseBranch: Nullable[ElseGenerateBranch]
@@ -378,7 +520,7 @@ def IndexStatement(self) -> None:
378520

379521
@export
380522
class ConcurrentChoice(BaseChoice):
381-
"""A ``ConcurrentChoice`` is a base-class for all concurrent choices (in case...generate statements)."""
523+
"""A base-class for all concurrent choices (in case...generate statements)."""
382524

383525

384526
@export
@@ -421,6 +563,23 @@ def __str__(self) -> str:
421563

422564
@export
423565
class CaseGenerateStatement(GenerateStatement):
566+
"""
567+
Represents a case...generate statement.
568+
569+
.. admonition:: Example
570+
571+
.. code-block:: VHDL
572+
573+
gen: case selector generate
574+
case choice1 =>
575+
-- ...
576+
case choice2 =>
577+
-- ...
578+
case others =>
579+
-- ...
580+
end generate;
581+
"""
582+
424583
_expression: ExpressionUnion
425584
_cases: List[GenerateCase]
426585

@@ -456,6 +615,18 @@ def IndexStatement(self):
456615

457616
@export
458617
class ForGenerateStatement(GenerateStatement, ConcurrentDeclarationRegionMixin, ConcurrentStatementsMixin):
618+
"""
619+
Represents a for...generate statement.
620+
621+
.. admonition:: Example
622+
623+
.. code-block:: VHDL
624+
625+
gen: for i in 0 to 3 generate
626+
-- ...
627+
end generate;
628+
"""
629+
459630
_loopIndex: str
460631
_range: Range
461632

0 commit comments

Comments
 (0)