Coverage for pyVHDLModel/Interface.py: 98%

486 statements  

« prev     ^ index     » next       coverage.py v7.17.0, created at 2026-10-25 10:05 +0000

1# ==================================================================================================================== # 

2# __ ___ _ ____ _ __ __ _ _ # 

3# _ __ _ \ \ / / | | | _ \| | | \/ | ___ __| | ___| | # 

4# | '_ \| | | \ \ / /| |_| | | | | | | |\/| |/ _ \ / _` |/ _ \ | # 

5# | |_) | |_| |\ V / | _ | |_| | |___| | | | (_) | (_| | __/ | # 

6# | .__/ \__, | \_/ |_| |_|____/|_____|_| |_|\___/ \__,_|\___|_| # 

7# |_| |___/ # 

8# ==================================================================================================================== # 

9# Authors: # 

10# Patrick Lehmann # 

11# # 

12# License: # 

13# ==================================================================================================================== # 

14# Copyright 2017-2026 Patrick Lehmann - Boetzingen, Germany # 

15# Copyright 2016-2017 Patrick Lehmann - Dresden, Germany # 

16# # 

17# Licensed under the Apache License, Version 2.0 (the "License"); # 

18# you may not use this file except in compliance with the License. # 

19# You may obtain a copy of the License at # 

20# # 

21# http://www.apache.org/licenses/LICENSE-2.0 # 

22# # 

23# Unless required by applicable law or agreed to in writing, software # 

24# distributed under the License is distributed on an "AS IS" BASIS, # 

25# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # 

26# See the License for the specific language governing permissions and # 

27# limitations under the License. # 

28# # 

29# SPDX-License-Identifier: Apache-2.0 # 

30# ==================================================================================================================== # 

31# 

32""" 

33This module contains parts of an abstract document language model for VHDL. 

34 

35Interface items are used in generic, port and parameter declarations. 

36""" 

37from __future__ import annotations 

38 

39from typing import TYPE_CHECKING, ClassVar, Iterable, Optional as Nullable, Iterator, Self 

40 

41from pyTooling.Common import getFullyQualifiedName 

42from pyTooling.Decorators import export, readonly 

43from pyTooling.MetaClasses import ExtendedType, abstractclass, expects 

44 

45from pyVHDLModel.Symbol import Symbol, SubtypeSymbol, ModeViewSymbol 

46from pyVHDLModel.Base import ModelEntity, DocumentedEntityMixin, NamedEntityMixin, OptionallyNamedEntityMixin, \ 

47 MultipleNamedEntityMixin, identifiersOf, normalizedIdentifiersOf, ExpressionUnion, \ 

48 Mode 

49from pyVHDLModel.Object import Constant, Signal, Variable, File 

50from pyVHDLModel.Regions import WithGenericsMixin, WithPortsMixin, WithParametersMixin 

51from pyVHDLModel.Subprogram import Procedure, Function 

52from pyVHDLModel.Type import Type 

53 

54if TYPE_CHECKING: 54 ↛ 55line 54 didn't jump to line 55 because the condition on line 54 was never true

55 from pyVHDLModel.Visitor import Visitor 

56 

57 

58@export 

59@abstractclass 

60class ModeViewElement(ModelEntity, MultipleNamedEntityMixin, DocumentedEntityMixin): 

61 """ 

62 Base-class for one element definition inside a mode view declaration (VHDL-2019). 

63 

64 An element may name several fields sharing the same specification (e.g. ``a, b : out;``), hence 

65 :class:`~pyVHDLModel.Base.MultipleNamedEntityMixin` is inherited. 

66 

67 .. seealso:: 

68 

69 * :class:`Simple mode view element <pyVHDLModel.Interface.SimpleModeViewElement>` 

70 * :class:`Composite mode view element <pyVHDLModel.Interface.CompositeModeViewElement>` 

71 """ 

72 

73 def __init__( 

74 self, 

75 identifiers: Iterable[str], 

76 documentation: Nullable[str] = None, 

77 parent: Nullable[ModelEntity] = None 

78 ) -> None: 

79 """ 

80 Initializes a mode view element. 

81 

82 :param identifiers: A list of identifiers. 

83 :param documentation: The documentation comment associated with this declaration. 

84 :param parent: The parent model entity of this entity. 

85 """ 

86 super().__init__(parent) 

87 MultipleNamedEntityMixin.__init__(self, identifiers) 

88 DocumentedEntityMixin.__init__(self, documentation) 

89 

90 def __str__(self) -> str: 

91 """ 

92 Formats the mode view element as its identifiers. 

93 

94 **Format:** ``a, b`` 

95 

96 :returns: The element's identifiers, comma-separated. 

97 """ 

98 return ", ".join(self._identifiers) 

99 

100 

101@export 

102class SimpleModeViewElement(ModeViewElement): 

103 """ 

104 A mode view element with a plain (simple) mode. 

105 

106 .. admonition:: Example 

107 

108 .. code-block:: VHDL 

109 

110 view MyView of RecordType is 

111 a, b : out; 

112 -- ^^^ 

113 end view; 

114 """ 

115 

116 _mode: Mode #: The element's mode. 

117 

118 def __init__( 

119 self, 

120 identifiers: Iterable[str], 

121 mode: Mode, 

122 documentation: Nullable[str] = None, 

123 parent: Nullable[ModelEntity] = None 

124 ) -> None: 

125 """ 

126 Initializes a simple mode view element. 

127 

128 :param identifiers: A list of identifiers. 

129 :param mode: The element's mode. 

130 :param documentation: The documentation comment associated with this declaration. 

131 :param parent: The parent model entity of this entity. 

132 """ 

133 super().__init__(identifiers, documentation, parent) 

134 self._mode = mode 

135 

136 def Visit(self, visitor: Visitor) -> None: 

137 """ 

138 Walk this simple mode view element with a visitor. 

139 

140 :param visitor: The visitor receiving the events. 

141 """ 

142 visitor.VisitSimpleModeViewElement(self) 

143 visitor.DepartSimpleModeViewElement(self) 

144 

145 @readonly 

146 def Mode(self) -> Mode: 

147 """ 

148 Read-only property to access the mode (:attr:`_mode`). 

149 

150 :returns: The mode. 

151 """ 

152 return self._mode 

153 

154 def Copy(self) -> Self: 

155 """ 

156 Create a copy of this simple mode view element. 

157 

158 The copy has no parent. 

159 

160 :returns: The new simple mode view element. 

161 """ 

162 return self.__class__(self._identifiers, self._mode, self._documentation) 

163 

164 

165@export 

166class CompositeModeViewElement(ModeViewElement): 

167 """ 

168 A mode view element that refers to another (named) mode view for an array or record sub-element. 

169 .. admonition:: Example 

170 

171 .. code-block:: VHDL 

172 

173 view OuterView of OuterRecord is 

174 b : view InnerView; 

175 -- ^^^^^^^^^ 

176 end view; 

177 """ 

178 

179 _modeViewName: ModeViewSymbol #: Reference to the mode view applied to this element. 

180 

181 def __init__( 

182 self, 

183 identifiers: Iterable[str], 

184 modeViewName: ModeViewSymbol, 

185 documentation: Nullable[str] = None, 

186 parent: Nullable[ModelEntity] = None 

187 ) -> None: 

188 """ 

189 Initializes a composite mode view element. 

190 

191 :param identifiers: A list of identifiers. 

192 :param modeViewName: Reference to the mode view applied to this element. 

193 :param documentation: The documentation comment associated with this declaration. 

194 :param parent: The parent model entity of this entity. 

195 """ 

196 super().__init__(identifiers, documentation, parent) 

197 

198 self._modeViewName = modeViewName 

199 modeViewName.Parent = self 

200 

201 def Visit(self, visitor: Visitor) -> None: 

202 """ 

203 Walk this composite mode view element and its mode view name with a visitor. 

204 

205 :param visitor: The visitor receiving the events. 

206 """ 

207 visitor.VisitCompositeModeViewElement(self) 

208 self._modeViewName.Visit(visitor) 

209 visitor.DepartCompositeModeViewElement(self) 

210 

211 @readonly 

212 def ModeViewName(self) -> ModeViewSymbol: 

213 """ 

214 Read-only property to access the mode view name (:attr:`_modeViewName`). 

215 

216 :returns: The mode view name. 

217 """ 

218 return self._modeViewName 

219 

220 def Copy(self) -> Self: 

221 """ 

222 Create a copy of this composite mode view element. 

223 

224 The copy has no parent. Its mode view name is a copy of this element's mode view name. 

225 

226 :returns: The new composite mode view element. 

227 """ 

228 return self.__class__(self._identifiers, self._modeViewName.Copy(), self._documentation) 

229 

230 

231@export 

232class ModeViewDeclaration(ModelEntity, NamedEntityMixin, DocumentedEntityMixin): 

233 """ 

234 Represents a mode view declaration (VHDL-2019). 

235 

236 .. admonition:: Example 

237 

238 .. code-block:: VHDL 

239 

240 view MyView of RecordType is 

241 a : out; 

242 b : in; 

243 end view; 

244 

245 .. seealso:: 

246 

247 * :class:`Port declared with a mode view <pyVHDLModel.Interface.PortViewSignalInterfaceItem>` 

248 * :class:`Parameter declared with a mode view <pyVHDLModel.Interface.ParameterViewSignalInterfaceItem>` 

249 * :class:`Reference to a mode view <pyVHDLModel.Symbol.ModeViewSymbol>` 

250 """ 

251 

252 _subtype: SubtypeSymbol #: Reference to the subtype this mode view applies to. 

253 _elements: list[ModeViewElement] #: List of all mode view elements, in declaration order. 

254 

255 def __init__( 

256 self, 

257 identifier: str, 

258 subtype: SubtypeSymbol, 

259 elements: Nullable[Iterable[ModeViewElement]] = None, 

260 documentation: Nullable[str] = None, 

261 parent: Nullable[ModelEntity] = None 

262 ) -> None: 

263 """ 

264 Initializes a mode view declaration (VHDL-2019). 

265 

266 :param identifier: The identifier of a model entity. 

267 :param subtype: Reference to the subtype this mode view applies to. 

268 :param elements: List of all mode view elements, in declaration order. 

269 :param documentation: The documentation comment associated with this declaration. 

270 :param parent: The parent model entity of this entity. 

271 """ 

272 super().__init__(parent) 

273 NamedEntityMixin.__init__(self, identifier) 

274 DocumentedEntityMixin.__init__(self, documentation) 

275 

276 self._subtype = subtype 

277 subtype.Parent = self 

278 

279 self._elements = elementList = [] 

280 if elements is not None: 

281 for element in elements: 

282 elementList.append(element) 

283 element.Parent = self 

284 

285 def Visit(self, visitor: Visitor) -> None: 

