Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.
Use this veriloga file, just connect your clock to this clock
// VerilogA for bmslib, Sig2FreqJitter, veriloga
// last revised: 7/21/03 (ronv)
//
// DESCRIPTION:
// Measures the frequency and Jitter of the input signal by detecting
// the times at which the last two zero crossings occured. This method
// will only work accurately on single tone signals.
//
// LIMITATIONS:
// This only measures instantaneous Freq and Delta Period
// no measurement until after 2nd clock edge
//
// INCLUDE FILES:
`include "constants.h"
`include "discipline.h"
// Frequency in Hertz, nature and signal-flow discipline:
nature Freq_Hz
units = "Hz";
access = FF;
abstol = 1m;
blowup = 1G;
endnature
discipline freq_hz
potential Freq_Hz;
enddiscipline
// Time in Seconds, nature and signal-flow discipline:
nature Time_Sec
abstol = 1f;
access = TT;
units = "s";
blowup = 1G;
endnature
module Sig2FreqJitter(IN, Fout, Jitter);
// PINS
input IN; // input node
electrical IN;
output Fout; // cycle/cycle Frequency in Hz
freq_hz Fout;
output Jitter; // delta period in sec
time_sec Jitter;
// INTERNAL NODES
// {none}
// INSTANCE PARAMETERS:
parameter real Vtrig = 0.9; // Threshold voltage for edge detection
parameter integer dir = 1 from [-1:1] exclude 0;
parameter real ttol = 1p from (0:inf);
// LOCAL VARIABLES: (Comment each one)
real tlastx, x1,x2,x3 ; // crossing times
real period, lastperiod, delper, fout_val;
// FUNCTIONS
// {none}
//---------------------------------------------------------------------------
analog begin
// unless you want different values this is not needed
/**********************
@(initial_step) begin
period = 0;
lastperiod = 0;
delper = 0;
fout_val = 0;
end
*********************/
@ ( cross (V(IN)-Vtrig,dir,ttol) ) begin
x3 = x2;
x2 = x1;
x1 = tlastx;
end
tlastx = last_crossing(V(IN)-Vtrig,dir);
if (x3>0) begin // enough edges to start
period = tlastx - x1;
lastperiod = x1 - x2;
delper = (period - lastperiod)*1e12;
fout_val = 1/period;
end
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.