# Can anyone suggest how to write assertion for this question. once enable is high in the next clock cycle one pulse on signal a( width is 1 clk cycle) should be generated every 10 clock cycles

**URL:** <https://verificationacademy.com/forums/t/can-anyone-suggest-how-to-write-assertion-for-this-question-once-enable-is-high-in-the-next-clock-cycle-one-pulse-on-signal-a-width-is-1-clk-cycle-should-be-generated-every-10-clock-cycles/49467>\
**Category:** SystemVerilog\
**Tags:** assertion\
**Created:** [January 24, 2025, 4:30pm UTC](https://verificationacademy.com/forums/t/can-anyone-suggest-how-to-write-assertion-for-this-question-once-enable-is-high-in-the-next-clock-cycle-one-pulse-on-signal-a-width-is-1-clk-cycle-should-be-generated-every-10-clock-cycles/49467 "2025-01-24T16:30:19Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vidhi](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/v/3be4f8/32.png) [@Vidhi](https://verificationacademy.com/forums/u/Vidhi)\
**Post date:** [January 24, 2025, 4:30pm UTC](https://verificationacademy.com/forums/t/can-anyone-suggest-how-to-write-assertion-for-this-question-once-enable-is-high-in-the-next-clock-cycle-one-pulse-on-signal-a-width-is-1-clk-cycle-should-be-generated-every-10-clock-cycles/49467/1 "2025-01-24T16:30:19Z")

</div>

```auto
property prop;
    @(posedge clk)
    if(enable)
      ##1 ((a) ##1 !a[*9])[*1:$];	
endproperty : prop

```

I tried like this. As per the question if should run infinite time but I don’t get it.

---

<div class="post-metadata">

**Author:** ![user49](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/user49/32/4533_2.png) [@user49](https://verificationacademy.com/forums/u/user49)\
**Post date:** [January 24, 2025, 11:14pm UTC](https://verificationacademy.com/forums/t/can-anyone-suggest-how-to-write-assertion-for-this-question-once-enable-is-high-in-the-next-clock-cycle-one-pulse-on-signal-a-width-is-1-clk-cycle-should-be-generated-every-10-clock-cycles/49467/2 "2025-01-24T23:14:53Z")

</div>

This works

```auto
 module m;
  bit clk, enb, a;
  bit[2:0] p0, f0, p1, f1; // p2, f2;
  initial forever #3 clk = !clk;

 
  // if enb && a then a==0 9 more times 
  ap_a9: assert property(@ (posedge clk) enb && a |-> ##1 !a[*9]);  

  // never a==0 occuring 10 times in a row
  ap_no10a: assert property(@ (posedge clk) enb |-> not(!a[*10]));  

 

  initial begin 
    @(posedge clk) enb <= 1; 
      repeat(3) begin 
        @(posedge clk) a<=1; 
         repeat(9) @(posedge clk) a<=0; 
      end
  end
endmodule

```

Link to the list of papers and books that I wrote, many are now donated.  
[https://systemverilog.us/vf/Cohen\_Links\_to\_papers\_books.pdf](https://systemverilog.us/vf/Cohen_Links_to_papers_books.pdf)

---

<div class="post-metadata">

**Author:** ![user49](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/user49/32/4533_2.png) [@user49](https://verificationacademy.com/forums/u/user49)\
**Post date:** [January 25, 2025, 5:29pm UTC](https://verificationacademy.com/forums/t/can-anyone-suggest-how-to-write-assertion-for-this-question-once-enable-is-high-in-the-next-clock-cycle-one-pulse-on-signal-a-width-is-1-clk-cycle-should-be-generated-every-10-clock-cycles/49467/3 "2025-01-25T17:29:44Z")

</div>

```auto
module m;
  bit clk, enb, a;
  bit[2:0] p0, f0, p1, f1; // p2, f2;
  initial forever #3 clk = !clk;

 // Need to handle border cases on "a" after the fist rise of enb.
  // if new enb then ##1 a then no a 9 more times 
 ap_a9enb: assert property(@ (posedge clk) $rose(enb) |-> ##1 a ##1 !a[*9]); 
 
 // if stable enb && a then a==0 9 more times  
  ap_a9: assert property(@ (posedge clk) $stable( enb) && a |-> ##1 !a[*9]);
 
 // never a==0 occurring 10 times in a row
  ap_no10a: assert property(@ (posedge clk) enb |-> not(!a[*10]));

  initial begin 
    @(posedge clk) enb <= 1; 
      repeat(3) begin 
        @(posedge clk) a<=1; 
         repeat(9) @(posedge clk) a<=0; 
      end
  end
endmodule

```

Link to the list of papers and books that I wrote, many are now donated.  
[https://systemverilog.us/vf/Cohen\_Links\_to\_papers\_books.pdf](https://systemverilog.us/vf/Cohen_Links_to_papers_books.pdf)

---

<div class="post-metadata">

**Author:** ![user49](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/user49/32/4533_2.png) [@user49](https://verificationacademy.com/forums/u/user49)\
**Post date:** [January 25, 2025, 9:23pm UTC](https://verificationacademy.com/forums/t/can-anyone-suggest-how-to-write-assertion-for-this-question-once-enable-is-high-in-the-next-clock-cycle-one-pulse-on-signal-a-width-is-1-clk-cycle-should-be-generated-every-10-clock-cycles/49467/4 "2025-01-25T21:23:14Z")

</div>

> [@Vidhi](#):
>
> ```auto
> property prop;
> @(posedge clk)
> if(enable)
> ##1 ((a) ##1 !a[*9])[*1:$];	
> endproperty : prop
>  
> I tried like this. As per the question if should run infinite time but I don’t get it.
> 
> ```

 ![a10times_onlyPass](https://verificationacademy.com/forums/uploads/default/original/2X/9/9903caff2d471fb25c173007805e5dfeb7445f4e.png)  
If (enable) is stable, you also require by the assertion that ( ##1 ((a)) matches. But the previous attempt requires !a repeated 9 times.  
Yoiu have a new attempt at every clock. The other attempts will cause errors

```auto
module m;
  bit clk, enb, a;
  bit[2:0] p0, f0, p1, f1; // p2, f2;
  initial forever #3 clk = !clk;
  event e;

 // Need to handle border cases on "a" after the fist rise of enb.
  // if new enb then ##1 a then no a 9 more times 
 ap_a9enb: assert property(@ (posedge clk) $rose(enb) |-> ##1 a ##1 !a[*9]); 
 
 // if stable enb && a then a==0 9 more times  
  ap_a9: assert property(@ (posedge clk) $stable( enb) && a |-> ##1 !a[*9]);
 
 // never a==0 occurring 10 times in a row
  ap_no10a: assert property(@ (posedge clk) enb |-> not(!a[*10]));

  ap_prop: assert property( @(posedge clk)
    if(enb) ##1 ((a) ##1 !a[*9])[*1:$]);	 

  initial begin 
    int rp; 
    @(posedge clk) enb <= 1; 
    repeat(15) @(posedge clk) a<=1; 
    
      repeat(10) begin 
        if (!randomize(rp) with { rp >4; rp <15; }) ;  
        //`uvm_error("MYERR", "This is a randomize error");

        @(posedge clk) a<=1; 
         repeat(rp) @(posedge clk) a<=0; 
      end
      -> e; 
  end
endmodule

```

---

<div class="post-metadata">

**Author:** ![Vidhi](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/v/3be4f8/32.png) [@Vidhi](https://verificationacademy.com/forums/u/Vidhi)\
**Post date:** [January 27, 2025, 4:43pm UTC](https://verificationacademy.com/forums/t/can-anyone-suggest-how-to-write-assertion-for-this-question-once-enable-is-high-in-the-next-clock-cycle-one-pulse-on-signal-a-width-is-1-clk-cycle-should-be-generated-every-10-clock-cycles/49467/5 "2025-01-27T16:43:06Z")

</div>

Thank you so much Ben for this solution. Can you explain the significance of 4th assertion?  
ap\_prop: assert property( @(posedge clk)  
if(enb) ##1 ((a) ##1 !a[\*9])[\*1:$]);

---

<div class="post-metadata">

**Author:** ![user49](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/user49/32/4533_2.png) [@user49](https://verificationacademy.com/forums/u/user49)\
**Post date:** [January 27, 2025, 5:51pm UTC](https://verificationacademy.com/forums/t/can-anyone-suggest-how-to-write-assertion-for-this-question-once-enable-is-high-in-the-next-clock-cycle-one-pulse-on-signal-a-width-is-1-clk-cycle-should-be-generated-every-10-clock-cycles/49467/6 "2025-01-27T17:51:27Z")

</div>

I was replying to the question and show that this is an incorrect answer because one attempt requires a==1 and then a==0.  
but the next attempt requires a==1. That was a bad assertion

---

<div class="post-metadata">

**Author:** ![Vidhi](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/v/3be4f8/32.png) [@Vidhi](https://verificationacademy.com/forums/u/Vidhi)\
**Post date:** [January 27, 2025, 6:13pm UTC](https://verificationacademy.com/forums/t/can-anyone-suggest-how-to-write-assertion-for-this-question-once-enable-is-high-in-the-next-clock-cycle-one-pulse-on-signal-a-width-is-1-clk-cycle-should-be-generated-every-10-clock-cycles/49467/7 "2025-01-27T18:13:15Z")

</div>

Okay Ben, thanks alot for solving query.

---

<div class="post-metadata">

**Author:** ![user49](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/user49/32/4533_2.png) [@user49](https://verificationacademy.com/forums/u/user49)\
**Post date:** [February 2, 2025, 5:52pm UTC](https://verificationacademy.com/forums/t/can-anyone-suggest-how-to-write-assertion-for-this-question-once-enable-is-high-in-the-next-clock-cycle-one-pulse-on-signal-a-width-is-1-clk-cycle-should-be-generated-every-10-clock-cycles/49467/8 "2025-02-02T17:52:06Z")

</div>

Updated with

```auto
/ if stable enb && a then a==0 9 more times. One "a" every 10
  ap_a9: assert property(@ (posedge clk) $stable( enb) |-> a[=1] intersect 1[*10]);
// also remove the 
// ap_no10a: assert property(@ (posedge clk) enb |-> not(!a[*10]));

```

```auto
module m;
  bit clk, enb, a;
  bit[2:0] p0, f0, p1, f1; // p2, f2;
  initial forever #3 clk = !clk;

 // Need to handle border cases on "a" after the fist rise of enb.
  // if new enb then ##1 a then no a 9 more times 
  ap_a9enb: assert property(@ (posedge clk) $rose(enb) |-> ##1 a ##1 !a[*9]); 
  ap_a9newa: assert property(@ (posedge clk) $stable( enb) && $rose(a) |-> ##1 !a[*9]);
 
 // if stable enb && a then a==0 9 more times. One "a" every 10
  ap_a9: assert property(@ (posedge clk) $stable( enb) |-> a[=1] intersect 1[*10]);
 // $stable( enb) && a |-> ##1 !a[*9]);
 // never a==0 occurring 10 times in a row
  // not needed 
  // ap_no10a: assert property(@ (posedge clk) enb |-> not(!a[*10]));

  initial begin 
    @(posedge clk) enb <= 1; 
      repeat(3) begin 
        @(posedge clk) a<=1; 
         repeat(9) @(posedge clk) a<=0; 
      end
  end
endmodule

```

---

<div class="post-metadata">

**Author:** ![Vidhi](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/v/3be4f8/32.png) [@Vidhi](https://verificationacademy.com/forums/u/Vidhi)\
**Post date:** [February 8, 2025, 12:31pm UTC](https://verificationacademy.com/forums/t/can-anyone-suggest-how-to-write-assertion-for-this-question-once-enable-is-high-in-the-next-clock-cycle-one-pulse-on-signal-a-width-is-1-clk-cycle-should-be-generated-every-10-clock-cycles/49467/9 "2025-02-08T12:31:41Z")

</div>

Thanks alot @ben2
