Count number of rises of a signal

hi , i want to assert using SVA that after a number of rises of a certain signal the output will be high i mean , i want signal (M) to rise ( 9 times for example ) -between each rise it will be zero for some clocks i don’t care about the duration i want to check only that it rises 9 times and then after a clock cycle output flag is high ,i want to write another assertion where the number of rises is signal variable… any help

In reply to bassem yasser:
Typical requirements include a trigger fo the process. Thus,
Folowing a “go”, “m” rises ntimes and tath is folloed by “b”.


// assuming default clocking, n==0 
ap_gmb: assert property(
   $rose(go) |-> m[->9] ##1 b);   

FOr dynamic repeats, see http://systemverilog.us/vf/SolvingComplexUsersAssertions.pdf


import uvm_pkg::*; `include "uvm_macros.svh" 
package sva_delay_repeat_pkg;
    sequence dynamic_repeat(q_s, count);
        int v=count;
        (1, v=count) ##0 first_match((q_s, v=v-1'b1) [*1:$] ##0 v<=0);
    endsequence
    
    sequence dynamic_delay(count);
        int v;
        (1, v=count) ##0 first_match((1, v=v-1'b1) [*0:$] ##1 v<=0);
    endsequence
endpackage

import sva_delay_repeat_pkg::*;
module top;     
    timeunit 1ns;     timeprecision 100ps;    
    bit clk, a, b, m, go;  
    bit[3:0] n=7;
    default clocking @(posedge clk); 
    endclocking
    initial forever #10 clk=!clk;  
    ap_gmb: assert property(
    $rose(go) |-> m[->9] ##1 b);
    
    sequence s_m; 
        m[->1]; 
    endsequence 
    
    ap_gmb2: assert property(
    $rose(go) |-> dynamic_repeat(s_m, n) ##1 b);

endmodule   
 

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

In reply to ben@SystemVerilog.us:

thanks a lot that was very helpful

In reply to ben@SystemVerilog.us:

thanks a lot that was very helpful