Coverage for pyVHDLModel/Interface.py: 66%
86 statements
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-22 22:15 +0000
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-22 22:15 +0000
1# ==================================================================================================================== #
2# __ ___ _ ____ _ __ __ _ _ #
3# _ __ _ \ \ / / | | | _ \| | | \/ | ___ __| | ___| | #
4# | '_ \| | | \ \ / /| |_| | | | | | | |\/| |/ _ \ / _` |/ _ \ | #
5# | |_) | |_| |\ V / | _ | |_| | |___| | | | (_) | (_| | __/ | #
6# | .__/ \__, | \_/ |_| |_|____/|_____|_| |_|\___/ \__,_|\___|_| #
7# |_| |___/ #
8# ==================================================================================================================== #
9# Authors: #
10# Patrick Lehmann #
11# #
12# License: #
13# ==================================================================================================================== #
14# Copyright 2017-2024 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
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 GenericPackageInterfaceItem(GenericInterfaceItemMixin):
134 def __init__(self, identifier: str, documentation: Nullable[str] = None, parent: ModelEntity = None) -> None:
135 super().__init__(identifier, documentation, parent)
136 GenericInterfaceItemMixin.__init__(self)
139@export
140class PortSignalInterfaceItem(Signal, PortInterfaceItemMixin):
141 def __init__(
142 self,
143 identifiers: Iterable[str],
144 mode: Mode,
145 subtype: Symbol,
146 defaultExpression: Nullable[ExpressionUnion] = None,
147 documentation: Nullable[str] = None,
148 parent: ModelEntity = None
149 ) -> None:
150 super().__init__(identifiers, subtype, defaultExpression, documentation, parent)
151 PortInterfaceItemMixin.__init__(self, mode)
154@export
155class ParameterConstantInterfaceItem(Constant, ParameterInterfaceItemMixin, InterfaceItemWithModeMixin):
156 def __init__(
157 self,
158 identifiers: Iterable[str],
159 mode: Mode,
160 subtype: Symbol,
161 defaultExpression: Nullable[ExpressionUnion] = None,
162 documentation: Nullable[str] = None,
163 parent: ModelEntity = None
164 ) -> None:
165 super().__init__(identifiers, subtype, defaultExpression, documentation, parent)
166 ParameterInterfaceItemMixin.__init__(self)
167 InterfaceItemWithModeMixin.__init__(self, mode)
170@export
171class ParameterVariableInterfaceItem(Variable, ParameterInterfaceItemMixin, InterfaceItemWithModeMixin):
172 def __init__(
173 self,
174 identifiers: Iterable[str],
175 mode: Mode,
176 subtype: Symbol,
177 defaultExpression: Nullable[ExpressionUnion] = None,
178 documentation: Nullable[str] = None,
179 parent: ModelEntity = None
180 ) -> None:
181 super().__init__(identifiers, subtype, defaultExpression, documentation, parent)
182 ParameterInterfaceItemMixin.__init__(self)
183 InterfaceItemWithModeMixin.__init__(self, mode)
186@export
187class ParameterSignalInterfaceItem(Signal, ParameterInterfaceItemMixin, InterfaceItemWithModeMixin):
188 def __init__(
189 self,
190 identifiers: Iterable[str],
191 mode: Mode,
192 subtype: Symbol,
193 defaultExpression: Nullable[ExpressionUnion] = None,
194 documentation: Nullable[str] = None,
195 parent: ModelEntity = None
196 ) -> None:
197 super().__init__(identifiers, subtype, defaultExpression, documentation, parent)
198 ParameterInterfaceItemMixin.__init__(self)
199 InterfaceItemWithModeMixin.__init__(self, mode)
202@export
203class ParameterFileInterfaceItem(File, ParameterInterfaceItemMixin):
204 def __init__(
205 self,
206 identifiers: Iterable[str],
207 subtype: Symbol,
208 documentation: Nullable[str] = None,
209 parent: ModelEntity = None
210 ) -> None:
211 super().__init__(identifiers, subtype, documentation, parent)
212 ParameterInterfaceItemMixin.__init__(self)