286 """ 

287 Walk this mode view declaration, its subtype and its elements with a visitor. 

288 

289 :param visitor: The visitor receiving the events. 

290 """ 

291 visitor.VisitModeViewDeclaration(self) 

292 self._subtype.Visit(visitor) 

293 visitor.VisitIs(self) 

294 for element in self._elements: 

295 element.Visit(visitor) 

296 

297 visitor.DepartModeViewDeclaration(self) 

298 

299 @readonly 

300 def Subtype(self) -> SubtypeSymbol: 

301 """ 

302 Read-only property to access the subtype (:attr:`_subtype`). 

303 

304 :returns: The subtype. 

305 """ 

306 return self._subtype 

307 

308 @readonly 

309 def Elements(self) -> list[ModeViewElement]: 

310 """ 

311 Read-only property to access the elements (:attr:`_elements`). 

312 

313 :returns: List of elements. 

314 """ 

315 return self._elements 

316 

317 def __str__(self) -> str: 

318 """ 

319 Formats the mode view declaration. 

320 

321 **Format:** ``view myView of myRecord: a, b`` 

322 

323 :returns: Formatted mode view declaration. 

324 """ 

325 elements = ", ".join(str(element) for element in self._elements) 

326 return f"view {self._identifier} of {self._subtype}: {elements}" 

327 

328 

329@export 

330class InterfaceItemMixin(metaclass=ExtendedType, mixin=True): 

331 """ 

332 A mixin-class marking a declaration as an interface item. 

333 

334 Interface items appear in generic clauses, port clauses and parameter lists. 

335 

336 .. seealso:: 

337 

338 * :class:`Generic interface item mixin <pyVHDLModel.Interface.GenericInterfaceItemMixin>` 

339 * :class:`Port interface item mixin <pyVHDLModel.Interface.PortInterfaceItemMixin>` 

340 * :class:`Parameter interface item mixin <pyVHDLModel.Interface.ParameterInterfaceItemMixin>` 

341 * :class:`Port signal interface item <pyVHDLModel.Interface.PortSignalInterfaceItem>` 

342 """ 

343 

344 @expects("_OBJECT_KEYWORD", "_identifiers", "_subtype") 

345 def _FormatInterfaceItem(self, mode: Nullable[Mode] = None, isModeView: bool = False) -> str: 

346 """ 

347 Format this interface item as a single-line declaration. 

348 

349 Interface items are objects, so they render like one (``signal p : bit``), but an object's own 

350 rendering cannot show the interface *mode* - a mode is not part of an object declaration. This 

351 adds it, for the derived class's :meth:`__str__` to return. The host class provides the object's reserved words 

352 ``_OBJECT_KEYWORD``, identifiers ``_identifiers`` and subtype ``_subtype``. 

353 

354 :param mode: This item's mode, or ``None`` when it declares none. 

355 :param isModeView: ``True`` if the subtype position holds a mode view (VHDL-2019), not a subtype. 

356 :returns: Formatted interface item. 

357 """ 

358 prefix = "" if mode is None or mode is Mode.Default else f"{mode!s} " 

359 if isModeView: 

360 prefix = "view " 

361 

362 return f"{' '.join(self._OBJECT_KEYWORD)} {', '.join(self._identifiers)} : {prefix}{self._subtype}" 

363 

364 

365@export 

366class InterfaceItemWithModeMixin(metaclass=ExtendedType, mixin=True): 

367 """ 

368 A mixin-class for interface items declared with a mode. 

369 

370 The mode is available as :data:`Mode`. 

371 

372 .. seealso:: 

373 

374 * :class:`Port interface item mixin <pyVHDLModel.Interface.PortInterfaceItemMixin>` 

375 * :class:`Generic constant interface item <pyVHDLModel.Interface.GenericConstantInterfaceItem>` 

376 * :class:`Port simple signal interface item <pyVHDLModel.Interface.PortSimpleSignalInterfaceItem>` 

377 * :class:`Parameter constant interface item <pyVHDLModel.Interface.ParameterConstantInterfaceItem>` 

378 * :class:`Parameter variable interface item <pyVHDLModel.Interface.ParameterVariableInterfaceItem>` 

379 * :class:`Parameter simple signal interface item <pyVHDLModel.Interface.ParameterSimpleSignalInterfaceItem>` 

380 """ 

381 

382 _mode: Mode #: The interface item's mode. 

383 

384 def __init__(self, mode: Mode) -> None: 

385 """ 

386 Initializes an interface item with mode. 

387 

388 :param mode: The interface item's mode. 

389 """ 

390 self._mode = mode 

391 

392 @readonly 

393 def Mode(self) -> Mode: 

394 """ 

395 Read-only property to access the mode (:attr:`_mode`). 

396 

397 :returns: The mode. 

398 """ 

399 return self._mode 

400 

401 

402@export 

403class GenericInterfaceItemMixin(InterfaceItemMixin, mixin=True): 

404 """ 

405 A mixin-class for all items in a generic clause. 

406 

407 .. seealso:: 

408 

409 * :class:`Generic constant interface item <pyVHDLModel.Interface.GenericConstantInterfaceItem>` 

410 * :class:`Generic type interface item <pyVHDLModel.Interface.GenericTypeInterfaceItem>` 

411 * :class:`Generic subprogram interface item mixin <pyVHDLModel.Interface.GenericSubprogramInterfaceItemMixin>` 

412 * :class:`Generic package interface item <pyVHDLModel.Interface.GenericPackageInterfaceItem>` 

413 """ 

414 

415 

416@export 

417class GenericSubprogramInterfaceItemMixin(GenericInterfaceItemMixin, mixin=True): 

418 """ 

419 A mixin-class for subprograms in a generic clause. 

420 

421 .. seealso:: 

422 

423 * :class:`Generic procedure interface item <pyVHDLModel.Interface.GenericProcedureInterfaceItem>` 

424 * :class:`Generic function interface item <pyVHDLModel.Interface.GenericFunctionInterfaceItem>` 

425 """ 

426 

427 

428@export 

429class PortInterfaceItemMixin(InterfaceItemMixin, InterfaceItemWithModeMixin, mixin=True): 

430 """ 

431 A mixin-class for all items in a port clause. 

432 """ 

433 

434 def __init__(self, mode: Mode) -> None: 

435 """ 

436 Initializes a port interface item. 

437 

438 :param mode: The interface item's mode. 

439 """ 

440 super().__init__() 

441 InterfaceItemWithModeMixin.__init__(self, mode) 

442 

443 

444@export 

445class ParameterInterfaceItemMixin(InterfaceItemMixin, mixin=True): 

446 """ 

447 A mixin-class for all items in a subprogram's parameter list. 

448 

449 .. seealso:: 

450 

451 * :class:`Parameter constant interface item <pyVHDLModel.Interface.ParameterConstantInterfaceItem>` 

452 * :class:`Parameter variable interface item <pyVHDLModel.Interface.ParameterVariableInterfaceItem>` 

453 * :class:`Parameter signal interface item <pyVHDLModel.Interface.ParameterSignalInterfaceItem>` 

454 * :class:`Parameter file interface item <pyVHDLModel.Interface.ParameterFileInterfaceItem>` 

455 """ 

456 

457 

458@export 

459class WithSingleDeclarationsMixin( 

460 metaclass=ExtendedType, 

461 mixin=True, 

462 expects=("_identifiers", "_normalizedIdentifiers") 

463): 

464 """ 

465 A mixin-class for interface items declaring several identifiers, which offer one single declaration per identifier. 

466 

467 The single declarations are created on first access of :data:`SingleDeclarations` and kept in 

468 :attr:`_singleDeclarations`. 

469 

470 .. seealso:: 

471 

472 :class:`~pyVHDLModel.Interface.SingleDeclarationMixin` 

473 |rarr| One identifier of a declaration with an identifier list. 

474 """ 

475 

476 _SINGLE_DECLARATION: ClassVar[type[SingleDeclarationMixin]] #: The class of a single declaration of one identifier. 

477 

478 _singleDeclarations: Nullable[list[SingleDeclarationMixin]] #: Cached single declarations, or ``None``. 

479 

480 def __init__(self) -> None: 

481 """ 

482 Initializes an interface item without single declarations yet. 

483 """ 

484 self._singleDeclarations = None 

485 

486 @readonly 

487 def SingleDeclarations(self) -> list[SingleDeclarationMixin]: 

488 """ 

489 Read-only property to access the single declarations (:attr:`_singleDeclarations`). 

490 

491 The list is created on first access, one single declaration per identifier in list order. 

492 

493 :returns: The single declarations. 

494 """ 

495 if self._singleDeclarations is None: 

496 self._singleDeclarations = singleDeclarations = [] 

497 for position, identifier in enumerate(self._identifiers): 

498 normalizedIdentifier = self._normalizedIdentifiers[position] 

499 singleDeclaration = self._SINGLE_DECLARATION(identifier, normalizedIdentifier, position, parent=self) 

500 singleDeclarations.append(singleDeclaration) 

501 

502 return self._singleDeclarations 

503 

504 

505@export 

506class GenericConstantInterfaceItem( 

507 Constant, 

508 GenericInterfaceItemMixin, 

509 InterfaceItemWithModeMixin, 

510 WithSingleDeclarationsMixin 

511): 

512 """ 

513 Represents a constant in a generic clause. 

514 

515 .. admonition:: Example 

516 

517 .. code-block:: VHDL 

518 

519 generic (W : positive := 8); 

520 -- ^ <- Identifiers 

521 -- ^^^^^^^^ <- Subtype 

522 -- ^ <- DefaultExpression 

523 """ 

524 

525 def __init__( 

526 self, 

527 identifiers: Iterable[str], 

528 mode: Mode, 

529 subtype: Symbol, 

530 defaultExpression: Nullable[ExpressionUnion] = None, 

531 documentation: Nullable[str] = None, 

532 parent: Nullable[ModelEntity] = None 

533 ) -> None: 

534 """ 

535 Initializes a constant in a generic clause. 

536 

537 :param identifiers: A list of identifiers. 

538 :param mode: The interface item's mode. 

539 :param subtype: Reference to the object's subtype. 

540 :param defaultExpression: The default value, or ``None`` if none was given. 

541 :param documentation: The documentation comment associated with this declaration. 

542 :param parent: The parent model entity of this entity. 

543 """ 

544 super().__init__(identifiers, subtype, defaultExpression, documentation, parent) 

545 GenericInterfaceItemMixin.__init__(self) 

546 InterfaceItemWithModeMixin.__init__(self, mode) 

547 WithSingleDeclarationsMixin.__init__(self) 

548 

549 def Copy(self) -> Self: 

550 """ 

551 Create a copy of this generic constant. 

552 

553 The copy has no parent and no object vertex. Its subtype and default expression are copies of this item's 

554 subtype and default expression. 

555 

556 :returns: The new generic constant. 

557 """ 

558 defaultExpression = None if self._defaultExpression is None else self._defaultExpression.Copy() 

559 return self.__class__( 

560 self._identifiers, 

561 self._mode, 

562 self._subtype.Copy(), 

563 defaultExpression, 

564 self._documentation 

565 ) 

566 

567 def Visit(self, visitor: Visitor) -> None: 

568 """ 

569 Walk this generic constant, its subtype and its default expression with a visitor. 

570 

571 :param visitor: The visitor receiving the events. 

572 """ 

573 visitor.VisitGenericConstantInterfaceItem(self) 

574 self._subtype.Visit(visitor) 

575 self._VisitDefaultExpression(visitor) 

576 visitor.DepartGenericConstantInterfaceItem(self) 

577 

578 def __str__(self) -> str: 

579 """ 

580 Formats the generic constant. 

581 

582 **Format:** ``constant G : in positive`` 

583 

584 :returns: Formatted generic constant. 

585 """ 

586 return self._FormatInterfaceItem(self._mode) 

587 

588 

589@export 

590class GenericTypeInterfaceItem(Type, GenericInterfaceItemMixin): 

591 """ 

592 Represents a type in a generic clause. 

593 

594 A generic type introduces a type name without defining the type. 

595 

596 .. admonition:: Example 

597 

598 .. code-block:: VHDL 

599 

600 generic (type T); 

601 -- ^ <- Identifier 

602 """ 

603 def __init__(self, identifier: str, documentation: Nullable[str] = None, parent: Nullable[ModelEntity] = None) -> None: 

604 """ 

605 Initializes a type in a generic clause. 

606 

607 :param identifier: The identifier of a model entity. 

608 :param documentation: The documentation comment associated with this declaration. 

609 :param parent: The parent model entity of this entity. 

610 """ 

611 super().__init__(identifier, documentation, parent) 

612 GenericInterfaceItemMixin.__init__(self) 

613 

614 def Copy(self) -> Self: 

615 """ 

616 Create a copy of this generic type. 

617 

618 The copy has no parent and no object vertex. 

619 

620 :returns: The new generic type. 

621 """ 

622 return self.__class__(self._identifier, self._documentation) 

623 

624 def Visit(self, visitor: Visitor) -> None: 

625 """ 

626 Walk this generic type with a visitor. 

627 

628 :param visitor: The visitor receiving the events. 

629 """ 

630 visitor.VisitGenericTypeInterfaceItem(self) 

631 visitor.DepartGenericTypeInterfaceItem(self) 

632 

633 

634@export 

635class GenericProcedureInterfaceItem(Procedure, GenericSubprogramInterfaceItemMixin): 

636 """ 

637 Represents a procedure in a generic clause. 

638 

639 .. admonition:: Example 

640 

641 .. code-block:: VHDL 

642 

643 generic (procedure log(msg : string)); 

644 -- ^^^ <- Identifier 

645 -- ^^^^^^^^^^^^ <- ParameterItems 

646 """ 

647 def __init__(self, identifier: str, documentation: Nullable[str] = None, parent: Nullable[ModelEntity] = None) -> None: 

648 """ 

649 Initializes a procedure in a generic clause. 

650 

651 :param identifier: The identifier of a model entity. 

652 :param documentation: The documentation comment associated with this declaration. 

653 :param parent: The parent model entity of this entity. 

654 """ 

655 super().__init__(identifier, documentation=documentation, parent=parent) 

656 GenericSubprogramInterfaceItemMixin.__init__(self) 

657 

658 def Visit(self, visitor: Visitor) -> None: 

659 """ 

660 Walk this generic procedure and its parameters with a visitor. 

661 

662 :param visitor: The visitor receiving the events. 

663 """ 

664 visitor.VisitGenericProcedureInterfaceItem(self) 

665 self._VisitFormalParameterList(visitor) 

666 visitor.DepartGenericProcedureInterfaceItem(self) 

667 

668 def Copy(self) -> Self: 

669 """ 

670 Create a copy of this generic procedure. 

671 

672 The copy has no parent. Its parameters are copies of this procedure's parameters. 

673 

674 :returns: The new generic procedure. 

675 """ 

676 copy = self.__class__(self._identifier, self._documentation) 

677 for parameterItem in self._parameterItems: 

678 copy.AddParameterItem(parameterItem.Copy()) 

679 

680 return copy 

681 

682 

683@export 

684class GenericFunctionInterfaceItem(Function, GenericSubprogramInterfaceItemMixin): 

685 """ 

686 Represents a function in a generic clause. 

687 

688 .. admonition:: Example 

689 

690 .. code-block:: VHDL 

691 

692 generic (function cmp(a, b : integer) return boolean); 

693 -- ^^^ <- Identifier 

694 -- ^^^^^^^^^^^^^^ <- ParameterItems 

695 -- ^^^^^^^ <- ReturnType 

696 """ 

697 def __init__( 

698 self, 

699 identifier: str, 

700 returnType: SubtypeSymbol, 

701 documentation: Nullable[str] = None, 

702 parent: Nullable[ModelEntity] = None 

703 ) -> None: 

704 """ 

705 Initializes a function in a generic clause. 

706 

707 :param identifier: The identifier of a model entity. 

708 :param returnType: Reference to the subtype of the function's return value. 

709 :param documentation: The documentation comment associated with this declaration. 

710 :param parent: The parent model entity of this entity. 

711 """ 

712 super().__init__(identifier, returnType, documentation=documentation, parent=parent) 

713 GenericSubprogramInterfaceItemMixin.__init__(self) 

714 

715 def Visit(self, visitor: Visitor) -> None: 

716 """ 

717 Walk this generic function, its parameters and its return type with a visitor. 

718 

719 :param visitor: The visitor receiving the events. 

720 """ 

721 visitor.VisitGenericFunctionInterfaceItem(self) 

722 self._VisitFormalParameterList(visitor) 

723 visitor.VisitReturn(self) 

724 self._returnType.Visit(visitor) 

725 visitor.DepartGenericFunctionInterfaceItem(self) 

726 

727 def Copy(self) -> Self: 

728 """ 

729 Create a copy of this generic function. 

730 

731 The copy has no parent. Its return type and parameters are copies of this function's return type and parameters. 

732 

733 :returns: The new generic function. 

734 """ 

735 copy = self.__class__(self._identifier, self._returnType.Copy(), self._documentation) 

736 for parameterItem in self._parameterItems: 

737 copy.AddParameterItem(parameterItem.Copy()) 

738 

739 return copy 

740 

741 

742@export 

743@abstractclass 

744class InterfacePackage(ModelEntity, NamedEntityMixin, DocumentedEntityMixin): 

745 """ 

746 Represents a package as a generic of a design unit. 

747 

748 An interface package parameterises a design unit with an instantiated package. 

749 

750 .. seealso:: 

751 

752 * :class:`Generic package interface item <pyVHDLModel.Interface.GenericPackageInterfaceItem>` 

753 """ 

754 def __init__(self, identifier: str, documentation: Nullable[str] = None, parent: Nullable[ModelEntity] = None) -> None: 

755 """ 

756 Initializes a package as a generic of a design unit. 

757 

758 :param identifier: The identifier of a model entity. 

759 :param documentation: The documentation comment associated with this declaration. 

760 :param parent: The parent model entity of this entity. 

761 """ 

762 super().__init__(parent) 

763 NamedEntityMixin.__init__(self, identifier) 

764 DocumentedEntityMixin.__init__(self, documentation) 

765 

766 def __str__(self) -> str: 

767 """ 

768 Formats the interface package. 

769 

770 **Format:** ``package myPackage`` 

771 

772 :returns: Formatted interface package. 

773 """ 

774 return f"package {self._identifier}" 

775 

776 

777@export 

778class GenericPackageInterfaceItem(InterfacePackage, GenericInterfaceItemMixin): 

779 """ 

780 Represents a package in a generic clause. 

781 

782 A generic package parameterises a design unit with an instantiated package. 

783 """ 

784 def __init__(self, identifier: str, documentation: Nullable[str] = None, parent: Nullable[ModelEntity] = None) -> None: 

785 """ 

786 Initializes a package in a generic clause. 

787 

788 :param identifier: The identifier of a model entity. 

789 :param documentation: The documentation comment associated with this declaration. 

790 :param parent: The parent model entity of this entity. 

791 """ 

792 super().__init__(identifier, documentation, parent) 

793 GenericInterfaceItemMixin.__init__(self) 

794 

795 def Copy(self) -> Self: 

796 """ 

797 Create a copy of this generic package. 

798 

799 The copy has no parent. 

800 

801 :returns: The new generic package. 

802 """ 

803 return self.__class__(self._identifier, self._documentation) 

804 

805 

806@export 

807@abstractclass 

808class PortSignalInterfaceItem(Signal, InterfaceItemMixin): 

809 """ 

810 Represents the base-class of all signals in a port clause. 

811 

812 A port is declared either with a simple mode (:class:`PortSimpleSignalInterfaceItem`) or with a 

813 mode view (:class:`PortViewSignalInterfaceItem`). 

814 

815 .. seealso:: 

816 

817 * :class:`Port simple signal interface item <pyVHDLModel.Interface.PortSimpleSignalInterfaceItem>` 

818 * :class:`Port view signal interface item <pyVHDLModel.Interface.PortViewSignalInterfaceItem>` 

819 """ 

820 

821 

822@export 

823class PortSimpleSignalInterfaceItem(PortSignalInterfaceItem, InterfaceItemWithModeMixin, WithSingleDeclarationsMixin): 

824 """ 

825 Represents a port declared with a simple mode. 

826 

827 The port's mode is available as :data:`Mode`, its subtype as :data:`Subtype`. 

828 

829 .. admonition:: Example 

830 

831 .. code-block:: VHDL 

832 

833 port (p : in bit); 

834 -- ^ <- Identifiers 

835 -- ^^ <- Mode 

836 -- ^^^ <- Subtype 

837 

838 .. seealso:: 

839 

840 * :class:`Port declared with a mode view <pyVHDLModel.Interface.PortViewSignalInterfaceItem>` 

841 """ 

842 

843 def __init__( 

844 self, 

845 identifiers: Iterable[str], 

846 mode: Mode, 

847 subtype: Symbol, 

848 defaultExpression: Nullable[ExpressionUnion] = None, 

849 documentation: Nullable[str] = None, 

850 parent: Nullable[ModelEntity] = None 

851 ) -> None: 

852 """ 

853 Initializes a port declared with a simple mode. 

854 

855 :param identifiers: A list of identifiers. 

856 :param mode: The interface item's mode. 

857 :param subtype: Reference to the object's subtype. 

858 :param defaultExpression: The default value, or ``None`` if none was given. 

859 :param documentation: The documentation comment associated with this declaration. 

860 :param parent: The parent model entity of this entity. 

861 """ 

862 super().__init__(identifiers, subtype, defaultExpression, documentation, parent) 

863 InterfaceItemWithModeMixin.__init__(self, mode) 

864 WithSingleDeclarationsMixin.__init__(self) 

865 

866 def Copy(self) -> Self: 

867 """ 

868 Create a copy of this port. 

869 

870 The copy has no parent and no object vertex. Its subtype and default expression are copies of this item's 

871 subtype and default expression. 

872 

873 :returns: The new port. 

874 """ 

875 defaultExpression = None if self._defaultExpression is None else self._defaultExpression.Copy() 

876 return self.__class__( 

877 self._identifiers, 

878 self._mode, 

879 self._subtype.Copy(), 

880 defaultExpression, 

881 self._documentation 

882 ) 

883 

884 def Visit(self, visitor: Visitor) -> None: 

885 """ 

886 Walk this port, its subtype and its default expression with a visitor. 

887 

888 :param visitor: The visitor receiving the events. 

889 """ 

890 visitor.VisitPortSimpleSignalInterfaceItem(self) 

891 self._subtype.Visit(visitor) 

892 self._VisitDefaultExpression(visitor) 

893 visitor.DepartPortSimpleSignalInterfaceItem(self) 

894 

895 def __str__(self) -> str: 

896 """ 

897 Formats the port. 

898 

899 **Format:** ``signal p : in bit`` 

900 

901 :returns: Formatted port. 

902 """ 

903 return self._FormatInterfaceItem(self._mode) 

904 

905 

906@export 

907class PortViewSignalInterfaceItem(PortSignalInterfaceItem, WithSingleDeclarationsMixin): 

908 """ 

909 Represents a port declared with a mode view (VHDL-2019). 

910 

911 Instead of a mode, the port names a mode view (:data:`ModeViewIndication`) that assigns a mode to 

912 each element of its record type. 

913 

914 .. admonition:: Example 

915 

916 .. code-block:: VHDL 

917 

918 port (p : view MyView); 

919 -- ^ <- Identifiers 

920 -- ^^^^^^ <- ModeViewIndication 

921 

922 .. seealso:: 

923 

924 * :class:`Mode view declaration <pyVHDLModel.Interface.ModeViewDeclaration>` 

925 * :class:`Port declared with a simple mode <pyVHDLModel.Interface.PortSimpleSignalInterfaceItem>` 

926 """ 

927 

928 def __init__( 

929 self, 

930 identifiers: Iterable[str], 

931 modeViewIndication: ModeViewSymbol, 

932 documentation: Nullable[str] = None, 

933 parent: Nullable[ModelEntity] = None 

934 ) -> None: 

935 """ 

936 Initializes a port declared with a mode view (VHDL-2019). 

937 

938 :param identifiers: A list of identifiers. 

939 :param modeViewIndication: Reference to the mode view applied to this port. 

940 :param documentation: The documentation comment associated with this declaration. 

941 :param parent: The parent model entity of this entity. 

942 """ 

943 super().__init__(identifiers, modeViewIndication, None, documentation, parent) 

944 WithSingleDeclarationsMixin.__init__(self) 

945 

946 def Visit(self, visitor: Visitor) -> None: 

947 """ 

948 Walk this port and its mode view indication with a visitor. 

949 

950 :param visitor: The visitor receiving the events. 

951 """ 

952 visitor.VisitPortViewSignalInterfaceItem(self) 

953 self._subtype.Visit(visitor) 

954 visitor.DepartPortViewSignalInterfaceItem(self) 

955 

956 @readonly 

957 def ModeViewIndication(self) -> ModeViewSymbol: 

958 """ 

959 Read-only property to access the mode view indication (:attr:`_subtype`). 

960 

961 :returns: The mode view indication. 

962 """ 

963 return self._subtype 

964 

965 def Copy(self) -> Self: 

966 """ 

967 Create a copy of this port declared with a mode view. 

968 

969 The copy has no parent and no object vertex. Its mode view indication is a copy of this item's mode view 

970 indication. 

971 

972 :returns: The new port declared with a mode view. 

973 """ 

974 return self.__class__(self._identifiers, self._subtype.Copy(), self._documentation) 

975 

976 def __str__(self) -> str: 

977 """ 

978 Formats the port declared with a mode view. 

979 

980 **Format:** ``signal p : view myView`` 

981 

982 :returns: Formatted port declared with a mode view. 

983 """ 

984 return self._FormatInterfaceItem(isModeView=True) 

985 

986 

987@export 

988class ParameterConstantInterfaceItem( 

989 Constant, 

990 ParameterInterfaceItemMixin, 

991 InterfaceItemWithModeMixin, 

992 WithSingleDeclarationsMixin 

993): 

994 """ 

995 Represents a constant parameter of a subprogram. 

996 

997 .. admonition:: Example 

998 

999 .. code-block:: VHDL 

1000 

1001 function fun(constant cst : in integer) return integer; 

1002 -- ^^^ <- Identifiers 

1003 -- ^^ <- Mode 

1004 -- ^^^^^^^ <- Subtype 

1005 """ 

1006 def __init__( 

1007 self, 

1008 identifiers: Iterable[str], 

1009 mode: Mode, 

1010 subtype: Symbol, 

1011 defaultExpression: Nullable[ExpressionUnion] = None, 

1012 documentation: Nullable[str] = None, 

1013 parent: Nullable[ModelEntity] = None 

1014 ) -> None: 

1015 """ 

1016 Initializes a constant parameter of a subprogram. 

1017 

1018 :param identifiers: A list of identifiers. 

1019 :param mode: The interface item's mode. 

1020 :param subtype: Reference to the object's subtype. 

1021 :param defaultExpression: The default value, or ``None`` if none was given. 

1022 :param documentation: The documentation comment associated with this declaration. 

1023 :param parent: The parent model entity of this entity. 

1024 """ 

1025 super().__init__(identifiers, subtype, defaultExpression, documentation, parent) 

1026 ParameterInterfaceItemMixin.__init__(self) 

1027 InterfaceItemWithModeMixin.__init__(self, mode) 

1028 WithSingleDeclarationsMixin.__init__(self) 

1029 

1030 def Copy(self) -> Self: 

1031 """ 

1032 Create a copy of this constant parameter. 

1033 

1034 The copy has no parent and no object vertex. Its subtype and default expression are copies of this item's 

1035 subtype and default expression. 

1036 

1037 :returns: The new constant parameter. 

1038 """ 

1039 defaultExpression = None if self._defaultExpression is None else self._defaultExpression.Copy() 

1040 return self.__class__( 

1041 self._identifiers, 

1042 self._mode, 

1043 self._subtype.Copy(), 

1044 defaultExpression, 

1045 self._documentation 

1046 ) 

1047 

1048 def Visit(self, visitor: Visitor) -> None: 

1049 """ 

1050 Walk this constant parameter, its subtype and its default expression with a visitor. 

1051 

1052 :param visitor: The visitor receiving the events. 

1053 """ 

1054 visitor.VisitParameterConstantInterfaceItem(self) 

1055 self._subtype.Visit(visitor) 

1056 self._VisitDefaultExpression(visitor) 

1057 visitor.DepartParameterConstantInterfaceItem(self) 

1058 

1059 def __str__(self) -> str: 

1060 """ 

1061 Formats the constant parameter. 

1062 

1063 **Format:** ``constant a : in integer`` 

1064 

1065 :returns: Formatted constant parameter. 

1066 """ 

1067 return self._FormatInterfaceItem(self._mode) 

1068 

1069 

1070@export 

1071class ParameterVariableInterfaceItem( 

1072 Variable, 

1073 ParameterInterfaceItemMixin, 

1074 InterfaceItemWithModeMixin, 

1075 WithSingleDeclarationsMixin 

1076): 

1077 """ 

1078 Represents a variable parameter of a subprogram. 

1079 

1080 .. admonition:: Example 

1081 

1082 .. code-block:: VHDL 

1083 

1084 procedure proc(variable var : out bit); 

1085 -- ^^^ <- Identifiers 

1086 -- ^^^ <- Mode 

1087 -- ^^^ <- Subtype 

1088 """ 

1089 def __init__( 

1090 self, 

1091 identifiers: Iterable[str], 

1092 mode: Mode, 

1093 subtype: Symbol, 

1094 defaultExpression: Nullable[ExpressionUnion] = None, 

1095 documentation: Nullable[str] = None, 

1096 parent: Nullable[ModelEntity] = None 

1097 ) -> None: 

1098 """ 

1099 Initializes a variable parameter of a subprogram. 

1100 

1101 :param identifiers: A list of identifiers. 

1102 :param mode: The interface item's mode. 

1103 :param subtype: Reference to the object's subtype. 

1104 :param defaultExpression: The default value, or ``None`` if none was given. 

1105 :param documentation: The documentation comment associated with this declaration. 

1106 :param parent: The parent model entity of this entity. 

1107 """ 

1108 super().__init__(identifiers, subtype, defaultExpression, documentation, parent) 

1109 ParameterInterfaceItemMixin.__init__(self) 

1110 InterfaceItemWithModeMixin.__init__(self, mode) 

1111 WithSingleDeclarationsMixin.__init__(self) 

1112 

1113 def Copy(self) -> Self: 

1114 """ 

1115 Create a copy of this variable parameter. 

1116 

1117 The copy has no parent and no object vertex. Its subtype and default expression are copies of this item's 

1118 subtype and default expression. 

1119 

1120 :returns: The new variable parameter. 

1121 """ 

1122 defaultExpression = None if self._defaultExpression is None else self._defaultExpression.Copy() 

1123 return self.__class__( 

1124 self._identifiers, 

1125 self._mode, 

1126 self._subtype.Copy(), 

1127 defaultExpression, 

1128 self._documentation 

1129 ) 

1130 

1131 def Visit(self, visitor: Visitor) -> None: 

1132 """ 

1133 Walk this variable parameter, its subtype and its default expression with a visitor. 

1134 

1135 :param visitor: The visitor receiving the events. 

1136 """ 

1137 visitor.VisitParameterVariableInterfaceItem(self) 

1138 self._subtype.Visit(visitor) 

1139 self._VisitDefaultExpression(visitor) 

1140 visitor.DepartParameterVariableInterfaceItem(self) 

1141 

1142 def __str__(self) -> str: 

1143 """ 

1144 Formats the variable parameter. 

1145 

1146 **Format:** ``variable v : inout integer`` 

1147 

1148 :returns: Formatted variable parameter. 

1149 """ 

1150 return self._FormatInterfaceItem(self._mode) 

1151 

