diff options
author | Patrick Lehmann <Patrick.Lehmann@plc2.de> | 2021-08-26 21:08:02 +0200 |
---|---|---|
committer | Patrick Lehmann <Patrick.Lehmann@plc2.de> | 2021-08-26 21:08:13 +0200 |
commit | a7d20ad12d778278452e4ed0351bb98ea73da949 (patch) | |
tree | 000e9e6cfa1e54f38e2ebf6826041e45b7ab81a0 /pyGHDL | |
parent | cb0ec4a5d35d6eb071864f42adefd8d4e2ebaabb (diff) | |
download | ghdl-a7d20ad12d778278452e4ed0351bb98ea73da949.tar.gz ghdl-a7d20ad12d778278452e4ed0351bb98ea73da949.tar.bz2 ghdl-a7d20ad12d778278452e4ed0351bb98ea73da949.zip |
Added concurrent (PSL) assertion.
Diffstat (limited to 'pyGHDL')
-rw-r--r-- | pyGHDL/dom/Concurrent.py | 29 | ||||
-rw-r--r-- | pyGHDL/dom/_Translate.py | 7 |
2 files changed, 31 insertions, 5 deletions
diff --git a/pyGHDL/dom/Concurrent.py b/pyGHDL/dom/Concurrent.py index 560acafb2..c248378b9 100644 --- a/pyGHDL/dom/Concurrent.py +++ b/pyGHDL/dom/Concurrent.py @@ -57,6 +57,7 @@ from pyVHDLModel.SyntaxModel import ( WaveformElement as VHDLModel_WaveformElement, ConcurrentSimpleSignalAssignment as VHDLModel_ConcurrentSimpleSignalAssignment, ConcurrentProcedureCall as VHDLModel_ConcurrentProcedureCall, + ConcurrentAssertStatement as VHDLModel_ConcurrentAssertStatement, Name, ConcurrentStatement, SequentialStatement, @@ -719,3 +720,31 @@ class ConcurrentProcedureCall(VHDLModel_ConcurrentProcedureCall, DOMMixin): parameterAssociations = GetParameterMapAspect(nodes.Get_Parameter_Association_Chain(callNode)) return cls(concurrentCallNode, label, procedureName, parameterAssociations) + + +@export +class ConcurrentAssertStatement(VHDLModel_ConcurrentAssertStatement, DOMMixin): + def __init__( + self, + assertNode: Iir, + condition: ExpressionUnion, + message: ExpressionUnion = None, + severity: ExpressionUnion = None, + label: str = None, + ): + super().__init__(condition, message, severity, label) + DOMMixin.__init__(self, assertNode) + + @classmethod + def parse(cls, assertNode: Iir, label: str) -> "ConcurrentAssertStatement": + from pyGHDL.dom._Translate import GetExpressionFromNode + + # FIXME: how to get the condition? + # assertNode is a Psl_Assert_Directive + condition = None # GetExpressionFromNode(nodes.Get_Assertion_Condition(assertNode)) + messageNode = nodes.Get_Report_Expression(assertNode) + message = None if messageNode is nodes.Null_Iir else GetExpressionFromNode(messageNode) + severityNode = nodes.Get_Severity_Expression(assertNode) + severity = None if severityNode is nodes.Null_Iir else GetExpressionFromNode(severityNode) + + return cls(assertNode, condition, message, severity, label) diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index 9fe6e9ddd..fe66f2c98 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -166,6 +166,7 @@ from pyGHDL.dom.Concurrent import ( GenericAssociationItem, PortAssociationItem, ParameterAssociationItem, + ConcurrentAssertStatement, ) from pyGHDL.dom.Subprogram import Function, Procedure from pyGHDL.dom.Misc import Alias @@ -922,11 +923,7 @@ def GetConcurrentStatementsFromChainedNodes( 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( - label=label, line=pos.Line - ) - ) + yield ConcurrentAssertStatement.parse(statement, label) else: raise DOMException( "Unknown statement of kind '{kind}' in {entity} '{name}' at {file}:{line}:{column}.".format( |