I would like to measure the ON time of a clock pulse.
Code:`include "disciplines.vams"
module measure_periods(in);
parameter real vdd_half=2.5;
input in;
voltage in;
real t0, t1;
analog begin
@(cross(V(in)-vdd_half,1)) //record time when clock rises beyond Vdd/2
t0=$abstime;
@(cross(V(in)-vdd_half,-1)) //record time when clock falls beyond Vdd/2
t1=$abstime;
t1=t1-t0;
end
endmodule
Will t1 record the ON time? Is this logic correct?