Results 1 to 7 of 7

Thread: [SVA] signal rise and stay stable -> how to write an assertion?

  1. #1
    Join Date
    Jul 2015
    Posts
    220
    Rep Power
    1

    Default [SVA] signal rise and stay stable -> how to write an assertion?

    Hi All,

    How can I write an assertion for a signal, which should rise within between 10 to 20 cycles and stay stable (HIGH) until the assertion will be disabled?

    Thank you!

  2. #2
    Tricky is offline Moderator **Forum Master**
    Join Date
    Oct 2008
    Posts
    6,031
    Rep Power
    1

    Default Re: [SVA] signal rise and stay stable -> how to write an assertion?

    Best to write a counter to count the number of cycles signal is high, then assert the counter when the signal goes low.

    Code:
    Int cnt;
    
    Always @(posedge clk) begin
      If signal = 1'b0 cnt = 0;
      Else cnt = cnt + 1;
    End;
    
    Assert property ( @(posedge clk) $fell(sig) |-> (cnt >= 10 && cnt <= 20); )

  3. #3
    Join Date
    Jul 2015
    Posts
    220
    Rep Power
    1

    Default Re: [SVA] signal rise and stay stable -> how to write an assertion?

    Thank you Tricky for your response, but actually I wanted something else... Probably I did not explain myself well...

    Actually, I wanted to assert/check the following scenario:
    1) some event (let's name it event1) happens in TestBench
    2) since this event, the signal should rise within between 10 to 20 cycles (if the signal rises after 11 cycles it's OK, if after 19 cycles it's also OK)
    3) once the signal rises, it should stay stable (no changes in the signal) utill another event (let's name it event2) in the TestBench happens

    Here is how I would check that the signal rises within 10 to 20 cycles after event1 happens (is this correct?):
    Code:
    assert property ((posedge clk) (event1) [#10:20] $rose(signal) );
    But how can I add the check what the signal is stable after it's rose and until the assertion is disabled (the check should be disabled when event2==1'b1)?

    Could I write it in the following way?
    Code:
    assert property (@(posedge clk) $rose(event1) [#10:20] $rose(signal));
    assert property (@(posedge clk) disable iff (event2==1'b1) $rose(signal) |-> $stable(signal));
    How to write the above as a single assertion?

    Thank you!
    Last edited by dmitryl; May 6th, 2018 at 11:47 AM.

  4. #4
    Tricky is offline Moderator **Forum Master**
    Join Date
    Oct 2008
    Posts
    6,031
    Rep Power
    1

    Default Re: [SVA] signal rise and stay stable -> how to write an assertion?

    The more complicated your assertion, the harder your simulator has to work on every cycle to check an assertion. If you have a multi cycle assertion, you could have several overlapping assertions, which just adds load to your cpu. And if you ever get into formal verification, your prove time will just explode, if the assertion works at all.

    Ideally you want assertions that are as simple as possible, ideally a |-> b. If necessary, you should write auxiliary code to achieve this, rather than putting the code in the assertion.

    My example can easily be adapted to check for property 2), possibly as a sequence with your first line in your example code.

    For 3), you could just write.

    Code:
    Assert property (@(posedge clk) $rose(event2) |=> $fell(signal) )
    I am not a regular user of sva. Sva is also something very few FPGA engineers will be using. You might get better answers at the mentor verification academy forum.

  5. #5
    Join Date
    Jul 2015
    Posts
    220
    Rep Power
    1

    Default Re: [SVA] signal rise and stay stable -> how to write an assertion?

    "SVA is also something very few FPGA engineers will be using" - why? FPGA engineers still need to write TestBench... it should be much easier to write assertions than going to waveform each time and check behavior of all the signals there...

  6. #6
    Tricky is offline Moderator **Forum Master**
    Join Date
    Oct 2008
    Posts
    6,031
    Rep Power
    1

    Default Re: [SVA] signal rise and stay stable -> how to write an assertion?

    Most FPGA engineers are happy writing immediate assertions (using assert statement without a property), but SVA is another thing, and comes under the verification topic. Most FPGA engineers are happy writing a testbench that gives them a waveform and/or writing a self checking testbench. These can be done without SVA/PSL. As the syntax is nothing like standard RTL, it is outside the comfort zone for most, and is often the preserve of verification engineers, or people that work on ASICs. Im not sure about Modelsim, But I know that the cheapest versions of ActiveHDL and Xilinx Xsim do not support SVA (XSim just ignores SVA, ActiveHDL needs a more expensive licence).

    And as I pointed out earlier, assertions can be a CPU killer when badly written.

  7. #7
    Join Date
    Jul 2015
    Posts
    220
    Rep Power
    1

    Default Re: [SVA] signal rise and stay stable -> how to write an assertion?

    Thanks for sharing your thoughts!

    BTW, what's the difference between the ##[1:3]a and a[1:3] syntax?

Similar Threads

  1. VGA - output of a graphic not stable
    By orPoG in forum VHDL
    Replies: 2
    Last Post: November 20th, 2016, 06:19 AM
  2. What is the mean of "Assertion misses" and "Assertion hits" in Modelsim sim tab?
    By buddha1987 in forum Quartus II and EDA Tools Discussion
    Replies: 3
    Last Post: April 29th, 2013, 08:26 AM
  3. master write done signal high on startup
    By giorgio.lopez in forum IP Discussion
    Replies: 2
    Last Post: May 20th, 2011, 12:19 AM
  4. Cyclone III user I/O stay LOW during JTAG configration
    By hustzq in forum FPGA, Hardcopy, and CPLD Discussion
    Replies: 7
    Last Post: December 11th, 2008, 12:12 AM
  5. Quartus II is NOT stable itself
    By Borden in forum Quartus II and EDA Tools Discussion
    Replies: 16
    Last Post: August 28th, 2007, 11:04 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •