Hi All,
I was trying to write clock checker, initially I calculated actual_period between two posedge of clocks and expected_period calculated from freequency,
Im trying to calculate expected period based on freequency division, Im putting output log also Im getting check failed even values are same, if I convert to integer and compare then it is matching, anyone help with this, I want to compare clocks without converting into integers, and im using timescale 1ns/1fs
Thanks In Advance.
this is my code:
int freq = 156250;//KHz
bit[3:0] f_div;
realtime exp_period;
realtime actual_period;
realtime c;
realtime p;
initial begin
@(posedge input_clk)
p=$realtime;
$display(" period P is:%0t",p);
forever
begin
@(posedge input_clk)
c=$realtime;
$display(" period C is:%0t",c);
actual_period=c-p;
$display("actual period is:%0t",actual_period);
p=c;
if(f_div==1)
begin
exp_period=1000000000000000fs/(freq*1000);
end
else if(f_div==2)
begin
exp_period=2000000000000fs/(freq*1000);
end
else if(f_div==4)
begin
exp_period=4000000000000000fs/(freq*1000);
end
else if(f_div==8)
begin
exp_period=8000000000000000fs/(freq*1000);
end
if((exp_period!= actual_period))
begin
$display("clock check FAILED for clkout_dig0 actual_period is :%0f expected period is:%0f f_div is %0d ",actual_period,exp_period,f_div);
//`uvm_error($psprintf("actual_period is :%0t expected period is:%0t and f_div is %0d",actual_period,exp_period,f_div,$time),$psprintf("clock check failed for clkout_dig0!"));
end
else begin
$display("clock check PASSED for clkout_dig0 actual_period is :%0t expected period is:%0t f_div is %0d ",actual_period,exp_period,f_div);
end
end
end
LOG
**clock check FAILED for clkout_dig0 actual_period is :6.400000 expected period is:6.400000 f_div is 1 period C is:281985100000
clock check FAILED for clkout_dig0 actual_period is :6.400000 expected period is:6.400000 f_div is 1**