Assertion to check for the toggle (0->1) of a signal

In reply to pvpatel:

In reply to ben@SystemVerilog.us:
What about if I want to see that signal sig2 should change only once during simulation after sig1 asserted and error should fire if changed more than once.
@(posedge clk) strong(##[1:$] $rose(sig1)) );
This assertion only check once and it will be finished.

Your above sequence (used as a property) does not meet your requirements as it makes no mention of sig2. Also, with what you wrote, if sig1 occurs after 1 million cycles, your assertion creates 1 million separate threads. The simulator may do some optimization.
Thus, for a single firing, put the assertion in an initial block.
assertions typically have an antecedent and a consequence. Something like:


  ap_s1s2: assert property (@(posedge clk) $rose(sig1) |-> s_eventually sig2 );
 ap_s1s2b: assert property (@(posedge clk) $rose(sig1) |->  strong(##[*0:$] sig2)); 
 ap_s1s2c: assert property (@(posedge clk) $rose(sig1) |->  strong(sig2[->1])); 

FOr and error should fire if changed more than once, consider the use of the cover
bit my_error; // If true, fire a message
cp_s1s2b: cover property (@(posedge clk) $rose(sig1) |->  (sig2[->2]) my_error <= 1'b1; 

Ben Cohen
http://www.systemverilog.us/ ben@systemverilog.us

  • SVA Handbook 4th Edition, 2016 ISBN 978-1518681448
  • A Pragmatic Approach to VMM Adoption 2006 ISBN 0-9705394-9-5
  • Using PSL/SUGAR for Formal and Dynamic Verification 2nd Edition, 2004, ISBN 0-9705394-6-0
  • Real Chip Design and Verification Using Verilog and VHDL, 2002 isbn 0-9705394-2-8
  • Component Design by Example ", 2001 ISBN 0-9705394-0-1
  • VHDL Coding Styles and Methodologies, 2nd Edition, 1999 ISBN 0-7923-8474-1
  • VHDL Answers to Frequently Asked Questions, 2nd Edition ISBN 0-7923-8115