Coverage for pyVHDLModel/Interface.py: 65%
92 statements
« prev ^ index » next coverage.py v7.6.12, created at 2025-03-07 22:12 +0000
« prev ^ index » next coverage.py v7.6.12, created at 2025-03-07 22:12 +0000
1# ==================================================================================================================== #
2# __ ___ _ ____ _ __ __ _ _ #
3# _ __ _ \ \ / / | | | _ \| | | \/ | ___ __| | ___| | #
4# | '_ \| | | \ \ / /| |_| | | | | | | |\/| |/ _ \ / _` |/ _ \ | #
5# | |_) | |_| |\ V / | _ | |_| | |___| | | | (_) | (_| | __/ | #
6# | .__/ \__, | \_/ |_| |_|____/|_____|_| |_|\___/ \__,_|\___|_| #
7# |_| |___/ #
8# ==================================================================================================================== #
9# Authors: #
10# Patrick Lehmann #
11# #
12# License: #
13# ==================================================================================================================== #
14# Copyright 2017-2025 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.
35Interface items are used in generic, port and parameter declarations.
36"""
37from typing import Iterable, Optional as Nullable
39from pyTooling.Decorators import export, readonly
40from pyTooling.MetaClasses import ExtendedType
42from pyVHDLModel.Symbol import Symbol
43from pyVHDLModel.Base import ModelEntity, DocumentedEntityMixin, ExpressionUnion, Mode, NamedEntityMixin
44from pyVHDLModel.Object import Constant, Signal, Variable, File
45from pyVHDLModel.Subprogram import Procedure, Function
46from pyVHDLModel.Type import Type
49@export
50class InterfaceItemMixin(DocumentedEntityMixin, mixin=True):
51 """An ``InterfaceItem`` is a base-class for all mixin-classes for all interface items."""
53 def __init__(self, documentation: Nullable[str] = None) -> None:
54 super().__init__(documentation)
57@export
58class InterfaceItemWithModeMixin(metaclass=ExtendedType, mixin=True):
59 """An ``InterfaceItemWithMode`` is a mixin-class to provide a ``Mode`` to interface items."""
61 _mode: Mode
63 def __init__(self, mode: Mode) -> None:
64 self._mode = mode
66 @readonly
67 def Mode(self) -> Mode:
68 return self._mode
71@export
72class GenericInterfaceItemMixin(InterfaceItemMixin, mixin=True):
73 """A ``GenericInterfaceItem`` is a mixin class for all generic interface items."""
76@export
77class PortInterfaceItemMixin(InterfaceItemMixin, InterfaceItemWithModeMixin, mixin=True):
78 """A ``PortInterfaceItem`` is a mixin class for all port interface items."""
80 def __init__(self, mode: Mode) -> None:
81 super().__init__()
82 InterfaceItemWithModeMixin.__init__(self, mode)
85@export
86class ParameterInterfaceItemMixin(InterfaceItemMixin, mixin=True):
87 """A ``ParameterInterfaceItem`` is a mixin class for all parameter interface items."""
90@export
91class GenericConstantInterfaceItem(Constant, GenericInterfaceItemMixin, InterfaceItemWithModeMixin):
92 def __init__(
93 self,
94 identifiers: Iterable[str],
95 mode: Mode,
96 subtype: Symbol,
97 defaultExpression: Nullable[ExpressionUnion] = None,
98 documentation: Nullable[str] = None,
99 parent: ModelEntity = None
100 ) -> None:
101 super().__init__(identifiers, subtype, defaultExpression, documentation, parent)
102 GenericInterfaceItemMixin.__init__(self)
103 InterfaceItemWithModeMixin.__init__(self, mode)
106@export
107class GenericTypeInterfaceItem(Type, GenericInterfaceItemMixin):
108 def __init__(self, identifier: str, documentation: Nullable[str] = None, parent: ModelEntity = None) -> None:
109 super().__init__(identifier, documentation, parent)
110 GenericInterfaceItemMixin.__init__(self)
113@export
114class GenericSubprogramInterfaceItem(GenericInterfaceItemMixin):
115 pass
118@export
119class GenericProcedureInterfaceItem(Procedure, GenericInterfaceItemMixin):
120 def __init__(self, identifier: str, documentation: Nullable[str] = None, parent: ModelEntity = None) -> None:
121 super().__init__(identifier, documentation, parent)
122 GenericInterfaceItemMixin.__init__(self)
125@export
126class GenericFunctionInterfaceItem(Function, GenericInterfaceItemMixin):
127 def __init__(self, identifier: str, documentation: Nullable[str] = None, parent: ModelEntity = None) -> None:
128 super().__init__(identifier, documentation, parent)
129 GenericInterfaceItemMixin.__init__(self)
132@export
133class InterfacePackage(ModelEntity, NamedEntityMixin, DocumentedEntityMixin):
134 def __init__(self, identifier: str, documentation: Nullable[str] = None, parent: ModelEntity = None) -> None:
135 super().__init__(parent)
136 NamedEntityMixin.__init__(self, identifier)
137 DocumentedEntityMixin.__init__(self, documentation)
140@export
141class GenericPackageInterfaceItem(InterfacePackage, GenericInterfaceItemMixin):
142 def __init__(self, identifier: str, documentation: Nullable[str] = None, parent: ModelEntity = None) -> None:
143 super().__init__(identifier, documentation, parent)
144 GenericInterfaceItemMixin.__init__(self)
147@export
148class PortSignalInterfaceItem(Signal, PortInterfaceItemMixin):
149 def __init__(
150 self,
151 identifiers: Iterable[str],
152 mode: Mode,
153 subtype: Symbol,
154 defaultExpression: Nullable[ExpressionUnion] = None,
155 documentation: Nullable[str] = None,
156 parent: ModelEntity = None
157 ) -> None:
158 super().__init__(identifiers, subtype, defaultExpression, documentation, parent)
159 PortInterfaceItemMixin.__init__(self, mode)
162@export
163class ParameterConstantInterfaceItem(Constant, ParameterInterfaceItemMixin, InterfaceItemWithModeMixin):
164 def __init__(
165 self,
166 identifiers: Iterable[str],
167 mode: Mode,
168 subtype: Symbol,
169 defaultExpression: Nullable[ExpressionUnion] = None,
170 documentation: Nullable[str] = None,
171 parent: ModelEntity = None
172 ) -> None:
173 super().__init__(identifiers, subtype, defaultExpression, documentation, parent)
174 ParameterInterfaceItemMixin.__init__(self)
175 InterfaceItemWithModeMixin.__init__(self, mode)
178@export
179class ParameterVariableInterfaceItem(Variable, ParameterInterfaceItemMixin, InterfaceItemWithModeMixin):
180 def __init__(
181 self,
182 identifiers: Iterable[str],
183 mode: Mode,
184 subtype: Symbol,
185 defaultExpression: Nullable[ExpressionUnion] = None,
186 documentation: Nullable[str] = None,
187 parent: ModelEntity = None
188 ) -> None:
189 super().__init__(identifiers, subtype, defaultExpression, documentation, parent)
190 ParameterInterfaceItemMixin.__init__(self)
191 InterfaceItemWithModeMixin.__init__(self, mode)
194@export
195class ParameterSignalInterfaceItem(Signal, ParameterInterfaceItemMixin, InterfaceItemWithModeMixin):
196 def __init__(
197 self,
198 identifiers: Iterable[str],
199 mode: Mode,
200 subtype: Symbol,
201 defaultExpression: Nullable[ExpressionUnion] = None,
202 documentation: Nullable[str] = None,
203 parent: ModelEntity = None
204 ) -> None:
205 super().__init__(identifiers, subtype, defaultExpression, documentation, parent)
206 ParameterInterfaceItemMixin.__init__(self)
207 InterfaceItemWithModeMixin.__init__(self, mode)
210@export
211class ParameterFileInterfaceItem(File, ParameterInterfaceItemMixin):
212 def __init__(
213 self,
214 identifiers: Iterable[str],
215 subtype: Symbol,
216 documentation: Nullable[str] = None,
217 parent: ModelEntity = None
218 ) -> None:
219 super().__init__(identifiers, subtype, documentation, parent)
220 ParameterInterfaceItemMixin.__init__(self)