# System Verilog Assertion For Checking A Signal Being Low During A Power Down, With Time Delays

**URL:** <https://verificationacademy.com/forums/t/system-verilog-assertion-for-checking-a-signal-being-low-during-a-power-down-with-time-delays/41879>\
**Category:** SystemVerilog\
**Tags:** Assertions-clock, system-verilog-assertions-past-stable, SystemVerilog, system-verilog-assertions-disable-iff\
**Created:** [June 29, 2023, 6:59pm UTC](https://verificationacademy.com/forums/t/system-verilog-assertion-for-checking-a-signal-being-low-during-a-power-down-with-time-delays/41879 "2023-06-29T18:59:18Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [June 30, 2023, 12:47am UTC](https://verificationacademy.com/forums/t/system-verilog-assertion-for-checking-a-signal-being-low-during-a-power-down-with-time-delays/41879/2 "2023-06-30T00:47:39Z")

</div>

_In reply to [assert\_yourself](https://verificationacademy.com/forums/t/system-verilog-assertion-for-checking-a-signal-being-low-during-a-power-down-with-time-delays/41879):_  
Your requirements were ambiguous at first, and your description _…n cycles before power\_off_ is confusing. However, if you approach the problem in a forward looking direction, the requirements can easily be translated to SVA.  
Below is my code and simulation. I used the pass/fail signals to more easily see when an assertion passes or fails.

[https://systemverilog.us/vf/powern.sv](https://systemverilog.us/vf/powern.sv) // code  
[Edit code - EDA Playground](https://www.edaplayground.com/x/ssDN)

```verilog

module m; 
  bit clk, p_off, a; 
  int n=4, pass1, pass2, pass3, pass4, pass5, fail1, fail2, fail3, fail4, fail5; 
  initial forever #1 clk = !clk;
  // p_off +--------+---**-----+--------+
  // --------+ +-----------
  // <---n---> <---n--->
  // a +---**-----+
  // ------------------+ +-----------------
  // 1) a==0 p_off==1 while number of clocks from $rose(p_off)to $rose(a) == n
  // 2) a==0 p_off==1 while number of clocks from $fell(a)to $fell(p_off) == n
  // 3) p_off==1 from $rose(p_off) to $fell(a)
  // 4) $rose(a) to $fell(a) is within $rose(p_off) to $fell(p_off)
  // 5) fell(p_off) then a==0
  //
  // 1) a==0 p==1 while number of clocks from $rose(p_off)to $rose(a) == n
  property p_PtoA; 
     int v; 
    @(posedge clk) ($rose(p_off), v=0) |-> 
    (a==0 && p_off==1, v=v+1)[*1:$] ##1 $rose(a) ##0 v==n;
  endproperty
  ap_PtoA: assert property(p_PtoA) pass1=1; else fail1=1;

    // 2) a==0 p_off==1 while number of clocks from $fell(a)to $fell(p_off) == n
  property p_A0toP1; 
  int v; 
    @(posedge clk) ($fell(a), v=0) |-> 
    (a==0 && p_off==1, v=v+1)[*1:$] ##1 $fell(p_off) ##0 v==n;
  endproperty
  ap_P0toA1: assert property(p_A0toP1) pass2=1; else fail2=1;;

// 3) p_off==1 from $rose(p_off) to $fell(a)+1
  ap_poff_toa0: assert property(@(posedge clk) $rose(p_off) |-> 
                                p_off[*1:$] ##0 $fell(a)) pass3=1; else fail3=1;

// 4) $rose(a) to $fell(a) is within $rose(p_off) $fell(p_off)
 ap_a_within: assert property(@(posedge clk) $rose(p_off) |->
          $rose(a) ##[1:$] $fell(a) within 1 ##[1:$] $fell(p_off)) pass4=1; else fail4=1;

            // 5) fell(p_off) then a==0
 ap_poff_0a0: assert property(@(posedge clk) $fell(p_off) |-> a==0) pass5=1; else fail5=1;

    
initial begin 
    
    $dumpfile("dump.vcd"); $dumpvars;
    @(posedge clk) p_off<=1; 
    repeat(4) @(posedge clk);
    a <=1; 
  repeat(6) @(posedge clk);
    a<=0;
    repeat(4) @(posedge clk);
    p_off <=0; 
  #20 $finish;
end
endmodule

```

 ![](https://verificationacademy.com/forums/uploads/default/original/1X/420ac93e918fda2f29a5611dec5f1940b2682b31.png)

 ![](https://verificationacademy.com/forums/uploads/default/original/1X/420ac93e918fda2f29a5611dec5f1940b2682b31.png)

Ben Cohen  
[Ben@systemverilog.us](mailto:Ben@systemverilog.us)  
Link to the list of papers and books that I wrote, many are now donated.

> **[Cohen\_Links\_to\_papers\_books.pdf](https://systemverilog.us/vf/Cohen_Links_to_papers_books.pdf)**
>
> 141.16 KB

or [Cohen\_Links\_to\_papers\_books - Google Docs](https://rb.gy/ibks5p)

Getting started with verification with SystemVerilog

> **[Ben Cohen on LinkedIn: Road map to start with verification: SV, SVA , UVM and TB](https://www.linkedin.com/posts/ben-cohen-1172a0_road-map-to-start-with-verification-sv-activity-7050267628208062464-wnzN?utm_source=share&utm_medium=member_desktop)**
>
> Got this question: 
> Q: I need your advice in getting started with verification with systemverilog. I 've built various projects using Verilog and they was…

---

_[View the full topic](https://verificationacademy.com/forums/t/system-verilog-assertion-for-checking-a-signal-being-low-during-a-power-down-with-time-delays/41879)._
