The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
May 4th, 2024, 8:46pm
Pages: 1 2 
Send Topic Print
Frequency-to-current converter in phase domain (Read 12950 times)
Emre
Junior Member
**
Offline



Posts: 10

Frequency-to-current converter in phase domain
Feb 22nd, 2006, 3:32am
 
I tried to design a frequency to current converter in phase domain using Ken's phase noise paper. The block will take the phase output of the VCO as input and give a current as output, which I will sum with the charge pump current. You can see the code below.

When I run a transient simulation using spectre, the ouput current is between -9mA and -11mA, whereas I set it to be between -1mA and 1 mA. I gave the frequency to the output as well and saw that required 9G-11G is calculated.

In the simulation, spectre gives warnings in at 10e-24 stating that minimum time step is used and solution can be in error. And in the begining of the simulation, current output goes to -9mA and continues as expected afterwards. What can be the reason for this initial error and how can I fix it? Can it be a bug in verilogA or did I use a wrong coding style?

Emre


`include "constants.h"
`include "discipline.h"


discipline phase
     potential Angle;
enddiscipline

nature Frequency
     abstol = 1m;
     access = FF;
     units = "Hz";
     blowup = 2e10;
endnature

discipline freq_current
     potential Frequency;
     flow Current;
enddiscipline

module F2Iconv(Out,Fout_osc,In);

output Out; current Out;
input In; phase In;

output Fout_osc; freq_current Fout_osc;

parameter real Imin=-1e-3;                            // minimum output current
parameter real Imax=1e-3 from (Imin:inf);                      // maximum output current
parameter real Fmin=9G from (0:inf);            // minimum input frequency (Hz)
parameter real Fmax=11G from (Fmin:inf);      // maximum input frequency (Hz)

parameter real n = 0 from [0:inf); // white output current noise (A2/Hz)
parameter real fc = 0 from [0:inf); // flicker noise corner frequency (Hz)

parameter real Iinit=0;     // initial output value.

real Freq, Iout;             // computed frequency & output voltage.


