# Solve the following assertion

**URL:** <https://verificationacademy.com/forums/t/solve-the-following-assertion/49406>\
**Category:** SystemVerilog\
**Tags:** SVA, assertion\
**Created:** [January 14, 2025, 2:43pm UTC](https://verificationacademy.com/forums/t/solve-the-following-assertion/49406 "2025-01-14T14:43:14Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deep\_R](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/d/839c29/32.png) [@Deep\_R](https://verificationacademy.com/forums/u/Deep_R)\
**Post date:** [January 14, 2025, 2:43pm UTC](https://verificationacademy.com/forums/t/solve-the-following-assertion/49406/1 "2025-01-14T14:43:14Z")

</div>

If REQ is asserted then the GRANT will be asserted after 3 clock cycles and the GRANT need to be high for the no.of cycles that the REQ was high

---

<div class="post-metadata">

**Author:** ![LFT](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/l/34f0e0/32.png) [@LFT](https://verificationacademy.com/forums/u/LFT)\
**Post date:** [January 14, 2025, 3:12pm UTC](https://verificationacademy.com/forums/t/solve-the-following-assertion/49406/2 "2025-01-14T15:12:11Z")

</div>

I didn’t get the last part

> GRANT need to be high for the no.of cycles that the REQ was high

Assume that $rose( req ) is true at T0 so $rose( grant ) must be true at T3.  
Do you mean that req will go low i.e de-assert after T3 or at T3 ?  
(a) If Req goes low at T3 then grant should be remain asserted for 3 clocks ? i.e T3 T4 T5  
(a) If Req goes low at T5 then grant should be remain asserted for 5 clocks ? i.,e T3 T4 T5 T6 T7

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [January 14, 2025, 5:21pm UTC](https://verificationacademy.com/forums/t/solve-the-following-assertion/49406/3 "2025-01-14T17:21:42Z")

</div>

This would just be

```verilog
REQ |-> ##3 GRANT;

```

---

<div class="post-metadata">

**Author:** ![Deep\_R](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/d/839c29/32.png) [@Deep\_R](https://verificationacademy.com/forums/u/Deep_R)\
**Post date:** [January 15, 2025, 4:57am UTC](https://verificationacademy.com/forums/t/solve-the-following-assertion/49406/4 "2025-01-15T04:57:20Z")

</div>

If Req is high for 1 cycle, then grant will be high for 1cycle after #3 delay  
If Req is high for 2 cycles, then grant will be high for 2cycles after #3 delay  
If Req is high for random cycles continuously, then grant will be high for that many cycles of req after #3 delay  
overall grant is dependent on req

---

<div class="post-metadata">

**Author:** ![Deep\_R](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/d/839c29/32.png) [@Deep\_R](https://verificationacademy.com/forums/u/Deep_R)\
**Post date:** [January 15, 2025, 5:01am UTC](https://verificationacademy.com/forums/t/solve-the-following-assertion/49406/5 "2025-01-15T05:01:08Z")

</div>

Hi dave,  
If Req is high for 2 cycle then grant should be high for 2 cycles  
is it possible to count how many cycles req is high and can we place that many cycles for grant to be high after #3 dealy

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [January 15, 2025, 6:15am UTC](https://verificationacademy.com/forums/t/solve-the-following-assertion/49406/6 "2025-01-15T06:15:36Z")

</div>

It would really help if you could create an example that demonstrates the conditions you want to check and we can test the validity of the assertions.

---

<div class="post-metadata">

**Author:** ![Deep\_R](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/d/839c29/32.png) [@Deep\_R](https://verificationacademy.com/forums/u/Deep_R)\
**Post date:** [January 15, 2025, 9:20am UTC](https://verificationacademy.com/forums/t/solve-the-following-assertion/49406/7 "2025-01-15T09:20:32Z")

</div>

always @(posedge clk) begin  
req=$random;  
grant=$random;  
end

property prop\_1;  
@(posedge clk) $rose(req) |-\> ##3 $rose(grant);  
endproperty  
assert property(prop\_1);

property prop\_2;  
@(posedge clk) req |-\> ##3 grant;  
endproperty  
assert property(prop\_2);

property prop\_3;  
@(posedge clk) $rose(req) |-\> ##3 $fell(grant);  
endproperty  
assert property(prop\_3)  
Note: Can we use multiple property for it? If Yes, then here all 3 properties must pass then only our design check is successful

- As per my understanding I wrote it, expecting good solution for the above question

---

<div class="post-metadata">

**Author:** ![Have\_A\_Doubt](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/h/51bf81/32.png) [@Have\_A\_Doubt](https://verificationacademy.com/forums/u/Have_A_Doubt)\
**Post date:** [January 15, 2025, 2:49pm UTC](https://verificationacademy.com/forums/t/solve-the-following-assertion/49406/8 "2025-01-15T14:49:49Z")

</div>

It would easier to split it into 2 concurrent assertions

**(1) Grant should be asserted 3 clocks after $rose( req)**

```auto
property prop_1;
@(posedge clk) $rose(req) |-> ##3 $rose(grant);
endproperty
assert property(prop_1);

```

**(2) Grant should remain asserted for same no. of clocks as Req**

```auto
 property p2;
    int unsigned req_t , grant_t ;
    ( ($rose(req),req_t = 0) ##0( (req,req_t++)[*1:$] ##1 $fell(req) ) ) and  
    ( ($rose(grant)[->1],grant_t = 0) ##0( (grant,grant_t++ )[*1:$] ##1 $fell(grant) ) ) |-> ( req_t == grant_t );       
  endproperty  
  
  assert property( @(posedge clk) p2) $display("T:%0t Pass",$time);
                                 else $display("T:%0t Fails",$time);

```

Note: **‘and’ operator requires LHS & RHS sequence start at same clock.**  
Since grant ideally is to be asserted after 3 clocks, I use $grant[-\>1] in RHS.  
`$rose(grant)[->1]` could also be replaced with `$rose(req) ##3 $rose(grant)`

I tested (2) with the following stimulus. It’s working as per expectations

```auto
always #5 clk = !clk;

initial begin
    #4 ; req = 1;    
   `ifdef M1    
 // req is high for 1 clock from T0 to T1. Grant is asserted from T3 to T4    
    #10 ; req = 0;    
    #20 ; grant = 1;
    #10 ; grant = 0;    
  `elsif M2
 // req is high for 1 clock from T0 to T1. Grant is asserted from T3 to T5 i.e 2 clocks ( which is Incorrect ) !!    
    #10 ; req = 0;    
    #20 ; grant = 1;
    #20 ; grant = 0;          
   `elsif M3
 // req is high for 2 clocks from T0 to T2. Grant is asserted from T3 to T5    
    #20 ; req = 0;    
    #10 ; grant = 1;
    #20 ; grant = 0;    
  `elsif M4
 // req is high for 2 clocks from T0 to T2. Grant is asserted from T3 to T4 i.e 1 clock ( which is Incorrect ) !!    
    #20 ; req = 0;    
    #10 ; grant = 1;
    #10 ; grant = 0;      
   `elsif M5
 // req is high for 3 clocks from T0 to T3. Grant is asserted fro T3 to T6  
    #30 ; req = 0;  
        grant = 1;
    #30 ; grant = 0;   
  `elsif M6
  // req is high for 3 clocks from T0 to T3. Grant is asserted from T3 to T5 i.e 2 clocks ( which is Incorrect ) !!   
    #30 ; req = 0;
        grant = 1;
    #20 ; grant = 0;        
   `endif    
    #2 ; $finish();    
  end  

```

---

<div class="post-metadata">

**Author:** ![arshiya\_s](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/f1d935/32.png) [@arshiya\_s](https://verificationacademy.com/forums/u/arshiya_s)\
**Post date:** [January 16, 2025, 5:20am UTC](https://verificationacademy.com/forums/t/solve-the-following-assertion/49406/9 "2025-01-16T05:20:16Z")

</div>

Would this assertion not pass if req is high for 2 cycles and gnt is high for 3 or more cycles as well?

---

<div class="post-metadata">

**Author:** ![Abhinash\_Prasad\_Dash](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/f08c70/32.png) [@Abhinash\_Prasad\_Dash](https://verificationacademy.com/forums/u/Abhinash_Prasad_Dash)\
**Post date:** [January 29, 2025, 3:58pm UTC](https://verificationacademy.com/forums/t/solve-the-following-assertion/49406/10 "2025-01-29T15:58:07Z")

</div>

```auto
property p;
@(posedge clk) $rose(req) |-> !grant[*3] ##1 grant [*1:$] intersect !req[->1];
endproperty

```

---

<div class="post-metadata">

**Author:** ![Have\_A\_Doubt](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/h/51bf81/32.png) [@Have\_A\_Doubt](https://verificationacademy.com/forums/u/Have_A_Doubt)\
**Post date:** [January 30, 2025, 5:56pm UTC](https://verificationacademy.com/forums/t/solve-the-following-assertion/49406/11 "2025-01-30T17:56:58Z")

</div>

@Abhinash_Prasad_Dash  
A few observations ::  
(1) As clarified by [Deep\_R](https://verificationacademy.com/forums/t/solve-the-following-assertion/49406/4) ::  
If Req is high for 1 cycle, then grant will be high for 1cycle after #3 delay  
If Req is high for 2 cycles, then grant will be high for 2cycles after #3 delay

These cases are not covered using your solution.

(2) Your consequent requires grant to be low on the clock that $rose(req) is true and grant should remain low for next 2 clocks as well.

```
  The original post doesn't specifically mention this as requirement.

```

(3) Intersect operator requires LHS & RHS sequence to be start at the same clock as well as end at the same clock.

For the following stimulus ::

```auto
always #5 clk = !clk;

initial begin
    #4 ; req = 1;
  #30 ; grant = 1 ; req = 0;   
    #2 ; $finish();
end

```

The assertion passes although ‘req’ was high for 3 clocks and ‘grant’ was high for 1 clock.  
Ideally as per intention this should have resulted in assertion failure

---

<div class="post-metadata">

**Author:** ![Abhinash\_Prasad\_Dash](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/f08c70/32.png) [@Abhinash\_Prasad\_Dash](https://verificationacademy.com/forums/u/Abhinash_Prasad_Dash)\
**Post date:** [January 30, 2025, 7:08pm UTC](https://verificationacademy.com/forums/t/solve-the-following-assertion/49406/12 "2025-01-30T19:08:19Z")

</div>

Thanks @Have_A_Doubt for pointing out. Confusion on my end thought that after grant goes high it should remain high as long as req is high. Your solution seems to be correct for the requirement.

---

<div class="post-metadata">

**Author:** ![flyant](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/f/7cd45c/32.png) [@flyant](https://verificationacademy.com/forums/u/flyant)\
**Post date:** [January 31, 2025, 2:48am UTC](https://verificationacademy.com/forums/t/solve-the-following-assertion/49406/13 "2025-01-31T02:48:54Z")

</div>

I wrote this assertion, do you think it will pass?

```auto
property P1;
@(posedge clk)
$rose(REQ) ##3 (grant[*1:$] intersect !REQ[->1]) ##1 (grant == $past(REQ, 3)) ##1 (grant == $past(REQ, 2)) ##1 (grant == $past(REQ, 1)) ##1 (grant == 0);
endproperty

```

---

<div class="post-metadata">

**Author:** ![Have\_A\_Doubt](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/h/51bf81/32.png) [@Have\_A\_Doubt](https://verificationacademy.com/forums/u/Have_A_Doubt)\
**Post date:** [January 31, 2025, 7:13am UTC](https://verificationacademy.com/forums/t/solve-the-following-assertion/49406/14 "2025-01-31T07:13:32Z")

</div>

@flyant  
I haven’t tested your code with stimulus but one quick observation is your property expects $rose(REQ) to be True on every clock else assertion would fail.  
If you insist on using ‘intersect’ operator here is one solution which works for the 7 stimulus that I tried ( let me know if it isn’t working as per expectation for any particular stimulus ) ::

```auto
property p3;
  $rose(req) |-> ( $fell(req)[->1] ##3 1 ) intersect ( 1 ##3 $rose(grant) ##1 $fell(grant)[->1] );
 endproperty

```

Note that intersect operator requires that both LHS & RHS sequence start at the same clock as well as end at the same clock.  
**Since $fell(req) could be true as soon as 1 clock after $rose(req) I use `##3 1` at the end of LHS sequence**

**EDIT :: property ‘p3’ clubs (1) and (2). So if grant isn’t asserted 3 clocks after req, ‘p3’ will catch it as well.**

---

<div class="post-metadata">

**Author:** ![flyant](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/f/7cd45c/32.png) [@flyant](https://verificationacademy.com/forums/u/flyant)\
**Post date:** [January 31, 2025, 10:06pm UTC](https://verificationacademy.com/forums/t/solve-the-following-assertion/49406/15 "2025-01-31T22:06:07Z")

</div>

> [@Have\_A\_Doubt](#):
>
> I haven’t tested your code with stimulus but one quick observation is your property expects $rose(REQ) to be True on every clock else assertion would fail.

the LHS and RHS of intersect are grant[\*1:$] and !REQ[-\>1], why does the property expect $rose(REQ) to be True on every clock

---

<div class="post-metadata">

**Author:** ![Have\_A\_Doubt](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/h/51bf81/32.png) [@Have\_A\_Doubt](https://verificationacademy.com/forums/u/Have_A_Doubt)\
**Post date:** [February 1, 2025, 5:31am UTC](https://verificationacademy.com/forums/t/solve-the-following-assertion/49406/16 "2025-02-01T05:31:11Z")

</div>

> [@flyant](#):
>
> > [@Have\_A\_Doubt](#):
> >
> > I haven’t tested your code with stimulus but one quick observation is your property expects $rose(REQ) to be True on every clock else assertion would fail.
> 
> the LHS and RHS of intersect are grant[\*1:$] and !REQ[-\>1], why does the property expect $rose(REQ) to be True on every clock

When your **property executes on every posedge of clk** ,  
what’s the first thing aka sequence\_expression that is evaluated / checked ?

Test the following **over multiple clocks** ::

```auto
 property p1;
  @(posedge clk) $rose(req) |-> ##3 $rose(grant);
 endproperty

 property p2;
  @(posedge clk) $rose(req) ##3 $rose(grant);
 endproperty

```
