# Assertion for check SOP signal loss

**URL:** <https://verificationacademy.com/forums/t/assertion-for-check-sop-signal-loss/41037>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, assertion\
**Created:** [November 24, 2022, 3:13pm UTC](https://verificationacademy.com/forums/t/assertion-for-check-sop-signal-loss/41037 "2022-11-24T15:13:28Z")\
**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:** [November 24, 2022, 7:42pm UTC](https://verificationacademy.com/forums/t/assertion-for-check-sop-signal-loss/41037/2 "2022-11-24T19:42:44Z")

</div>

_In reply to [DefaultName](https://verificationacademy.com/forums/t/assertion-for-check-sop-signal-loss/41037):_  
Your approach looks OK, but I took a different approach with support logic that addresses other cases. specifically, i address the following requirements

1. if(eop) then an sop has happened
2. Every sop has its own eop
3. After an sop no new sop until an eop

See my paper on support logic, the link is in my signature below.

> **[EDA Playground](https://www.edaplayground.com/x/XEwy)**
>
> Edit, save, simulate, synthesize SystemVerilog, Verilog, VHDL and other HDLs from your web browser.

```verilog

module top;
    `include "uvm_macros.svh"
    import uvm_pkg::*;
    bit clk, sop, eop, sop_happen;
    int sop_count, eop_count;
    default clocking @(posedge clk);
    endclocking
    initial forever #10 clk = !clk;
    // Support logic to detect the occurence of a sop 
    always @(posedge clk) begin
       if(sop) sop_happen<=1'b1; 
       if(eop & !sop) sop_happen <= 1'b0;
    end
    // if an eop then sop happened in the past 
    ap_eop_with_sop: assert property(eop |-> sop_happen==1);
    // **********
    // Functions to maintain the counts of sop, eop 
    function void inc_sop();
        sop_count=sop_count+1;
    endfunction: inc_sop
    
    function void inc_eop();
        eop_count=eop_count+1;
    endfunction: inc_eop
    // Every sop has its own eop 
    property p_sop_eop; 
      int sop_flag;
        (sop, sop_flag=sop_count, inc_sop()) |=> eop[->1] ##0 eop_count==sop_flag;
    endproperty
    // Pass or fail, the eop count is incremented 
    ap_sop_eop: assert property(p_sop_eop) inc_eop(); else inc_eop(); 

    initial begin
      bit v_a, v_b, v_err;
      repeat (200) begin
        @(posedge clk);
        if (!randomize(
                v_a, v_b, v_err
            ) with {
              v_a dist {
                1'b1 := 1,
                1'b0 := 1
              };
              v_b dist {
                1'b1 := 1,
                1'b0 := 2
              };
              v_err dist {
                1'b1 := 1,
                1'b0 := 15
              };
            })
          `uvm_error("MYERR", "This is a randomize error");
        sop <= v_a;
        if (v_err == 0) eop <= v_b;
        else eop <= !v_b;
      end
      $finish;
    end
  endmodule
  

```

Ben Cohen  
[http://www.systemverilog.us/](http://www.systemverilog.us/) [ben@systemverilog.us](mailto:ben@systemverilog.us)  
\*\* SVA Handbook 4th Edition, 2016 ISBN 978-1518681448  
…

1. SVA Package: Dynamic and range delays and repeats [SVA: Package for dynamic and range delays and repeats - SystemVerilog - Verification Academy](https://rb.gy/a89jlh)
2. Free books:

- Component Design by Example [https://rb.gy/9tcbhl](https://rb.gy/9tcbhl)
- Real Chip Design and Verification Using Verilog and VHDL($3) [https://rb.gy/cwy7nb](https://rb.gy/cwy7nb)
- A Pragmatic Approach to VMM Adoption  
[http://SystemVerilog.us/vf/VMM/VMM\_pdf\_release070506.zip](http://SystemVerilog.us/vf/VMM/VMM_pdf_release070506.zip)  
[http://SystemVerilog.us/vf/VMM/VMM\_code\_release\_071806.tar](http://SystemVerilog.us/vf/VMM/VMM_code_release_071806.tar)

1. Papers:  
Understanding the SVA Engine,  
[Verification Horizons](https://verificationacademy.com/verification-horizons/july-2020-volume-16-issue-2)  
Reflections on Users’ Experiences with SVA, part 1  
[Reflections on Users’ Experiences with SVA](https://verificationacademy.com/verification-horizons/march-2022-volume-18-issue-1/reflections-on-users-experiences-with-systemverilog-assertions-sva)  
Reflections on Users’ Experiences with SVA, part 2  
[Reflections on Users’ Experiences with SVA - Part II](https://verificationacademy.com/verification-horizons/july-2022-volume-18-issue-2/reflections-on-users-experiences-with-sva-part-2)  
SUPPORT LOGIC AND THE ALWAYS PROPERTY  
[http://systemverilog.us/vf/support\_logic\_always.pdf](http://systemverilog.us/vf/support_logic_always.pdf)  
SVA Alternative for Complex Assertions  
[https://verificationacademy.com/news/verification-horizons-march-2018-issue](https://verificationacademy.com/news/verification-horizons-march-2018-issue)  
SVA in a UVM Class-based Environment  
[https://verificationacademy.com/verification-horizons/february-2013-volume-9-issue-1/SVA-in-a-UVM-Class-based-Environment](https://verificationacademy.com/verification-horizons/february-2013-volume-9-issue-1/SVA-in-a-UVM-Class-based-Environment)  
SVA for statistical analysis of a weighted work-conserving prioritized round-robin arbiter.  
[https://verificationacademy.com/forums/coverage/sva-statistical-analysis-weighted-work-conserving-prioritized-round-robin-arbiter](https://verificationacademy.com/forums/coverage/sva-statistical-analysis-weighted-work-conserving-prioritized-round-robin-arbiter).  
Udemy courses by Srinivasan Venkataramanan ([http://cvcblr.com/home.html](http://cvcblr.com/home.html))  
[https://www.udemy.com/course/sva-basic/](https://www.udemy.com/course/sva-basic/)  
[https://www.udemy.com/course/sv-pre-uvm/](https://www.udemy.com/course/sv-pre-uvm/)

---

_[View the full topic](https://verificationacademy.com/forums/t/assertion-for-check-sop-signal-loss/41037)._