analog begin
 @(initial_step) begin
    Freq=0;
    Iout=Iinit;
 end


     Freq =ddt(Theta(In))/ `M_TWO_PI;               // compute the frequency,
                                         
                             // and inversely proportional output current.
 
Iout= ((Freq - Fmin) / (Fmin - Fmax))*(Imax - Imin) + Imax;

I(Out) <+ Iout;    
                   // Drive computed current to output node.
I(Out) <+ white_noise(n, "wpn") + flicker_noise(n*fc, 1, "fpn");

FF(Fout_osc) <+ Freq;

end
endmodule
Back to top
 
 
View Profile   IP Logged
Geoffrey_Coram
Senior Fellow
******
Offline



Posts: 1998
Massachusetts, USA
Re: Frequency-to-current converter in phase domain
Reply #1 - Feb 24th, 2006, 6:37am
 
Emre wrote on Feb 22nd, 2006, 3:32am:
And in the begining of the simulation, current output goes to -9mA and continues as expected afterwards. What can be the reason for this initial error and how can I fix it? Can it be a bug in verilogA or did I use a wrong coding style?


When the simulator solves for the time=0 solution, the result of ddt() is zero.  The @initial_step code has no effect, because you assign a new value to Iout later in the code.  If you now compute Iout using Freq=0, you get -9mA.

At the first timestep > 0, now the ddt() operator gives a value, presumably something dramatically different from zero, which causes a instantaneous jump in the output current.  Presumably, the element that receives this output current is not happy about the jump, which results in the minimum-time-step warning.
Back to top
 
 

If at first you do succeed, STOP, raise your standards, and stop wasting your time.
View Profile WWW   IP Logged
Emre
Junior Member
**
Offline



Posts: 10

Re: Frequency-to-current converter in phase domain
Reply #2 - Feb 24th, 2006, 10:11am
 
Thank you Geoffrey, I think your definition is exactly to the point, because freq jumps to 9GHz after 0, which is the frequency that I'm designing for.

I put just a resistor to the ground to see the effect and another strange thing is the current changes proportional to that resistance. When I put capacitors, it complains and give blowup error.

Is there a solution to this problem? How can I avoid this big jump and define the initial condition correctly?

Emre
Back to top
 
 
View Profile   IP Logged
Geoffrey_Coram
Senior Fellow
******
Offline



Posts: 1998
Massachusetts, USA
Re: Frequency-to-current converter in phase domain
Reply #3 - Feb 24th, 2006, 11:36am
 
There are probably a couple solutions:
1) apply some clamping to Freq so that the value used in the computation of Iout is bounded sensibly
2) apply some clamping to Iout so that it actually stays between Imin and Imax
3) use the transition() filter in  Verilog-A so that the output current doesn't jump instantaneously

I'd lean towards the last solution, but you may want to include more than one.
Back to top
 
 

If at first you do succeed, STOP, raise your standards, and stop wasting your time.
View Profile WWW   IP Logged
Ken Kundert
Global Moderator
*****
Offline



Posts: 2384
Silicon Valley
Re: Frequency-to-current converter in phase domain
Reply #4 - Feb 24th, 2006, 11:41am
 
You also probably want to change your Frequency nature. The absolute tolerance is too small. It should be around 10-6 of the maximum you expect to see, so in this case it should be around 1K. And your blow up could be much larger, at least 1K times the maximum you expect, so in this case 1T.

-Ken
Back to top
 
 
View Profile WWW   IP Logged
Emre
Junior Member
**
Offline



Posts: 10

Re: Frequency-to-current converter in phase domain
Reply #5 - Feb 27th, 2006, 6:43am
 
Thank you both for your replies. I changed my Frequency nature and tried all the solutions that you suggested. However; when I apply any of those solutions, I got an error near that line stating: dynamic quantities must be directly accessible to the outputs

The ways how I implemented solutions are;

1) if (Freq > Fmax) Freq = Fmax;
   if (Freq < Fmin) Freq = Fmin;

2) if (Iout > Imax) Iout = Imax;
   if (Iout < Imin) Iout = Imin;

3) Iout_trans = transition ( Iout , 1p , 1.0/Freq);

Especially, the first solution is almost the same way that Ken used in the VCO in his Verilog AMS book at page 74.  The differences are; I use ddt() function and get the phase as input. ddt() is a dynamic funtion, so most probably this causes the error. Can you help me, in order to implement one of these solutions.

Emre

Back to top
 
 
View Profile   IP Logged
Ken Kundert
Global Moderator
*****
Offline



Posts: 2384
Silicon Valley
Re: Frequency-to-current converter in phase domain
Reply #6 - Feb 27th, 2006, 10:44am
 
Try clipping the output rather than the input. And do you really want that transition function in there? Do you expect Iout to be piecewise constant?

-Ken
Back to top
 
 
View Profile WWW   IP Logged
Emre
Junior Member
**
Offline



Posts: 10

Re: Frequency-to-current converter in phase domain
Reply #7 - Feb 28th, 2006, 4:36am
 
     
You are definetely right about the transition function. I tried it, because Geoffrey offered it, but it was not the case for my circuit and it didn't work anyway.

I tried to clip the output like this.

if (I(Out) > Imax) I(Out) <+ Imax;
if (I(Out) < Imin) I(Out) <+ Imin;

But it didn't work as well and give the same error: dynamic quantities must be directly accessible to the outputs, this time without stating the line (it first complained about the lines near initial conditions and when I commented them out without any line reference)

Is this a problem about ddt() function in VerilogA that gives you limited access to outputs, once you use it or is it a problem about phase input?

Can also the expression " Iout= ((Freq - Fmin) / (Fmin - Fmax))*(Imax - Imin) + Imax; " after the ddt() be problem, or can we access the output of the ddt() function only once?

Emre
Back to top
 
 
View Profile   IP Logged
Ken Kundert
Global Moderator
*****
Offline



Posts: 2384
Silicon Valley
Re: Frequency-to-current converter in phase domain
Reply #8 - Feb 28th, 2006, 6:35am
 
It would help if you posted the model and the error message.

-Ken
Back to top
 
 
View Profile WWW   IP Logged
Emre
Junior Member
**
Offline



Posts: 10

Re: Frequency-to-current converter in phase domain
Reply #9 - Feb 28th, 2006, 7:07am
 
The model is below. When I comment out any of the commented parts about clipping, it gives the error:

Dynamic quantities must be directly accessible to the outputs

Or; Dynamic quantities not linearly accessible to the outputs

One more interesting characteristic is; when I changed the resistance at the output in the testbench, the current scales proportionally, as if it's a voltage output.

Emre

--------------------------------------------------------------------------------
---

`include "constants.h"
`include "discipline.h"


discipline phase
     potential Angle;
enddiscipline

nature Frequency
     abstol = 1K;
     access = FF;
     units = "Hz";
     blowup = 1T;
endnature

discipline freq_current
     potential Frequency;
     flow Current;
enddiscipline

module F2Iconv(Out,Fout_osc,In);

output Out; current Out;
input In; phase In;

output Fout_osc; freq_current Fout_osc;

parameter real Imin=-1e-3;                        // minimum output current
parameter real Imax=1e-3 from (Imin:inf);                                     // maximum output current
parameter real Fmin=9G from (0:inf);            // minimum input frequency (Hz)
parameter real Fmax=11G from (Fmin:inf);                     // maximum input frequency (Hz)

parameter real n = 0 from [0:inf); // white output current noise (A2/Hz)
parameter real fc = 0 from [0:inf); // flicker noise corner frequency (Hz)

parameter real Iinit=0;     // initial output value.
parameter real finit=0;

real Freq, Iout;             // computed frequency & output voltage.


analog begin

 @(initial_step) begin
    Freq=finit;
    Iout=Iinit;
 end


Freq =ddt(Theta(In))/ `M_TWO_PI;               // compute the frequency,
                                         
                             // and proportional output current.
