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

@ -10,68 +10,77 @@ 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 diff [8] ;
double tol; double deltmp [8] ;
double del; double factor = 0 ;
double diff[8]; int i, j ;
double deltmp[8]; static double gearCoeff [] = {
double factor=0;
int i;
int j;
static double gearCoeff[] = {
.5, .5,
.2222222222, .2222222222,
.1363636364, .1363636364,
.096, .096,
.07299270073, .07299270073,
.05830903790 .05830903790
}; } ;
static double trapCoeff[] = { static double trapCoeff [] = {
.5, .5,
.08333333333 .08333333333
}; } ;
volttol = ckt->CKTabstol + ckt->CKTreltol * MAX (fabs (ckt->CKTstate0 [ccap]), fabs (ckt->CKTstate1 [ccap])) ;
chargetol = MAX (fabs (ckt->CKTstate0 [qcap]), fabs (ckt->CKTstate1 [qcap])) ;
chargetol = ckt->CKTreltol * MAX (chargetol, ckt->CKTchgtol) / ckt->CKTdelta ;
tol = MAX (volttol, chargetol) ;
volttol = ckt->CKTabstol + ckt->CKTreltol *
MAX( fabs(ckt->CKTstate0[ccap]), fabs(ckt->CKTstate1[ccap]));
chargetol = MAX(fabs(ckt->CKTstate0[qcap]),fabs(ckt->CKTstate1[qcap]));
chargetol = ckt->CKTreltol * MAX(chargetol,ckt->CKTchgtol)/ckt->CKTdelta;
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++) { {
diff[i] = (diff[i] - diff[i+1])/deltmp[i]; for (i = 0 ; i <= j ; i++)
{
diff [i] = (diff [i] - diff [i + 1]) / deltmp [i] ;
} }
if (--j < 0) break;
for(i=0;i <= j;i++) { if (--j < 0)
deltmp[i] = deltmp[i+1] + ckt->CKTdeltaOld[i]; break ;
for (i = 0 ; i <= j ; 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 ;
case TRAPEZOIDAL: case TRAPEZOIDAL:
factor = trapCoeff[ckt->CKTorder - 1] ; factor = trapCoeff [ckt->CKTorder - 1] ;
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);
return; *timeStep = MIN (*timeStep, del) ;
return ;
} }

View File

@ -17,43 +17,51 @@ Author: 1985 Thomas L. Quarles
int int
CKTtrunc(CKTcircuit *ckt, double *timeStep) CKTtrunc (CKTcircuit *ckt, double *timeStep)
{ {
#ifndef NEWTRUNC #ifndef NEWTRUNC
int i; int i ;
double timetemp; double timetemp ;
#ifdef STEPDEBUG
double debugtemp;
#endif /* STEPDEBUG */
double startTime;
int error = OK;
startTime = SPfrontEnd->IFseconds();
timetemp = HUGE;
for (i=0;i<DEVmaxnum;i++) {
if (DEVices[i] && DEVices[i]->DEVtrunc && ckt->CKThead[i]) {
#ifdef STEPDEBUG #ifdef STEPDEBUG
debugtemp = timetemp; double debugtemp ;
#endif /* STEPDEBUG */ #endif /* STEPDEBUG */
error = DEVices[i]->DEVtrunc (ckt->CKThead[i], ckt, &timetemp);
if(error) { double startTime ;
ckt->CKTstat->STATtranTruncTime += SPfrontEnd->IFseconds() int error = OK ;
- startTime;
return(error); startTime = SPfrontEnd->IFseconds () ;
timetemp = HUGE ;
for (i = 0 ; i < DEVmaxnum ; i++)
{
if (DEVices[i] && DEVices[i]->DEVtrunc && ckt->CKThead[i])
{
#ifdef STEPDEBUG
debugtemp = timetemp ;
#endif /* STEPDEBUG */
error = DEVices[i]->DEVtrunc (ckt->CKThead[i], ckt, &timetemp) ;
if (error)
{
ckt->CKTstat->STATtranTruncTime += SPfrontEnd->IFseconds () - startTime ;
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) ;
ckt->CKTstat->STATtranTruncTime += SPfrontEnd->IFseconds() - startTime; ckt->CKTstat->STATtranTruncTime += SPfrontEnd->IFseconds () - startTime ;
return(OK); return (OK) ;
#else /* NEWTRUNC */ #else /* NEWTRUNC */
int i; int i;
CKTnode *node; CKTnode *node;

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->BSIM4v7qg,ckt,timeStep); CKTterr(here->BSIM4v7qb, ckt, timeStep);
CKTterr(here->BSIM4v7qd,ckt,timeStep); CKTterr(here->BSIM4v7qg, 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->BSIM4v7qbd,ckt,timeStep); CKTterr(here->BSIM4v7qbs, ckt, timeStep);
} CKTterr(here->BSIM4v7qbd, ckt, timeStep);
if (here->BSIM4v7rgateMod == 3)
CKTterr(here->BSIM4v7qgmid,ckt,timeStep);
#ifdef STEPDEBUG
if(debugtemp != *timeStep)
{ printf("device %s reduces step from %g to %g\n",
here->BSIM4v7name,debugtemp,*timeStep);
} }
#endif /* STEPDEBUG */
if (here->BSIM4v7rgateMod == 3)
CKTterr(here->BSIM4v7qgmid, ckt, timeStep);
#ifdef STEPDEBUG
if (debugtemp != *timeStep)
printf("device %s reduces step from %g to %g\n", here->BSIM4v7name, debugtemp, *timeStep);
#endif
} }
}
return(OK); return OK;
} }

View File

@ -14,17 +14,18 @@ Modified: September 2003 Paolo Nenzi
int int
CAPtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep) 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

@ -13,16 +13,17 @@ Author: 1985 Thomas L. Quarles
int int
INDtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep) 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) ;
} }

View File

@ -142,5 +142,5 @@ do { if((here->ptr = SMPmakeElt(matrix, here->first, here->second)) == NULL){\
} }
#endif #endif
return(OK); return (OK) ;
} }

View File

@ -147,7 +147,7 @@ do { if((here->ptr = SMPmakeElt(matrix, here->first, here->second)) == NULL){\
} }
#endif #endif
return(OK); return (OK) ;
} }
int int