diff options
Diffstat (limited to 'pyGHDL/dom/InterfaceItem.py')
-rw-r--r-- | pyGHDL/dom/InterfaceItem.py | 109 |
1 files changed, 99 insertions, 10 deletions
diff --git a/pyGHDL/dom/InterfaceItem.py b/pyGHDL/dom/InterfaceItem.py index 6c0d2641b..eac92c8a6 100644 --- a/pyGHDL/dom/InterfaceItem.py +++ b/pyGHDL/dom/InterfaceItem.py @@ -30,28 +30,30 @@ # # SPDX-License-Identifier: GPL-2.0-or-later # ============================================================================ -from pyGHDL.libghdl.vhdl.nodes import Null_Iir - -from pyGHDL.libghdl.vhdl import nodes from pydecor import export from pyVHDLModel.VHDLModel import ( GenericConstantInterfaceItem as VHDLModel_GenericConstantInterfaceItem, PortSignalInterfaceItem as VHDLModel_PortSignalInterfaceItem, + ParameterConstantInterfaceItem as VHDLModel_ParameterConstantInterfaceItem, + ParameterVariableInterfaceItem as VHDLModel_ParameterVariableInterfaceItem, + ParameterSignalInterfaceItem as VHDLModel_ParameterSignalInterfaceItem, Mode, SubTypeOrSymbol, Expression, ) +from pyGHDL.libghdl.vhdl import nodes +from pyGHDL.libghdl.vhdl.nodes import Null_Iir from pyGHDL.dom._Utils import GetNameOfNode, GetModeOfNode from pyGHDL.dom._Translate import GetSubtypeIndicationFromNode, GetExpressionFromNode -from pyGHDL.dom.Common import GHDLMixin + __all__ = [] @export -class GenericConstantInterfaceItem(VHDLModel_GenericConstantInterfaceItem, GHDLMixin): +class GenericConstantInterfaceItem(VHDLModel_GenericConstantInterfaceItem): @classmethod def parse(cls, generic): name = GetNameOfNode(generic) @@ -60,9 +62,9 @@ class GenericConstantInterfaceItem(VHDLModel_GenericConstantInterfaceItem, GHDLM default = nodes.Get_Default_Value(generic) value = GetExpressionFromNode(default) if default else None - generic = cls(name, mode, subTypeIndication, value) + g = cls(name, mode, subTypeIndication, value) - return generic + return g def __init__( self, @@ -77,7 +79,7 @@ class GenericConstantInterfaceItem(VHDLModel_GenericConstantInterfaceItem, GHDLM @export -class PortSignalInterfaceItem(VHDLModel_PortSignalInterfaceItem, GHDLMixin): +class PortSignalInterfaceItem(VHDLModel_PortSignalInterfaceItem): @classmethod def parse(cls, port): name = GetNameOfNode(port) @@ -89,9 +91,96 @@ class PortSignalInterfaceItem(VHDLModel_PortSignalInterfaceItem, GHDLMixin): GetExpressionFromNode(defaultValue) if defaultValue != Null_Iir else None ) - port = cls(name, mode, subTypeIndication, value) + p = cls(name, mode, subTypeIndication, value) + + return p + + def __init__( + self, + name: str, + mode: Mode, + subType: SubTypeOrSymbol, + defaultExpression: Expression = None, + ): + super().__init__(name=name, mode=mode) + self._subType = subType + self._defaultExpression = defaultExpression + + +@export +class ParameterConstantInterfaceItem(VHDLModel_ParameterConstantInterfaceItem): + @classmethod + def parse(cls, parameter): + name = GetNameOfNode(parameter) + mode = GetModeOfNode(parameter) + subTypeIndication = GetSubtypeIndicationFromNode(parameter, "parameter", name) + + defaultValue = nodes.Get_Default_Value(parameter) + value = ( + GetExpressionFromNode(defaultValue) if defaultValue != Null_Iir else None + ) + + param = cls(name, mode, subTypeIndication, value) + + return param + + def __init__( + self, + name: str, + mode: Mode, + subType: SubTypeOrSymbol, + defaultExpression: Expression = None, + ): + super().__init__(name=name, mode=mode) + self._subType = subType + self._defaultExpression = defaultExpression + + +@export +class ParameterVariableInterfaceItem(VHDLModel_ParameterVariableInterfaceItem): + @classmethod + def parse(cls, parameter): + name = GetNameOfNode(parameter) + mode = GetModeOfNode(parameter) + subTypeIndication = GetSubtypeIndicationFromNode(parameter, "parameter", name) + + defaultValue = nodes.Get_Default_Value(parameter) + value = ( + GetExpressionFromNode(defaultValue) if defaultValue != Null_Iir else None + ) + + param = cls(name, mode, subTypeIndication, value) + + return param + + def __init__( + self, + name: str, + mode: Mode, + subType: SubTypeOrSymbol, + defaultExpression: Expression = None, + ): + super().__init__(name=name, mode=mode) + self._subType = subType + self._defaultExpression = defaultExpression + + +@export +class ParameterSignalInterfaceItem(VHDLModel_ParameterSignalInterfaceItem): + @classmethod + def parse(cls, parameter): + name = GetNameOfNode(parameter) + mode = GetModeOfNode(parameter) + subTypeIndication = GetSubtypeIndicationFromNode(parameter, "parameter", name) + + defaultValue = nodes.Get_Default_Value(parameter) + value = ( + GetExpressionFromNode(defaultValue) if defaultValue != Null_Iir else None + ) + + param = cls(name, mode, subTypeIndication, value) - return port + return param def __init__( self, |