//      if (Freq > Fmax) Freq = Fmax;
//      if (Freq < Fmin) Freq = Fmin;

     Iout= ((Freq - Fmin) / (Fmax - Fmin))*(Imax - Imin) + Imin;

//      if (Iout > Imax) Iout = Imax;
//      if (Iout < Imin) Iout = Imin;

I(Out) <+ Iout;  

                   // Drive computed current to output node.

I(Out) <+ white_noise(n, "wpn") + flicker_noise(n*fc, 1, "fpn");

//      if (I(Out) > Imax) I(Out) <+ Imax;
//      if (I(Out) < Imin) I(Out) <+ Imin;

     FF(Fout_osc) <+ Freq;

end
endmodule
Back to top
 
 
View Profile   IP Logged
Ken Kundert
Global Moderator
*****
Offline



Posts: 2384
Silicon Valley
Re: Frequency-to-current converter in phase domain
Reply #10 - Feb 28th, 2006, 9:18am
 
There are a couple of things to try. First, you might want to try giving ddt a tolerance. If that does not work, try making Freq a node rather than a variable (declare it as freq_current rather than real).

Concerning the output current looking like a voltage .... In fact it is a voltage. This is the result of a blunder made by the committee defining the language. When declaring a discipline, you cannot have a flow unless you also have a potential (that is the blunder, in the original version of the language this was possible, the unfortunate restriction was added by the committee). Thus, if you have a signal flow current, the current is not a flow but a potential. This causes trouble when connecting this terminal to anything electrical, like a resistor. Ideally the simulator should inform you that your disciplines are not compatible, but apparently it does not. It just gives you the wrong answer because the current is being treated as if it is a potential.

Given this situation, you should use "electrical" rather than "current".

