Using ternary operator as an alternative to if-else in consequent

Hi Forum Moderators,
I am trying an alternative to the following if-else constraint using a ternary operator
Here is my code snippet using if-else which works as per intention

 property prop1;
   disable iff ( seq.triggered )
   $rose(sig1) |-> if( sig2 > 0 )
                     ( !sig3 throughout seq_expr1 ) ##1 $rose(sig4)[->1]
                   else ##0 $rose(sig4)[->1];
 endproperty                    

When I re-write the consequent as ::

 property prop2;
   disable iff ( seq.triggered )
   $rose(sig1) |-> ( sig2 > 0 ) ? (  ( !sig3 throughout seq_expr1 ) ##1 $rose(sig4)[->1] );
                                : $rose(sig4)[->1];
 endproperty                    

I run into compilation issue ::
"near “throughout”: syntax error, unexpected “SystemVerilog Keyword ‘throughout’”.

[Q1] Is there anything syntactically wrong with my consequent ?

[Q2] As per LRM the syntax for if-else property is

if ( expression_or_dist )  property_expr1 else property_expr2

However to my surprise the semicolon is only valid in property_expr2 and not in property_expr1
Why is it so ?

Ternary operator cannot have sequences or property expressions.

Thanks Dave. Two quick questions to conclude the discussion

(A) On writing the consequent as

if( sig2 > 0 )
  ( !sig3 throughout seq_expr1 ) ##1 $rose(sig4)[->1] ; // Added semicolon
else ##0 $rose(sig4)[->1];

I observe a Compilation Error.
Generally a semicolon is always written at the end of a sequence expression / property expression.
I am curious on why there is an exception with property_expr following the if ( as part of if-else ) ?
( I notice that syntax is valid if I don’t have else part )

(B) If I were to add strong operator in consequent as part of both the property expressions

if( sig2 > 0 )
     strong( ( !sig3 throughout seq_expr1 ) ##1 $rose(sig4)[->1] )
else strong( ##0 $rose(sig4)[->1] );

I observe a Compilation Error on one of the licensed tools ( VCS ) at work

Error-[SVA-SONS] Strong operator not supported

I am aware that we don’t discuss tool related issues here.
However I just wanted to check whether the above consequent ( with strong ) is valid ?

The semicolon ; goes at the end of a property/sequence_spec, not a property/sequence_expr. This means at the end of the entire property/sequence declaration.

“Not supported” is a term vendors use when a tool recognizes valid syntax but have not implemented the corresponding functionality.

1 Like