diff options
-rw-r--r-- | pyGHDL/dom/Concurrent.py | 29 | ||||
-rw-r--r-- | pyGHDL/dom/_Translate.py | 7 | ||||
-rw-r--r-- | testsuite/pyunit/Current.vhdl | 4 |
3 files changed, 35 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( diff --git a/testsuite/pyunit/Current.vhdl b/testsuite/pyunit/Current.vhdl index c7ce678b3..96e9433d9 100644 --- a/testsuite/pyunit/Current.vhdl +++ b/testsuite/pyunit/Current.vhdl @@ -134,6 +134,10 @@ begin a <= b; + assert false; + assert false report "some error"; + assert false severity warning; + assert false report "some note" severity note; inst1: entity work.counter1(rtl) generic map ( |