# Assertion property to check for toggle count of a signal between two control signals

**URL:** <https://verificationacademy.com/forums/t/assertion-property-to-check-for-toggle-count-of-a-signal-between-two-control-signals/41282>\
**Category:** SystemVerilog\
**Tags:** System-Verilog, SystemVerilog, assertion\
**Created:** [February 16, 2023, 5:57am UTC](https://verificationacademy.com/forums/t/assertion-property-to-check-for-toggle-count-of-a-signal-between-two-control-signals/41282 "2023-02-16T05:57:58Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![Shubhabrata](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/shubhabrata/32/1644_2.png) [@Shubhabrata](https://verificationacademy.com/forums/u/Shubhabrata)\
**Post date:** [February 22, 2023, 7:42am UTC](https://verificationacademy.com/forums/t/assertion-property-to-check-for-toggle-count-of-a-signal-between-two-control-signals/41282/7 "2023-02-22T07:42:56Z")

</div>

_In reply to [ben@SystemVerilog.us](https://verificationacademy.com/forums/t/assertion-property-to-check-for-toggle-count-of-a-signal-between-two-control-signals/41282/6):_

Hi Ben ,

I was trying to solve it using $past(). It’s not throwing any error on eda-playground , but it’s not displaying what I want.

```verilog

module m;
    bit clk, vld, req, ack, rst_n;
    initial forever #10 clk = !clk;
  property p1;
    int count = 0;
    @(posedge clk) disable iff(!rst_n)
    $rose(req) |=> ((vld != $past(vld),count++)[->0:$] ##1 ($rose(ack),$display("count is:%0d and time is:%0t",count,$realtime))) ##0 (count >= 10);
  endproperty
  assert property (p1);
    initial begin :init1
      $dumpfile("dump.vcd"); $dumpvars;
      repeat (1) @(posedge clk);
        req <= 1'b1; 
        repeat(2) begin :rpt1
            @(posedge clk);
            vld<= 1; req<=0; ack <=0;
            @(posedge clk);
            vld<= 0; req<=0;
            repeat(2) @(posedge clk);
        end :rpt1 
        ack <=1;
        @(posedge clk) req<=1; ack<=0; 
        repeat(3) begin 
          @(posedge clk);
          vld<= 1; req<=0; ack <=0;
          @(posedge clk);
          vld<= 0; req<=0;
          repeat(2) @(posedge clk);
        end
        ack <=1;
        repeat(2) @(posedge clk);
      $finish;
    end
  endmodule

```

-Is it right process or Do I need to think of alternative ?

---

_[View the full topic](https://verificationacademy.com/forums/t/assertion-property-to-check-for-toggle-count-of-a-signal-between-two-control-signals/41282)._
