Using Ternary operator in SVA for Temporal scenario

Hi All ,
A recent thread invoked interest whether ternary operator can replace if - else .

The example in the thread has consequent in non-temporal context .
I was wondering if ternary operator can replace if-else in temporary context as well :

Consider the following concurrent assertion where the if-else is used in temporal context :


  property  ife ;
    @( posedge clk ) a ##1 ( b || c )[->1 ]  |->  if( b )  ( ##1 d ) else ( ##1 e ) ;  //  Consequent is Temporal due to ##1d and ##1 e
  endproperty

Now when I try using ternary operator :


  property  Ternary ;
    @( posedge clk ) a ##1 ( b || c )[->1 ]  |->  ( b == 1 ) ? ( ##1 d ) : ( ##1 e ) ;  //  Syntax error !!
  endproperty

Any suggestions on how could I resolve the compilation error ? Also can a temporal expression be written using ternary operator ?

In reply to MICRO_91:

As I mentioned to you in this reply, There are three layers of assertion expressions: Boolean, sequences, and properties. The ternary operator is part of any Boolean expression, lust like any other logical or arithmetic operator. You cannot have sequence or properties inside a Boolean expression. if/else is an operation on properties.

if (boolean_expression) property_expr;

// is equivalent to

booloen_expression |-> property_expr;

Note that the if condition only allows a boolean expression for its antecedent while the implication operator allows a sequence expression.

In reply to dave_59:

The ternary operator is part of any Boolean expression .You cannot have sequence or properties inside a Boolean expression

Thanks Dave .

In reply to dave_59:

Hi Dave ,

One quick question :


if (boolean_expression) property_expr; 
[ OR ]
if (boolean_expression) property_expr1  else  property_expr2 ;

[Q] Why is it mentioned as property expression specifically ? Can’t it be a sequence expression ?

In the example on top :


 property  ife ;
   @( posedge clk ) a ##1 ( b || c )[->1 ]  |->  if( b )  ( ##1 d ) else ( ##1 e ) ; 
 endproperty

##1 d and ##1 e are basically sequences , so what makes it a property expression and not a sequence expression ?

In reply to Have_A_Doubt:

A property can be a sequence, and a sequence can be a boolean. But the reverse is not true.

Just like in the English language. A sentence is a group of words, but some sentences can be one word (Yes. Go. Correct.). A word is a group of letters, but some words are one letter (“I” “a”).

In reply to dave_59:

Thanks Dave .

I also observed that since if-else operates on property expression :


sequence  seq_if ;
 @( posedge clk0 ) a ##0 if( D ) B ;
endsequence

ap:assert  property( seq_if );

//  Output :  Compilation Error : "property operator inside sequence definition"

[Q] So basically if-else can only be written within a property block , right ?

In reply to Have_A_Doubt:

you can only use property operators/constructs where property expressions are allowed.