Whitespaces and cosmetic changes to improve readability

This commit is contained in:
Francesco Lannutti 2014-05-01 14:17:12 +02:00 committed by rlar
parent 6dabbb86c4
commit 4e6bd40f19
7 changed files with 135 additions and 115 deletions

View File

@ -12,15 +12,11 @@ Author: 1985 Thomas L. Quarles
void void
CKTterr (int qcap, CKTcircuit *ckt, double *timeStep) CKTterr (int qcap, CKTcircuit *ckt, double *timeStep)
{ {
double volttol; double volttol, chargetol, tol, del ;
double chargetol;
double tol;
double del;
double diff [8] ; double diff [8] ;
double deltmp [8] ; double deltmp [8] ;
double factor = 0 ; double factor = 0 ;
int i; int i, j ;
int j;
static double gearCoeff [] = { static double gearCoeff [] = {
.5, .5,
.2222222222, .2222222222,
@ -34,30 +30,40 @@ CKTterr(int qcap, CKTcircuit *ckt, double *timeStep)
.08333333333 .08333333333
} ; } ;
volttol = ckt->CKTabstol + ckt->CKTreltol * volttol = ckt->CKTabstol + ckt->CKTreltol * MAX (fabs (ckt->CKTstate0 [ccap]), fabs (ckt->CKTstate1 [ccap])) ;
MAX( fabs(ckt->CKTstate0[ccap]), fabs(ckt->CKTstate1[ccap]));
chargetol = MAX (fabs (ckt->CKTstate0 [qcap]), fabs (ckt->CKTstate1 [qcap])) ; chargetol = MAX (fabs (ckt->CKTstate0 [qcap]), fabs (ckt->CKTstate1 [qcap])) ;
chargetol = ckt->CKTreltol * MAX (chargetol, ckt->CKTchgtol) / ckt->CKTdelta ; chargetol = ckt->CKTreltol * MAX (chargetol, ckt->CKTchgtol) / ckt->CKTdelta ;
tol = MAX (volttol, chargetol) ; tol = MAX (volttol, chargetol) ;
/* now divided differences */ /* now divided differences */
for(i=ckt->CKTorder+1;i>=0;i--) { for (i = ckt->CKTorder + 1 ; i >= 0 ; i--)
{
diff [i] = ckt->CKTstates[i] [qcap] ; diff [i] = ckt->CKTstates[i] [qcap] ;
} }
for(i=0 ; i <= ckt->CKTorder ; i++) { for (i = 0 ; i <= ckt->CKTorder ; i++)
{
deltmp [i] = ckt->CKTdeltaOld [i] ; deltmp [i] = ckt->CKTdeltaOld [i] ;
} }
j = ckt->CKTorder ; j = ckt->CKTorder ;
for (;;) { for (;;)
for(i=0;i <= j;i++) { {
for (i = 0 ; i <= j ; i++)
{
diff [i] = (diff [i] - diff [i + 1]) / deltmp [i] ; diff [i] = (diff [i] - diff [i + 1]) / deltmp [i] ;
} }
if (--j < 0) break;
for(i=0;i <= j;i++) { if (--j < 0)
break ;
for (i = 0 ; i <= j ; i++)
{
deltmp [i] = deltmp [i + 1] + ckt->CKTdeltaOld [i] ; deltmp [i] = deltmp [i + 1] + ckt->CKTdeltaOld [i] ;
} }
} }
switch(ckt->CKTintegrateMethod) { switch (ckt->CKTintegrateMethod)
{
case GEAR: case GEAR:
factor = gearCoeff [ckt->CKTorder - 1] ; factor = gearCoeff [ckt->CKTorder - 1] ;
break ; break ;
@ -67,11 +73,14 @@ CKTterr(int qcap, CKTcircuit *ckt, double *timeStep)
break ; break ;
} }
del = ckt->CKTtrtol * tol / MAX (ckt->CKTabstol, factor * fabs (diff [0])) ; del = ckt->CKTtrtol * tol / MAX (ckt->CKTabstol, factor * fabs (diff [0])) ;
if(ckt->CKTorder == 2) { if (ckt->CKTorder == 2)
{
del = sqrt (del) ; del = sqrt (del) ;
} else if (ckt->CKTorder > 2) { } else if (ckt->CKTorder > 2) {
del = exp (log (del) / ckt->CKTorder) ; del = exp (log (del) / ckt->CKTorder) ;
} }
*timeStep = MIN (*timeStep, del) ; *timeStep = MIN (*timeStep, del) ;
return ; return ;
} }

View File

