aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Lehmann <Patrick.Lehmann@plc2.de>2021-07-28 23:52:31 +0200
committerumarcor <unai.martinezcorral@ehu.eus>2021-08-23 16:35:32 +0200
commit50f65e4255f62e662d781d01f395c029426c1529 (patch)
tree912ff02260754ece39cd566932c75f552b8de764
parent20b636decb9c502891fbf5f9a15cf8e7126904a5 (diff)
downloadghdl-50f65e4255f62e662d781d01f395c029426c1529.tar.gz
ghdl-50f65e4255f62e662d781d01f395c029426c1529.tar.bz2
ghdl-50f65e4255f62e662d781d01f395c029426c1529.zip
More handling of concurrent statements.
-rw-r--r--pyGHDL/dom/Concurrent.py171
-rw-r--r--pyGHDL/dom/_Translate.py72
2 files changed, 178 insertions, 65 deletions
diff --git a/pyGHDL/dom/Concurrent.py b/pyGHDL/dom/Concurrent.py
index 2698054e5..d4e7cf6ff 100644
--- a/pyGHDL/dom/Concurrent.py
+++ b/pyGHDL/dom/Concurrent.py
@@ -35,42 +35,63 @@ from typing import Iterable
from pydecor import export
from pyVHDLModel.SyntaxModel import (
- ConcurrentBlockStatement as VHDLModel_ConcurrentBlockStatement,
ComponentInstantiation as VHDLModel_ComponentInstantiation,
EntityInstantiation as VHDLModel_EntityInstantiation,
ConfigurationInstantiation as VHDLModel_ConfigurationInstantiation,
- ConcurrentStatement, Name,
+ ConcurrentBlockStatement as VHDLModel_ConcurrentBlockStatement,
+ ProcessStatement as VHDLModel_ProcessStatement,
+ IfGenerateBranch as VHDLModel_IfGenerateBranch,
+ IfGenerateStatement as VHDLModel_IfGenerateStatement,
+ CaseGenerateStatement as VHDLModel_CaseGenerateStatement,
+ ForGenerateStatement as VHDLModel_ForGenerateStatement,
+ ConcurrentStatement,
+ Name,
+ SequentialStatement,
+ IfGenerateBranch,
)
from pyGHDL.libghdl import Iir
from pyGHDL.libghdl.vhdl import nodes
from pyGHDL.dom import DOMMixin
-from pyGHDL.dom._Utils import GetNameOfNode
+from pyGHDL.dom._Utils import GetNameOfNode, GetIirKindOfNode
@export
class ComponentInstantiation(VHDLModel_ComponentInstantiation, DOMMixin):
- def __init__(self, node: Iir, label: str, componentName: Name):
+ def __init__(self, instantiationNode: Iir, label: str, componentName: Name):
super().__init__(label, componentName)
- DOMMixin.__init__(self, node)
+ DOMMixin.__init__(self, instantiationNode)
@classmethod
- def parse(cls, instantiationNode: Iir, instantiatedUnit: Iir, label: str) -> "ComponentInstantiation":
+ def parse(
+ cls, instantiationNode: Iir, instantiatedUnit: Iir, label: str
+ ) -> "ComponentInstantiation":
from pyGHDL.dom._Translate import GetNameFromNode
componentName = GetNameFromNode(instantiatedUnit)
+ # TODO: get mapped generics
+ # TODO: get mapped ports
+
return cls(instantiationNode, label, componentName)
@export
class EntityInstantiation(VHDLModel_EntityInstantiation, DOMMixin):
- def __init__(self, node: Iir, label: str, entityName: Name, architectureName: Name = None):
+ def __init__(
+ self,
+ instantiationNode: Iir,
+ label: str,
+ entityName: Name,
+ architectureName: Name = None,
+ ):
super().__init__(label, entityName, architectureName)
- DOMMixin.__init__(self, node)
+ DOMMixin.__init__(self, instantiationNode)
@classmethod
- def parse(cls, instantiationNode: Iir, instantiatedUnit: Iir, label: str) -> "EntityInstantiation":
+ def parse(
+ cls, instantiationNode: Iir, instantiatedUnit: Iir, label: str
+ ) -> "EntityInstantiation":
from pyGHDL.dom._Translate import GetNameFromNode
entityId = nodes.Get_Entity_Name(instantiatedUnit)
@@ -81,22 +102,30 @@ class EntityInstantiation(VHDLModel_EntityInstantiation, DOMMixin):
if architectureId != nodes.Null_Iir:
architectureName = GetNameOfNode(architectureId)
+ # TODO: get mapped generics
+ # TODO: get mapped ports
+
return cls(instantiationNode, label, entityName, architectureName)
@export
class ConfigurationInstantiation(VHDLModel_ConfigurationInstantiation, DOMMixin):
- def __init__(self, node: Iir, label: str, configurationName: Name):
+ def __init__(self, instantiationNode: Iir, label: str, configurationName: Name):
super().__init__(label, configurationName)
- DOMMixin.__init__(self, node)
+ DOMMixin.__init__(self, instantiationNode)
@classmethod
- def parse(cls, instantiationNode: Iir, instantiatedUnit: Iir, label: str) -> "ConfigurationInstantiation":
+ def parse(
+ cls, instantiationNode: Iir, instantiatedUnit: Iir, label: str
+ ) -> "ConfigurationInstantiation":
from pyGHDL.dom._Translate import GetNameFromNode
configurationId = nodes.Get_Configuration_Name(instantiatedUnit)
configurationName = GetNameFromNode(configurationId)
+ # TODO: get mapped generics
+ # TODO: get mapped ports
+
return cls(instantiationNode, label, configurationName)
@@ -104,14 +133,13 @@ class ConfigurationInstantiation(VHDLModel_ConfigurationInstantiation, DOMMixin)
class ConcurrentBlockStatement(VHDLModel_ConcurrentBlockStatement, DOMMixin):
def __init__(
self,
- node: Iir,
+ blockNode: Iir,
label: str,
- # portItems: Iterable[PortInterfaceItem] = None,
declaredItems: Iterable = None,
bodyItems: Iterable["ConcurrentStatement"] = None,
):
super().__init__(label, None, declaredItems, bodyItems)
- DOMMixin.__init__(self, node)
+ DOMMixin.__init__(self, blockNode)
@classmethod
def parse(cls, blockNode: Iir, label: str) -> "ConcurrentBlockStatement":
@@ -128,3 +156,116 @@ class ConcurrentBlockStatement(VHDLModel_ConcurrentBlockStatement, DOMMixin):
)
return cls(blockNode, label, declaredItems, bodyItems)
+
+
+@export
+class ProcessStatement(VHDLModel_ProcessStatement, DOMMixin):
+ def __init__(
+ self,
+ processNode: Iir,
+ label: str = None,
+ declaredItems: Iterable = None,
+ statements: Iterable[SequentialStatement] = None,
+ sensitivityList: Iterable[Name] = None,
+ ):
+ super().__init__(label, declaredItems, statements, sensitivityList)
+ DOMMixin.__init__(self, processNode)
+
+ @classmethod
+ def parse(
+ cls, processNode: Iir, label: str, hasSensitivityList: bool
+ ) -> "ProcessStatement":
+ from pyGHDL.dom._Translate import (
+ GetDeclaredItemsFromChainedNodes,
+ GetStatementsFromChainedNodes,
+ )
+
+ # TODO: get sensitivity list
+ # TODO: get declared items
+ # TODO: get sequential statements
+
+ declaredItems = None
+ statements = None
+ sensitivityList = None
+
+ if hasSensitivityList:
+ pass
+
+ return cls(processNode, label, declaredItems, statements, sensitivityList)
+
+
+@export
+class IfGenerateBranch(VHDLModel_IfGenerateBranch):
+ def __init__(
+ self,
+ branchNode: Iir,
+ alternativeLabel: str = None,
+ declaredItems: Iterable = None,
+ statements: Iterable[ConcurrentStatement] = None,
+ ):
+ super().__init__(declaredItems, statements)
+ DOMMixin.__init__(self, branchNode)
+
+
+@export
+class IfGenerateStatement(VHDLModel_IfGenerateStatement, DOMMixin):
+ def __init__(self, generateNode: Iir, label: str, ifBranch: IfGenerateBranch):
+ super().__init__(label, ifBranch)
+ DOMMixin.__init__(self, generateNode)
+
+ @classmethod
+ def parse(cls, generateNode: Iir, label: str) -> "IfGenerateStatement":
+ from pyGHDL.dom._Translate import (
+ GetDeclaredItemsFromChainedNodes,
+ GetStatementsFromChainedNodes,
+ )
+
+ # TODO: get branches
+ # TODO: get declared items
+ # TODO: get concurrent statements
+
+ body = nodes.Get_Generate_Statement_Body(generateNode)
+ alternativeLabelId = nodes.Get_Alternative_Label(body)
+ alternativeLabel = ""
+
+ declarationChain = nodes.Get_Declaration_Chain(body)
+ declaredItems = GetDeclaredItemsFromChainedNodes(
+ declarationChain, "if-generate", label
+ )
+
+ statementChain = nodes.Get_Concurrent_Statement_Chain(body)
+ statements = GetStatementsFromChainedNodes(statementChain, "if-generate", label)
+
+ ifBranch = IfGenerateBranch(body, alternativeLabel, declaredItems, statements)
+
+ return cls(generateNode, label, ifBranch)
+
+
+@export
+class CaseGenerateStatement(VHDLModel_CaseGenerateStatement, DOMMixin):
+ def __init__(self, generateNode: Iir, label: str):
+ super().__init__(label)
+ DOMMixin.__init__(self, generateNode)
+
+ @classmethod
+ def parse(cls, generateNode: Iir, label: str) -> "CaseGenerateStatement":
+ # TODO: get choices
+ # TODO: get declared items
+ # TODO: get concurrent statements
+
+ return cls(generateNode, label)
+
+
+@export
+class ForGenerateStatement(VHDLModel_ForGenerateStatement, DOMMixin):
+ def __init__(self, generateNode: Iir, label: str):
+ super().__init__(label)
+ DOMMixin.__init__(self, generateNode)
+
+ @classmethod
+ def parse(cls, generateNode: Iir, label: str) -> "ForGenerateStatement":
+ # TODO: get index and range
+ # TODO: get declared items
+ # TODO: get concurrent statements
+
+ return cls(generateNode, label)
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(