1152 

1153@export 

1154@abstractclass 

1155class ParameterSignalInterfaceItem(Signal, ParameterInterfaceItemMixin): 

1156 """ 

1157 Represents a signal parameter of a subprogram. 

1158 

1159 .. admonition:: Example 

1160 

1161 .. code-block:: VHDL 

1162 

1163 procedure proc(signal sig : in bit); 

1164 -- ^^^ <- Identifiers 

1165 -- ^^ <- Mode 

1166 -- ^^^ <- Subtype 

1167 

1168 .. seealso:: 

1169 

1170 * :class:`Parameter simple signal interface item <pyVHDLModel.Interface.ParameterSimpleSignalInterfaceItem>` 

1171 * :class:`Parameter view signal interface item <pyVHDLModel.Interface.ParameterViewSignalInterfaceItem>` 

1172 """ 

1173 

1174 

1175@export 

1176class ParameterSimpleSignalInterfaceItem( 

1177 ParameterSignalInterfaceItem, 

1178 InterfaceItemWithModeMixin, 

1179 WithSingleDeclarationsMixin 

1180): 

1181 """ 

1182 Represents a signal parameter declared with a simple mode. 

1183 

1184 The parameter's mode is available as :data:`Mode`, its subtype as :data:`Subtype`. 

1185 

1186 .. admonition:: Example 

1187 

1188 .. code-block:: VHDL 

1189 

1190 procedure proc(signal sig : in bit); 

1191 -- ^^^ <- Identifiers 

1192 -- ^^ <- Mode 

1193 -- ^^^ <- Subtype 

1194 """ 

1195 

1196 def __init__( 

1197 self, 

1198 identifiers: Iterable[str], 

1199 mode: Mode, 

1200 subtype: Symbol, 

1201 defaultExpression: Nullable[ExpressionUnion] = None, 

1202 documentation: Nullable[str] = None, 

1203 parent: Nullable[ModelEntity] = None 

1204 ) -> None: 

1205 """ 

1206 Initializes a signal parameter declared with a simple mode. 

1207 

1208 :param identifiers: A list of identifiers. 

1209 :param mode: The interface item's mode. 

1210 :param subtype: Reference to the object's subtype. 

1211 :param defaultExpression: The default value, or ``None`` if none was given. 

1212 :param documentation: The documentation comment associated with this declaration. 

1213 :param parent: The parent model entity of this entity. 

1214 """ 

1215 super().__init__(identifiers, subtype, defaultExpression, documentation, parent) 

1216 ParameterInterfaceItemMixin.__init__(self) 

1217 InterfaceItemWithModeMixin.__init__(self, mode) 

1218 WithSingleDeclarationsMixin.__init__(self) 

1219 

1220 def Copy(self) -> Self: 

1221 """ 

1222 Create a copy of this signal parameter. 

1223 

1224 The copy has no parent and no object vertex. Its subtype and default expression are copies of this item's 

1225 subtype and default expression. 

1226 

1227 :returns: The new signal parameter. 

1228 """ 

1229 defaultExpression = None if self._defaultExpression is None else self._defaultExpression.Copy() 

1230 return self.__class__( 

1231 self._identifiers, 

1232 self._mode, 

1233 self._subtype.Copy(), 

1234 defaultExpression, 

1235 self._documentation 

1236 ) 

1237 

1238 def Visit(self, visitor: Visitor) -> None: 

1239 """ 

1240 Walk this signal parameter, its subtype and its default expression with a visitor. 

1241 

1242 :param visitor: The visitor receiving the events. 

1243 """ 

1244 visitor.VisitParameterSimpleSignalInterfaceItem(self) 

1245 self._subtype.Visit(visitor) 

1246 self._VisitDefaultExpression(visitor) 

1247 visitor.DepartParameterSimpleSignalInterfaceItem(self) 

1248 

1249 def __str__(self) -> str: 

1250 """ 

1251 Formats the signal parameter. 

1252 

1253 **Format:** ``signal s : in bit`` 

1254 

1255 :returns: Formatted signal parameter. 

1256 """ 

1257 return self._FormatInterfaceItem(self._mode) 

1258 

1259 

1260@export 

1261class ParameterViewSignalInterfaceItem(ParameterSignalInterfaceItem, WithSingleDeclarationsMixin): 

1262 """ 

1263 Represents a signal parameter declared with a mode view (VHDL-2019). 

1264 

1265 Instead of a mode, the parameter names a mode view (:data:`ModeViewIndication`) that assigns a mode 

1266 to each element of its record type. 

1267 

1268 .. admonition:: Example 

1269 

1270 .. code-block:: VHDL 

1271 

1272 procedure proc(signal sig : view MasterView); 

1273 -- ^^^ <- Identifiers 

1274 -- ^^^^^^^^^^ <- ModeViewIndication 

1275 

1276 .. seealso:: 

1277 

1278 * :class:`Mode view declaration <pyVHDLModel.Interface.ModeViewDeclaration>` 

1279 * :class:`Parameter declared with a simple mode <pyVHDLModel.Interface.ParameterSimpleSignalInterfaceItem>` 

1280 """ 

1281 

1282 def __init__( 

1283 self, 

1284 identifiers: Iterable[str], 

1285 modeViewIndication: ModeViewSymbol, 

1286 documentation: Nullable[str] = None, 

1287 parent: Nullable[ModelEntity] = None 

1288 ) -> None: 

1289 """ 

1290 Initializes a signal parameter declared with a mode view (VHDL-2019). 

1291 

1292 :param identifiers: A list of identifiers. 

1293 :param modeViewIndication: Reference to the mode view applied to this parameter. 

1294 :param documentation: The documentation comment associated with this declaration. 

1295 :param parent: The parent model entity of this entity. 

1296 """ 

1297 super().__init__(identifiers, modeViewIndication, None, documentation, parent) 

1298 ParameterInterfaceItemMixin.__init__(self) 

1299 WithSingleDeclarationsMixin.__init__(self) 

1300 

1301 def Visit(self, visitor: Visitor) -> None: 

1302 """ 

1303 Walk this signal parameter and its mode view indication with a visitor. 

1304 

1305 :param visitor: The visitor receiving the events. 

1306 """ 

1307 visitor.VisitParameterViewSignalInterfaceItem(self) 

1308 self._subtype.Visit(visitor) 

1309 visitor.DepartParameterViewSignalInterfaceItem(self) 

1310 

1311 @readonly 

1312 def ModeViewIndication(self) -> ModeViewSymbol: 

1313 """ 

1314 Read-only property to access the mode view indication (:attr:`_subtype`). 

1315 

1316 :returns: The mode view indication. 

1317 """ 

1318 return self._subtype 

1319 

1320 def Copy(self) -> Self: 

1321 """ 

1322 Create a copy of this signal parameter declared with a mode view. 

1323 

1324 The copy has no parent and no object vertex. Its mode view indication is a copy of this item's mode view 

1325 indication. 

1326 

1327 :returns: The new signal parameter declared with a mode view. 

1328 """ 

1329 return self.__class__(self._identifiers, self._subtype.Copy(), self._documentation) 

1330 

1331 def __str__(self) -> str: 

1332 """ 

1333 Formats the signal parameter declared with a mode view. 

1334 

1335 **Format:** ``signal s : view myView`` 

1336 

1337 :returns: Formatted signal parameter declared with a mode view. 

1338 """ 

1339 return self._FormatInterfaceItem(isModeView=True) 

1340 

1341 

1342@export 

1343class ParameterFileInterfaceItem(File, ParameterInterfaceItemMixin, WithSingleDeclarationsMixin): 

1344 """ 

1345 Represents a file parameter of a subprogram. 

1346 

1347 .. admonition:: Example 

1348 

1349 .. code-block:: VHDL 

1350 

1351 procedure proc(file fil : text_file); 

1352 -- ^^^ <- Identifiers 

1353 -- ^^^^^^^^^ <- Subtype 

1354 """ 

1355 def __init__( 

1356 self, 

1357 identifiers: Iterable[str], 

1358 subtype: Symbol, 

1359 documentation: Nullable[str] = None, 

1360 parent: Nullable[ModelEntity] = None 

1361 ) -> None: 

1362 """ 

1363 Initializes a file parameter of a subprogram. 

1364 

1365 :param identifiers: A list of identifiers. 

1366 :param subtype: Reference to the object's subtype. 

1367 :param documentation: The documentation comment associated with this declaration. 

1368 :param parent: The parent model entity of this entity. 

1369 """ 

1370 super().__init__(identifiers, subtype, documentation, parent) 

1371 ParameterInterfaceItemMixin.__init__(self) 

1372 WithSingleDeclarationsMixin.__init__(self) 

1373 

1374 def Copy(self) -> Self: 

1375 """ 

1376 Create a copy of this file parameter. 

1377 

1378 The copy has no parent and no object vertex. Its subtype is a copy of this item's subtype. 

1379 

1380 :returns: The new file parameter. 

1381 """ 

1382 return self.__class__(self._identifiers, self._subtype.Copy(), self._documentation) 

1383 

1384 def Visit(self, visitor: Visitor) -> None: 

1385 """ 

1386 Walk this file parameter and its subtype with a visitor. 

1387 

1388 :param visitor: The visitor receiving the events. 

1389 """ 

1390 visitor.VisitParameterFileInterfaceItem(self) 

1391 self._subtype.Visit(visitor) 

1392 visitor.DepartParameterFileInterfaceItem(self) 

1393 

1394 def __str__(self) -> str: 

1395 """ 

1396 Formats the file parameter. 

1397 

1398 **Format:** ``file f : text`` 

1399 

1400 :returns: Formatted file parameter. 

1401 """ 

1402 return self._FormatInterfaceItem() 

1403 

1404 

1405@export 

1406class SingleDeclarationMixin(metaclass=ExtendedType, mixin=True, expects=("_parent", )): 

1407 """ 

1408 A mixin-class for one identifier of a declaration with an identifier list. 

1409 

1410 A declaration may declare several identifiers sharing one specification (``a, b : in bit``). IEEE Std 1076 defines it 

1411 as equivalent to a sequence of single declarations, one per identifier, in list order. A single declaration 

1412 represents one of them: it has its own identifier and its position in the identifier list, and it accesses the 

1413 specification of its declaration, which is its parent. The declaration creates its single declarations on first 

1414 access of :data:`~pyVHDLModel.Interface.WithSingleDeclarationsMixin.SingleDeclarations` and keeps them; they aren't 

1415 part of the model's declarations. 

1416 

1417 .. seealso:: 

1418 

1419 :class:`~pyVHDLModel.Interface.SingleGenericDeclarationMixin` 

1420 |rarr| A single declaration of a generic. 

1421 :class:`~pyVHDLModel.Interface.SinglePortDeclarationMixin` 

1422 |rarr| A single declaration of a port. 

1423 :class:`~pyVHDLModel.Interface.SingleParameterDeclarationMixin` 

1424 |rarr| A single declaration of a parameter. 

1425 """ 

