Frequency_checker

Hi,

I have below code to verify frequency with SVA assertion, but it is failing can you help me here. and ‘clk’ frequency is 2Ghz ,1.998Ghz,2.01Ghz, 1.997Ghz(this is output so freq will change)

`timescale 1ns/10fs
module m2b;
property abc;
time current_time;
disable iff (!lock)
('1,current_time = $realtime ) |=> ($realtime -current_time == 0.5ns) || ($realtime -current_time == 0.500500501ns) || ($realtime -current_time == 0.499750125ns) || ($realtime -current_time == 0.500751127ns) || ($realtime -current_time == 0.476190476ns);
endproperty

check1 : assert property(@(posedge clk) abc
endmodule

In reply to iamPkumar:
The following works for me


//`timescale 1ps/10fs
module m2b;
  timeunit 1ps;  timeprecision 100fs;  
  bit clk, lock=1; 
  event pass, fail; 
  initial forever #250 clk = !clk;
  property abc;
    time current_time;
    disable iff (!lock)
        ('1,current_time = $realtime ) |=> 
        ($realtime -current_time == 0.5ns) || 
        ($realtime -current_time == 0.500500501ns) || 
        ($realtime -current_time == 0.499750125ns) || 
        ($realtime -current_time == 0.500751127ns) || 
        ($realtime -current_time == 0.476190476ns);
   endproperty
   check1 : assert property(@(posedge clk) abc) -> pass; else -> fail; 
endmodule

Ben Cohen
http://www.systemverilog.us/ ben@systemverilog.us
For training, consulting, services: contact http://cvcblr.com/home.html
** 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 | Verification Academy
  2. Free books: Component Design by Example FREE BOOK: Component Design by Example … A Step-by-Step Process Using VHDL with UART as Vehicle | Verification Academy
    Real Chip Design and Verification Using Verilog and VHDL($3) Amazon.com
  3. Papers:

In reply to ben@SystemVerilog.us:

Hi ben@SystemVerilog.us,
Thanks for replay, Can you please tell me what is the role of timescale here,
what happen if we use timeprecision as 10fs ??
timeunit 1ps; timeprecision 10fs;

Thanks,

In reply to iamPkumar:

SystemVerilog uses a discrete simulation event model, which means that time is an integer. It will round a real time value to the nearest specified time precision. The smallest time precision it allows is 1 femtosecond (1fs).

The level of precision you are asking for will not work. The literal time value 0.476190476ns is 476190.476fs. With a timeunit 1ps; timeprecision 10fs;, that value gets converted to 476.19ps. The time datatype is a 64-bit integer, so if you were to store this literal in current_time, it would just be 476.

The conclusion I am coming to is that you should be using some other timing analysis tool for this level of accuracy, not discrete event simulation.

In reply to dave_59:
Hi dave,
Thanks for reply,
with mentioned timeprecision = 100fs , am still seeing below issue.

check1 : assert property(@(posedge clk) abc)
$display(“pass at time %t”, $realtime); else
$display(“fail at time %t”, $realtime);

started at 5045198069fs failed at 5045698069fs
Offending ‘(((((($realtime - current_time) == 500.00000000000000) || (($realtime - current_time) == 500.50050099999999)) || (($realtime - current_time) == 499.75012499999997)) || (($realtime - current_time) == 500.75112700000000)) || (($realtime - current_time) == 476.19047599999999))’
fail at time 5045.698ns

In reply to iamPkumar:

Please post a complete minimal example, like what Ben wrote.

In reply to dave_59:

Hi dev, please find the code

module m2b;
  timeunit 1ps;  timeprecision 100fs;  
  bit clk, lock=1; 
  event pass, fail; 
  initial forever #250 clk = !clk;
  property abc;
    time current_time;
    disable iff (!lock)
        ('1,current_time = $realtime ) |=> 
        ($realtime -current_time == 0.5ns) || 
        ($realtime -current_time == 0.500500501ns) || 
        ($realtime -current_time == 0.499750125ns) || 
        ($realtime -current_time == 0.500751127ns) || 
        ($realtime -current_time == 0.476190476ns);
   endproperty
   check1 : assert property(@(posedge clk) abc)
$display("pass at time %t", $realtime); else
$display("fail at time %t", $realtime);
endmodule

In reply to iamPkumar:

From the above code, can we print $real_time - current_time like below

//////
($realtime -current_time == 0.5ns) ||
($realtime -current_time == 0.500500501ns, $display(“Time_period = %t”,$realtime - currenttime) ||
($realtime -current_time == 0.499750125ns) ||
($realtime -current_time == 0.500751127ns) ||
($realtime -current_time == 0.476190476ns);

In reply to iamPkumar:

This might be an issue with precision of real numbers which only has 56 bits. But you run you r simulation indefinitely so that the 64-bit integer time loses precision when converting to a real number.

In reply to dave_59:

But you run you r simulation indefinitely so that the 64-bit integer time loses precision when converting to a real number.

So, is there any other way to check this type of issues?

In reply to iamPkumar:

The conclusion I am coming to is that you should be using some other timing analysis tool for this level of accuracy, not discrete event simulation.

Look for tools provided by the vendor you are implemented your hardware on.

In reply to dave_59:

Hi Above code working with adding of tolerance. but i want to print current_time value on wave. i have tried with multiple examples but not working. can anyone help me?
module m2b;
timeunit 1ps; timeprecision 100fs;
bit clk, lock=1;
event pass, fail;
time clk_period = 0.5ns
initial forever #250 clk = !clk;
property abc;
time current_time;
disable iff (!lock)
('1,current_time = $realtime ) |=>
((clk_period <= $realtime-(current_time-0.001ns)) &&
(clk_period >= $realtime-(current_time+ 0.001ns)));

endproperty
check1 : assert property(@(posedge clk) abc)
$display(“pass at time %t”, $realtime); else
$display(“fail at time %t”, $realtime);
endmodule

In reply to iamPkumar:
This Mentor/Siemens EDA sponsored public forum is not for discussing tool specific usage or issues. Please read your tool’s user manual or contact your tool vendor directly for support.