Timing Assertions

The following scenario should give errors as assertions should be violated (on purpose). But, the check is extending from one “run” to the next, and the assertion is being checked as valid.

I’ve used $rose(valid) so that the assertion begins only when valid has asserted HIGH, not for every clock cycle it finds valid to be high. Is there a better way to do this?? as this makes the assertion start at 20ns, while valid was asserted HIGH at 10ns.


module assertions_1;
    bit valid, ready, clk;
    
    always #5 clk = ~clk;
    
    initial begin
        repeat (5) run();
        repeat (5) begin @(negedge clk); 
        end 
        $finish;
    end
    
    task run();
        @(negedge clk) valid = 1;
        repeat ($urandom_range(1,4)) begin 
            @(negedge clk);
        end 
        ready = 1;
        @(negedge clk) ready = 0; valid = 0;
    endtask

    property RUN;
        @(negedge clk) $rose(valid) |-> valid ##[6:10] $stable(valid) && ready;
    endproperty
    
    assert property(RUN) $display($time, "ns Signal Transition is ok");
        else $error($time, "ns Signal Transition has Issues");

endmodule

In reply to Husni Mahdi:

  1. You need the $rose(valid). I don’t see any issue with your assertion. On your TB, I prefer to use nonblocking assignments as a style, though the model would work.
  2. $rose(valid) |-> valid // at $rose(valid) valid==1, thus the valid in the consequent is not needed

task run();
        @(negedge clk) valid <= 1; 
// the valid=1 works because signals are sampled and 
//   use the values of the Preponed region of the time stamp.
        repeat ($urandom_range(1,4)) begin 
            @(negedge clk);
        end 
        ready <= 1;
        @(negedge clk) ready <= 0; valid <= 0;
    endtask
 
property RUN;
        @(negedge clk) $rose(valid) |-> ##[6:10] $stable(valid) && ready;
    endproperty
 

Ben Cohen
http://www.systemverilog.us/ ben@systemverilog.us
** SVA Handbook 4th Edition, 2016 ISBN 978-1518681448

  1. SVA Package: Dynamic and range delays and repeats SVA: Package for dynamic and range delays and repeats | Verification Academy
  2. Free books:
  1. Papers:
    Understanding the SVA Engine,
    Verification Horizons - July 2020 | Verification Academy
    Reflections on Users’ Experiences with SVA, part 1
    Reflections on Users’ Experiences with SVA | Verification Horizons - March 2022 | Verification Academy
    Reflections on Users’ Experiences with SVA, part 2
    Reflections on Users’ Experiences with SVA, Part II | Verification Horizons - July 2022 | Verification Academy
    Understanding and Using Immediate Assertions
    Understanding and Using Immediate Assertions | Verification Horizons - December 2022 | Verification Academy
    SUPPORT LOGIC AND THE ALWAYS PROPERTY
    http://systemverilog.us/vf/support_logic_always.pdf
    SVA Alternative for Complex Assertions
    Verification Horizons - March 2018 Issue | Verification Academy
    SVA in a UVM Class-based Environment
    SVA in a UVM Class-based Environment | Verification Horizons | Verification Academy
    SVA for statistical analysis of a weighted work-conserving prioritized round-robin arbiter.
    https://verificationacademy.com/forums/coverage/sva-statistical-analysis-weighted-work-conserving-prioritized-round-robin-arbiter.
    Udemy courses by Srinivasan Venkataramanan (http://cvcblr.com/home.html)
    https://www.udemy.com/course/sva-basic/
    https://www.udemy.com/course/sv-pre-uvm/

In reply to Husni Mahdi:

By saying you don’t want the assertion checking “from one “run” to the next”, I think you want this to fail if valid falls and ready has not been asserted. I think you might look to see if this meets your needs:

$rose(valid) |-> ready[=1] within valid[*6:10];

In reply to dave_59:

Thank You Mr. Dave,
This was what I was looking for.

But there remains an issue, I made slight changes, so that ready triggers, 4 to 7 clocks cycles after valid is HIGH. And the assertion will pass for when ready is triggered 6:10 cycles after valid.


    task run();
        @(negedge clk) valid <= 1;
        repeat ($urandom_range(4,7)) begin 
            @(negedge clk);
        end 
        ready <= 1;
        @(negedge clk) ready <= 0; valid <= 0;
    endtask
    
    property RUN;
//        @(negedge clk) $rose(valid) |-> ##[6:10] $stable(valid) && ready;
        @(negedge clk) $rose(valid) |-> ready[=1] within valid[*6:10];
    endproperty

In this case, it shows error for 4 cycle delay. And shows passed for 6 and 7 cycle delays i.e., as we want it to behave.

But for delays of 5 cycle it shows passed, but that should also state an error, as the least delay should be 6 cycles.

In reply to dave_59:
Also, in case of $rose(valid) will start the assertion the next clock after the valid has actually gone HIGH. While stating only “valid” starts the assertion on every negative clock edge it finds valid to be HIGH.

Is there any way to start the assertion on exactly the time valid has gone HIGH and only then not every time the edge finds valid HIGH??

In reply to ben@SystemVerilog.us:

Write assertion for signal “B” will be low after the start bit becomes high within the range of [4:15] clock cycles. “B” will be high at posedge of “A” till this time “B” should be low. See the below diagram for reference.

In reply to Mrutunjay:


clocking df_clk @(posedge clk);
endclocking
default clocking df_clk;
property p1;
$rose(start)|-> ##[4:15] $fell(B) ##0 !B[*1:$] ##1 $rose(A) ##0 B;
endproperty
assert property (p1);

  • I guess this will satiate your requirement. I am unsure whether I should use first_match over here cause I am assuming the tool will automatically defenestrate other possible scenarios.

In reply to Shubhabrata:

What is the purpose of the clocking block here.

In reply to Mrutunjay:


property check_b ;
 start && b && !a|-> ##[4:15] !b ;
endproperty 

property check_a_b ;
 start && a |-> b ;
endproperty 

property check_a_b ;
 start && a && $fell(b) |-> what will happen to a ? ;
endproperty 


In reply to Husni Mahdi:

Nothing special. I used a default clocking for this assertion. It id one of the ways to mention clocking edge.