How to write assertions for a Clock divider

In reply to pk_94:


($rose(div_clk[n]) ,local_cnte=0) |=> ((1'b1,local_cnte=local_cnte+1)[*1:$] ##0 (local_cnte==VALUE/2)) ##0 $fell(div_clk[n]);
If (local_cnte==VALUE/2) is true and in the same cycle $fell(div_clk[n] is false, the consequent will keep on trying for another thread.  Specifically, an assertion of the form: 
(a, v=k) |=> (1, v=v+1)[*1:$] ##0 v==x ##0 b; // is same as 
(a, v=k) |=? (1, v=v+1)[*1] ##0 v==x   ##0 b or
      (1, v=v+1)[*2] ##0 v==x   ##0 b or 
      (1, v=v+1)1[*3]##0 v==x ##0 b or 
      .......
      (1, v=v+1)[*n] ##0 v==x##0 b; // where n is infinity/ 
Thus, if any of the thread fails, the simulator will try other threads. 
The first_match() traps the 1st good condition when v==x, and then tests of the b. 
If b==0, assertion fails. thus, 
(a, v=k) |=> first_match((1, v=v+1)[*1:$] ##0 v==x) ##0 b; 
 

Ben Cohen
http://www.systemverilog.us/ ben@systemverilog.us
For training, consulting, services: contact Home - My cvcblr


  1. VF Horizons:PAPER: SVA Alternative for Complex Assertions | Verification Academy
  2. http://systemverilog.us/vf/SolvingComplexUsersAssertions.pdf
  3. “Using SVA for scoreboarding and TB designs”
    http://systemverilog.us/papers/sva4scoreboarding.pdf
  4. “Assertions Instead of FSMs/logic for Scoreboarding and Verification”
    October 2013 | Volume 9, Issue 3 | Verification Academy
  5. SVA in a UVM Class-based Environment
    SVA in a UVM Class-based Environment | Verification Horizons | Verification Academy