dkumar
New Member
Offline
Posts: 6
chennai
|
i want to generate the verilogA model for square wave and sine wave with jitter in both.Like same amount of random jitter in both.
I tried looking designer's guide and i did get the square wave generation with jitter. i tried to modify the same for sine wave and was successfully able to do that but the problem is , then i give the same amount of rms jitter value in both sine and square wave and then i plot the eye diagram , i see different pk-pk value of jitter.
i have posted the code here...please let me know if there is any other way of generating jittery sine and square wave with same amount of random jitter. OR what is the mistake am i doing?
I want to give some jitter RMS value as input and get same amount of random ( and pk-pk) jitter in both square and sine wave.
thanks
==================== CODE:
"SQUARE WAVE WITH JITTER"
// VerilogA for SSS, sqarJ2, veriloga
`include "constants.vams" `include "disciplines.vams"
module squrJ2 (out);
output out; voltage out; // output terminal parameter real vl=-1; //low output voltage parameter real vh=1; //high output voltage parameter real freqT=1 from (0:inf); // output frequency parameter real tt=0.01/freqT from (0:inf); //output transition time parameter real ttol=1u/freqT from (0:1/freqT); // time tolerance parameter real jitter=0 from [0:0.25/freqT); // period jitter (produces white accumulating jitter), variance of random normal distribution. real freq, phase, dT ; integer n, seed;
analog begin @(initial_step) seed = -561;
// freq to freq2 freq = freqT;
// add the phase noise freq = freq/(1 + dT*freq);
// bound the time step to assure no cycles are skipped $bound_step(0.6/freqT);
// phase is the integral of the freq modulo 2p phase = 2*`M_PI*idtmod(freq, 0.0, 1.0, -0.5);
// update jitter twice per period // `M_SQRT2=sqrt(K), K=2 jitter updates/period @(cross(phase + `M_PI/2, +1, ttol) or cross(phase - `M_PI/2, +1, ttol)) begin dT = `M_SQRT2*jitter*$rdist_normal(seed,0, 1); n = (phase >= -`M_PI/2) && (phase < `M_PI/2); end
// generate the output V(out) <+ transition(n ? vh : vl,330p ,tt);
end endmodule\ ================================================================================ ================================ "SINE WAVE WITH JITTER" ( modified the above one to get this.) // VerilogA for SSS, sineJ2, veriloga
`include "constants.vams" `include "disciplines.vams"
module sineJ2 (out);
output out; voltage out; // output terminal parameter real freqT=1 from (0:inf); // output frequency parameter real ttol=1u/freqT from (0:1/freqT); // time tolerance parameter real jitter=0 from [0:0.25/freqT); // period jitter (produces white accumulating jitter), variance of random normal distribution. real freq, phase, dT ; integer seed;
analog begin @(initial_step) seed = -561;
// freq to freq2 freq = freqT;
// add the phase noise freq = freq/(1 + dT*freq);
// bound the time step to assure no cycles are skipped // $bound_step(0.6/freqT);
// phase is the integral of the freq modulo 2p phase = 2*`M_PI*idtmod(freq, 0.0, 1.0, -0.5);
// update jitter twice per period // `M_SQRT2=sqrt(K), K=2 jitter updates/period @(cross(phase + `M_PI/2, +1, ttol) or cross(phase - `M_PI/2, +1, ttol)) begin dT = `M_SQRT2*jitter*$rdist_normal(seed,0, 1); end
// generate the output V(out) <+ 1.2*sin(`M_TWO_PI*freqT*$realtime + phase) ; $bound_step(0.06/freqT);
end endmodule
|