Difference between ' ##0 ' and ' && ' in Assertions

Hi ,
I was trying scenarios using ’ ##0 ’ and ’ && ’ interchangeably .

Consider the following property expression :


  @( posedge clk )  a |=> $rose( b )  ##0 $rose( c );

An alternative to the above using logical operator ’ && ’ would be ::


  @( posedge clk )  a |=> ( $rose( b ) &&  $rose( c ) ) ;

Now if the signals ’ b ’ and ’ c ’ are to be asserted after unknown clocks , I would write property expression as :


  @( posedge clk )  a |-> ##[1:$] ( $rose( b ) ##0 $rose( c ) );

Alternative using ’ && ’ would be :


  @( posedge clk )  a |-> ##[1:$] ( $rose( b ) && $rose( c ) );

A better simulation efficient solution would be :


  @( posedge clk )  a |=> ( $rose( b ) && $rose( c ) ) [->1] ;  // Could be [=1]  as  well in this case  !!

However on writing :


  @( posedge clk )  a |=> ( $rose( b ) ##0 $rose( c ) ) [->1] ;  // Compilation Error !!

Why is it ##0 is considered Illegal using go-to operator ?

In reply to Have_A_Doubt:

It is a syntactical restriction. The left operand of the goto operator [->] must be a boolean expression (or distribution). ##0 is not boolean operator. Even though some sequence expression degenerate into boolean expressions, they are not syntactically boolean expressions.

In reply to dave_59:

One more thing to add on Dave’s reply:
I read the ##0 as the start of a new sequence that starts in the same time
step as the end point of the preceding sequence. Thus,
@( posedge clk ) a |=> $rose(b) ##0 $rose( c );

It’s a different connotation than the logical && that represents combinational logic.
Ben Cohen
Ben@systemverilog.us
Link to the list of papers and books that I wrote, many are now donated.

or Cohen_Links_to_papers_books - Google Docs

Getting started with verification with SystemVerilog

In reply to ben@SystemVerilog.us:

Hi Ben ,

I read the ##0 as the start of a new sequence that starts in the same time step as the end point of the preceding sequence.

Do you mean to say that go-to repetition can only be used with a sequence and not with a concatenation of 2 sequences using ##0 ?

In reply to Have_A_Doubt:

In reply to ben@SystemVerilog.us:
Hi Ben ,
Do you mean to say that go-to repetition can only be used with a sequence and not concatenation of 2 sequences using ##0 ?

The syntax for the goto is Boolean [> n].
b[->1] is equivalent to: !b[*0:] ##1 b b[->2] is equivalent to: !b[*0:] ##1 b ##1 !b[*0:$] ##1 b
b[->2] is equivalent to b[>1] ##0 b[->1]