Browse Source

Alan fixed some typo introduced in the last commits.

pre-master-46
pnenzi 26 years ago
parent
commit
ac84baab65
  1. 147
      src/frontend/outitf.c
  2. 15
      src/spicelib/devices/devsup.c
  3. 14
      src/spicelib/devices/mos3/mos3load.c

147
src/frontend/outitf.c

@ -1,6 +1,7 @@
/**********
Copyright 1990 Regents of the University of California. All rights reserved.
Author: 1988 Wayne A. Christopher, U. C. Berkeley CAD Group
Modified: 2000 AlansFixes
**********/
/*
@ -20,16 +21,19 @@ Author: 1988 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "ifsim.h"
#include "jobdefs.h"
#include "iferrmsg.h"
#include "cktdefs.h"
#include "circuits.h"
#include "outitf.h"
#include "variable.h"
#include <fcntl.h>
#include <time.h>
#include "cktdefs.h"
extern void gr_end_iplot(void);
extern char *spice_analysis_get_name(int index);
extern char *spice_analysis_get_description(int index);
/* static declarations */
static int beginPlot(void *analysisPtr, void *circuitPtr, char *cktName, char *analName,
char *refName, int refType, int numNames, char **dataNames, int dataType,
@ -61,11 +65,10 @@ static clock_t lastclock, currclock;
static float *rowbuf;
static int column, rowbuflen;
static bool shouldstop = FALSE; /* Tell simulator to stop next time it asks. */
static bool printinfo = FALSE; /* Print informational "error messages". */
/* The two "begin plot" routines share all their internals... */
@ -115,9 +118,9 @@ beginPlot(void *analysisPtr, void *circuitPtr, char *cktName, char *analName, ch
int numsaves;
int i, j, depind;
char namebuf[BSIZE_SP], parambuf[BSIZE_SP], depbuf[BSIZE_SP];
char *ch, tmpname[BSIZE_SP]; /* AF */
char *ch, tmpname[BSIZE_SP];
bool saveall = TRUE;
bool savealli = TRUE; /* AF */
bool savealli = FALSE;
char *an_name;
/* Check to see if we want to print informational data. */
@ -151,13 +154,13 @@ beginPlot(void *analysisPtr, void *circuitPtr, char *cktName, char *analName, ch
savesused[i] = TRUE;
continue;
}
if (cieq(saves[i].name, "all") || cieq(saves[i].name, "allv" )) {
if (cieq(saves[i].name, "all") || cieq(saves[i].name, "allv")) {
saveall = TRUE;
savesused[i] = TRUE;
saves[i].used = 1;
continue;
}
if (cieq(saves[i].name, "alli")) { /*AF */
if (cieq(saves[i].name, "alli")) {
savealli = TRUE;
savesused[i] = TRUE;
saves[i].used = 1;
@ -196,7 +199,7 @@ beginPlot(void *analysisPtr, void *circuitPtr, char *cktName, char *analName, ch
} else {
for (i = 0; i < numNames; i++)
if (!refName || !name_eq(dataNames[i], refName)) {
if (!strstr(dataNames[i], "#internal") && /* AF */
if (!strstr(dataNames[i], "#internal") &&
!strstr(dataNames[i], "#source") &&
!strstr(dataNames[i], "#drain") &&
!strstr(dataNames[i], "#collector") &&
@ -207,7 +210,6 @@ beginPlot(void *analysisPtr, void *circuitPtr, char *cktName, char *analName, ch
}
}
/* Pass 1 and a bit. */
if (savealli) {
depind=0;
@ -265,7 +267,6 @@ beginPlot(void *analysisPtr, void *circuitPtr, char *cktName, char *analName, ch
}
/* Pass 2. */
for (i = 0; i < numsaves; i++) {
if (savesused[i])
@ -310,11 +311,8 @@ beginPlot(void *analysisPtr, void *circuitPtr, char *cktName, char *analName, ch
tfree(savesused);
}
if (numNames
&& (run->numData == 1
&& (run->refIndex != -1
|| run->numData == 0)
&& run->refIndex == -1))
if (numNames && (run->numData == 1 && run->refIndex != -1
|| run->numData == 0 && run->refIndex == -1))
{
fprintf(cp_err, "Error: no data saved for %s; analysis not run\n",
spice_analysis_get_description(((JOB *) analysisPtr)->JOBtype));
@ -403,7 +401,7 @@ addSpecialDesc(runDesc *run, char *name, char *devname, char *param, int depind)
return (OK);
}
int
OUTpData(void *plotPtr, IFvalue *refValue, IFvalue *valuePtr)
@ -423,7 +421,7 @@ OUTpData(void *plotPtr, IFvalue *refValue, IFvalue *valuePtr)
fileStartPoint(run->fp, run->binary, run->pointCount);
if (run->refIndex != -1) {
if (run->isComplex) {
if (run->isComplex){
fileAddComplexValue(run->fp, run->binary, refValue->cValue);
currclock = clock();
if ((currclock-lastclock)>(0.25*CLOCKS_PER_SEC)) {
@ -458,7 +456,6 @@ OUTpData(void *plotPtr, IFvalue *refValue, IFvalue *valuePtr)
} else {
/* should pre-check instance */
if (!getSpecial(&run->data[i], run, &val))
{
if (run->pointCount==1)
fprintf(stderr, "Warning: unrecognized variable - %s\n",
@ -475,7 +472,6 @@ OUTpData(void *plotPtr, IFvalue *refValue, IFvalue *valuePtr)
};
continue;
};
if (run->data[i].type == IF_REAL)
fileAddRealValue(run->fp, run->binary,
val.rValue);
@ -489,7 +485,7 @@ OUTpData(void *plotPtr, IFvalue *refValue, IFvalue *valuePtr)
fileEndPoint(run->fp, run->binary);
if (ferror(run->fp)) {
fprintf(stderr, "Warning: rawfile write error !!\n");
shouldstop=TRUE;
shouldstop = TRUE;
};
} else {
for (i = 0; i < run->numData; i++) {
@ -532,7 +528,7 @@ OUTpData(void *plotPtr, IFvalue *refValue, IFvalue *valuePtr)
return (OK);
}
/* ARGSUSED */ /* until some code gets written */
int
@ -554,7 +550,7 @@ OUTwEnd(void *plotPtr)
return (OK);
}
int
OUTendPlot(void *plotPtr)
@ -577,7 +573,7 @@ OUTendPlot(void *plotPtr)
return (OK);
}
/* ARGSUSED */ /* until some code gets written */
int
@ -593,7 +589,7 @@ OUTendDomain(void *plotPtr)
return (OK);
}
/* ARGSUSED */ /* until some code gets written */
int
@ -632,7 +628,7 @@ OUTattributes(void *plotPtr, char *varName, int param, IFvalue *value)
return (OK);
}
/* The file writing routines. */
@ -655,8 +651,6 @@ fileInit(runDesc *run)
i = 0;
/* Write PROBE version marker */
tmp=0xFFFFFFFF;
@ -666,27 +660,23 @@ fileInit(runDesc *run)
fwrite((char *)&tmp,sizeof(tmp),1,run->fp);
i += sizeof(tmp);
/* Write Title String */
sprintf(buf, "Title: %s\n", run->name);
i += strlen(buf);
fputs(buf, run->fp);
/* Write \0 for Title string and \0 for empty SubTitle string */
tmp=0;
fwrite((char *)&tmp,2,1,run->fp);
i += 2;
/* get the time and date */
time_of_day = time( NULL );
/* Write Time String */
/* Write Time String */
strftime( buf, 9, "%H:%M:%S",
localtime( &time_of_day ) );
@ -697,7 +687,6 @@ fileInit(runDesc *run)
fwrite((char *)&tmp,1,1,run->fp);
i += 1;
/* Write Date String */
strftime( buf, 9, "%d/%m/%y",
@ -709,7 +698,6 @@ fileInit(runDesc *run)
fwrite((char *)&tmp,1,1,run->fp);
i += 1;
/* Write Temperature */
ckt=run->circuit;
@ -733,44 +721,43 @@ fileInit(runDesc *run)
i += strlen(buf);
fputs(buf, run->fp);
/* Write \0 for Analysis Type string and \0 for empty Comment string */
/* Write \0 for Analysis Type string and \0 for empty Comment string */
tmp=0;
fwrite((char *)&tmp,2,1,run->fp);
i += 2;
/* Write Program ID */
/* Write Program ID */
tmp=0x00011A22;
fwrite((char *)&tmp,sizeof(tmp),1,run->fp);
i += sizeof(tmp);
/* Write All-Columns Flag */
/* Write All-Columns Flag */
tmp=0;
fwrite((char *)&tmp,2,1,run->fp);
i += 2;
/* Write Complex-Data Flag */
/* Write Complex-Data Flag */
tmp = run->isComplex ? 2 : 1;
fwrite((char *)&tmp,2,1,run->fp);
i += 2;
/* Write Datatype Flag (PROBE_ANALOG) */
/* Write Datatype Flag (PROBE_ANALOG) */
tmp = 0;
fwrite((char *)&tmp,2,1,run->fp);
i += 2;
/* Write Digital Data Length (meaningless if analogue data) */
/* Write Digital Data Length (meaningless if analogue data) */
tmp=0;
fwrite((char *)&tmp,sizeof(tmp),1,run->fp);
i += sizeof(tmp);
/* Write space for no. of rows */
/* Write space for no. of rows */
fflush(run->fp); /* Gotta do this for LATTICE. */
if (run->fp == stdout || (run->pointPos = ftell(run->fp)) <= 0)
@ -779,13 +766,15 @@ fileInit(runDesc *run)
fwrite((char *)&tmp,sizeof(tmp),1,run->fp);
i += sizeof(tmp);
/* Write no. of cols */
/* Write no. of cols */
fwrite(&(run->numData),2,1,run->fp);
i += 2;
#ifdef AlansFixes
fprintf(stderr, "No. of Data Columns : %d \n", run->numData);
#endif
/* Write Sweep Mode Flag */
/* Write Sweep Mode Flag */
fwrite((char *)&sweep,2,1,run->fp);
i += 2;
@ -796,20 +785,19 @@ fileInit(runDesc *run)
fwrite((char *)&ftmp,sizeof(ftmp),1,run->fp);
i += sizeof(ftmp);
/* Write sweep variable end value */
/* Write sweep variable end value */
ftmp=0;
fwrite((char *)&ftmp,sizeof(ftmp),1,run->fp);
i += sizeof(ftmp);
/* Write Secondary Sweep Variable name (null string) */
/* Write Secondary Sweep Variable name (null string) */
tmp=0;
fwrite((char *)&tmp,1,1,run->fp);
i += 1;
/* Write Digital Section Flag */
/* Write Digital Section Flag */
tmp = 0;
fwrite((char *)&tmp,2,1,run->fp);
@ -821,8 +809,6 @@ fileInit(runDesc *run)
}
static void
fileInit_pass2(runDesc *run)
{
@ -831,7 +817,7 @@ fileInit_pass2(runDesc *run)
for (i = 0; i < run->numData; i++) {
if ((run->data[i].regular==FALSE) ||
if ((run->data[i].regular == FALSE) ||
cieq(run->data[i].name, "time") ||
cieq(run->data[i].name, "sweep") ||
cieq(run->data[i].name, "frequency"))
@ -851,7 +837,6 @@ fileInit_pass2(runDesc *run)
type = SV_FREQUENCY;
else
type = SV_VOLTAGE;
if (*name=='@') {
type = SV_CURRENT;
memmove(name, &name[1], strlen(name)-1);
@ -880,7 +865,8 @@ fileInit_pass2(runDesc *run)
strncpy(name, buf, BSIZE_SP);
};
while ((ch=strchr(name, ':'))!=NULL) *ch='.';
while ((ch=strchr(name, ':'))!=NULL)
*ch='.';
if ((ch=strchr(name, '('))!=NULL) {
ch++;
@ -896,13 +882,13 @@ fileInit_pass2(runDesc *run)
fprintf(run->fp, "%s", name);
tmp=0;
fwrite((char*)&tmp,1,1,run->fp);
fwrite((void *)&tmp,1,1,run->fp);
}
fflush(run->fp); /* Make all sure this gets to disk */
/* Allocate Row buffer */
/* Allocate Row buffer */
rowbuflen=(run->numData)*sizeof(float);
if (run->isComplex) rowbuflen *=2;
@ -912,24 +898,22 @@ fileInit_pass2(runDesc *run)
}
static void
fileStartPoint(FILE *fp, bool bin, int num)
{
if (!bin)
fprintf(fp, "%d\t", num - 1);
/* reset set buffer pointer to zero */
/* reset set buffer pointer to zero */
column = 0;
column=0;
return;
}
static void
fileAddRealValue( FILE *fp, bool bin, double value)
fileAddRealValue(FILE *fp, bool bin, double value)
{
if (bin) {
if (value<(-FLT_MAX)) {
@ -949,12 +933,8 @@ fileAddRealValue( FILE *fp, bool bin, double value)
return;
}
static void
fileAddComplexValue(fp, bin, value)
FILE *fp;
bool bin;
IFcomplex value;
fileAddComplexValue(FILE *fp, bool bin, IFcomplex value)
{
if (bin) {
@ -987,15 +967,11 @@ fileAddComplexValue(fp, bin, value)
}
/* ARGSUSED */ /* until some code gets written */
static void
fileEndPoint(FILE *fp, bool bin)
{
/* write row buffer to file */
fwrite((char *)rowbuf, rowbuflen, 1, fp);
return;
}
@ -1008,6 +984,7 @@ fileEnd(runDesc *run)
long place;
int nrows;
if (run->fp != stdout) {
place = ftell(run->fp);
fseek(run->fp, run->pointPos, 0);
@ -1021,14 +998,14 @@ fileEnd(runDesc *run)
}
fflush(run->fp);
/* deallocate row buffer */
/* deallocate row buffer */
tfree(rowbuf);
return;
}
/* The plot maintenance routines. */
@ -1132,7 +1109,7 @@ plotEnd(runDesc *run)
return;
}
/* ParseSpecial takes something of the form "@name[param,index]" and rips
* out name, param, andstrchr.
@ -1146,7 +1123,7 @@ parseSpecial(char *name, char *dev, char *param, char *ind)
*dev = *param = *ind = '\0';
if (*name != '@')
return (FALSE);
return FALSE;
name++;
s = dev;
@ -1154,7 +1131,7 @@ parseSpecial(char *name, char *dev, char *param, char *ind)
*s++ = *name++;
*s = '\0';
if (!*name)
return (TRUE);
return TRUE;
name++;
s = param;
@ -1164,7 +1141,7 @@ parseSpecial(char *name, char *dev, char *param, char *ind)
if (*name == ']')
return (!name[1] ? TRUE : FALSE);
else if (!*name)
return (FALSE);
return FALSE;
name++;
s = ind;
@ -1172,9 +1149,9 @@ parseSpecial(char *name, char *dev, char *param, char *ind)
*s++ = *name++;
*s = '\0';
if (*name && !name[1])
return (TRUE);
return TRUE;
else
return (FALSE);
return FALSE;
}
/* This routine must match two names with or without a V() around them. */
@ -1187,14 +1164,14 @@ name_eq(char *n1, char *n2)
if ((s =strchr(n1, '('))) {
strcpy(buf1, s);
if (!(s =strchr(buf1, ')')))
return (FALSE);
return FALSE;
*s = '\0';
n1 = buf1;
}
if ((s =strchr(n2, '('))) {
strcpy(buf2, s);
if (!(s =strchr(buf2, ')')))
return (FALSE);
return FALSE;
*s = '\0';
n2 = buf2;
}
@ -1213,7 +1190,7 @@ getSpecial(dataDesc *desc, runDesc *run, IFvalue *val)
desc->specName, &desc->specFast, ft_sim, &desc->type,
&selector) == OK) {
desc->type &= (IF_REAL | IF_COMPLEX); /* mask out other bits */
return(TRUE);
return TRUE;
} else if ((vv = if_getstat(run->circuit, &desc->name[1]))) {
/* skip @ sign */
desc->type = IF_REAL;
@ -1224,13 +1201,13 @@ getSpecial(dataDesc *desc, runDesc *run, IFvalue *val)
else if (vv->va_type == VT_BOOL)
val->rValue = (vv->va_bool ? 1.0 : 0.0);
else {
return (FALSE); /* not a real */
return FALSE; /* not a real */
}
tfree(vv);
return(TRUE);
return TRUE;
}
return (FALSE);
return FALSE;
}
static void

15
src/spicelib/devices/devsup.c

@ -91,7 +91,7 @@ DEVfetlim(double vnew,
double vtemp;
vtsthi = fabs(2*(vold-vto))+2;
vtstlo = fabs(vold-vto)*1;
vtstlo = fabs(vold-vto)+1;
vtox = vto + 3.5;
delv = vnew-vold;
@ -251,7 +251,10 @@ DEVqmeyer(double vgs, /* initial voltage gate-source */
double vddif2;
double vgst;
#define MAGIC_VDS 0.025
vgst = vgs-von;
vdsat = MAX(vdsat, MAGIC_VDS);
if (vgst <= -phi) {
*capgb = cox/2;
*capgs = 0;
@ -263,9 +266,19 @@ DEVqmeyer(double vgs, /* initial voltage gate-source */
} else if (vgst <= 0) {
*capgb = -vgst*cox/(2*phi);
*capgs = vgst*cox/(1.5*phi)+cox/3;
vds = vgs-vgd;
if (vds>=vdsat) {
*capgd = 0;
} else {
vddif = 2.0*vdsat-vds;
vddif1 = vdsat-vds/*-1.0e-12*/;
vddif2 = vddif*vddif;
*capgd = *capgs*(1.0-vdsat*vdsat/vddif2);
*capgs = *capgs*(1.0-vddif1*vddif1/vddif2);
}
} else {
vds = vgs-vgd;
vdsat = MAX(vdsat, MAGIC_VDS);
if (vdsat <= vds) {
*capgs = cox/3;
*capgd = 0;

14
src/spicelib/devices/mos3/mos3load.c

@ -400,7 +400,7 @@ MOS3load(GENmodel *inModel, CKTcircuit *ckt)
* corresponding derivative (conductance).
*/
next1: if(vbs <= -3*vt) {
next1: if(vbs <= -3*vt) {
arg=3*vt/(vbs*CONSTe);
arg = arg * arg * arg;
here->MOS3cbs = -SourceSatCur*(1+arg)+ckt->CKTgmin*vbs;
@ -730,6 +730,7 @@ MOS3load(GENmodel *inModel, CKTcircuit *ckt)
ddldvb = 0.0;
goto line520;
};
};
if ( model->MOS3maxDriftVel <= 0.0 ) goto line510;
if (model->MOS3alpha == 0.0) goto line700;
@ -768,7 +769,7 @@ MOS3load(GENmodel *inModel, CKTcircuit *ckt)
ddldvd = dldem*demdvd-dldvd;
ddldvb = dldem*demdvb;
goto line520;
line510:
line510:
if (ckt->CKTbadMos3) {
delxl = sqrt(model->MOS3kappa*((here->MOS3mode*vds)-vdsat)*
model->MOS3alpha);
@ -784,7 +785,7 @@ MOS3load(GENmodel *inModel, CKTcircuit *ckt)
/*
*.....punch through approximation
*/
line520:
line520:
if ( delxl > (0.5*EffectiveLength) ) {
delxl = EffectiveLength-(EffectiveLength*EffectiveLength/
(4.0*delxl));
@ -816,7 +817,7 @@ MOS3load(GENmodel *inModel, CKTcircuit *ckt)
/*
*.....finish strong inversion case
*/
line700:
line700:
if ( (here->MOS3mode==1?vgs:vgd) < von ) {
/*
*.....weak inversion
@ -842,7 +843,7 @@ MOS3load(GENmodel *inModel, CKTcircuit *ckt)
/*
*.....special case of vds = 0.0d0
*/
line900:
line900:
Beta = Beta*fgate;
cdrain = 0.0;
here->MOS3gm = 0.0;
@ -852,7 +853,7 @@ MOS3load(GENmodel *inModel, CKTcircuit *ckt)
((here->MOS3mode==1?vgs:vgd) < von) ) {
here->MOS3gds *=exp(((here->MOS3mode==1?vgs:vgd)-von)/(vt*xn));
}
innerline1000:;
innerline1000:;
/*
*.....done
*/
@ -1240,7 +1241,6 @@ MOS3load(GENmodel *inModel, CKTcircuit *ckt)
xrev*(here->MOS3gm+here->MOS3gmbs));
}
}
}
return(OK);
}
Loading…
Cancel
Save