@ -22,32 +22,40 @@ CKTtrunc(CKTcircuit *ckt, double *timeStep)
#ifndef NEWTRUNC #ifndef NEWTRUNC
int i ; int i ;
double timetemp ; double timetemp ;
#ifdef STEPDEBUG #ifdef STEPDEBUG
double debugtemp ; double debugtemp ;
#endif /* STEPDEBUG */ #endif /* STEPDEBUG */
double startTime ; double startTime ;
int error = OK ; int error = OK ;
startTime = SPfrontEnd->IFseconds () ; startTime = SPfrontEnd->IFseconds () ;
timetemp = HUGE ; timetemp = HUGE ;
for (i=0;i<DEVmaxnum;i++) { for (i = 0 ; i < DEVmaxnum ; i++)
if (DEVices[i] && DEVices[i]->DEVtrunc && ckt->CKThead[i]) { {
if (DEVices[i] && DEVices[i]->DEVtrunc && ckt->CKThead[i])
{
#ifdef STEPDEBUG #ifdef STEPDEBUG
debugtemp = timetemp ; debugtemp = timetemp ;
#endif /* STEPDEBUG */ #endif /* STEPDEBUG */
error = DEVices[i]->DEVtrunc (ckt->CKThead[i], ckt, &timetemp) ; error = DEVices[i]->DEVtrunc (ckt->CKThead[i], ckt, &timetemp) ;
if(error) { if (error)
ckt->CKTstat->STATtranTruncTime += SPfrontEnd->IFseconds() {
- startTime; ckt->CKTstat->STATtranTruncTime += SPfrontEnd->IFseconds () - startTime ;
return (error) ; return (error) ;
} }
#ifdef STEPDEBUG #ifdef STEPDEBUG
if(debugtemp != timetemp) { if (debugtemp != timetemp)
printf("timestep cut by device type %s from %g to %g\n", {
DEVices[i]->DEVpublic.name, debugtemp, timetemp); printf ("timestep cut by device type %s from %g to %g\n", DEVices[i]->DEVpublic.name, debugtemp, timetemp) ;
} }
#endif /* STEPDEBUG */ #endif /* STEPDEBUG */
} }
} }
*timeStep = MIN (2 * *timeStep, timetemp) ; *timeStep = MIN (2 * *timeStep, timetemp) ;

View File

@ -18,43 +18,44 @@
int int
BSIM4v7trunc( BSIM4v7trunc (GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
GENmodel *inModel,
CKTcircuit *ckt,
double *timeStep)
{ {
BSIM4v7model *model = (BSIM4v7model*)inModel; BSIM4v7model *model = (BSIM4v7model*)inModel;
BSIM4v7instance *here; BSIM4v7instance *here;
#ifdef STEPDEBUG #ifdef STEPDEBUG
double debugtemp; double debugtemp;
#endif /* STEPDEBUG */ #endif
for (; model; model = BSIM4v7nextModel(model))
for (here = BSIM4v7instances(model); here; here = BSIM4v7nextInstance(here)) {
for (; model != NULL; model = BSIM4v7nextModel(model))
{ for (here = BSIM4v7instances(model); here != NULL;
here = BSIM4v7nextInstance(here))
{
#ifdef STEPDEBUG #ifdef STEPDEBUG
debugtemp = *timeStep; debugtemp = *timeStep;
#endif /* STEPDEBUG */ #endif
CKTterr(here->BSIM4v7qb, ckt, timeStep); CKTterr(here->BSIM4v7qb, ckt, timeStep);
CKTterr(here->BSIM4v7qg, ckt, timeStep); CKTterr(here->BSIM4v7qg, ckt, timeStep);
CKTterr(here->BSIM4v7qd, ckt, timeStep); CKTterr(here->BSIM4v7qd, ckt, timeStep);
if (here->BSIM4v7trnqsMod) if (here->BSIM4v7trnqsMod)
CKTterr(here->BSIM4v7qcdump, ckt, timeStep); CKTterr(here->BSIM4v7qcdump, ckt, timeStep);
if (here->BSIM4v7rbodyMod) if (here->BSIM4v7rbodyMod)
{ CKTterr(here->BSIM4v7qbs,ckt,timeStep); {
CKTterr(here->BSIM4v7qbs, ckt, timeStep);
CKTterr(here->BSIM4v7qbd, ckt, timeStep); CKTterr(here->BSIM4v7qbd, ckt, timeStep);
} }
if (here->BSIM4v7rgateMod == 3) if (here->BSIM4v7rgateMod == 3)
CKTterr(here->BSIM4v7qgmid, ckt, timeStep); CKTterr(here->BSIM4v7qgmid, ckt, timeStep);
#ifdef STEPDEBUG #ifdef STEPDEBUG
if (debugtemp != *timeStep) if (debugtemp != *timeStep)
{ printf("device %s reduces step from %g to %g\n", printf("device %s reduces step from %g to %g\n", here->BSIM4v7name, debugtemp, *timeStep);
here->BSIM4v7name,debugtemp,*timeStep); #endif
} }
#endif /* STEPDEBUG */
} return OK;
}
return(OK);
} }

View File

@ -19,12 +19,13 @@ CAPtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
CAPmodel *model = (CAPmodel*)inModel ; CAPmodel *model = (CAPmodel*)inModel ;
CAPinstance *here ; CAPinstance *here ;
for( ; model!= NULL; model = CAPnextModel(model)) { for ( ; model != NULL ; model = CAPnextModel(model))
for(here = CAPinstances(model); here != NULL ; {
here = CAPnextInstance(here)) { for (here = CAPinstances(model); here != NULL ; here = CAPnextInstance(here))
{
CKTterr (here->CAPqcap, ckt, timeStep) ; CKTterr (here->CAPqcap, ckt, timeStep) ;
} }
} }
return (OK) ; return (OK) ;
} }

View File

@ -17,12 +17,13 @@ INDtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
{ {
INDmodel *model = (INDmodel*)inModel ; INDmodel *model = (INDmodel*)inModel ;
INDinstance *here ; INDinstance *here ;
for( ; model!= NULL; model = INDnextModel(model)) { for ( ; model!= NULL ; model = INDnextModel(model))
for(here = INDinstances(model); here != NULL ; {
here = INDnextInstance(here)) { for (here = INDinstances(model); here != NULL ; here = INDnextInstance(here))
{
CKTterr (here->INDflux, ckt, timeStep) ; CKTterr (here->INDflux, ckt, timeStep) ;
} }
} }
return (OK) ; return (OK) ;
} }