SVA assertion for realtime variables

Hi all ,

I am trying to run following code to check a fixed delay value 4440ps . I want difference of two realtimes’ to be exactly equal to 4440ps . The difference is all correct when I keep $displays and see the logs .But the following code doesn’t pass as a checker. Please see .



realtime mc_b = 4440ps;

 always begin
    @(posedge di_b)   //This is not a clock 
      start_time= $realtime;
    @(posedge indd_b)
     diff= $realtime - start_time;
end

property idel_b;
     @(posedge indd_b) disable iff (!reset)   //indd_b is a signal not a clock .
    diff == mc_b ; 
endproperty

CHECK_delay : assert property (idel_b);

 

In reply to sarth21:

Just to add : “diff” and “start_time” are declared as realtime .

In reply to sarth21:
Removed the always block and modified the property as below.

property idel_b;
     realtime ctime;
     disable iff (!reset)
     @(posedge di_b)
     	(1'b1,ctime=$realtime) |=> 
     @(posedge indd_b)
      (mc_b == $floor($realtime-ctime));
endproperty

In reply to bdreku:

Thanks for the reply. The assertion still fails on posedge of @indd_b

In reply to sarth21:

The display values in logs are same. Yet the assertion fails. Can this happen because of DUT timescale 1ns/1ps.

In reply to sarth21:
It would really help to show a complete example demonstrating your problem and provide the display messages you are seeing.

The following works for me.

`timescale 1ns/1ps
module top;
  
  realtime mc_b = 4440ps;

  bit di_b, indd_b,reset=1;
  
  initial begin
    #1ns
    di_b   <= 1;
    indd_b <= #4440ps 1; //pass
    #10ns
    di_b   <= 0;
    indd_b <= 0;
    #10ns
    di_b   <= 1;
    indd_b <= #4441ps 1; //fail
    #10ns;
  end

  property idel_b;
     realtime ctime;
    disable iff (!reset)
     @(posedge di_b)
     	(1'b1,ctime=$realtime) |=> 
     @(posedge indd_b)
       mc_b == $realtime-ctime;
   endproperty
  
  assert property (idel_b) $info("pass"); else $error("fail");
endmodule

In reply to dave_59:
Hi Dave,

In the below statement, don’t we require $floor as we differentiate two realtime variable which can result to real output?


mc_b == $realtime-ctime;

In reply to bdreku:

You don’t want to use the $floor function here because it converts realtime to an integer in nanoseconds.

That said, it is indeed a bad idea to use equality operators with real numbers. (See this article and this one).

In reply to dave_59:
Yes Dave. Agreed with you. We should avoid comparing the real values whenever it’s possible. But if needed, we can add some tolerance to avoid the rounding error.
I’ve drafted my experience with $floor in this post.