From ca39821dc013a877a8dbdfabbc3b861eb4d4d2e3 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Mon, 26 Jul 2021 00:13:11 +0200 Subject: Adjusted to renaming in pyVHDLModel. --- pyGHDL/dom/_Translate.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'pyGHDL/dom/_Translate.py') diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index fc804caf4..46cb352c7 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -9,7 +9,7 @@ # Authors: # Patrick Lehmann # -# Package module: DOM: Interface items (e.g. generic or port) +# Package module: DOM: IIR to *** translations. # # License: # ============================================================================ @@ -34,10 +34,7 @@ from typing import List, Generator from pydecor import export -from pyGHDL.dom import Position, DOMException -from pyGHDL.dom.Object import Variable -from pyGHDL.dom.PSL import DefaultClock -from pyVHDLModel.VHDLModel import ( +from pyVHDLModel.SyntaxModel import ( Constraint, Direction, Expression, @@ -53,6 +50,7 @@ from pyVHDLModel.VHDLModel import ( from pyGHDL.libghdl import utils from pyGHDL.libghdl._types import Iir from pyGHDL.libghdl.vhdl import nodes +from pyGHDL.dom import Position, DOMException from pyGHDL.dom._Utils import ( GetNameOfNode, GetIirKindOfNode, @@ -94,6 +92,7 @@ from pyGHDL.dom.Literal import ( PhysicalFloatingLiteral, NullLiteral, ) +from pyGHDL.dom.Object import Variable from pyGHDL.dom.Expression import ( SubtractionExpression, AdditionExpression, @@ -140,6 +139,7 @@ from pyGHDL.dom.Expression import ( ) from pyGHDL.dom.Subprogram import Function, Procedure from pyGHDL.dom.Misc import Alias +from pyGHDL.dom.PSL import DefaultClock __all__ = [] -- cgit v1.2.3 From 587ec3d1822b34875c12d7daf79bbc3dfcb13533 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Mon, 26 Jul 2021 00:39:26 +0200 Subject: Wrap typeMarks in a SimpleName. --- pyGHDL/dom/_Translate.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'pyGHDL/dom/_Translate.py') diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index 46cb352c7..2cceec4e3 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -348,9 +348,10 @@ def GetScalarConstrainedSubtypeFromNode( ) -> ConstrainedScalarSubtypeSymbol: typeMark = nodes.Get_Subtype_Type_Mark(subtypeIndicationNode) typeMarkName = GetNameOfNode(typeMark) + simpleTypeMark = SimpleName(typeMark, typeMarkName) rangeConstraint = nodes.Get_Range_Constraint(subtypeIndicationNode) r = GetRangeFromNode(rangeConstraint) - return ConstrainedScalarSubtypeSymbol(subtypeIndicationNode, typeMarkName, r) + return ConstrainedScalarSubtypeSymbol(subtypeIndicationNode, simpleTypeMark, r) @export @@ -359,10 +360,11 @@ def GetCompositeConstrainedSubtypeFromNode( ) -> ConstrainedCompositeSubtypeSymbol: typeMark = nodes.Get_Subtype_Type_Mark(subtypeIndicationNode) typeMarkName = GetNameOfNode(typeMark) + simpleTypeMark = SimpleName(typeMark, typeMarkName) constraints = GetArrayConstraintsFromSubtypeIndication(subtypeIndicationNode) return ConstrainedCompositeSubtypeSymbol( - subtypeIndicationNode, typeMarkName, constraints + subtypeIndicationNode, simpleTypeMark, constraints ) -- cgit v1.2.3 From 7d1f39e542f9ca00bd56b96337fcf82314de538f Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Mon, 26 Jul 2021 00:40:36 +0200 Subject: Fixed typo in IIR translation of Greater_Than_Or_Equal_Operator: should be GreaterEqualExpression. --- pyGHDL/dom/_Translate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pyGHDL/dom/_Translate.py') diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index 2cceec4e3..cbe707319 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -425,7 +425,7 @@ __EXPRESSION_TRANSLATION = { nodes.Iir_Kind.Less_Than_Operator: LessThanExpression, nodes.Iir_Kind.Less_Than_Or_Equal_Operator: LessEqualExpression, nodes.Iir_Kind.Greater_Than_Operator: GreaterThanExpression, - nodes.Iir_Kind.Greater_Than_Or_Equal_Operator: MatchingGreaterEqualExpression, + nodes.Iir_Kind.Greater_Than_Or_Equal_Operator: GreaterEqualExpression, nodes.Iir_Kind.Match_Equality_Operator: MatchingEqualExpression, nodes.Iir_Kind.Match_Inequality_Operator: MatchingUnequalExpression, nodes.Iir_Kind.Match_Less_Than_Operator: MatchingLessThanExpression, -- cgit v1.2.3 From 5fae449cbac688b5779f0ef2ec2052bb3f9bed00 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Mon, 26 Jul 2021 01:21:36 +0200 Subject: Needed for changes in prettyprint for the Identifier(s) change in pyVHDLModel. --- pyGHDL/dom/_Translate.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'pyGHDL/dom/_Translate.py') diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index cbe707319..adff02041 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -301,8 +301,6 @@ def GetAnonymousTypeFromNode(node: Iir) -> BaseType: @export def GetSubtypeIndicationFromNode(node: Iir, entity: str, name: str) -> SubtypeOrSymbol: subtypeIndicationNode = nodes.Get_Subtype_Indication(node) - # if subtypeIndicationNode is nodes.Null_Iir: - # return None return GetSubtypeIndicationFromIndicationNode(subtypeIndicationNode, entity, name) -- cgit v1.2.3 From 1a67eb54fc54601dd4945d75d53da87b8e152053 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Mon, 26 Jul 2021 02:36:23 +0200 Subject: Handle declarations with multiple identifiers. --- pyGHDL/dom/_Translate.py | 106 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 73 insertions(+), 33 deletions(-) (limited to 'pyGHDL/dom/_Translate.py') diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index adff02041..3a10eba3b 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -266,7 +266,6 @@ def GetAnonymousTypeFromNode(node: Iir) -> BaseType: typeName = GetNameOfNode(node) typeDefinition = nodes.Get_Type_Definition(node) if typeDefinition is nodes.Null_Iir: - print(1, node, typeName) return IncompleteType(node, typeName) kind = GetIirKindOfNode(typeDefinition) @@ -309,12 +308,8 @@ def GetSubtypeIndicationFromIndicationNode( subtypeIndicationNode: Iir, entity: str, name: str ) -> SubtypeOrSymbol: if subtypeIndicationNode is nodes.Null_Iir: - print( - "[NOT IMPLEMENTED]: Unhandled multiple declarations for {entity} '{name}'.".format( - entity=entity, name=name - ) - ) - return None + raise ValueError("Parameter 'subtypeIndicationNode' is 'Null_Iir'.") + kind = GetIirKindOfNode(subtypeIndicationNode) if kind in ( nodes.Iir_Kind.Simple_Name, @@ -475,45 +470,75 @@ def GetGenericsFromChainedNodes( GenericFunctionInterfaceItem, ) - for generic in utils.chain_iter(nodeChain): + generic = nodeChain + while generic != nodes.Null_Iir: kind = GetIirKindOfNode(generic) if kind == nodes.Iir_Kind.Interface_Constant_Declaration: from pyGHDL.dom.InterfaceItem import GenericConstantInterfaceItem - yield GenericConstantInterfaceItem.parse(generic) - elif kind == nodes.Iir_Kind.Interface_Type_Declaration: - yield GenericTypeInterfaceItem.parse(generic) - elif kind == nodes.Iir_Kind.Interface_Package_Declaration: - yield GenericPackageInterfaceItem.parse(generic) - elif kind == nodes.Iir_Kind.Interface_Procedure_Declaration: - yield GenericProcedureInterfaceItem.parse(generic) - elif kind == nodes.Iir_Kind.Interface_Function_Declaration: - yield GenericFunctionInterfaceItem.parse(generic) + genericConstant = GenericConstantInterfaceItem.parse(generic) + + if nodes.Get_Has_Identifier_List(generic): + nextNode = nodes.Get_Chain(generic) + for nextGeneric in utils.chain_iter(nextNode): + if nodes.Get_Subtype_Indication(nextGeneric) == nodes.Null_Iir: + genericConstant.Identifiers.append(GetNameOfNode(nextGeneric)) + else: + generic = nextGeneric + break + else: + generic = nodes.Get_Chain(generic) + + yield genericConstant else: - position = Position.parse(generic) - raise DOMException( - "Unknown generic kind '{kindName}'({kind}) in generic '{generic}' at {file}:{line}:{column}.".format( - kind=kind, - kindName=kind.name, - generic=generic, - file=position.Filename, - line=position.Line, - column=position.Column, + if kind == nodes.Iir_Kind.Interface_Type_Declaration: + yield GenericTypeInterfaceItem.parse(generic) + elif kind == nodes.Iir_Kind.Interface_Package_Declaration: + yield GenericPackageInterfaceItem.parse(generic) + elif kind == nodes.Iir_Kind.Interface_Procedure_Declaration: + yield GenericProcedureInterfaceItem.parse(generic) + elif kind == nodes.Iir_Kind.Interface_Function_Declaration: + yield GenericFunctionInterfaceItem.parse(generic) + else: + position = Position.parse(generic) + raise DOMException( + "Unknown generic kind '{kindName}'({kind}) in generic '{generic}' at {file}:{line}:{column}.".format( + kind=kind, + kindName=kind.name, + generic=generic, + file=position.Filename, + line=position.Line, + column=position.Column, + ) ) - ) + + generic = nodes.Get_Chain(generic) @export def GetPortsFromChainedNodes( nodeChain: Iir, ) -> Generator[PortInterfaceItem, None, None]: - for port in utils.chain_iter(nodeChain): + + port = nodeChain + while port != nodes.Null_Iir: kind = GetIirKindOfNode(port) if kind == nodes.Iir_Kind.Interface_Signal_Declaration: from pyGHDL.dom.InterfaceItem import PortSignalInterfaceItem portSignal = PortSignalInterfaceItem.parse(port) + if nodes.Get_Has_Identifier_List(port): + nextNode = nodes.Get_Chain(port) + for nextPort in utils.chain_iter(nextNode): + if nodes.Get_Subtype_Indication(nextPort) == nodes.Null_Iir: + portSignal.Identifiers.append(GetNameOfNode(nextPort)) + else: + port = nextPort + break + else: + port = nodes.Get_Chain(port) + yield portSignal else: position = Position.parse(port) @@ -533,24 +558,26 @@ def GetPortsFromChainedNodes( def GetParameterFromChainedNodes( nodeChain: Iir, ) -> Generator[ParameterInterfaceItem, None, None]: - for parameter in utils.chain_iter(nodeChain): + + parameter = nodeChain + while parameter != nodes.Null_Iir: kind = GetIirKindOfNode(parameter) if kind == nodes.Iir_Kind.Interface_Constant_Declaration: from pyGHDL.dom.InterfaceItem import ParameterConstantInterfaceItem - yield ParameterConstantInterfaceItem.parse(parameter) + param = ParameterConstantInterfaceItem.parse(parameter) elif kind == nodes.Iir_Kind.Interface_Variable_Declaration: from pyGHDL.dom.InterfaceItem import ParameterVariableInterfaceItem - yield ParameterVariableInterfaceItem.parse(parameter) + param = ParameterVariableInterfaceItem.parse(parameter) elif kind == nodes.Iir_Kind.Interface_Signal_Declaration: from pyGHDL.dom.InterfaceItem import ParameterSignalInterfaceItem - yield ParameterSignalInterfaceItem.parse(parameter) + param = ParameterSignalInterfaceItem.parse(parameter) elif kind == nodes.Iir_Kind.Interface_File_Declaration: from pyGHDL.dom.InterfaceItem import ParameterFileInterfaceItem - yield ParameterFileInterfaceItem.parse(parameter) + param = ParameterFileInterfaceItem.parse(parameter) else: position = Position.parse(parameter) raise DOMException( @@ -564,6 +591,19 @@ def GetParameterFromChainedNodes( ) ) + if nodes.Get_Has_Identifier_List(parameter): + nextNode = nodes.Get_Chain(parameter) + for nextParameter in utils.chain_iter(nextNode): + if nodes.Get_Subtype_Indication(nextParameter) == nodes.Null_Iir: + param.Identifiers.append(GetNameOfNode(nextParameter)) + else: + parameter = nextParameter + break + else: + parameter = nodes.Get_Chain(parameter) + + yield param + def GetDeclaredItemsFromChainedNodes( nodeChain: Iir, entity: str, name: str -- cgit v1.2.3 From 77f969a11ea5ac38f007dbf3aab986dcf10125b0 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Mon, 26 Jul 2021 03:11:03 +0200 Subject: Also handle multiple identifiers in signal, variable, object and file declarations. --- pyGHDL/dom/_Translate.py | 190 ++++++++++++++++++++++++++--------------------- 1 file changed, 106 insertions(+), 84 deletions(-) (limited to 'pyGHDL/dom/_Translate.py') diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index 3a10eba3b..740c613b6 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -490,6 +490,7 @@ def GetGenericsFromChainedNodes( generic = nodes.Get_Chain(generic) yield genericConstant + continue else: if kind == nodes.Iir_Kind.Interface_Type_Declaration: yield GenericTypeInterfaceItem.parse(generic) @@ -512,7 +513,7 @@ def GetGenericsFromChainedNodes( ) ) - generic = nodes.Get_Chain(generic) + generic = nodes.Get_Chain(generic) @export @@ -540,6 +541,7 @@ def GetPortsFromChainedNodes( port = nodes.Get_Chain(port) yield portSignal + continue else: position = Position.parse(port) raise DOMException( @@ -608,109 +610,129 @@ def GetParameterFromChainedNodes( def GetDeclaredItemsFromChainedNodes( nodeChain: Iir, entity: str, name: str ) -> Generator[ModelEntity, None, None]: - for item in utils.chain_iter(nodeChain): + item = nodeChain + while item != nodes.Null_Iir: kind = GetIirKindOfNode(item) if kind == nodes.Iir_Kind.Constant_Declaration: from pyGHDL.dom.Object import Constant - yield Constant.parse(item) + obj = Constant.parse(item) elif kind == nodes.Iir_Kind.Variable_Declaration: from pyGHDL.dom.Object import SharedVariable if nodes.Get_Shared_Flag(item): - yield SharedVariable.parse(item) + obj = SharedVariable.parse(item) else: - yield Variable.parse(item) + obj = Variable.parse(item) # raise DOMException("Found non-shared variable.") elif kind == nodes.Iir_Kind.Signal_Declaration: from pyGHDL.dom.Object import Signal - yield Signal.parse(item) + obj = Signal.parse(item) elif kind == nodes.Iir_Kind.File_Declaration: from pyGHDL.dom.Object import File - yield File.parse(item) - elif kind == nodes.Iir_Kind.Type_Declaration: - yield GetTypeFromNode(item) - - elif kind == nodes.Iir_Kind.Anonymous_Type_Declaration: - yield GetAnonymousTypeFromNode(item) - - elif kind == nodes.Iir_Kind.Subtype_Declaration: - yield GetSubtypeFromNode(item) - - elif kind == nodes.Iir_Kind.Function_Declaration: - yield Function.parse(item) - - elif kind == nodes.Iir_Kind.Function_Body: - # procedureName = NodeToName(item) - print("found function body '{name}'".format(name="????")) - elif kind == nodes.Iir_Kind.Procedure_Declaration: - yield Procedure.parse(item) - elif kind == nodes.Iir_Kind.Procedure_Body: - # procedureName = NodeToName(item) - print("found procedure body '{name}'".format(name="????")) - elif kind == nodes.Iir_Kind.Protected_Type_Body: - yield ProtectedTypeBody.parse(item) - elif kind == nodes.Iir_Kind.Object_Alias_Declaration: - yield GetAliasFromNode(item) - elif kind == nodes.Iir_Kind.Component_Declaration: - from pyGHDL.dom.DesignUnit import Component - - yield Component.parse(item) - elif kind == nodes.Iir_Kind.Attribute_Declaration: - from pyGHDL.dom.Attribute import Attribute - - yield Attribute.parse(item) - elif kind == nodes.Iir_Kind.Attribute_Specification: - from pyGHDL.dom.Attribute import AttributeSpecification - - yield AttributeSpecification.parse(item) - elif kind == nodes.Iir_Kind.Use_Clause: - from pyGHDL.dom.DesignUnit import UseClause - - yield UseClause.parse(item) - elif kind == nodes.Iir_Kind.Package_Declaration: - from pyGHDL.dom.DesignUnit import Package - - yield Package.parse(item) - elif kind == nodes.Iir_Kind.Package_Instantiation_Declaration: - from pyGHDL.dom.DesignUnit import PackageInstantiation - - yield PackageInstantiation.parse(item) - elif kind == nodes.Iir_Kind.Configuration_Specification: - print( - "[NOT IMPLEMENTED] Configuration specification in {name}".format( - name=name + obj = File.parse(item) + else: + if kind == nodes.Iir_Kind.Type_Declaration: + yield GetTypeFromNode(item) + + elif kind == nodes.Iir_Kind.Anonymous_Type_Declaration: + yield GetAnonymousTypeFromNode(item) + + elif kind == nodes.Iir_Kind.Subtype_Declaration: + yield GetSubtypeFromNode(item) + + elif kind == nodes.Iir_Kind.Function_Declaration: + yield Function.parse(item) + + elif kind == nodes.Iir_Kind.Function_Body: + # procedureName = NodeToName(item) + print("found function body '{name}'".format(name="????")) + elif kind == nodes.Iir_Kind.Procedure_Declaration: + yield Procedure.parse(item) + elif kind == nodes.Iir_Kind.Procedure_Body: + # procedureName = NodeToName(item) + print("found procedure body '{name}'".format(name="????")) + elif kind == nodes.Iir_Kind.Protected_Type_Body: + yield ProtectedTypeBody.parse(item) + elif kind == nodes.Iir_Kind.Object_Alias_Declaration: + yield GetAliasFromNode(item) + elif kind == nodes.Iir_Kind.Component_Declaration: + from pyGHDL.dom.DesignUnit import Component + + yield Component.parse(item) + elif kind == nodes.Iir_Kind.Attribute_Declaration: + from pyGHDL.dom.Attribute import Attribute + + yield Attribute.parse(item) + elif kind == nodes.Iir_Kind.Attribute_Specification: + from pyGHDL.dom.Attribute import AttributeSpecification + + yield AttributeSpecification.parse(item) + elif kind == nodes.Iir_Kind.Use_Clause: + from pyGHDL.dom.DesignUnit import UseClause + + yield UseClause.parse(item) + elif kind == nodes.Iir_Kind.Package_Declaration: + from pyGHDL.dom.DesignUnit import Package + + yield Package.parse(item) + elif kind == nodes.Iir_Kind.Package_Instantiation_Declaration: + from pyGHDL.dom.DesignUnit import PackageInstantiation + + yield PackageInstantiation.parse(item) + elif kind == nodes.Iir_Kind.Configuration_Specification: + print( + "[NOT IMPLEMENTED] Configuration specification in {name}".format( + name=name + ) ) - ) - elif kind == nodes.Iir_Kind.Psl_Default_Clock: - yield DefaultClock.parse(item) - elif kind == nodes.Iir_Kind.Group_Declaration: - print("[NOT IMPLEMENTED] Group declaration in {name}".format(name=name)) - elif kind == nodes.Iir_Kind.Group_Template_Declaration: - print( - "[NOT IMPLEMENTED] Group template declaration in {name}".format( - name=name + elif kind == nodes.Iir_Kind.Psl_Default_Clock: + yield DefaultClock.parse(item) + elif kind == nodes.Iir_Kind.Group_Declaration: + print("[NOT IMPLEMENTED] Group declaration in {name}".format(name=name)) + elif kind == nodes.Iir_Kind.Group_Template_Declaration: + print( + "[NOT IMPLEMENTED] Group template declaration in {name}".format( + name=name + ) ) - ) - elif kind == nodes.Iir_Kind.Disconnection_Specification: - print( - "[NOT IMPLEMENTED] Disconnect specification in {name}".format(name=name) - ) - else: - position = Position.parse(item) - raise DOMException( - "Unknown declared item kind '{kind}' in {entity} '{name}' at {file}:{line}:{column}.".format( - kind=kind.name, - entity=entity, - name=name, - file=position.Filename, - line=position.Line, - column=position.Column, + elif kind == nodes.Iir_Kind.Disconnection_Specification: + print( + "[NOT IMPLEMENTED] Disconnect specification in {name}".format( + name=name + ) ) - ) + else: + position = Position.parse(item) + raise DOMException( + "Unknown declared item kind '{kind}' in {entity} '{name}' at {file}:{line}:{column}.".format( + kind=kind.name, + entity=entity, + name=name, + file=position.Filename, + line=position.Line, + column=position.Column, + ) + ) + + item = nodes.Get_Chain(item) + continue + + if nodes.Get_Has_Identifier_List(item): + nextNode = nodes.Get_Chain(item) + for nextItem in utils.chain_iter(nextNode): + if nodes.Get_Subtype_Indication(nextItem) == nodes.Null_Iir: + obj.Identifiers.append(GetNameOfNode(nextItem)) + else: + item = nextItem + break + else: + item = nodes.Get_Chain(item) + + yield obj def GetAliasFromNode(aliasNode: Iir): -- cgit v1.2.3 From 47ec53b54ce661a806f371734754483ef906c563 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Mon, 26 Jul 2021 21:38:43 +0200 Subject: Also handle multiple identifiers in record elements. --- pyGHDL/dom/_Translate.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'pyGHDL/dom/_Translate.py') diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index 740c613b6..916f0c8df 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -478,9 +478,11 @@ def GetGenericsFromChainedNodes( genericConstant = GenericConstantInterfaceItem.parse(generic) + # Lookahead for generics with multiple identifiers at once if nodes.Get_Has_Identifier_List(generic): nextNode = nodes.Get_Chain(generic) for nextGeneric in utils.chain_iter(nextNode): + # Consecutive identifiers are found, if the subtype indication is Null if nodes.Get_Subtype_Indication(nextGeneric) == nodes.Null_Iir: genericConstant.Identifiers.append(GetNameOfNode(nextGeneric)) else: @@ -529,9 +531,11 @@ def GetPortsFromChainedNodes( portSignal = PortSignalInterfaceItem.parse(port) + # Lookahead for ports with multiple identifiers at once if nodes.Get_Has_Identifier_List(port): nextNode = nodes.Get_Chain(port) for nextPort in utils.chain_iter(nextNode): + # Consecutive identifiers are found, if the subtype indication is Null if nodes.Get_Subtype_Indication(nextPort) == nodes.Null_Iir: portSignal.Identifiers.append(GetNameOfNode(nextPort)) else: @@ -593,9 +597,11 @@ def GetParameterFromChainedNodes( ) ) + # Lookahead for parameters with multiple identifiers at once if nodes.Get_Has_Identifier_List(parameter): nextNode = nodes.Get_Chain(parameter) for nextParameter in utils.chain_iter(nextNode): + # Consecutive identifiers are found, if the subtype indication is Null if nodes.Get_Subtype_Indication(nextParameter) == nodes.Null_Iir: param.Identifiers.append(GetNameOfNode(nextParameter)) else: @@ -721,9 +727,11 @@ def GetDeclaredItemsFromChainedNodes( item = nodes.Get_Chain(item) continue + # Lookahead for objects with multiple identifiers at once if nodes.Get_Has_Identifier_List(item): nextNode = nodes.Get_Chain(item) for nextItem in utils.chain_iter(nextNode): + # Consecutive identifiers are found, if the subtype indication is Null if nodes.Get_Subtype_Indication(nextItem) == nodes.Null_Iir: obj.Identifiers.append(GetNameOfNode(nextItem)) else: -- cgit v1.2.3 From de44ee29acb01edfb429eb88d96f0bb904adefd0 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Tue, 27 Jul 2021 18:48:08 +0200 Subject: Changed List to Iterable. Parse instantiations. Some SimpleName fixes. --- pyGHDL/dom/_Translate.py | 93 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 92 insertions(+), 1 deletion(-) (limited to 'pyGHDL/dom/_Translate.py') diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index 916f0c8df..eac5476c9 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -45,9 +45,10 @@ from pyVHDLModel.SyntaxModel import ( ParameterInterfaceItem, ModelEntity, Name, + ConcurrentStatement, ) -from pyGHDL.libghdl import utils +from pyGHDL.libghdl import utils, name_table from pyGHDL.libghdl._types import Iir from pyGHDL.libghdl.vhdl import nodes from pyGHDL.dom import Position, DOMException @@ -137,6 +138,7 @@ from pyGHDL.dom.Expression import ( MatchingLessEqualExpression, MatchingGreaterThanExpression, ) +from pyGHDL.dom.Concurrent import ConcurrentBlockStatement from pyGHDL.dom.Subprogram import Function, Procedure from pyGHDL.dom.Misc import Alias from pyGHDL.dom.PSL import DefaultClock @@ -743,6 +745,95 @@ def GetDeclaredItemsFromChainedNodes( yield obj +def GetStatementsFromChainedNodes( + nodeChain: Iir, entity: str, name: str +) -> Generator[ConcurrentStatement, None, None]: + for statement in utils.chain_iter(nodeChain): + label = nodes.Get_Label(statement) + if label != nodes.Null_Iir: + label = name_table.Get_Name_Ptr(label) + + pos = Position.parse(statement) + + kind = GetIirKindOfNode(statement) + if kind == nodes.Iir_Kind.Sensitized_Process_Statement: + print( + "[NOT IMPLEMENTED] Process (label: '{label}') with sensitivity list at line {line}".format( + label=label, line=pos.Line + ) + ) + elif kind == nodes.Iir_Kind.Concurrent_Simple_Signal_Assignment: + print( + "[NOT IMPLEMENTED] Concurrent (simple) signal assignment (label: '{label}') at line {line}".format( + label=label, line=pos.Line + ) + ) + elif kind == nodes.Iir_Kind.Component_Instantiation_Statement: + instantiatedUnit = nodes.Get_Instantiated_Unit(statement) + instantiatedUnitKind = GetIirKindOfNode(instantiatedUnit) + if instantiatedUnitKind == nodes.Iir_Kind.Entity_Aspect_Entity: + entityId = nodes.Get_Entity_Name(instantiatedUnit) + entityName = GetNameFromNode(entityId) + + architectureName = "" + architectureId = nodes.Get_Architecture(instantiatedUnit) + if architectureId != nodes.Null_Iir: + architectureName = GetNameOfNode(architectureId) + + print( + "Instance of '{component!s}({architecture})' with label '{label}' at line {line}".format( + component=entityName, + architecture=architectureName, + label=label, + line=pos.Line, + ) + ) + elif instantiatedUnitKind == nodes.Iir_Kind.Entity_Aspect_Configuration: + configurationId = nodes.Get_Configuration_Name(instantiatedUnit) + configurationName = GetNameFromNode(configurationId) + + print( + "Instance of '{configuration}' with label '{label}' at line {line}".format( + configuration=configurationName, label=label, line=pos.Line + ) + ) + elif instantiatedUnitKind in ( + nodes.Iir_Kind.Simple_Name, + nodes.Iir_Kind.Parenthesis_Name, + ): + componentName = GetNameFromNode(instantiatedUnit) + + print( + "Component '{component}' instantiated with label '{label}' at line {line}".format( + component=componentName, label=label, line=pos.Line + ) + ) + else: + raise DOMException( + "Unknown instantiation kind '{kind}' in instantiation of label {label} at {file}:{line}:{column}.".format( + kind=instantiatedUnitKind.name, + label=label, + file=pos.Filename, + line=pos.Line, + column=pos.Column, + ) + ) + + elif kind == nodes.Iir_Kind.Block_Statement: + yield ConcurrentBlockStatement.parse(statement, label) + else: + raise DOMException( + "Unknown statement of kind '{kind}' in {entity} '{name}' at {file}:{line}:{column}.".format( + kind=kind.name, + entity=entity, + name=name, + file=pos.Filename, + line=pos.Line, + column=pos.Column, + ) + ) + + def GetAliasFromNode(aliasNode: Iir): aliasName = GetNameOfNode(aliasNode) -- cgit v1.2.3 From ee933a5fc78353e7a87fe64616b25387fdc12b2b Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Tue, 27 Jul 2021 19:02:10 +0200 Subject: Handle more concurrent statements and report as not implemented yet. --- pyGHDL/dom/_Translate.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) (limited to 'pyGHDL/dom/_Translate.py') diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index eac5476c9..84b99a4a3 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -762,12 +762,36 @@ def GetStatementsFromChainedNodes( label=label, line=pos.Line ) ) + elif kind == nodes.Iir_Kind.Process_Statement: + print( + "[NOT IMPLEMENTED] Process (label: '{label}') without sensitivity list at line {line}".format( + label=label, line=pos.Line + ) + ) elif kind == nodes.Iir_Kind.Concurrent_Simple_Signal_Assignment: print( "[NOT IMPLEMENTED] Concurrent (simple) signal assignment (label: '{label}') at line {line}".format( label=label, line=pos.Line ) ) + elif kind == nodes.Iir_Kind.Concurrent_Conditional_Signal_Assignment: + print( + "[NOT IMPLEMENTED] Concurrent (conditional) signal assignment (label: '{label}') at line {line}".format( + label=label, line=pos.Line + ) + ) + elif kind == nodes.Iir_Kind.Concurrent_Selected_Signal_Assignment: + print( + "[NOT IMPLEMENTED] Concurrent (selected) signal assignment (label: '{label}') at line {line}".format( + label=label, line=pos.Line + ) + ) + elif kind == nodes.Iir_Kind.Concurrent_Procedure_Call_Statement: + print( + "[NOT IMPLEMENTED] Concurrent procedure call (label: '{label}') at line {line}".format( + label=label, line=pos.Line + ) + ) elif kind == nodes.Iir_Kind.Component_Instantiation_Statement: instantiatedUnit = nodes.Get_Instantiated_Unit(statement) instantiatedUnitKind = GetIirKindOfNode(instantiatedUnit) @@ -818,9 +842,32 @@ def GetStatementsFromChainedNodes( column=pos.Column, ) ) - elif kind == nodes.Iir_Kind.Block_Statement: yield ConcurrentBlockStatement.parse(statement, label) + elif kind == nodes.Iir_Kind.If_Generate_Statement: + print( + "[NOT IMPLEMENTED] If-generate statement (label: '{label}') at line {line}".format( + label=label, line=pos.Line + ) + ) + elif kind == nodes.Iir_Kind.For_Generate_Statement: + print( + "[NOT IMPLEMENTED] For-generate statement (label: '{label}') at line {line}".format( + label=label, line=pos.Line + ) + ) + elif kind == nodes.Iir_Kind.Case_Generate_Statement: + print( + "[NOT IMPLEMENTED] Case-generate statement (label: '{label}') at line {line}".format( + label=label, line=pos.Line + ) + ) + elif kind == nodes.Iir_Kind.Psl_Assert_Directive: + print( + "[NOT IMPLEMENTED] PSL assert directive (label: '{label}') at line {line}".format( + label=label, line=pos.Line + ) + ) else: raise DOMException( "Unknown statement of kind '{kind}' in {entity} '{name}' at {file}:{line}:{column}.".format( -- cgit v1.2.3 From 20b636decb9c502891fbf5f9a15cf8e7126904a5 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Wed, 28 Jul 2021 09:00:03 +0200 Subject: Handle instantiations 1/2. --- pyGHDL/dom/_Translate.py | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) (limited to 'pyGHDL/dom/_Translate.py') diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index 84b99a4a3..b7e8f5ab9 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -138,7 +138,7 @@ from pyGHDL.dom.Expression import ( MatchingLessEqualExpression, MatchingGreaterThanExpression, ) -from pyGHDL.dom.Concurrent import ConcurrentBlockStatement +from pyGHDL.dom.Concurrent import ConcurrentBlockStatement, EntityInstantiation, ConfigurationInstantiation, ComponentInstantiation from pyGHDL.dom.Subprogram import Function, Procedure from pyGHDL.dom.Misc import Alias from pyGHDL.dom.PSL import DefaultClock @@ -796,40 +796,30 @@ def GetStatementsFromChainedNodes( instantiatedUnit = nodes.Get_Instantiated_Unit(statement) instantiatedUnitKind = GetIirKindOfNode(instantiatedUnit) if instantiatedUnitKind == nodes.Iir_Kind.Entity_Aspect_Entity: - entityId = nodes.Get_Entity_Name(instantiatedUnit) - entityName = GetNameFromNode(entityId) - - architectureName = "" - architectureId = nodes.Get_Architecture(instantiatedUnit) - if architectureId != nodes.Null_Iir: - architectureName = GetNameOfNode(architectureId) + entityInstance = EntityInstantiation.parse(statement, instantiatedUnit, label) print( - "Instance of '{component!s}({architecture})' with label '{label}' at line {line}".format( - component=entityName, - architecture=architectureName, - label=label, + "Entity '{entity!s}({architecture})' instantiated with label '{label}' at line {line}".format( + entity=entityInstance.Entity, + architecture=entityInstance.Architecture, + label=entityInstance.Label, line=pos.Line, ) ) elif instantiatedUnitKind == nodes.Iir_Kind.Entity_Aspect_Configuration: - configurationId = nodes.Get_Configuration_Name(instantiatedUnit) - configurationName = GetNameFromNode(configurationId) + configurationInstance = ConfigurationInstantiation.parse(statement, instantiatedUnit, label) print( - "Instance of '{configuration}' with label '{label}' at line {line}".format( - configuration=configurationName, label=label, line=pos.Line + "Configuration '{configuration}' instantiated with label '{label}' at line {line}".format( + configuration=configurationInstance.Configuration, label=configurationInstance.Label, line=pos.Line ) ) - elif instantiatedUnitKind in ( - nodes.Iir_Kind.Simple_Name, - nodes.Iir_Kind.Parenthesis_Name, - ): - componentName = GetNameFromNode(instantiatedUnit) + elif instantiatedUnitKind == nodes.Iir_Kind.Simple_Name: + configurationInstance = ComponentInstantiation.parse(statement, instantiatedUnit, label) print( "Component '{component}' instantiated with label '{label}' at line {line}".format( - component=componentName, label=label, line=pos.Line + component=configurationInstance.Component, label=label, line=pos.Line ) ) else: -- cgit v1.2.3 From 50f65e4255f62e662d781d01f395c029426c1529 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Wed, 28 Jul 2021 23:52:31 +0200 Subject: More handling of concurrent statements. --- pyGHDL/dom/_Translate.py | 72 +++++++++++++++--------------------------------- 1 file changed, 22 insertions(+), 50 deletions(-) (limited to 'pyGHDL/dom/_Translate.py') diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index b7e8f5ab9..bb96cf8c6 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -138,7 +138,16 @@ from pyGHDL.dom.Expression import ( MatchingLessEqualExpression, MatchingGreaterThanExpression, ) -from pyGHDL.dom.Concurrent import ConcurrentBlockStatement, EntityInstantiation, ConfigurationInstantiation, ComponentInstantiation +from pyGHDL.dom.Concurrent import ( + ConcurrentBlockStatement, + EntityInstantiation, + ConfigurationInstantiation, + ComponentInstantiation, + ProcessStatement, + IfGenerateStatement, + ForGenerateStatement, + CaseGenerateStatement, +) from pyGHDL.dom.Subprogram import Function, Procedure from pyGHDL.dom.Misc import Alias from pyGHDL.dom.PSL import DefaultClock @@ -757,17 +766,11 @@ def GetStatementsFromChainedNodes( kind = GetIirKindOfNode(statement) if kind == nodes.Iir_Kind.Sensitized_Process_Statement: - print( - "[NOT IMPLEMENTED] Process (label: '{label}') with sensitivity list at line {line}".format( - label=label, line=pos.Line - ) - ) + yield ProcessStatement.parse(statement, label, True) + elif kind == nodes.Iir_Kind.Process_Statement: - print( - "[NOT IMPLEMENTED] Process (label: '{label}') without sensitivity list at line {line}".format( - label=label, line=pos.Line - ) - ) + yield ProcessStatement.parse(statement, label, False) + elif kind == nodes.Iir_Kind.Concurrent_Simple_Signal_Assignment: print( "[NOT IMPLEMENTED] Concurrent (simple) signal assignment (label: '{label}') at line {line}".format( @@ -796,32 +799,13 @@ def GetStatementsFromChainedNodes( instantiatedUnit = nodes.Get_Instantiated_Unit(statement) instantiatedUnitKind = GetIirKindOfNode(instantiatedUnit) if instantiatedUnitKind == nodes.Iir_Kind.Entity_Aspect_Entity: - entityInstance = EntityInstantiation.parse(statement, instantiatedUnit, label) - - print( - "Entity '{entity!s}({architecture})' instantiated with label '{label}' at line {line}".format( - entity=entityInstance.Entity, - architecture=entityInstance.Architecture, - label=entityInstance.Label, - line=pos.Line, - ) - ) + yield EntityInstantiation.parse(statement, instantiatedUnit, label) elif instantiatedUnitKind == nodes.Iir_Kind.Entity_Aspect_Configuration: - configurationInstance = ConfigurationInstantiation.parse(statement, instantiatedUnit, label) - - print( - "Configuration '{configuration}' instantiated with label '{label}' at line {line}".format( - configuration=configurationInstance.Configuration, label=configurationInstance.Label, line=pos.Line - ) + yield ConfigurationInstantiation.parse( + statement, instantiatedUnit, label ) elif instantiatedUnitKind == nodes.Iir_Kind.Simple_Name: - configurationInstance = ComponentInstantiation.parse(statement, instantiatedUnit, label) - - print( - "Component '{component}' instantiated with label '{label}' at line {line}".format( - component=configurationInstance.Component, label=label, line=pos.Line - ) - ) + yield ComponentInstantiation.parse(statement, instantiatedUnit, label) else: raise DOMException( "Unknown instantiation kind '{kind}' in instantiation of label {label} at {file}:{line}:{column}.".format( @@ -835,23 +819,11 @@ def GetStatementsFromChainedNodes( elif kind == nodes.Iir_Kind.Block_Statement: yield ConcurrentBlockStatement.parse(statement, label) elif kind == nodes.Iir_Kind.If_Generate_Statement: - print( - "[NOT IMPLEMENTED] If-generate statement (label: '{label}') at line {line}".format( - label=label, line=pos.Line - ) - ) - elif kind == nodes.Iir_Kind.For_Generate_Statement: - print( - "[NOT IMPLEMENTED] For-generate statement (label: '{label}') at line {line}".format( - label=label, line=pos.Line - ) - ) + yield IfGenerateStatement.parse(statement, label) elif kind == nodes.Iir_Kind.Case_Generate_Statement: - print( - "[NOT IMPLEMENTED] Case-generate statement (label: '{label}') at line {line}".format( - label=label, line=pos.Line - ) - ) + yield CaseGenerateStatement.parse(statement, label) + elif kind == nodes.Iir_Kind.For_Generate_Statement: + yield ForGenerateStatement.parse(statement, label) elif kind == nodes.Iir_Kind.Psl_Assert_Directive: print( "[NOT IMPLEMENTED] PSL assert directive (label: '{label}') at line {line}".format( -- cgit v1.2.3 From 31eb230938730059254bc4778bf1eff14015221f Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Fri, 30 Jul 2021 02:14:33 +0200 Subject: Fixed handling of declarations with multiple identifiers, if this is the last item in the chain. --- pyGHDL/dom/_Translate.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'pyGHDL/dom/_Translate.py') diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index bb96cf8c6..8a76f8a4f 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -499,6 +499,8 @@ def GetGenericsFromChainedNodes( else: generic = nextGeneric break + else: + generic = nodes.Null_Iir else: generic = nodes.Get_Chain(generic) @@ -552,6 +554,8 @@ def GetPortsFromChainedNodes( else: port = nextPort break + else: + port = nodes.Null_Iir else: port = nodes.Get_Chain(port) @@ -618,6 +622,8 @@ def GetParameterFromChainedNodes( else: parameter = nextParameter break + else: + parameter = nodes.Null_Iir else: parameter = nodes.Get_Chain(parameter) @@ -748,6 +754,8 @@ def GetDeclaredItemsFromChainedNodes( else: item = nextItem break + else: + item = nodes.Null_Iir else: item = nodes.Get_Chain(item) -- cgit v1.2.3 From 9e612ed4cacdc6bd1e24b41747c49a3fd9b1f24e Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Sun, 1 Aug 2021 20:44:16 +0200 Subject: Another fix for consecutive identifiers. --- pyGHDL/dom/_Translate.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'pyGHDL/dom/_Translate.py') diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index 8a76f8a4f..44915c026 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -499,6 +499,11 @@ def GetGenericsFromChainedNodes( else: generic = nextGeneric break + + # The last consecutive identifiers has no Identifier_List flag + if not nodes.Get_Has_Identifier_List(nextGeneric): + generic = nodes.Get_Chain(nextGeneric) + break else: generic = nodes.Null_Iir else: @@ -554,6 +559,11 @@ def GetPortsFromChainedNodes( else: port = nextPort break + + # The last consecutive identifiers has no Identifier_List flag + if not nodes.Get_Has_Identifier_List(nextPort): + port = nodes.Get_Chain(nextPort) + break else: port = nodes.Null_Iir else: @@ -622,6 +632,11 @@ def GetParameterFromChainedNodes( else: parameter = nextParameter break + + # The last consecutive identifiers has no Identifier_List flag + if not nodes.Get_Has_Identifier_List(nextParameter): + parameter = nodes.Get_Chain(nextParameter) + break else: parameter = nodes.Null_Iir else: @@ -754,6 +769,11 @@ def GetDeclaredItemsFromChainedNodes( else: item = nextItem break + + # The last consecutive identifiers has no Identifier_List flag + if not nodes.Get_Has_Identifier_List(nextItem): + item = nodes.Get_Chain(nextItem) + break else: item = nodes.Null_Iir else: -- cgit v1.2.3 From 407f07a7b3100020bb9f5dbe5863c0b8b45cdd9d Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Mon, 2 Aug 2021 11:52:48 +0200 Subject: Added handling of simple concurrent statements. --- pyGHDL/dom/_Translate.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'pyGHDL/dom/_Translate.py') diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index 44915c026..32e2c45f7 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -147,6 +147,7 @@ from pyGHDL.dom.Concurrent import ( IfGenerateStatement, ForGenerateStatement, CaseGenerateStatement, + ConcurrentSignalAssignment, ) from pyGHDL.dom.Subprogram import Function, Procedure from pyGHDL.dom.Misc import Alias @@ -800,11 +801,7 @@ def GetStatementsFromChainedNodes( yield ProcessStatement.parse(statement, label, False) elif kind == nodes.Iir_Kind.Concurrent_Simple_Signal_Assignment: - print( - "[NOT IMPLEMENTED] Concurrent (simple) signal assignment (label: '{label}') at line {line}".format( - label=label, line=pos.Line - ) - ) + yield ConcurrentSignalAssignment.parse(statement, label) elif kind == nodes.Iir_Kind.Concurrent_Conditional_Signal_Assignment: print( "[NOT IMPLEMENTED] Concurrent (conditional) signal assignment (label: '{label}') at line {line}".format( -- cgit v1.2.3 From c80c2e02dda356e3eb00ae6a097ff62c0f08fc79 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Fri, 6 Aug 2021 20:11:33 +0200 Subject: Renamed to ConcurrentSimpleSignalAssignment. --- pyGHDL/dom/_Translate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'pyGHDL/dom/_Translate.py') diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index 32e2c45f7..b53b7976e 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -147,7 +147,7 @@ from pyGHDL.dom.Concurrent import ( IfGenerateStatement, ForGenerateStatement, CaseGenerateStatement, - ConcurrentSignalAssignment, + ConcurrentSimpleSignalAssignment, ) from pyGHDL.dom.Subprogram import Function, Procedure from pyGHDL.dom.Misc import Alias @@ -801,7 +801,7 @@ def GetStatementsFromChainedNodes( yield ProcessStatement.parse(statement, label, False) elif kind == nodes.Iir_Kind.Concurrent_Simple_Signal_Assignment: - yield ConcurrentSignalAssignment.parse(statement, label) + yield ConcurrentSimpleSignalAssignment.parse(statement, label) elif kind == nodes.Iir_Kind.Concurrent_Conditional_Signal_Assignment: print( "[NOT IMPLEMENTED] Concurrent (conditional) signal assignment (label: '{label}') at line {line}".format( -- cgit v1.2.3 From bc09bbf10599436e1efdb0432886b2bb8b4bf890 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Wed, 11 Aug 2021 15:49:39 +0200 Subject: Support for concurrent procedure call. --- pyGHDL/dom/_Translate.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'pyGHDL/dom/_Translate.py') diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index b53b7976e..c8b34ba8c 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -148,6 +148,7 @@ from pyGHDL.dom.Concurrent import ( ForGenerateStatement, CaseGenerateStatement, ConcurrentSimpleSignalAssignment, + ConcurrentProcedureCall, ) from pyGHDL.dom.Subprogram import Function, Procedure from pyGHDL.dom.Misc import Alias @@ -815,11 +816,7 @@ def GetStatementsFromChainedNodes( ) ) elif kind == nodes.Iir_Kind.Concurrent_Procedure_Call_Statement: - print( - "[NOT IMPLEMENTED] Concurrent procedure call (label: '{label}') at line {line}".format( - label=label, line=pos.Line - ) - ) + yield ConcurrentProcedureCall.parse(statement, label) elif kind == nodes.Iir_Kind.Component_Instantiation_Statement: instantiatedUnit = nodes.Get_Instantiated_Unit(statement) instantiatedUnitKind = GetIirKindOfNode(instantiatedUnit) -- cgit v1.2.3 From 357cb9746c53e3f32fc9c2f28686c25e388918c3 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Thu, 12 Aug 2021 13:06:11 +0200 Subject: Preparations for sequential statements. --- pyGHDL/dom/_Translate.py | 50 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 4 deletions(-) (limited to 'pyGHDL/dom/_Translate.py') diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index c8b34ba8c..2103064a4 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -45,7 +45,7 @@ from pyVHDLModel.SyntaxModel import ( ParameterInterfaceItem, ModelEntity, Name, - ConcurrentStatement, + ConcurrentStatement, SequentialStatement, ) from pyGHDL.libghdl import utils, name_table @@ -784,13 +784,12 @@ def GetDeclaredItemsFromChainedNodes( yield obj -def GetStatementsFromChainedNodes( +def GetConcurrentStatementsFromChainedNodes( nodeChain: Iir, entity: str, name: str ) -> Generator[ConcurrentStatement, None, None]: for statement in utils.chain_iter(nodeChain): label = nodes.Get_Label(statement) - if label != nodes.Null_Iir: - label = name_table.Get_Name_Ptr(label) + label = name_table.Get_Name_Ptr(label) if label != nodes.Null_Iir else None pos = Position.parse(statement) @@ -865,6 +864,49 @@ def GetStatementsFromChainedNodes( ) +def GetSequentialStatementsFromChainedNodes( + nodeChain: Iir, entity: str, name: str +) -> Generator[SequentialStatement, None, None]: + for statement in utils.chain_iter(nodeChain): + label = nodes.Get_Label(statement) + label = name_table.Get_Name_Ptr(label) if label != nodes.Null_Iir else None + + pos = Position.parse(statement) + + kind = GetIirKindOfNode(statement) +# if kind == nodes.Iir_Kind.Sensitized_Process_Statement: +# yield ProcessStatement.parse(statement, label, True) + if kind == nodes.Iir_Kind.If_Statement: + print( + "[NOT IMPLEMENTED] If statement (label: '{label}') at line {line}".format( + label=label, line=pos.Line + ) + ) + elif kind == nodes.Iir_Kind.For_Loop_Statement: + print( + "[NOT IMPLEMENTED] For-loop statement (label: '{label}') at line {line}".format( + label=label, line=pos.Line + ) + ) + elif kind == nodes.Iir_Kind.Case_Statement: + print( + "[NOT IMPLEMENTED] For-loop statement (label: '{label}') at line {line}".format( + label=label, line=pos.Line + ) + ) + else: + raise DOMException( + "Unknown statement of kind '{kind}' in {entity} '{name}' at {file}:{line}:{column}.".format( + kind=kind.name, + entity=entity, + name=name, + file=pos.Filename, + line=pos.Line, + column=pos.Column, + ) + ) + + def GetAliasFromNode(aliasNode: Iir): aliasName = GetNameOfNode(aliasNode) -- cgit v1.2.3 From c4326161ce97d3286e8dffe31d0c168e05f3f9ea Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Fri, 13 Aug 2021 22:21:04 +0200 Subject: Improved handling of ranges (e.g. via attribute names). --- pyGHDL/dom/_Translate.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'pyGHDL/dom/_Translate.py') diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index 2103064a4..6e3a95ea7 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -45,7 +45,8 @@ from pyVHDLModel.SyntaxModel import ( ParameterInterfaceItem, ModelEntity, Name, - ConcurrentStatement, SequentialStatement, + ConcurrentStatement, + SequentialStatement, ) from pyGHDL.libghdl import utils, name_table -- cgit v1.2.3 From edd59b8997c30c8a559d4d7d433631ef03c19546 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Fri, 13 Aug 2021 22:36:41 +0200 Subject: Black formatting. --- pyGHDL/dom/_Translate.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'pyGHDL/dom/_Translate.py') diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index 6e3a95ea7..a6ad1ca42 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -200,8 +200,8 @@ def GetAssociations(node: Iir) -> List: associations.append(expr) else: raise DOMException( - "Unknown association kind '{kindName}'({kind}) in array index/slice or function call '{node}'.".format( - kind=kind, kindName=kind.name, node=node + "Unknown association kind '{kind}' in array index/slice or function call '{node}'.".format( + kind=kind.name, node=node ) ) @@ -526,9 +526,8 @@ def GetGenericsFromChainedNodes( else: position = Position.parse(generic) raise DOMException( - "Unknown generic kind '{kindName}'({kind}) in generic '{generic}' at {file}:{line}:{column}.".format( - kind=kind, - kindName=kind.name, + "Unknown generic kind '{kind}' in generic '{generic}' at {file}:{line}:{column}.".format( + kind=kind.name, generic=generic, file=position.Filename, line=position.Line, @@ -577,9 +576,8 @@ def GetPortsFromChainedNodes( else: position = Position.parse(port) raise DOMException( - "Unknown port kind '{kindName}'({kind}) in port '{port}' at {file}:{line}:{column}.".format( - kind=kind, - kindName=kind.name, + "Unknown port kind '{kind}' in port '{port}' at {file}:{line}:{column}.".format( + kind=kind.name, port=port, file=position.Filename, line=position.Line, @@ -615,9 +613,8 @@ def GetParameterFromChainedNodes( else: position = Position.parse(parameter) raise DOMException( - "Unknown parameter kind '{kindName}'({kind}) in parameter '{param}' at {file}:{line}:{column}.".format( - kind=kind, - kindName=kind.name, + "Unknown parameter kind '{kind}' in parameter '{param}' at {file}:{line}:{column}.".format( + kind=kind.name, param=parameter, file=position.Filename, line=position.Line, -- cgit v1.2.3 From 16c7b04b252428ebf131ecd4956e099f766d118e Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Fri, 13 Aug 2021 22:39:13 +0200 Subject: Preparations for sequential statements. --- pyGHDL/dom/_Translate.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'pyGHDL/dom/_Translate.py') diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index a6ad1ca42..a4be6a792 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -892,6 +892,45 @@ def GetSequentialStatementsFromChainedNodes( label=label, line=pos.Line ) ) + elif kind == nodes.Iir_Kind.Simple_Signal_Assignment_Statement: + print( + "[NOT IMPLEMENTED] (Simple) signal assignment (label: '{label}') at line {line}".format( + label=label, line=pos.Line + ) + ) + elif kind in ( + nodes.Iir_Kind.Variable_Assignment_Statement, + nodes.Iir_Kind.Conditional_Variable_Assignment_Statement, + ): + print( + "[NOT IMPLEMENTED] Variable assignment (label: '{label}') at line {line}".format( + label=label, line=pos.Line + ) + ) + elif kind == nodes.Iir_Kind.Wait_Statement: + print( + "[NOT IMPLEMENTED] For-loop statement (label: '{label}') at line {line}".format( + label=label, line=pos.Line + ) + ) + elif kind == nodes.Iir_Kind.Procedure_Call_Statement: + print( + "[NOT IMPLEMENTED] Procedure call (label: '{label}') at line {line}".format( + label=label, line=pos.Line + ) + ) + elif kind == nodes.Iir_Kind.Report_Statement: + print( + "[NOT IMPLEMENTED] Report statement (label: '{label}') at line {line}".format( + label=label, line=pos.Line + ) + ) + elif kind == nodes.Iir_Kind.Assertion_Statement: + print( + "[NOT IMPLEMENTED] Report statement (label: '{label}') at line {line}".format( + label=label, line=pos.Line + ) + ) else: raise DOMException( "Unknown statement of kind '{kind}' in {entity} '{name}' at {file}:{line}:{column}.".format( -- cgit v1.2.3 From 6bd13c9f82e2b06bebdea8fc82a83604d5d500d1 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Fri, 13 Aug 2021 23:12:20 +0200 Subject: Fixed missed adjustments to range in expressions. --- pyGHDL/dom/_Translate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'pyGHDL/dom/_Translate.py') diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index a4be6a792..f5f2eda3e 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -872,8 +872,8 @@ def GetSequentialStatementsFromChainedNodes( pos = Position.parse(statement) kind = GetIirKindOfNode(statement) -# if kind == nodes.Iir_Kind.Sensitized_Process_Statement: -# yield ProcessStatement.parse(statement, label, True) + # if kind == nodes.Iir_Kind.Sensitized_Process_Statement: + # yield ProcessStatement.parse(statement, label, True) if kind == nodes.Iir_Kind.If_Statement: print( "[NOT IMPLEMENTED] If statement (label: '{label}') at line {line}".format( -- cgit v1.2.3 From db48ba4042769646676f7ffb981149cbb5e52740 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Mon, 16 Aug 2021 18:06:59 +0200 Subject: Implemented if, case and for-loop statements. --- pyGHDL/dom/_Translate.py | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) (limited to 'pyGHDL/dom/_Translate.py') diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index f5f2eda3e..18a4d9fda 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -34,6 +34,7 @@ from typing import List, Generator from pydecor import export +from pyGHDL.dom.Sequential import IfStatement, ForLoopStatement, CaseStatement from pyVHDLModel.SyntaxModel import ( Constraint, Direction, @@ -872,26 +873,12 @@ def GetSequentialStatementsFromChainedNodes( pos = Position.parse(statement) kind = GetIirKindOfNode(statement) - # if kind == nodes.Iir_Kind.Sensitized_Process_Statement: - # yield ProcessStatement.parse(statement, label, True) if kind == nodes.Iir_Kind.If_Statement: - print( - "[NOT IMPLEMENTED] If statement (label: '{label}') at line {line}".format( - label=label, line=pos.Line - ) - ) + yield IfStatement.parse(statement, label) elif kind == nodes.Iir_Kind.For_Loop_Statement: - print( - "[NOT IMPLEMENTED] For-loop statement (label: '{label}') at line {line}".format( - label=label, line=pos.Line - ) - ) + yield ForLoopStatement.parse(statement, label) elif kind == nodes.Iir_Kind.Case_Statement: - print( - "[NOT IMPLEMENTED] For-loop statement (label: '{label}') at line {line}".format( - label=label, line=pos.Line - ) - ) + yield CaseStatement.parse(statement, label) elif kind == nodes.Iir_Kind.Simple_Signal_Assignment_Statement: print( "[NOT IMPLEMENTED] (Simple) signal assignment (label: '{label}') at line {line}".format( -- cgit v1.2.3 From 3f0308a5f807269aa5691fa1c704c0e9147d45f1 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Mon, 16 Aug 2021 23:47:04 +0200 Subject: Handle contexts. --- pyGHDL/dom/_Translate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pyGHDL/dom/_Translate.py') diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index 18a4d9fda..00194cb09 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -717,7 +717,7 @@ def GetDeclaredItemsFromChainedNodes( elif kind == nodes.Iir_Kind.Package_Declaration: from pyGHDL.dom.DesignUnit import Package - yield Package.parse(item) + yield Package.parse(item, None) # TODO: Can it have a context? elif kind == nodes.Iir_Kind.Package_Instantiation_Declaration: from pyGHDL.dom.DesignUnit import PackageInstantiation -- cgit v1.2.3 From c34b020a8c1b6aa5083a637e3e9062c7a71b309a Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Tue, 17 Aug 2021 10:16:59 +0200 Subject: Some updates. --- pyGHDL/dom/_Translate.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'pyGHDL/dom/_Translate.py') diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index 00194cb09..06afa960b 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -34,7 +34,13 @@ from typing import List, Generator from pydecor import export -from pyGHDL.dom.Sequential import IfStatement, ForLoopStatement, CaseStatement +from pyGHDL.dom.Sequential import ( + IfStatement, + ForLoopStatement, + CaseStatement, + SequentialReportStatement, + SequentialAssertStatement, +) from pyVHDLModel.SyntaxModel import ( Constraint, Direction, @@ -907,17 +913,9 @@ def GetSequentialStatementsFromChainedNodes( ) ) elif kind == nodes.Iir_Kind.Report_Statement: - print( - "[NOT IMPLEMENTED] Report statement (label: '{label}') at line {line}".format( - label=label, line=pos.Line - ) - ) + yield SequentialReportStatement.parse(statement, label) elif kind == nodes.Iir_Kind.Assertion_Statement: - print( - "[NOT IMPLEMENTED] Report statement (label: '{label}') at line {line}".format( - label=label, line=pos.Line - ) - ) + yield SequentialAssertStatement.parse(statement, label) else: raise DOMException( "Unknown statement of kind '{kind}' in {entity} '{name}' at {file}:{line}:{column}.".format( -- cgit v1.2.3 From d0dc820554320ad076854481f5cb0957edd3cda5 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Tue, 17 Aug 2021 12:17:51 +0200 Subject: Implemented handling of wait statements. --- pyGHDL/dom/_Translate.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'pyGHDL/dom/_Translate.py') diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index 06afa960b..dfc919504 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -40,6 +40,7 @@ from pyGHDL.dom.Sequential import ( CaseStatement, SequentialReportStatement, SequentialAssertStatement, + WaitStatement, ) from pyVHDLModel.SyntaxModel import ( Constraint, @@ -877,7 +878,6 @@ def GetSequentialStatementsFromChainedNodes( label = name_table.Get_Name_Ptr(label) if label != nodes.Null_Iir else None pos = Position.parse(statement) - kind = GetIirKindOfNode(statement) if kind == nodes.Iir_Kind.If_Statement: yield IfStatement.parse(statement, label) @@ -901,11 +901,7 @@ def GetSequentialStatementsFromChainedNodes( ) ) elif kind == nodes.Iir_Kind.Wait_Statement: - print( - "[NOT IMPLEMENTED] For-loop statement (label: '{label}') at line {line}".format( - label=label, line=pos.Line - ) - ) + yield WaitStatement.parse(statement, label) elif kind == nodes.Iir_Kind.Procedure_Call_Statement: print( "[NOT IMPLEMENTED] Procedure call (label: '{label}') at line {line}".format( -- cgit v1.2.3 From f8d7ac62564e4bdefb35e58178c4df1b4feae844 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Tue, 17 Aug 2021 13:30:49 +0200 Subject: Handle simple sequential signal assignments and it's waveforms. --- pyGHDL/dom/_Translate.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'pyGHDL/dom/_Translate.py') diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index dfc919504..133d9386f 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -41,6 +41,7 @@ from pyGHDL.dom.Sequential import ( SequentialReportStatement, SequentialAssertStatement, WaitStatement, + SequentialSimpleSignalAssignment, ) from pyVHDLModel.SyntaxModel import ( Constraint, @@ -886,11 +887,7 @@ def GetSequentialStatementsFromChainedNodes( elif kind == nodes.Iir_Kind.Case_Statement: yield CaseStatement.parse(statement, label) elif kind == nodes.Iir_Kind.Simple_Signal_Assignment_Statement: - print( - "[NOT IMPLEMENTED] (Simple) signal assignment (label: '{label}') at line {line}".format( - label=label, line=pos.Line - ) - ) + yield SequentialSimpleSignalAssignment.parse(statement, label) elif kind in ( nodes.Iir_Kind.Variable_Assignment_Statement, nodes.Iir_Kind.Conditional_Variable_Assignment_Statement, -- cgit v1.2.3 From 8c0f8e0ad95c53beac983546550222117c6a639c Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Tue, 17 Aug 2021 20:14:13 +0200 Subject: Handle associations. --- pyGHDL/dom/_Translate.py | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) (limited to 'pyGHDL/dom/_Translate.py') diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index 133d9386f..e7e862039 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -30,7 +30,7 @@ # # SPDX-License-Identifier: GPL-2.0-or-later # ============================================================================ -from typing import List, Generator +from typing import List, Generator, Type from pydecor import export @@ -56,6 +56,7 @@ from pyVHDLModel.SyntaxModel import ( Name, ConcurrentStatement, SequentialStatement, + AssociationItem, ) from pyGHDL.libghdl import utils, name_table @@ -159,6 +160,9 @@ from pyGHDL.dom.Concurrent import ( CaseGenerateStatement, ConcurrentSimpleSignalAssignment, ConcurrentProcedureCall, + GenericAssociationItem, + PortAssociationItem, + ParameterAssociationItem, ) from pyGHDL.dom.Subprogram import Function, Procedure from pyGHDL.dom.Misc import Alias @@ -654,6 +658,46 @@ def GetParameterFromChainedNodes( yield param +def GetMapAspect( + mapAspect: Iir, cls: Type, entity: str +) -> Generator[AssociationItem, None, None]: + for generic in utils.chain_iter(mapAspect): + kind = GetIirKindOfNode(generic) + if kind is nodes.Iir_Kind.Association_Element_By_Expression: + formalNode = nodes.Get_Formal(generic) + if formalNode is nodes.Null_Iir: + formal = None + else: + formal = GetNameFromNode(formalNode) + + actual = GetExpressionFromNode(nodes.Get_Actual(generic)) + + yield cls(generic, actual, formal) + else: + pos = Position.parse(generic) + raise DOMException( + "Unknown association kind '{kind}' in {entity} map at line {line}.".format( + kind=kind.name, entity=entity, line=pos.Line + ) + ) + + +def GetGenericMapAspect( + genericMapAspect: Iir, +) -> Generator[AssociationItem, None, None]: + return GetMapAspect(genericMapAspect, GenericAssociationItem, "generic") + + +def GetPortMapAspect(portMapAspect: Iir) -> Generator[AssociationItem, None, None]: + return GetMapAspect(portMapAspect, PortAssociationItem, "port") + + +def GetParameterMapAspect( + parameterMapAspect: Iir, +) -> Generator[AssociationItem, None, None]: + return GetMapAspect(parameterMapAspect, ParameterAssociationItem, "parameter") + + def GetDeclaredItemsFromChainedNodes( nodeChain: Iir, entity: str, name: str ) -> Generator[ModelEntity, None, None]: -- cgit v1.2.3 From 324d56b5ab4b1cdd1c43f412d4139a38dcb90eb9 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Wed, 18 Aug 2021 08:19:44 +0200 Subject: Handle open in map aspects. --- pyGHDL/dom/_Translate.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'pyGHDL/dom/_Translate.py') diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index e7e862039..ed2e32ce3 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -73,6 +73,7 @@ from pyGHDL.dom.Names import ( AttributeName, ParenthesisName, AllName, + OpenName, ) from pyGHDL.dom.Symbol import ( SimpleObjectOrFunctionCallSymbol, @@ -673,6 +674,15 @@ def GetMapAspect( actual = GetExpressionFromNode(nodes.Get_Actual(generic)) yield cls(generic, actual, formal) + elif kind is nodes.Iir_Kind.Association_Element_Open: + formalNode = nodes.Get_Formal(generic) + if formalNode is nodes.Null_Iir: + formal = None + else: + formal = GetNameFromNode(formalNode) + + open = OpenName(generic) + yield cls(generic, open, formal) else: pos = Position.parse(generic) raise DOMException( -- cgit v1.2.3 From 89aee29e92c09f9bfa7b01f39233636bbc938915 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Wed, 18 Aug 2021 08:20:17 +0200 Subject: Handle subprogram vs. subprogram body. --- pyGHDL/dom/_Translate.py | 52 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 7 deletions(-) (limited to 'pyGHDL/dom/_Translate.py') diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index ed2e32ce3..6231d93dd 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -712,6 +712,7 @@ def GetDeclaredItemsFromChainedNodes( nodeChain: Iir, entity: str, name: str ) -> Generator[ModelEntity, None, None]: item = nodeChain + lastKind = None while item != nodes.Null_Iir: kind = GetIirKindOfNode(item) if kind == nodes.Iir_Kind.Constant_Declaration: @@ -726,7 +727,6 @@ def GetDeclaredItemsFromChainedNodes( obj = SharedVariable.parse(item) else: obj = Variable.parse(item) - # raise DOMException("Found non-shared variable.") elif kind == nodes.Iir_Kind.Signal_Declaration: from pyGHDL.dom.Object import Signal @@ -746,16 +746,53 @@ def GetDeclaredItemsFromChainedNodes( yield GetSubtypeFromNode(item) elif kind == nodes.Iir_Kind.Function_Declaration: - yield Function.parse(item) + if nodes.Get_Has_Body(item): + yield Function.parse(item) + else: + print("[NOT IMPLEMENTED] function declaration without body") + lastKind = kind + item = nodes.Get_Chain(item) + continue elif kind == nodes.Iir_Kind.Function_Body: - # procedureName = NodeToName(item) - print("found function body '{name}'".format(name="????")) + if lastKind is nodes.Iir_Kind.Function_Declaration: + pass + else: + position = Position.parse(item) + raise DOMException( + "Found unexpected function body '{functionName}' in {entity} '{name}' at {file}:{line}:{column}.".format( + functionName=GetNameOfNode(item), + entity=entity, + name=name, + file=position.Filename, + line=position.Line, + column=position.Column, + ) + ) elif kind == nodes.Iir_Kind.Procedure_Declaration: - yield Procedure.parse(item) + if nodes.Get_Has_Body(item): + yield Procedure.parse(item) + else: + print("[NOT IMPLEMENTED] procedure declaration without body") + + lastKind = kind + item = nodes.Get_Chain(item) + continue elif kind == nodes.Iir_Kind.Procedure_Body: - # procedureName = NodeToName(item) - print("found procedure body '{name}'".format(name="????")) + if lastKind is nodes.Iir_Kind.Procedure_Declaration: + pass + else: + position = Position.parse(item) + raise DOMException( + "Found unexpected procedure body '{functionName}' in {entity} '{name}' at {file}:{line}:{column}.".format( + functionName=GetNameOfNode(item), + entity=entity, + name=name, + file=position.Filename, + line=position.Line, + column=position.Column, + ) + ) elif kind == nodes.Iir_Kind.Protected_Type_Body: yield ProtectedTypeBody.parse(item) elif kind == nodes.Iir_Kind.Object_Alias_Declaration: @@ -819,6 +856,7 @@ def GetDeclaredItemsFromChainedNodes( ) ) + lastKind = None item = nodes.Get_Chain(item) continue -- cgit v1.2.3 From 8fb4da723067b2ff99050f9ef9fc0bbd3c835ef4 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Mon, 23 Aug 2021 00:13:43 +0200 Subject: Some fixes. --- pyGHDL/dom/_Translate.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'pyGHDL/dom/_Translate.py') diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index 6231d93dd..626ffd3fa 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -681,8 +681,7 @@ def GetMapAspect( else: formal = GetNameFromNode(formalNode) - open = OpenName(generic) - yield cls(generic, open, formal) + yield cls(generic, OpenName(generic), formal) else: pos = Position.parse(generic) raise DOMException( @@ -694,17 +693,17 @@ def GetMapAspect( def GetGenericMapAspect( genericMapAspect: Iir, -) -> Generator[AssociationItem, None, None]: +) -> Generator[GenericAssociationItem, None, None]: return GetMapAspect(genericMapAspect, GenericAssociationItem, "generic") -def GetPortMapAspect(portMapAspect: Iir) -> Generator[AssociationItem, None, None]: +def GetPortMapAspect(portMapAspect: Iir) -> Generator[PortAssociationItem, None, None]: return GetMapAspect(portMapAspect, PortAssociationItem, "port") def GetParameterMapAspect( parameterMapAspect: Iir, -) -> Generator[AssociationItem, None, None]: +) -> Generator[ParameterAssociationItem, None, None]: return GetMapAspect(parameterMapAspect, ParameterAssociationItem, "parameter") -- cgit v1.2.3 From 8b98e2883b40b00922c9944c2470211ee055a9a5 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Mon, 23 Aug 2021 09:02:47 +0200 Subject: Fixes due to a bug in pyVHDLModel. Name Context was used twice. --- pyGHDL/dom/_Translate.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'pyGHDL/dom/_Translate.py') diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index 626ffd3fa..d64e38d82 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -44,9 +44,9 @@ from pyGHDL.dom.Sequential import ( SequentialSimpleSignalAssignment, ) from pyVHDLModel.SyntaxModel import ( - Constraint, + ConstraintUnion, Direction, - Expression, + ExpressionUnion, SubtypeOrSymbol, BaseType, GenericInterfaceItem, @@ -225,7 +225,7 @@ def GetAssociations(node: Iir) -> List: @export def GetArrayConstraintsFromSubtypeIndication( subtypeIndication: Iir, -) -> List[Constraint]: +) -> List[ConstraintUnion]: constraints = [] for constraint in utils.flist_iter( nodes.Get_Index_Constraint_List(subtypeIndication) @@ -467,7 +467,7 @@ __EXPRESSION_TRANSLATION = { @export -def GetExpressionFromNode(node: Iir) -> Expression: +def GetExpressionFromNode(node: Iir) -> ExpressionUnion: kind = GetIirKindOfNode(node) try: -- cgit v1.2.3 From b229fa55b6485350ced8e31d6a803d08544b6d22 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Mon, 23 Aug 2021 15:41:10 +0200 Subject: Skip null statement. --- pyGHDL/dom/_Translate.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'pyGHDL/dom/_Translate.py') diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index d64e38d82..43c443cc1 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -1000,6 +1000,12 @@ def GetSequentialStatementsFromChainedNodes( yield SequentialReportStatement.parse(statement, label) elif kind == nodes.Iir_Kind.Assertion_Statement: yield SequentialAssertStatement.parse(statement, label) + elif kind == nodes.Iir_Kind.Null_Statement: + print( + "[NOT IMPLEMENTED] null statement (label: '{label}') at line {line}".format( + label=label, line=pos.Line + ) + ) else: raise DOMException( "Unknown statement of kind '{kind}' in {entity} '{name}' at {file}:{line}:{column}.".format( -- cgit v1.2.3