The Designer's Guide Community Forum
https://designers-guide.org/forum/YaBB.pl
Measurements >> Phase Noise and Jitter Measurements >> jitter in sine and square wave.
https://designers-guide.org/forum/YaBB.pl?num=1249680434

Message started by dkumar on Aug 7th, 2009, 2:27pm

Title: jitter in sine and square wave.
Post by dkumar on Aug 7th, 2009, 2:27pm

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



Title: Re: jitter in sine and square wave.
Post by lunren on Aug 17th, 2009, 11:32am

http://www.designers-guide.org/Analysis/PLLjitter.pdf
Page 19. Ken recommends that when generating sine wave, the jitter updates once per periode. Maybe this is where the problem is. However, I am also wondering why in sine wave, the jitter updates only once per periode? Can any expert give us some hints?


Title: Re: jitter in sine and square wave.
Post by dkumar on Aug 17th, 2009, 11:42am

hi,
so i figured out and easy code for fixed frequency oscillator with jitter and i would like to modify this for sinewave as it if for square wave as of now.
-------------------------------------------------
`include “disciplines.vams”
module osc (out);
output out; electrical out;
parameter real freq=1 from (0:inf);
parameter real Vlo=–1, Vhi=1;
parameter real tt=0.01/freq from (0:inf);
parameter real jitter=0 from [0:0.1/freq); // period jitter
integer n, seed;
real next, dT;
analog begin
@(initial_step) begin
seed = 286;
next = 0.5/freq + $abstime;
end
@(timer(next)) begin
n = !n;
dT = jitter∗$rdist_normal(seed,0,1);
next = next + 0.5/freq + 0.707∗dT;
end
V(out) <+ transition(n ? Vhi : Vlo, 0, tt);
end
endmodule
-------------------------

it is on page 18 of this attachment.

Title: Re: jitter in sine and square wave.
Post by prcken on Apr 4th, 2016, 11:39am


dkumar wrote on Aug 7th, 2009, 2:27pm:
i  want to generate the verilogA model for........
   // generate the output
     V(out) <+ 1.2*sin(`M_TWO_PI*freqT*$realtime + phase) ;
     $bound_step(0.06/freqT);

end
endmodule



i found two issues:
1. the output  frequency of the sine wave of the one you are using will be doubled.
it should be
V(out) <+ 1.2*sin(phase) ;

2. the jitter is accumulating with time. the longer time you are simulating, the more peak to peak jitter

how can i get a p2p jitter independent to the simulation time?

thanks

Title: Re: jitter in sine and square wave.
Post by Ken Kundert on Apr 4th, 2016, 3:21pm

You should be using $abstime rather than $realtime.

-Ken

Title: Re: jitter in sine and square wave.
Post by prcken on Apr 7th, 2016, 12:10pm

Hi Ken,

i tried with $asbtime, as below for comparison

V(Ioutn) <+ sinedc+sineamp*sin(`M_TWO_PI*freqT*$abstime + phase) ;
V(Ioutp) <+ sinedc+sineamp*sin(phase +`M_PI);

Ioutn and Ioutp corresponds to t1 and t2, respectively, in the attached picture

two issues still there, frequency of Ioutn (t1) is doubled, and jitter still accumulates with time, eye diagram folded up to 50ns and 5ns are shown at the left and right in the picture

thanks!

Title: Re: jitter in sine and square wave.
Post by Ken Kundert on Apr 8th, 2016, 7:03am


Code:
V(Ioutn) <+ sinedc+sineamp*sin(`M_TWO_PI*freqT*$abstime + phase);


I think you are being confused by the term 'phase'. You are probably thinking it is relatively constant, perhaps varying only as a result of the jitter, but that is wrong. In this case phase contains the actual phase of the signal, not its phase offset. So it is going through a full 2π radians every cycle. So, you need to get rid of the `M_TWO_PI*freqT*$abstime. That is redundant and is causing the output to be at twice the frequency you expect.

As far as why the jitter accumulates, that is intended. That is what jitter does in free-running oscillators.

Are you modeling a free-running oscillator?

-Ken

Title: Re: jitter in sine and square wave.
Post by prcken on Apr 9th, 2016, 5:25pm

Hi Ken,

Yea, the phase contains the the freq. instead of the offset freq.

instead of an free-running oscillator, actually i want to produced a PLL output clock with a bounded p2p jitter, not varying with the simulation time.  any advice how to do that?

Thanks!


The Designer's Guide Community Forum » Powered by YaBB 2.2.2!
YaBB © 2000-2008. All Rights Reserved.