The Designer's Guide Community Forum
https://designers-guide.org/forum/YaBB.pl
Design Languages >> Verilog-AMS >> Very slow simulation in using current limiting voltage source
https://designers-guide.org/forum/YaBB.pl?num=1307493668

Message started by wanyancan on Jun 7th, 2011, 5:41pm

Title: Very slow simulation in using current limiting voltage source
Post by wanyancan on Jun 7th, 2011, 5:41pm

Hi all,

Following the example in Current limited voltage regulator (model, test) from http://www.designers-guide.org/VerilogAMS/, I designed another voltage follower with limited current 'imax' and 'imin' parameters. However, when simulating with a simple circuit, it becomes very slow. The steps seem to be incorrectly set. Would any one give me some advice? I suspect that 'cross' event detection is wrongly configured. How do I use 'expr_tol' parameter only while leave 'time_tol' as null (as default) ?


Code:
`include "constants.vams"
`include "disciplines.vams"

module CurrentLimiterVsource(in,out);
     input in;
     output out;
     electrical in;
     electrical out;
     real v, i, vin, sum1, sum2;
     parameter real imax = 1;
     parameter real imin = -1;

     analog begin
           vin = V(in);
           v = V(out);
           i = -I(<out>);
           sum1 = v-vin - (i-imax)*(out.potential.abstol/out.flow.abstol);
           sum2 = v-vin - (i-imin)*(out.potential.abstol/out.flow.abstol);
           @(cross(sum1,0,1p,out.potential.abstol))
                 $strobe("imax reached at time:%r, sum1:%r, sum2:%r",$abstime,sum1,sum2);
           @(cross(sum2,0,1p,out.potential.abstol))
                 $strobe("imin reached at time:%r, sum1:%r, sum2:%r",$abstime,sum1,sum2);
           
           if (sum1*sum2<0)
                 V(out) <+ vin;
           else
                 if (sum1<=0)
                       I(out) <+ -imax;
                 else
                       I(out) <+ -imin;
     end
endmodule


The test circuit is as below:

Code:
I41 (Vin Vout) CurrentLimiterVsource imax=2500u imin=-2m
V3 (Vin 0) vsource dc=0 type=sine delay=1u freq=5M ampl=1 mag=1
C1 (net1 0) capacitor c=1u
C0 (Vout net1) capacitor c=1p
R0 (Vout net1) resistor r=1K
simulatorOptions options reltol=1e-3 vabstol=1e-6 iabstol=1e-12 temp=27 \
   tnom=27 scalem=1.0 scale=1.0 gmin=1e-12 rforce=1 maxnotes=5 maxwarns=5 \
   digits=5 cols=80 pivrel=1e-3 sensfile="../psf/sens.output" \
   checklimitdest=psf
tran tran stop=2u errpreset=conservative write="spectre.ic" \
   writefinal="spectre.fc" annotate=status maxiters=5
finalTimeOP info what=oppoint where=rawfile
dcOp dc write="spectre.dc" maxiters=150 maxsteps=10000 annotate=status
capInfo_dc info what=captab where=rawfile threshold=0.0 detail=nodetonode \
   sort=name
dcOpInfo info what=oppoint where=rawfile
dc dc hysteresis=yes param=VH start=0 stop=3.3 oppoint=rawfile \
   maxiters=150 maxsteps=10000 annotate=status
ac ac start=10k stop=10M annotate=status

Title: Re: Very slow simulation in using current limiting voltage source
Post by Ken Kundert on Jun 8th, 2011, 12:14am

I see no obvious issue with your model, and when I ran it the speed seemed fine (I used Spectre version 7.1.1).

I have noticed that I normalizing with abstols can be problematic. Indeed you are adding voltage, which is scaled to near unity, to current times vabstol/iabstol, which is scaled to near 1000. That makes it difficult for the cross function. I found it better to scale by the estimated ratio of Vlimit to Ilimit.

-Ken

Title: Re: Very slow simulation in using current limiting voltage source
Post by wanyancan on Jun 9th, 2011, 6:11pm

Hi Ken,

I tried to print abstol values for both voltage and current, and the ratio is 10e6 (1uV and 1pA) which are indeed not suitable as scale factor. Besides this, I changed the if-clause to

Code:
if (sum1*sum2<0)
   V(outP,outN) <+ vin;
else
   if(sum1<0)
       I(outP,outN) <+ -imax;
   else if (sum2>0)
       I(outP,outN) <+ -imin;

which leaves the case when sum1==0 or sum2==0 to be unchanged. It seems helping to eliminate the saw waveform as attached image and give a better simulation time.

There's another question on @cross's parameters "time_tol" and "expr_tol". How does it affect the solving resolution? Do they need to be satisfied if they are both  given explicitly ? What if none of them are given? What if only "time_tol" is given to be a tiny value such as "10a" (Does it restrict the solving steps to be always less than "10a" secs)?

Title: Re: Very slow simulation in using current limiting voltage source
Post by Ken Kundert on Jun 10th, 2011, 1:21am

Default behavior of the cross tolerances is not really defined by the standard. You have to ask your simulator vendor what they do when you leave them off.

Many years ago I used to feel very comfortable not specifying the tolerances on the cross function, but in my experience the simulator vendors are loosening the tolerances to a degree that it is becoming problematic, particularly on signals not scaled near unity, such as currents.

I am not sure what the waveforms you showed are for, but the second seems like it is experiencing severe trapezoidal rule ringing. You might want to try the transient option method=gear2only.

-Ken

Title: Re: Very slow simulation in using current limiting voltage source
Post by ywguo on Jun 18th, 2011, 11:05pm

Hi Wanyancan,

Of course timeTol and exprTol should be satisfied if they were specified explicitly. But it does not restrict the analog solver steps always less than "10a" seconds in your case. It has effect on the step only if the event condition is met, i.e. the condition in the parentheses after cross is met.

I think that timeTol and exprTol in cross is used to reduce the error at the event occurs. Based on Ken's book, it is a time point that is just after the expression crosses the threshold.

Best Regards,
Yawei

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