RE: [sv-bc] question on triggering on sequence end point

From: Chris Spear <Chris.Spear_at_.....>
Date: Thu Feb 09 2006 - 09:43:46 PST
Shalom,

> My question is whether there is a practical difference between "@ abc" and "wait (abc.triggered)".

The difference is the same for procedural events. 
"@abc" blocks until the abc triggers, some time in the future.  
"wait (abc.triggered)" checks if abc has triggered in the current time slot. If not, it waits for abc to trigger.  This helps prevent race conditions where the wait and trigger both happen in the same timeslot, but the trigger executes just before.

Assertions run in the Observed region, while a program runs in the reactive. So potentially @abc will always miss the sequence event if it is started at the same time that the event triggers.

I've attached an example where c changes at 60, then the clock goes high at 70.
A wait-triggered starting at 70 sees the event, but @abc which started at 70 does not.
Every other @ and wait work except the final one.

Of course I could be wrong...

/*********************************************************   
Chris Spear              Verification Specialist             
Synopsys, Inc.           Phone 508-263-8114      ..  __@     
377 Simarano Drive       Fax   508-263-8123        _`\<,_    
Marlboro, MA 01752 USA   Cell  508-254-7223    .. (*)/ (*)   
Spear_ f rom _Synopsys.com       http://Chris.Spear.net              
*********************************************************/ 
module top;
  logic a, b, c, clk;
  gen g1(a, b, clk);
  test t1(c);

  sequence abc;
    @(posedge clk) a ##1 b ##1 c;
  endsequence

  initial $monitor("@%0d: a=%b, b=%b, c=%b, clk=%b", $time, a, b, c, clk);

endmodule: top


module gen(output logic a, b, clk);
  initial begin
    a = 0;
    b = 0;
    // c = 0;
    clk = 0;
    fork
      repeat (9) #10 clk = ~clk;
      begin repeat (1) @(negedge clk); a = 1; end
      begin repeat (2) @(negedge clk); b = 1; end
      //begin repeat (3) @(negedge clk); c = 1; end
      #0 wait (top.abc.triggered) $display("@%0d: module 0: wait abc.triggered", $time);
      #0 @top.abc $display("@%0d: module 0: @abc triggered", $time);
      #70 wait (top.abc.triggered) $display("@%0d: module 70: wait abc.triggered", $time);
      #70 @top.abc $display("@%0d: module 70: @abc triggered", $time);
    join
    $finish;
  end
endmodule


program test(output logic c);
    initial 
      fork
        c <= 0;
        #60 c <= 1;
        #0 wait (top.abc.triggered) $display("@%0d: program 0: wait abc.triggered", $time);
        #0 @top.abc $display("@%0d: program 0: @abc triggered", $time);
        #70 wait (top.abc.triggered) $display("@%0d: program 70: wait abc.triggered", $time);

        // The next does not work
        #70 @top.abc $display("@%0d: program 70: @abc triggered ***********", $time);
      join
endprogram
Received on Thu Feb 9 10:13:12 2006

This archive was generated by hypermail 2.1.8 : Thu Feb 09 2006 - 10:13:59 PST