I used a verilogA module in my schematic which measures the period of the output waveform of a block.
The verilogA code is as follows:-
`include "disciplines.vams"(*instrument_module*)module frequency_meter(in); parameter real thresh=0; // threshold (V) parameter integer dir = 1 from [-1:1] exclude 0; // 1 for rising edges, -1 for falling input in; voltage in; integer timing; real t0, t, period, freq; analog begin t = last_crossing(V(in) - thresh, dir); @(cross(V(in) - thresh, dir)) begin if (timing) begin period = t - t0; freq = 1/period; $strobe("period = %rs (measured at %rs).\n", t - t0, $abstime); end t0 = t; timing = 1; end endendmodule
I want to plot freq versus time using OCEAN script.
Can anybody please tell how it can be done.
I did :
save I5:period I5:freqplot(I5:freq).
This gives error in OCEAN script.
But in input.scs file I worte:-
save I5:period I5:freq
I ran the simulation and in the wavescan I was able to plot freq-vs-time.
In the spectre netlist, you can add:
myOpts options saveahdlvars=all
or in OCEAN you could say:
saveOption( ?saveahdlvars "all" )
And then to reference the freq signal, you'd do:
plot(getData("I5:freq" ?result 'tran))
Or you could make the frequency an output pin of the meter instead - but that involves changing it a bit so that you are contributing to a node - for your needs the above is probably sufficient?