Source code for pyVHDLModel.Interface

# ==================================================================================================================== #
#             __     ___   _ ____  _     __  __           _      _                                                     #
#   _ __  _   \ \   / / | | |  _ \| |   |  \/  | ___   __| | ___| |                                                    #
#  | '_ \| | | \ \ / /| |_| | | | | |   | |\/| |/ _ \ / _` |/ _ \ |                                                    #
#  | |_) | |_| |\ V / |  _  | |_| | |___| |  | | (_) | (_| |  __/ |                                                    #
#  | .__/ \__, | \_/  |_| |_|____/|_____|_|  |_|\___/ \__,_|\___|_|                                                    #
#  |_|    |___/                                                                                                        #
# ==================================================================================================================== #
# Authors:                                                                                                             #
#   Patrick Lehmann                                                                                                    #
#                                                                                                                      #
# License:                                                                                                             #
# ==================================================================================================================== #
# Copyright 2017-2023 Patrick Lehmann - Boetzingen, Germany                                                            #
# Copyright 2016-2017 Patrick Lehmann - Dresden, Germany                                                               #
#                                                                                                                      #
# Licensed under the Apache License, Version 2.0 (the "License");                                                      #
# you may not use this file except in compliance with the License.                                                     #
# You may obtain a copy of the License at                                                                              #
#                                                                                                                      #
#   http://www.apache.org/licenses/LICENSE-2.0                                                                         #
#                                                                                                                      #
# Unless required by applicable law or agreed to in writing, software                                                  #
# distributed under the License is distributed on an "AS IS" BASIS,                                                    #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.                                             #
# See the License for the specific language governing permissions and                                                  #
# limitations under the License.                                                                                       #
#                                                                                                                      #
# SPDX-License-Identifier: Apache-2.0                                                                                  #
# ==================================================================================================================== #
#
"""
This module contains parts of an abstract document language model for VHDL.

Interface items are used in generic, port and parameter declarations.
"""
from typing                 import Iterable

from pyTooling.Decorators   import export
from pyTooling.MetaClasses  import ExtendedType

from pyVHDLModel.Symbol     import Symbol
from pyVHDLModel.Base       import DocumentedEntityMixin, ExpressionUnion, Mode
from pyVHDLModel.Object     import Constant, Signal, Variable, File
from pyVHDLModel.Subprogram import Procedure, Function
from pyVHDLModel.Type       import Type


[docs] @export class InterfaceItemMixin(DocumentedEntityMixin, mixin=True): """An ``InterfaceItem`` is a base-class for all mixin-classes for all interface items."""
[docs] def __init__(self, documentation: str = None): super().__init__(documentation)
[docs] @export class InterfaceItemWithModeMixin(metaclass=ExtendedType, mixin=True): """An ``InterfaceItemWithMode`` is a mixin-class to provide a ``Mode`` to interface items.""" _mode: Mode
[docs] def __init__(self, mode: Mode): self._mode = mode
@property def Mode(self) -> Mode: return self._mode
[docs] @export class GenericInterfaceItemMixin(InterfaceItemMixin, mixin=True): """A ``GenericInterfaceItem`` is a mixin class for all generic interface items."""
[docs] @export class PortInterfaceItemMixin(InterfaceItemMixin, InterfaceItemWithModeMixin, mixin=True): """A ``PortInterfaceItem`` is a mixin class for all port interface items."""
[docs] def __init__(self, mode: Mode): super().__init__() InterfaceItemWithModeMixin.__init__(self, mode)
[docs] @export class ParameterInterfaceItemMixin(InterfaceItemMixin, mixin=True): """A ``ParameterInterfaceItem`` is a mixin class for all parameter interface items."""
[docs] @export class GenericConstantInterfaceItem(Constant, GenericInterfaceItemMixin, InterfaceItemWithModeMixin):
[docs] def __init__(self, identifiers: Iterable[str], mode: Mode, subtype: Symbol, defaultExpression: ExpressionUnion = None, documentation: str = None): super().__init__(identifiers, subtype, defaultExpression, documentation) GenericInterfaceItemMixin.__init__(self) InterfaceItemWithModeMixin.__init__(self, mode)
[docs] @export class GenericTypeInterfaceItem(Type, GenericInterfaceItemMixin):
[docs] def __init__(self, identifier: str, documentation: str = None): super().__init__(identifier, documentation) GenericInterfaceItemMixin.__init__(self)
[docs] @export class GenericSubprogramInterfaceItem(GenericInterfaceItemMixin): pass
[docs] @export class GenericProcedureInterfaceItem(Procedure, GenericInterfaceItemMixin):
[docs] def __init__(self, identifier: str, documentation: str = None): super().__init__(identifier, documentation) GenericInterfaceItemMixin.__init__(self)
[docs] @export class GenericFunctionInterfaceItem(Function, GenericInterfaceItemMixin):
[docs] def __init__(self, identifier: str, documentation: str = None): super().__init__(identifier, documentation) GenericInterfaceItemMixin.__init__(self)
[docs] @export class GenericPackageInterfaceItem(GenericInterfaceItemMixin):
[docs] def __init__(self, identifier: str, documentation: str = None): # super().__init__(identifier, documentation) GenericInterfaceItemMixin.__init__(self)
[docs] @export class PortSignalInterfaceItem(Signal, PortInterfaceItemMixin):
[docs] def __init__(self, identifiers: Iterable[str], mode: Mode, subtype: Symbol, defaultExpression: ExpressionUnion = None, documentation: str = None): super().__init__(identifiers, subtype, defaultExpression, documentation) PortInterfaceItemMixin.__init__(self, mode)
[docs] @export class ParameterConstantInterfaceItem(Constant, ParameterInterfaceItemMixin, InterfaceItemWithModeMixin):
[docs] def __init__(self, identifiers: Iterable[str], mode: Mode, subtype: Symbol, defaultExpression: ExpressionUnion = None, documentation: str = None): super().__init__(identifiers, subtype, defaultExpression, documentation) ParameterInterfaceItemMixin.__init__(self) InterfaceItemWithModeMixin.__init__(self, mode)
[docs] @export class ParameterVariableInterfaceItem(Variable, ParameterInterfaceItemMixin, InterfaceItemWithModeMixin):
[docs] def __init__(self, identifiers: Iterable[str], mode: Mode, subtype: Symbol, defaultExpression: ExpressionUnion = None, documentation: str = None): super().__init__(identifiers, subtype, defaultExpression, documentation) ParameterInterfaceItemMixin.__init__(self) InterfaceItemWithModeMixin.__init__(self, mode)
[docs] @export class ParameterSignalInterfaceItem(Signal, ParameterInterfaceItemMixin, InterfaceItemWithModeMixin):
[docs] def __init__(self, identifiers: Iterable[str], mode: Mode, subtype: Symbol, defaultExpression: ExpressionUnion = None, documentation: str = None): super().__init__(identifiers, subtype, defaultExpression, documentation) ParameterInterfaceItemMixin.__init__(self) InterfaceItemWithModeMixin.__init__(self, mode)
[docs] @export class ParameterFileInterfaceItem(File, ParameterInterfaceItemMixin):
[docs] def __init__(self, identifiers: Iterable[str], subtype: Symbol, documentation: str = None): super().__init__(identifiers, subtype, documentation) ParameterInterfaceItemMixin.__init__(self)