1426 

1427 _DECLARATION_TYPE: ClassVar[type] #: Accepted type of the declaration. 

1428 

1429 _identifier: str #: The identifier. 

1430 _normalizedIdentifier: str #: The normalized (lower case) identifier. 

1431 _position: int #: The identifier's position in the declaration's identifier list. 

1432 

1433 def __init__(self, identifier: str, normalizedIdentifier: str, position: int) -> None: 

1434 """ 

1435 Initializes a single declaration of one identifier of its parent declaration. 

1436 

1437 The declaration creates its single declarations (:data:`WithSingleDeclarationsMixin.SingleDeclarations`) and 

1438 passes each identifier as declared, normalized and with its position. 

1439 

1440 :param identifier: The identifier, as declared. 

1441 :param normalizedIdentifier: The normalized (lower case) identifier. 

1442 :param position: The identifier's position in the declaration's identifier list. 

1443 :raises ValueError: If parameter 'parent' is None. 

1444 :raises TypeError: If parameter 'parent' is not of the declaration type this class accepts. 

1445 """ 

1446 if self._parent is None: 

1447 raise ValueError("Parameter 'parent' is None.") 

1448 elif not isinstance(self._parent, self._DECLARATION_TYPE): 

1449 ex = TypeError(f"Parameter 'parent' is not of type '{self._DECLARATION_TYPE.__name__}'.") 

1450 ex.add_note(f"Got type '{getFullyQualifiedName(self._parent)}'.") 

1451 raise ex 

1452 

1453 self._identifier = identifier 

1454 self._normalizedIdentifier = normalizedIdentifier 

1455 self._position = position 

1456 

1457 @readonly 

1458 def Identifier(self) -> str: 

1459 """ 

1460 Read-only property to access the identifier (:attr:`_identifier`). 

1461 

1462 :returns: The identifier, as declared. 

1463 """ 

1464 return self._identifier 

1465 

1466 @readonly 

1467 def NormalizedIdentifier(self) -> str: 

1468 """ 

1469 Read-only property to access the normalized identifier (:attr:`_normalizedIdentifier`). 

1470 

1471 :returns: The normalized (lower case) identifier. 

1472 """ 

1473 return self._normalizedIdentifier 

1474 

1475 @readonly 

1476 def Position(self) -> int: 

1477 """ 

1478 Read-only property to access the identifier's position in the declaration's identifier list (:attr:`_position`). 

1479 

1480 :returns: The zero-based position of the identifier. 

1481 """ 

1482 return self._position 

1483 

1484 @readonly 

1485 def Declaration(self) -> MultipleNamedEntityMixin: 

1486 """ 

1487 Read-only property to access the declaration, which is the single declaration's parent (:attr:`_parent`). 

1488 

1489 :returns: The declaration with the identifier list. 

1490 """ 

1491 return self._parent 

1492 

1493 @readonly 

1494 def Subtype(self) -> Symbol: 

1495 """ 

1496 Read-only property to access the subtype of the declaration. 

1497 

1498 :returns: The declaration's subtype, or its mode view indication if it's declared with a mode view. 

1499 """ 

1500 return self._parent._subtype 

1501 

1502 @readonly 

1503 def Documentation(self) -> Nullable[str]: 

1504 """ 

1505 Read-only property to access the documentation of the declaration. 

1506 

1507 :returns: The declaration's documentation, or ``None`` if it has none. 

1508 """ 

1509 return self._parent._documentation 

1510 

1511 def __str__(self) -> str: 

1512 """ 

1513 Formats the single declaration as its identifier. 

1514 

1515 **Format:** ``a`` 

1516 

1517 :returns: The identifier. 

1518 """ 

1519 return self._identifier 

1520 

1521 

1522@export 

1523class SingleDeclarationWithModeMixin(metaclass=ExtendedType, mixin=True, expects=("_parent", )): 

1524 """ 

1525 A mixin-class for single declarations of a declaration with a mode. 

1526 

1527 The mode of the declaration is available as :data:`Mode`. 

1528 """ 

1529 

1530 @readonly 

1531 def Mode(self) -> Mode: 

1532 """ 

1533 Read-only property to access the mode of the declaration. 

1534 

1535 :returns: The declaration's mode. 

1536 """ 

1537 return self._parent._mode 

1538 

1539 

1540@export 

1541class SingleDeclarationWithDefaultExpressionMixin(metaclass=ExtendedType, mixin=True, expects=("_parent", )): 

1542 """ 

1543 A mixin-class for single declarations of a declaration with an optional default expression. 

1544 

1545 The default expression of the declaration is available as :data:`DefaultExpression`. 

1546 """ 

1547 

1548 @readonly 

1549 def DefaultExpression(self) -> Nullable[ExpressionUnion]: 

1550 """ 

1551 Read-only property to access the default expression of the declaration. 

1552 

1553 :returns: The declaration's default expression, or ``None`` if none was given. 

1554 """ 

1555 return self._parent._defaultExpression 

1556 

1557 

1558@export 

1559class SingleGenericDeclarationMixin(SingleDeclarationMixin, mixin=True): 

1560 """ 

1561 A mixin-class for single declarations of a generic. 

1562 

1563 Only a generic constant has an identifier list. A generic type, subprogram or package declares exactly one 

1564 identifier. 

1565 

1566 .. seealso:: 

1567 

1568 :class:`~pyVHDLModel.Interface.SingleGenericConstantDeclaration` 

1569 |rarr| One identifier of a generic constant. 

1570 """ 

1571 

1572 

1573@export 

1574class SinglePortDeclarationMixin(SingleDeclarationMixin, mixin=True): 

1575 """ 

1576 A mixin-class for single declarations of a port. 

1577 

1578 .. seealso:: 

1579 

1580 :class:`~pyVHDLModel.Interface.SinglePortSimpleSignalDeclaration` 

1581 |rarr| One identifier of a port with a mode. 

1582 :class:`~pyVHDLModel.Interface.SinglePortViewSignalDeclaration` 

1583 |rarr| One identifier of a port with a mode view. 

1584 """ 

1585 

1586 

1587@export 

1588class SingleParameterDeclarationMixin(SingleDeclarationMixin, mixin=True): 

1589 """ 

1590 A mixin-class for single declarations of a parameter. 

1591 

1592 .. seealso:: 

1593 

1594 :class:`~pyVHDLModel.Interface.SingleParameterConstantDeclaration` 

1595 |rarr| One identifier of a constant parameter. 

1596 :class:`~pyVHDLModel.Interface.SingleParameterVariableDeclaration` 

1597 |rarr| One identifier of a variable parameter. 

1598 :class:`~pyVHDLModel.Interface.SingleParameterSimpleSignalDeclaration` 

1599 |rarr| One identifier of a signal parameter with a mode. 

1600 :class:`~pyVHDLModel.Interface.SingleParameterViewSignalDeclaration` 

1601 |rarr| One identifier of a signal parameter with a mode view. 

1602 :class:`~pyVHDLModel.Interface.SingleParameterFileDeclaration` 

1603 |rarr| One identifier of a file parameter. 

1604 """ 

1605 

1606 

1607@export 

1608class SingleGenericConstantDeclaration( 

1609 ModelEntity, 

1610 SingleGenericDeclarationMixin, 

1611 SingleDeclarationWithModeMixin, 

1612 SingleDeclarationWithDefaultExpressionMixin 

1613): 

1614 """ 

1615 Represents one identifier of a generic constant. 

1616 

1617 .. admonition:: Example 

1618 

1619 .. code-block:: VHDL 

1620 

1621 generic (WIDTH, DEPTH : positive := 8); 

1622 -- ^^^^^ <- first single declaration 

1623 -- ^^^^^ <- second single declaration 

1624 """ 

1625 

1626 _DECLARATION_TYPE: ClassVar[type] = GenericConstantInterfaceItem #: Accepted type of the declaration. 

1627 

1628 def __init__( 

1629 self, 

1630 identifier: str, 

1631 normalizedIdentifier: str, 

1632 position: int, 

1633 *, 

1634 parent: GenericConstantInterfaceItem 

1635 ) -> None: 

1636 """ 

1637 Initializes a single declaration of one identifier of a generic constant. 

1638 

1639 :param identifier: The identifier, as declared. 

1640 :param normalizedIdentifier: The normalized (lower case) identifier. 

1641 :param position: The identifier's position in the identifier list of ``parent``. 

1642 :param parent: The generic constant declaring the identifier. 

1643 :raises ValueError: If parameter 'parent' is None. 

1644 :raises TypeError: If parameter 'parent' is not of type :class:`GenericConstantInterfaceItem`. 

1645 """ 

1646 super().__init__(parent) 

1647 SingleGenericDeclarationMixin.__init__(self, identifier, normalizedIdentifier, position) 

1648 

1649 

1650GenericConstantInterfaceItem._SINGLE_DECLARATION = SingleGenericConstantDeclaration 

1651 

1652 

1653@export 

1654class SinglePortSimpleSignalDeclaration( 

1655 ModelEntity, 

1656 SinglePortDeclarationMixin, 

1657 SingleDeclarationWithModeMixin, 

1658 SingleDeclarationWithDefaultExpressionMixin 

1659): 

1660 """ 

1661 Represents one identifier of a port with a mode. 

1662 

1663 .. admonition:: Example 

1664 

1665 .. code-block:: VHDL 

1666 

1667 port (a, b : in bit); 

1668 -- ^ <- first single declaration 

1669 -- ^ <- second single declaration 

1670 """ 

1671 

1672 _DECLARATION_TYPE: ClassVar[type] = PortSimpleSignalInterfaceItem #: Accepted type of the declaration. 

1673 

1674 def __init__( 

1675 self, 

1676 identifier: str, 

1677 normalizedIdentifier: str, 

1678 position: int, 

1679 *, 

1680 parent: PortSimpleSignalInterfaceItem 

1681 ) -> None: 

1682 """ 

1683 Initializes a single declaration of one identifier of a port with a mode. 

1684 

1685 :param identifier: The identifier, as declared. 

1686 :param normalizedIdentifier: The normalized (lower case) identifier. 

1687 :param position: The identifier's position in the identifier list of ``parent``. 

1688 :param parent: The port declaring the identifier. 

1689 :raises ValueError: If parameter 'parent' is None. 

1690 :raises TypeError: If parameter 'parent' is not of type :class:`PortSimpleSignalInterfaceItem`. 

1691 """ 

1692 super().__init__(parent) 

1693 SinglePortDeclarationMixin.__init__(self, identifier, normalizedIdentifier, position) 

1694 

