The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Aug 22nd, 2019, 3:06pm
Pages: 1
Send Topic Print
Difficulties in modeling switchable and variable caps with charge conservation (Read 214 times)
qilongliu
New Member
*
Offline



Posts: 5

Difficulties in modeling switchable and variable caps with charge conservation
Aug 01st, 2019, 6:43am
 
Hi all,

  Recently I am stuck in modeling a pair of commuting caps between two branches. I have two caps with total C as Ctot, which are connected between ion-gnd and iop-gnd branches, respectively. When a signal called D comes,  D*Ctot will stay at the ion branch while (1-D)*Ctot will stay at the iop branch. Since D may be different than the previous D_prev,  there will part of the cap and its associated charge being switched to the other branch, depending D>D_prev or D<D_prev.

   I realized that the charge on each branch maybe not conservative. But as a 3-terminal blackbox (iop,ion and gnd), the charge on the total two branches is conservative. Allowing for that, it seems the modeling of a single varactor (suggested by Ken https://designers-guide.org/modeling/varactors.pdf) may not help. I try to build some codes, but there is huge current spike shown during the cap switching, which is intolerable for my use. It seems the lines for the charge dump are the troublemakers. But have no idea how to model this cap network in an elegant way. Can anyone help me? Thanks!


   There should be some way to describe sudden capacitance and charge change in one capacitor. But I do not know how to integrate it in a clock-triggered event....


module switching_capacitor(d, dout, clk,iop,ion, gnd);

output dout, iop,gnd, ion ;
input  d, clk;


electrical clk,d,d_prev,dout,gnd,iop,ion ;  //d: input, dout: sampled d output at the current clock edge. d_prev: d from the previous clock dege.


parameter real Ctot=0;
parameter real vth_clk=0.5;
parameter integer dir = +1 from [-1:+1] exclude 0;

parameter real td_Z=0p;  //Z switching speed.
parameter real tt_Z=1p;

real td_D=10p;
real tt_D=10p;

real D;
real D_prev;
real dD;

real vop_transition;
real von_transition;

integer is_Charge_to_ion;

real dQn;
real dQp;

integer nr_clock=0; //use nr_clock to mimic dirac function


analog begin

//using clk rising edge to record d of the current cycle
   @(cross(V(clk) - vth_clk, dir)) begin
     nr_clock=nr_clock+1;          //clock counter used to generate dirac function
       D=V(d);
       D_prev=V(d_prev);
     dD=abs(D-D_prev);             // D change between the current cycle and the next cycle.
   
     vop_transition=V(iop,gnd);     //record iop and ion before the transition, in order to calculate the charge to be switched
     von_transition=V(ion,gnd);

      is_Charge_to_ion= (D>D_prev? 1:0);  // if D>D_prev, part of the cap and its associated charge will be switched from Iop to Ion, or vice versa

      dQn=    Ctot*is_Charge_to_ion *dD*(vop_transition-von_transition);        //If D>D_prev dQn=charge to be dumped to Ion from Iop, else dQn=0
      dQp=    Ctot*(1-is_Charge_to_ion)*dD*(von_transition-vop_transition);   //If D<D_prev dQp=charge to be dumped to Iop from Ion, else dQp=0
  end

//using clk falling edge to generate internal signal to record D from the previous cycle
     @ (cross(V(clk)-vth_clk, -dir)) begin
     D_prev= V(dout);      
     end

//d update
     V(dout) <+ transition(D,td_D,tt_D);                                  // dout generation
     V(d_prev)    <+ transition(D_prev,td_D,tt_D);                   // d_prev generation

//Cap update. During the update the charge conservation is not taken into account
     I(ion,gnd)<+  Ctot* transition(D,td_Z,tt_Z)* ddt(V(ion,gnd));                     //Cap size change: occurs between td_Z and td_Z+tt_Z;
     I(iop,gnd)<+  Ctot* transition(1-D,td_Z,tt_Z)*ddt(V(iop,gnd));                    //Cap size change: occurs between td_Z and td_Z+tt_Z;

//charge dump, from one branch to the opposite. it is dumped in the form of a current spike to mimic dirac function
       I(ion,gnd)<+  -transition(dQn,td_Z,tt_Z)/tt_Z* ( transition(nr_clock, td_Z+tt_Z,tt_Z)-transition(nr_clock, td_Z+2*tt_Z,tt_Z));      // dump the charge from the decending branch to the ascending branch.
       I(iop,gnd)<+  -transition(dQp,td_Z,tt_Z)/tt_Z* ( transition(nr_clock, td_Z+tt_Z,tt_Z)-transition(nr_clock, td_Z+2*tt_Z,tt_Z));      // (transition-transtion) is to mimic a delta current spike to inject
                                                                                                                                                       // the required charge. It is injected after cap size changing:
                                                                                                                                                       // between td_Z+tt_Z and td_Z+3*tt_Z. Put dQp/n into transtion between td_Z
                                                                                                                                                       // and td_Z+tt_Z is to aviod dQp/n of the previous cycle from being
                                                                                                                                                       // used in the current cycle.

end


endmodule


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



Posts: 2211
Silicon Valley
Re: Difficulties in modeling switchable and variable caps with charge conservation
Reply #1 - Aug 1st, 2019, 9:12pm
 
The way you model a capacitor in such a way that the model conserves charge is always the same. You start with the relationship between voltage and charge. Does not matter if the capacitor has two terminals or N terminals. The relationship must be algebraic. Then you pass charge through the ddt operator to convert it to a current.

If you do not have the charge equations, you would need to start with equations for the the capacitance and integrate them with respect to voltage to get the charge equations and go from there.

-Ken

Back to top
 
 
View Profile WWW   IP Logged
qilongliu
New Member
*
Offline



Posts: 5

Re: Difficulties in modeling switchable and variable caps with charge conservation
Reply #2 - Aug 2nd, 2019, 5:27am
 
Hi Ken,

  Thanks for the tips. I tried to implement the two ways you suggested. But it seems I am stuck in the last step for both cases.

   Solution 1: q and ddt(q) based cap modeling
   I know the total charge will be q<+Cp*idt((iop,gnd))+Cn*idt((ion,gnd)). How can I get the partial derivative of q as the current in each branch? Or say, how can I express the sudden change of Cp/Cn in the framework of charge conservation?

   Solution 2: integrate C(v) with v so as to get ddt (C(v)*v)
   I tried it in my code by using the lines below,

    I(ion,gnd)<+   ddt(Ctot* transition(D,td_Z,tt_Z)   *V(ion,gnd));                     //Cap size change: occurs between td_Z and td_Z+tt_Z;
    I(iop,gnd)<+   ddt(Ctot* transition(1-D,td_Z,tt_Z)*V(iop,gnd));                    //Cap size change: occurs between td_Z and td_Z+tt_Z;

    However, simulator gives convergence error during the D transition. I believe it is understandable, since my lines indicate charge conservation for each single branch, which is not what it should be.

    I think I missed some key functions/features in verilogA to model my capacitor network. But I do not know what they are.

    To make all the components clear, I draw a simple picture depicting the model.


Back to top
« Last Edit: Aug 2nd, 2019, 8:58am by qilongliu »  

Capture_022.PNG
View Profile   IP Logged
Ken Kundert
Global Moderator
*****
Offline



Posts: 2211
Silicon Valley
Re: Difficulties in modeling switchable and variable caps with charge conservation
Reply #3 - Aug 5th, 2019, 2:00am
 
To model a capacitor you need an algebraic equation that gives q as a function of v.

1. q<+Cp*idt((iop,gnd))+Cn*idt((ion,gnd))

I don't know what that means, but it is not an algebraic equation because it contains idt, and it is not a function of v, as V is not mentioned anywhere in the equation.

2. I(ion,gnd)<+   ddt(Ctot* transition(D,td_Z,tt_Z)   *V(ion,gnd));
   I(iop,gnd)<+   ddt(Ctot* transition(1-D,td_Z,tt_Z)*V(iop,gnd));

This suggests that the charge equations are:
   qion = Ctot* transition(D,td_Z,tt_Z)   *V(ion,gnd)
   qiop = Ctot* transition(1-D,td_Z,tt_Z)   *V(ion,gnd)

But that is not algebraic because it contains a transition function. Capacitors do not have transition functions.

What is D?  Your figure is not helping me.

Are you adding the transition function simply because the waveform for D is discontinuous? If so you are confusing the situation by presenting this as part of the capacitor model.  If your goal is to model the capacitor, you should do so without worrying about the shape of the stimulus waveforms First write the model, then as a second step you can think about how to make the model robust against discontinuous stimulus.

-Ken

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



Posts: 2211
Silicon Valley
Re: Difficulties in modeling switchable and variable caps with charge conservation
Reply #4 - Aug 5th, 2019, 2:20am
 
Are you trying to model two linear constant valued capacitors Cp and Cn, and then a third capacitor Cx that is also linear and constant valued that is sometimes connected to iop and sometimes it is connected to ion depending on whether D is 0 or 1. So it is as if you have three constant valued capacitors and a single-pole double-throw switch that is controlled by D such that Cx is either connected in parallel with either Cp or Cn?

-Ken
Back to top
 
 
View Profile WWW   IP Logged
qilongliu
New Member
*
Offline



Posts: 5

Re: Difficulties in modeling switchable and variable caps with charge conservation
Reply #5 - Aug 5th, 2019, 2:53am
 
Hi Ken,

  Exactly! That single-pole-double-throw (SPDT) switch is what I want! However, a slight difference is, none of Cp, Cn and Cx is constant, but the sum Cp+Cn+Cx=Ctot is a constant.

  Depending on the control word D (which is a real value between 0 and 1, updated by a clock), the "virtual" SPDT will switch capacitance of (dD*Ctot) from one branch to the other: If D from the current cycle is larger than that of the previous one, then the cap dD=D_current-D_prev will switch from iop to ion, or vice versa. During the switching, the charge on (D*Ctot) from the old branch will also be dumped to the new branch.

  I know that charge conservation holds in the total Cp+Cn+Cx, but that is not true in each single branch. Besides that, the switched cap is varying with control word D.

  Considering this specific case, I have not found a good way to model these properties at the same time...

Back to top
 
« Last Edit: Aug 5th, 2019, 7:18am by qilongliu »  
View Profile   IP Logged
Ken Kundert
Global Moderator
*****
Offline



Posts: 2211
Silicon Valley
Re: Difficulties in modeling switchable and variable caps with charge conservation
Reply #6 - Aug 5th, 2019, 10:26am
 
Quote:
I know that charge conservation holds in the total Cp+Cn+Cx, but that is not true in each single branch.


That statement indicates that you have an N-terminal capacitor, meaning that you need to find a function Q that takes N voltages and returns N currents. In this case it seems like N is 3, with the 3 corresponding to the three terminals: iop, ion, gnd. In this case, I am thinking that D can be treated as a time varying parameter rather than a terminal.

The function should be algebraic, meaning that the values of charge computed with the function should only depend on the present values of the terminal voltage, not on past values.

This function would be chosen such that its partial derivatives equal (or at least approximate) the capacitances you are expecting. This can be a very difficult problem.

-Ken
Back to top
 
 
View Profile WWW   IP Logged
qilongliu
New Member
*
Offline



Posts: 5

Re: Difficulties in modeling switchable and variable caps with charge conservation
Reply #7 - Aug 5th, 2019, 2:09pm
 
Hi Ken,

   The original idea of such a cap model to mimic a DAC switching cell. Your hints trigger me to think of the charge division in a 3-terminal MOS transistor (g,s,d). I know that the principle of "50-50" , "40-60" or "0-100" charge division is used in BSIM model, which is not accurate I believe. Do the modeling guys come up with this workaround because of the same problem as I have now?
Back to top
 
 
View Profile   IP Logged
Ken Kundert
Global Moderator
*****
Offline



Posts: 2211
Silicon Valley
Re: Difficulties in modeling switchable and variable caps with charge conservation
Reply #8 - Aug 5th, 2019, 3:32pm
 
I really have no idea what problem you have now. You asked about how to write a charge conserving model of a capacitor, and I answered that question. If you are trying to model a DAC switching cell, well that seems like a circuit not a capacitor. Maybe you can just give us your schematic and we can comment on how to model/simulate it.

-Ken
Back to top
 
 
View Profile WWW   IP Logged
Pages: 1
Send Topic Print
Copyright 2002-2019 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.