ccd
Junior Member

Offline
Posts: 18
|
Hello,
Does anyone know how to measure frequency of a PLL clock in Ultrasim? I created a verilogA model to do this, but I keep getting a spike in freq every so often and I know that's not real because the clock period doesn't change as abruptly as the freq spike indicates. For debugging purpose, I dumped two columns of data: time and frequency, and it seems the frequency spike occurs when time doesn' advance with time resolution to fs. This makes sense because my frequency is calculated as 1/period, so if time doesn't advance, period gets small. Here is my verilogA model:
`include "discipline.h" `include"constants.h" `define PI 3.14159265358979323846264338327950288419716939937511 nature Frequency abstol = 1m; access = FF; units = "Hz"; endnaturemodule freq_meter(vp,vn,fout); electrical vp, vn; freq_current fout; parameter integer log_to_file = 1; integer out_file; real tlast_cross; real fout_val; analog begin @ ( initial_step ) begin if (log_to_file ) begin out_file = $fopen( "%C:r.dat" ); $fstrobe(out_file,"# Generated by Spectre from module `%M'"); @ ( cross (V(vp,vn),1,10p,20m) ) begin fout_val = 1/($abstime-tlast_cross); tlast_cross = $abstime; end if (log_to_file) begin $fstrobe(out_file, "%-.18f\t%-.18f", $abstime, fout_val); end FF(fout) <+ fout_val; end endmodule
end end
Excerpt from my output file showing frequency jump when time doesn't advance. time in second frequency in hertz 0.000034319178918823 80861192.987152904272079468 0.000034319179282800 80861192.987152904272079468 0.000034319179282800 170571276.601905435323715210 0.000034319188537857 170571276.601905435323715210 0.000034319197792913 170571276.601905435323715210
potential Frequency; flow Current; enddiscipline
|