1695 

1696PortSimpleSignalInterfaceItem._SINGLE_DECLARATION = SinglePortSimpleSignalDeclaration 

1697 

1698 

1699@export 

1700class SinglePortViewSignalDeclaration( 

1701 ModelEntity, 

1702 SinglePortDeclarationMixin, 

1703 SingleDeclarationWithDefaultExpressionMixin 

1704): 

1705 """ 

1706 Represents one identifier of a port with a mode view. 

1707 

1708 .. admonition:: Example 

1709 

1710 .. code-block:: VHDL 

1711 

1712 port (a, b : view axi_slave); 

1713 -- ^ <- first single declaration 

1714 -- ^ <- second single declaration 

1715 """ 

1716 

1717 _DECLARATION_TYPE: ClassVar[type] = PortViewSignalInterfaceItem #: Accepted type of the declaration. 

1718 

1719 def __init__( 

1720 self, 

1721 identifier: str, 

1722 normalizedIdentifier: str, 

1723 position: int, 

1724 *, 

1725 parent: PortViewSignalInterfaceItem 

1726 ) -> None: 

1727 """ 

1728 Initializes a single declaration of one identifier of a port with a mode view. 

1729 

1730 :param identifier: The identifier, as declared. 

1731 :param normalizedIdentifier: The normalized (lower case) identifier. 

1732 :param position: The identifier's position in the identifier list of ``parent``. 

1733 :param parent: The port declaring the identifier. 

1734 :raises ValueError: If parameter 'parent' is None. 

1735 :raises TypeError: If parameter 'parent' is not of type :class:`PortViewSignalInterfaceItem`. 

1736 """ 

1737 super().__init__(parent) 

1738 SinglePortDeclarationMixin.__init__(self, identifier, normalizedIdentifier, position) 

1739 

1740 @readonly 

1741 def ModeViewIndication(self) -> ModeViewSymbol: 

1742 """ 

1743 Read-only property to access the mode view indication of the declaration. 

1744 

1745 :returns: The declaration's mode view indication. 

1746 """ 

1747 return self._parent._subtype 

1748 

1749 

1750PortViewSignalInterfaceItem._SINGLE_DECLARATION = SinglePortViewSignalDeclaration 

1751 

1752 

1753@export 

1754class SingleParameterConstantDeclaration( 

1755 ModelEntity, 

1756 SingleParameterDeclarationMixin, 

1757 SingleDeclarationWithModeMixin, 

1758 SingleDeclarationWithDefaultExpressionMixin 

1759): 

1760 """ 

1761 Represents one identifier of a constant parameter. 

1762 

1763 .. admonition:: Example 

1764 

1765 .. code-block:: VHDL 

1766 

1767 procedure p(constant a, b : in integer); 

1768 -- ^ <- first single declaration 

1769 -- ^ <- second single declaration 

1770 """ 

1771 

1772 _DECLARATION_TYPE: ClassVar[type] = ParameterConstantInterfaceItem #: Accepted type of the declaration. 

1773 

1774 def __init__( 

1775 self, 

1776 identifier: str, 

1777 normalizedIdentifier: str, 

1778 position: int, 

1779 *, 

1780 parent: ParameterConstantInterfaceItem 

1781 ) -> None: 

1782 """ 

1783 Initializes a single declaration of one identifier of a constant parameter. 

1784 

1785 :param identifier: The identifier, as declared. 

1786 :param normalizedIdentifier: The normalized (lower case) identifier. 

1787 :param position: The identifier's position in the identifier list of ``parent``. 

1788 :param parent: The parameter declaring the identifier. 

1789 :raises ValueError: If parameter 'parent' is None. 

1790 :raises TypeError: If parameter 'parent' is not of type :class:`ParameterConstantInterfaceItem`. 

1791 """ 

1792 super().__init__(parent) 

1793 SingleParameterDeclarationMixin.__init__(self, identifier, normalizedIdentifier, position) 

1794 

1795 

1796ParameterConstantInterfaceItem._SINGLE_DECLARATION = SingleParameterConstantDeclaration 

1797 

1798 

1799@export 

1800class SingleParameterVariableDeclaration( 

1801 ModelEntity, 

1802 SingleParameterDeclarationMixin, 

1803 SingleDeclarationWithModeMixin, 

1804 SingleDeclarationWithDefaultExpressionMixin 

1805): 

1806 """ 

1807 Represents one identifier of a variable parameter. 

1808 

1809 .. admonition:: Example 

1810 

1811 .. code-block:: VHDL 

1812 

1813 procedure p(variable a, b : inout integer); 

1814 -- ^ <- first single declaration 

1815 -- ^ <- second single declaration 

1816 """ 

1817 

1818 _DECLARATION_TYPE: ClassVar[type] = ParameterVariableInterfaceItem #: Accepted type of the declaration. 

1819 

1820 def __init__( 

1821 self, 

1822 identifier: str, 

1823 normalizedIdentifier: str, 

1824 position: int, 

1825 *, 

1826 parent: ParameterVariableInterfaceItem 

1827 ) -> None: 

1828 """ 

1829 Initializes a single declaration of one identifier of a variable parameter. 

1830 

1831 :param identifier: The identifier, as declared. 

1832 :param normalizedIdentifier: The normalized (lower case) identifier. 

1833 :param position: The identifier's position in the identifier list of ``parent``. 

1834 :param parent: The parameter declaring the identifier. 

1835 :raises ValueError: If parameter 'parent' is None. 

1836 :raises TypeError: If parameter 'parent' is not of type :class:`ParameterVariableInterfaceItem`. 

1837 """ 

1838 super().__init__(parent) 

1839 SingleParameterDeclarationMixin.__init__(self, identifier, normalizedIdentifier, position) 

1840 

1841 

1842ParameterVariableInterfaceItem._SINGLE_DECLARATION = SingleParameterVariableDeclaration 

1843 

1844 

1845@export 

1846class SingleParameterSimpleSignalDeclaration( 

1847 ModelEntity, 

1848 SingleParameterDeclarationMixin, 

1849 SingleDeclarationWithModeMixin, 

1850 SingleDeclarationWithDefaultExpressionMixin 

1851): 

1852 """ 

1853 Represents one identifier of a signal parameter with a mode. 

1854 

1855 .. admonition:: Example 

1856 

1857 .. code-block:: VHDL 

1858 

1859 procedure p(signal a, b : in bit); 

1860 -- ^ <- first single declaration 

1861 -- ^ <- second single declaration 

1862 """ 

1863 

1864 _DECLARATION_TYPE: ClassVar[type] = ParameterSimpleSignalInterfaceItem #: Accepted type of the declaration. 

1865 

1866 def __init__( 

1867 self, 

1868 identifier: str, 

1869 normalizedIdentifier: str, 

1870 position: int, 

1871 *, 

1872 parent: ParameterSimpleSignalInterfaceItem 

1873 ) -> None: 

1874 """ 

1875 Initializes a single declaration of one identifier of a signal parameter with a mode. 

1876 

1877 :param identifier: The identifier, as declared. 

1878 :param normalizedIdentifier: The normalized (lower case) identifier. 

1879 :param position: The identifier's position in the identifier list of ``parent``. 

1880 :param parent: The parameter declaring the identifier. 

1881 :raises ValueError: If parameter 'parent' is None. 

1882 :raises TypeError: If parameter 'parent' is not of type :class:`ParameterSimpleSignalInterfaceItem`. 

1883 """ 

1884 super().__init__(parent) 

1885 SingleParameterDeclarationMixin.__init__(self, identifier, normalizedIdentifier, position) 

1886 

1887 

1888ParameterSimpleSignalInterfaceItem._SINGLE_DECLARATION = SingleParameterSimpleSignalDeclaration 

1889 

1890 

1891@export 

1892class SingleParameterViewSignalDeclaration( 

1893 ModelEntity, 

1894 SingleParameterDeclarationMixin, 

1895 SingleDeclarationWithDefaultExpressionMixin 

1896): 

1897 """ 

1898 Represents one identifier of a signal parameter with a mode view. 

1899 

1900 .. admonition:: Example 

1901 

1902 .. code-block:: VHDL 

1903 

1904 procedure p(signal a, b : view axi_slave); 

1905 -- ^ <- first single declaration 

1906 -- ^ <- second single declaration 

1907 """ 

1908 

1909 _DECLARATION_TYPE: ClassVar[type] = ParameterViewSignalInterfaceItem #: Accepted type of the declaration. 

1910 

1911 def __init__( 

1912 self, 

1913 identifier: str, 

1914 normalizedIdentifier: str, 

1915 position: int, 

1916 *, 

1917 parent: ParameterViewSignalInterfaceItem 

1918 ) -> None: 

1919 """ 

1920 Initializes a single declaration of one identifier of a signal parameter with a mode view. 

1921 

1922 :param identifier: The identifier, as declared. 

1923 :param normalizedIdentifier: The normalized (lower case) identifier. 

1924 :param position: The identifier's position in the identifier list of ``parent``. 

1925 :param parent: The parameter declaring the identifier. 

1926 :raises ValueError: If parameter 'parent' is None. 

1927 :raises TypeError: If parameter 'parent' is not of type :class:`ParameterViewSignalInterfaceItem`. 

1928 """ 

1929 super().__init__(parent) 

1930 SingleParameterDeclarationMixin.__init__(self, identifier, normalizedIdentifier, position) 

1931 

1932 @readonly 

1933 def ModeViewIndication(self) -> ModeViewSymbol: 

1934 """ 

1935 Read-only property to access the mode view indication of the declaration. 

1936 

1937 :returns: The declaration's mode view indication. 

1938 """ 

1939 return self._parent._subtype 

1940 

1941 

1942ParameterViewSignalInterfaceItem._SINGLE_DECLARATION = SingleParameterViewSignalDeclaration 

1943 

1944 

1945@export 

1946class SingleParameterFileDeclaration(ModelEntity, SingleParameterDeclarationMixin): 

1947 """ 

1948 Represents one identifier of a file parameter. 

1949 

1950 .. admonition:: Example 

1951 

1952 .. code-block:: VHDL 

1953 

1954 procedure p(file a, b : text); 

1955 -- ^ <- first single declaration 

1956 -- ^ <- second single declaration 

1957 """ 

1958 

1959 _DECLARATION_TYPE: ClassVar[type] = ParameterFileInterfaceItem #: Accepted type of the declaration. 

1960 

1961 def __init__( 

1962 self, 

1963 identifier: str, 

1964 normalizedIdentifier: str, 

1965 position: int, 

1966 *, 

1967 parent: ParameterFileInterfaceItem 

1968 ) -> None: 

