Previous-value of sampling time in SVA

Hi,
I want to check whether a particular clock has a 50% duty cycle or not. And also intend not to use any local variable inside the property. To do this, I was pondering the possibility of using the $past function. Can we get the previous sampling value using this?

property answer (int clk_period);

@(posedge clk or negedge clk)
(clk_period/2) == ($time - $past($time , 1));

endproperty

  • Can I get the desired answer using this property?

In reply to Shubhabrata:

When in doubt, run a test.

What does $past($realtime, 1, 1, @(clk)) mean?
$realtime is a system function that returns the current time.
Unlike a variable, it has no storage.


/ $past(expr1     [, number_of_ticks]     [, expr2] [,clk_evnt])  

    assert property(@(clk)
     (clk_period/2) == ($realtime - $past($realtime , 1)));
      
      always @(clk) $display("rt= %t, past_rt=%t", 
          $realtime, $past($realtime, 1, 1, @(clk)));
 // Results
rt=                   20, past_rt=                   0
"testbench.sv", 12: top.unnamed$$_1: started at 2000ps failed at 2000ps
	Offending '((10.000000000000000 / 2) == ($realtime - $past($realtime, 1)))'
rt=                  100, past_rt=                   0
"testbench.sv", 12: top.unnamed$$_1: started at 10000ps failed at 10000ps
	Offending '((10.000000000000000 / 2) == ($realtime - $past($realtime, 1)))'
rt=                  120, past_rt=                   0

Ben Cohen
http://www.systemverilog.us/ 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
  2. Free books: * Component Design by Example https://rb.gy/9tcbhl
  1. Papers:

Udemy courses by Srinivasan Venkataramanan (http://cvcblr.com/home.html)
https://www.udemy.com/course/sva-basic/
https://www.udemy.com/course/sv-pre-uvm/