-Ken
Back to top
 
 
View Profile WWW   IP Logged
Geoffrey_Coram
Senior Fellow
******
Offline



Posts: 1998
Massachusetts, USA
Re: Frequency-to-current converter in phase domain
Reply #11 - Mar 1st, 2006, 5:06am
 
Emre wrote on Feb 28th, 2006, 4:36am:
     
You are definetely right about the transition function. I tried it, because Geoffrey offered it, but it was not the case for my circuit and it didn't work anyway.


The transition was suggested because your time=0 solution was 0, but at the first timepoint after zero, it jumped instantaneously to a large value.

Quote:
I tried to clip the output like this.

if (I(Out) > Imax) I(Out) <+ Imax;
if (I(Out) < Imin) I(Out) <+ Imin;


You also have  
 I(Out) <+ Iout;    
and recall that all contributions are summed.  What you really want for clipping is
 if (Iout > Imax) Iout = Imax;
 if (Iout < Imin) Iout = Imin;
and place these lines *before* the I(Out) <+ Iout; contribution.
Back to top
 
 

If at first you do succeed, STOP, raise your standards, and stop wasting your time.
View Profile WWW   IP Logged
Emre
Junior Member
**
Offline



Posts: 10

Re: Frequency-to-current converter in phase domain
Reply #12 - Mar 1st, 2006, 8:58am
 
Thank you both for your suggestions.

Giving tolerance didn't help, but Ken's suggestion on defining Freq as a node was a very clever solution and it solved the main problem. I didn't get any more complains about dynmic quantities' access to output by giving freq directly to the output. At same time, I used freq internally for the rest of calculations and I could use any function, as Freq is a node.

For clipping, I used the style that Geoffrey suggested and it works the best. The only problem is initial value of I(out) is always Imin, because result of ddt() is 0 in the begining. But this time, my feedback loop can recover.

If there is any other way to get rid of that initial zero, which is not the "real" value, it's always welcome. I didn't understand, how transition function can be used for that purpose effectively.

Using electrical also solved the other problem, but this time when I connected a capacitor in series with the resistor, to realize the filter, the simulator had problems in finding the dc operating point, as there is no dc path to the ground. I connected a resistance to ground to solve the problem, but I didn't like this solution, because it alters the voltage at that node and additon to the filter. If there is a more sophisticated solution that you can come up, I would like to hear it.

Emre
Back to top
 
 
View Profile   IP Logged
Geoffrey_Coram
Senior Fellow
******
Offline



Posts: 1998
Massachusetts, USA
Re: Frequency-to-current converter in phase domain
Reply #13 - Mar 3rd, 2006, 4:38am
 
Sorry, the transition filter was meant to smooth the abrupt jump, not to fix the 0 value at time=0.

Presently, your @(initial_step) isn't doing anything; you might be able to fix your problem by having
 @(initial_step) begin
   I(Out) <+ Iinit; // or maybe Iinit - Imin, if your clamping add Imin
 end

The current contributions are summed, so the later contribution will add on to this value for the first step.

As for the dc path to ground problem, you can use a huge resistor (1e9), which should not affect the filter performance.
Back to top
 
 

If at first you do succeed, STOP, raise your standards, and stop wasting your time.
View Profile WWW   IP Logged
Ken Kundert
Global Moderator
*****
Offline



Posts: 2384
Silicon Valley
Re: Frequency-to-current converter in phase domain
Reply #14 - Mar 3rd, 2006, 8:06am
 
You could always tell the simulator to skip the dc solution phase of its transient analysis.

-Ken
Back to top
 
 
View Profile WWW   IP Logged
Pages: 1 2 
Send Topic Print
Copyright 2002-2024 Designer’s Guide Consulting, Inc. Designer’s Guide® is a registered trademark of Designer’s Guide Consulting, Inc. All rights reserved. Send comments or questions to editor@designers-guide.org. Consider submitting a paper or model.