1969 """ 

1970 Initializes a single declaration of one identifier of a file parameter. 

1971 

1972 :param identifier: The identifier, as declared. 

1973 :param normalizedIdentifier: The normalized (lower case) identifier. 

1974 :param position: The identifier's position in the identifier list of ``parent``. 

1975 :param parent: The parameter declaring the identifier. 

1976 :raises ValueError: If parameter 'parent' is None. 

1977 :raises TypeError: If parameter 'parent' is not of type :class:`ParameterFileInterfaceItem`. 

1978 """ 

1979 super().__init__(parent) 

1980 SingleParameterDeclarationMixin.__init__(self, identifier, normalizedIdentifier, position) 

1981 

1982 

1983ParameterFileInterfaceItem._SINGLE_DECLARATION = SingleParameterFileDeclaration 

1984 

1985 

1986@export 

1987class InterfaceGroup(ModelEntity, OptionallyNamedEntityMixin, DocumentedEntityMixin): 

1988 """ 

1989 Represents a group of interface items sharing one clause. 

1990 

1991 The group may be named (:data:`Identifier`), which is optional. 

1992 

1993 .. seealso:: 

1994 

1995 * :class:`Generic group <pyVHDLModel.Interface.GenericGroup>` 

1996 * :class:`Port group <pyVHDLModel.Interface.PortGroup>` 

1997 * :class:`Parameter group <pyVHDLModel.Interface.ParameterGroup>` 

1998 """ 

1999 def __init__( 

2000 self, 

2001 name: Nullable[str] = None, 

2002 documentation: Nullable[str] = None, 

2003 parent: Nullable[ModelEntity] = None 

2004 ) -> None: 

2005 """ 

2006 Initializes a group of interface items sharing one clause. 

2007 

2008 :param name: The group's name. 

2009 :param documentation: The documentation comment associated with this declaration. 

2010 :param parent: The parent model entity of this entity. 

2011 """ 

2012 super().__init__(parent) 

2013 OptionallyNamedEntityMixin.__init__(self, name) 

2014 DocumentedEntityMixin.__init__(self, documentation) 

2015 

2016 def _AddToNamespace(self, element: NamedEntityMixin | MultipleNamedEntityMixin) -> None: 

2017 """ 

2018 Add nothing, because an interface group has no namespace. 

2019 

2020 :param element: The named element, e.g. an interface item. 

2021 """ 

2022 

2023 def _RemoveFromNamespace(self, element: NamedEntityMixin | MultipleNamedEntityMixin) -> None: 

2024 """ 

2025 Remove nothing, because an interface group has no namespace. 

2026 

2027 :param element: The named element, e.g. an interface item. 

2028 """ 

2029 

2030 

2031@export 

2032class GenericGroup(InterfaceGroup, WithGenericsMixin): 

2033 """ 

2034 Represents the generic clause of a design unit. 

2035 

2036 The generics are available as :data:`GenericItems`. 

2037 

2038 .. seealso:: 

2039 

2040 * :class:`Port clause <pyVHDLModel.Interface.PortGroup>` 

2041 * :class:`Parameter list <pyVHDLModel.Interface.ParameterGroup>` 

2042 """ 

2043 def __init__( 

2044 self, 

2045 genericItems: Iterable[GenericInterfaceItemMixin], 

2046 name: Nullable[str] = None, 

2047 documentation: Nullable[str] = None, 

2048 parent: Nullable[ModelEntity] = None 

2049 ) -> None: 

2050 """ 

2051 Initializes a generic group. 

2052 

2053 :param genericItems: List of all generics, in declaration order. 

2054 :param name: The group's name. 

2055 :param documentation: The documentation comment associated with this declaration. 

2056 :param parent: The parent model entity of this entity. 

2057 """ 

2058 super().__init__(name, documentation, parent) 

2059 WithGenericsMixin.__init__(self, genericItems) 

2060 

2061 def __len__(self) -> int: 

2062 """ 

2063 Returns the number of generics in this group. 

2064 

2065 :returns: Number of generics. 

2066 """ 

2067 return len(self._genericItems) 

2068 

2069 def __iter__(self) -> Iterator[GenericInterfaceItemMixin]: 

2070 """ 

2071 Iterates the generics in this group. 

2072 

2073 :returns: An iterator over the group's generics. 

2074 """ 

2075 return iter(self._genericItems) 

2076 

2077 def __str__(self) -> str: 

2078 """ 

2079 Formats the generic group. 

2080 

2081 **Format:** ``GenericGroup: myGroup (2): WIDTH, DEPTH`` 

2082 

2083 :returns: Formatted generic group. 

2084 """ 

2085 names = ", ".join(name for item in self._genericItems for name in identifiersOf(item)) 

2086 return f"GenericGroup: {self._identifier} ({len(self._genericItems)}): {names}" 

2087 

2088 def _ClashingDeclarations(self, item: NamedEntityMixin | MultipleNamedEntityMixin) -> tuple[ModelEntity, ...]: 

2089 """ 

2090 Return the generics of this group sharing an identifier with the given item. 

2091 

2092 :param item: The new generic. 

2093 :returns: Tuple of clashing generics. 

2094 """ 

2095 identifiers = set(normalizedIdentifiersOf(item)) 

2096 return tuple( 

2097 declaration for declaration in self._genericItems 

2098 if not identifiers.isdisjoint(normalizedIdentifiersOf(declaration)) 

2099 ) 

2100 

2101 

2102@export 

2103class PortGroup(InterfaceGroup, WithPortsMixin): 

2104 """ 

2105 Represents the port clause of a design unit. 

2106 

2107 The ports are available as :data:`PortItems`. 

2108 

2109 .. seealso:: 

2110 

2111 * :class:`Generic clause <pyVHDLModel.Interface.GenericGroup>` 

2112 * :class:`Parameter list <pyVHDLModel.Interface.ParameterGroup>` 

2113 """ 

2114 def __init__( 

2115 self, 

2116 portItems: Iterable[PortInterfaceItemMixin], 

2117 name: Nullable[str] = None, 

2118 documentation: Nullable[str] = None, 

2119 parent: Nullable[ModelEntity] = None 

2120 ) -> None: 

2121 """ 

2122 Initializes a port group. 

2123 

2124 :param portItems: List of all ports, in declaration order. 

2125 :param name: The group's name. 

2126 :param documentation: The documentation comment associated with this declaration. 

2127 :param parent: The parent model entity of this entity. 

2128 """ 

2129 super().__init__(name, documentation, parent) 

2130 WithPortsMixin.__init__(self, portItems) 

2131 

2132 def __len__(self) -> int: 

2133 """ 

2134 Returns the number of ports in this group. 

2135 

2136 :returns: Number of ports. 

2137 """ 

2138 return len(self._portItems) 

2139 

2140 def __iter__(self) -> Iterator[PortInterfaceItemMixin]: 

2141 """ 

2142 Iterates the ports in this group. 

2143 

2144 :returns: An iterator over the group's ports. 

2145 """ 

2146 return iter(self._portItems) 

2147 

2148 def __str__(self) -> str: 

2149 """ 

2150 Formats the port group. 

2151 

2152 **Format:** ``PortGroup: myGroup (2): clock, reset`` 

2153 

2154 :returns: Formatted port group. 

2155 """ 

2156 names = ", ".join(name for item in self._portItems for name in identifiersOf(item)) 

2157 return f"PortGroup: {self._identifier} ({len(self._portItems)}): {names}" 

2158 

2159 def _ClashingDeclarations(self, item: NamedEntityMixin | MultipleNamedEntityMixin) -> tuple[ModelEntity, ...]: 

2160 """ 

2161 Return the ports of this group sharing an identifier with the given item. 

2162 

2163 :param item: The new port. 

2164 :returns: Tuple of clashing ports. 

2165 """ 

2166 identifiers = set(normalizedIdentifiersOf(item)) 

2167 return tuple( 

2168 declaration for declaration in self._portItems 

2169 if not identifiers.isdisjoint(normalizedIdentifiersOf(declaration)) 

2170 ) 

2171 

2172 

2173@export 

2174class ParameterGroup(InterfaceGroup, WithParametersMixin): 

2175 """ 

2176 Represents the parameter list of a subprogram. 

2177 

2178 The parameters are available as :data:`ParameterItems`. 

2179 

2180 .. seealso:: 

2181 

2182 * :class:`Generic clause <pyVHDLModel.Interface.GenericGroup>` 

2183 * :class:`Port clause <pyVHDLModel.Interface.PortGroup>` 

2184 """ 

2185 def __init__( 

2186 self, 

2187 parameterItems: Iterable[ParameterInterfaceItemMixin], 

2188 name: Nullable[str] = None, 

2189 documentation: Nullable[str] = None, 

2190 parent: Nullable[ModelEntity] = None 

2191 ) -> None: 

2192 """ 

2193 Initializes a parameter group. 

2194 

2195 :param parameterItems: List of all parameters, in declaration order. 

2196 :param name: The group's name. 

2197 :param documentation: The documentation comment associated with this declaration. 

2198 :param parent: The parent model entity of this entity. 

2199 """ 

2200 super().__init__(name, documentation, parent) 

2201 WithParametersMixin.__init__(self, parameterItems) 

2202 

2203 def __len__(self) -> int: 

2204 """ 

2205 Returns the number of parameters in this group. 

2206 

2207 :returns: Number of parameters. 

2208 """ 

2209 return len(self._parameterItems) 

2210 

2211 def __iter__(self) -> Iterator[ParameterInterfaceItemMixin]: 

2212 """ 

2213 Iterates the parameters in this group. 

2214 

2215 :returns: An iterator over the group's parameters. 

2216 """ 

2217 return iter(self._parameterItems) 

2218 

2219 def __str__(self) -> str: 

2220 """ 

2221 Formats the parameter group. 

2222 

2223 **Format:** ``ParameterGroup: myGroup (2): a, b`` 

2224 

2225 :returns: Formatted parameter group. 

2226 """ 

2227 names = ", ".join(name for item in self._parameterItems for name in identifiersOf(item)) 

2228 return f"ParameterGroup: {self._identifier} ({len(self._parameterItems)}): {names}" 

2229 

2230 def _ClashingDeclarations(self, item: NamedEntityMixin | MultipleNamedEntityMixin) -> tuple[ModelEntity, ...]: 

2231 """ 

2232 Return the parameters of this group sharing an identifier with the given item. 

2233 

2234 :param item: The new parameter. 

2235 :returns: Tuple of clashing parameters. 

2236 """ 

2237 identifiers = set(normalizedIdentifiersOf(item)) 

2238 return tuple( 

2239 declaration for declaration in self._parameterItems 

2240 if not identifiers.isdisjoint(normalizedIdentifiersOf(declaration)) 

2241 ) 

2242 

2243 def _ParameterItemsChanged(self) -> None: 

2244 """Do nothing, because a parameter group keeps nothing derived from its parameters."""