How to write assertion with local variables

There are two questions I don’t know that both need local variable.

  1. a will be high for 1clk, then 10 clk later b will high for 1clk.
    But the tricky part is A can rise for several times. Then I need to check each a matches the right b.
  2. a will be always high until seeing b is high, then next clk both will be deasserted. Same thing, I think I need to add local variables to count a and b and check at the end if total are the same.
    But I never write before. Could anyone help on these two questions?

In reply to aaaaaa:

There are two questions I don’t know that both need local variable.

  1. a will be high for 1clk, then 10 clk later b will high for 1clk.
    But the tricky part is A can rise for several times. Then I need to check each a matches the right b.

see

  1. a will be always high until seeing b is high, then next clk both will be deasserted. Same thing, I think I need to add local variables to count a and b and check at the end if total are the same.
    But I never write before. Could anyone help on these two questions?

No need for local variables

 
first_match($rose(a) ##1 a[*1:$] ##1 b) |-> 
       ##1 !a && !b; 



Ben Cohen
http://www.systemverilog.us/ ben@systemverilog.us
For training, consulting, services: contact Home - My cvcblr
** 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
  2. Free books: Component Design by Example https://rb.gy/9tcbhl
    Real Chip Design and Verification Using Verilog and VHDL($3) https://rb.gy/cwy7nb
  3. Papers: