Code to link mos9 and bjt2 and some fixes from last Alan's code.

This commit is contained in:
pnenzi 2001-04-20 07:31:30 +00:00
parent 34d9855db1
commit 8551caa8e9
17 changed files with 205 additions and 62 deletions

View File

@ -225,6 +225,7 @@ src/spicelib/analysis/Makefile \
src/spicelib/devices/Makefile \
src/spicelib/devices/asrc/Makefile \
src/spicelib/devices/bjt/Makefile \
src/spicelib/devices/bjt2/Makefile \
src/spicelib/devices/bsim1/Makefile \
src/spicelib/devices/bsim2/Makefile \
src/spicelib/devices/bsim3v1/Makefile \
@ -249,6 +250,7 @@ src/spicelib/devices/mos1/Makefile \
src/spicelib/devices/mos2/Makefile \
src/spicelib/devices/mos3/Makefile \
src/spicelib/devices/mos6/Makefile \
src/spicelib/devices/mos9/Makefile \
src/spicelib/devices/res/Makefile \
src/spicelib/devices/sw/Makefile \
src/spicelib/devices/tra/Makefile \

View File

@ -18,6 +18,7 @@ initdata_DATA = spinit setplot spectrum
DYNAMIC_DEVICELIBS = \
spicelib/devices/asrc/libasrc.la \
spicelib/devices/bjt/libbjt.la \
spicelib/devices/bjt2/libbjt2.la \
spicelib/devices/bsim1/libbsim1.la \
spicelib/devices/bsim2/libbsim2.la \
spicelib/devices/bsim3/libbsim3.la \
@ -43,6 +44,7 @@ DYNAMIC_DEVICELIBS = \
spicelib/devices/mos2/libmos2.la \
spicelib/devices/mos3/libmos3.la \
spicelib/devices/mos6/libmos6.la \
spicelib/devices/mos9/libmos9.la \
spicelib/devices/res/libres.la \
spicelib/devices/sw/libsw.la \
spicelib/devices/tra/libtra.la \

View File

@ -1,6 +1,7 @@
/**********
Copyright 1990 Regents of the University of California. All rights reserved.
Author: 1985 Thomas L. Quarles
Modified: 2001 AlansFixes
**********/
/*
@ -36,6 +37,9 @@ NIiter(register CKTcircuit *ckt, int maxIter)
static char *msg = "Too many iterations without convergence";
CKTnode *node; /* current matrix entry */
double diff, maxdiff, damp_factor, *OldCKTstate0;
iterno=0;
ipass=0;
@ -65,6 +69,7 @@ NIiter(register CKTcircuit *ckt, int maxIter)
return(error);
}
}
OldCKTstate0=(double *)MALLOC((ckt->CKTnumStates+1)*sizeof(double));
for(;;){
ckt->CKTnoncon=0;
#ifdef NEWPRED
@ -81,6 +86,7 @@ NIiter(register CKTcircuit *ckt, int maxIter)
#ifdef STEPDEBUG
printf("load returned error \n");
#endif
FREE(OldCKTstate0);
return(error);
}
/*printf("after loading, before solving\n");*/
@ -93,6 +99,7 @@ NIiter(register CKTcircuit *ckt, int maxIter)
#ifdef STEPDEBUG
printf("pre-order returned error \n");
#endif
FREE(OldCKTstate0);
return(error); /* badly formed matrix */
}
ckt->CKTniState |= NIDIDPREORDER;
@ -123,6 +130,7 @@ NIiter(register CKTcircuit *ckt, int maxIter)
#ifdef STEPDEBUG
printf("reorder returned error \n");
#endif
FREE(OldCKTstate0);
return(error); /* can't handle these errors - pass up! */
}
ckt->CKTniState &= ~NISHOULDREORDER;
@ -145,10 +153,15 @@ NIiter(register CKTcircuit *ckt, int maxIter)
#ifdef STEPDEBUG
printf("lufac returned error \n");
#endif
FREE(OldCKTstate0);
return(error);
}
}
for(i=0;i<ckt->CKTnumStates;i++) {
*(OldCKTstate0+i) = *(ckt->CKTstate0+i);
};
startTime = (*(SPfrontEnd->IFseconds))();
SMPsolve(ckt->CKTmatrix,ckt->CKTrhs,ckt->CKTrhsSpare);
ckt->CKTstat->STATsolveTime += (*(SPfrontEnd->IFseconds))()-
@ -176,6 +189,7 @@ NIiter(register CKTcircuit *ckt, int maxIter)
#ifdef STEPDEBUG
printf("iterlim exceeded \n");
#endif
FREE(OldCKTstate0);
return(E_ITERLIM);
}
if(ckt->CKTnoncon==0 && iterno!=1) {
@ -188,6 +202,36 @@ NIiter(register CKTcircuit *ckt, int maxIter)
#endif
}
if( (ckt->CKTnodeDamping!=0) && (ckt->CKTnoncon!=0) &&
((ckt->CKTmode & MODETRANOP) || (ckt->CKTmode & MODEDCOP)) &&
(iterno>1) ) {
maxdiff=0;
for (node = ckt->CKTnodes->next; node; node = node->next) {
if(node->type == NODE_VOLTAGE) {
diff = (ckt->CKTrhs)[node->number] -
(ckt->CKTrhsOld)[node->number];
if (diff>maxdiff) maxdiff=diff;
};
};
if (maxdiff>10) {
damp_factor=10/maxdiff;
if (damp_factor<0.1) damp_factor=0.1;
for (node = ckt->CKTnodes->next; node; node = node->next) {
diff = (ckt->CKTrhs)[node->number] -
(ckt->CKTrhsOld)[node->number];
(ckt->CKTrhs)[node->number]=(ckt->CKTrhsOld)[node->number] +
(damp_factor * diff);
};
for(i=0;i<ckt->CKTnumStates;i++) {
diff = *(ckt->CKTstate0+i) - *(OldCKTstate0+i);
*(ckt->CKTstate0+i) = *(OldCKTstate0+i) +
(damp_factor * diff);
};
};
}
if(ckt->CKTmode & MODEINITFLOAT) {
if ((ckt->CKTmode & MODEDC) &&
( ckt->CKThadNodeset) ) {
@ -198,6 +242,7 @@ NIiter(register CKTcircuit *ckt, int maxIter)
}
if(ckt->CKTnoncon == 0) {
ckt->CKTstat->STATnumIter += iterno;
FREE(OldCKTstate0);
return(OK);
}
} else if(ckt->CKTmode & MODEINITJCT) {
@ -219,6 +264,7 @@ NIiter(register CKTcircuit *ckt, int maxIter)
#ifdef STEPDEBUG
printf("bad initf state \n");
#endif
FREE(OldCKTstate0);
return(E_INTERN);
/* impossible - no such INITF flag! */
}

View File

@ -22,6 +22,7 @@ libckt_a_SOURCES = \
cktdltn.c \
cktdojob.c \
cktdump.c \
cktncdump.c \
cktfbran.c \
cktfnda.c \
cktfndm.c \

View File

@ -1,6 +1,7 @@
/**********
Copyright 1990 Regents of the University of California. All rights reserved.
Author: 1985 Thomas L. Quarles
Modified 2001: AlansFixes
**********/
#include "ngspice.h"
@ -62,7 +63,11 @@ ACan(CKTcircuit *ckt, int restart)
(ckt->CKTmode & MODEUIC) | MODEDCOP | MODEINITJCT,
(ckt->CKTmode & MODEUIC) | MODEDCOP | MODEINITFLOAT,
ckt->CKTdcMaxIter);
if(error) return(error);
if(error){
fprintf(stdout,"\nAC operating point failed -\n");
CKTncDump(ckt);
return(error);
}
ckt->CKTmode = (ckt->CKTmode & MODEUIC) | MODEDCOP | MODEINITSMSIG;
error = CKTload(ckt);

View File

@ -1,7 +1,7 @@
/**********
Copyright 1990 Regents of the University of California. All rights reserved.
Author: 1985 Thomas L. Quarles
Modified: 2000 AlansFIxes
Modified: 2000 AlansFixes
**********/
/*
*/
@ -105,7 +105,7 @@ CKTload(CKTcircuit *ckt)
*(ckt->CKTrhs+node->number) += 1.0e10 * node->ic;
*/
*(ckt->CKTrhs+node->number) = 1.0e10 * node->ic *
ckt->CKTsrcFact; /* AlansFixes */
ckt->CKTsrcFact;
*(node->ptr) += 1.0e10;
} else {
/* Original code:

View File

@ -0,0 +1,46 @@
/**********
Copyright 1999 AG inc. All rights reserved.
Author: 1999 Alan Gillespie
**********/
#include "spice.h"
#include <stdio.h>
#include "cktdefs.h"
#include "util.h"
#include "misc.h"
#include "suffix.h"
void
CKTncDump(ckt)
CKTcircuit *ckt;
{
CKTnode *node;
double new, old, tol;
int i=1;
fprintf(stdout,"\n");
fprintf(stdout,"Last Node Voltages\n");
fprintf(stdout,"------------------\n\n");
fprintf(stdout,"%-30s %20s %20s\n", "Node", "Last Voltage", "Previous Iter");
fprintf(stdout,"%-30s %20s %20s\n", "----", "------------", "-------------");
for(node=ckt->CKTnodes->next;node;node=node->next) {
if (strstr(node->name, "#branch") || !strstr(node->name, "#")) {
new = *((ckt->CKTrhsOld) + i ) ;
old = *((ckt->CKTrhs) + i ) ;
fprintf(stdout,"%-30s %20g %20g", node->name, new, old);
if(node->type == 3) {
tol = ckt->CKTreltol * (MAX(FABS(old),FABS(new))) +
ckt->CKTvoltTol;
} else {
tol = ckt->CKTreltol * (MAX(FABS(old),FABS(new))) +
ckt->CKTabstol;
}
if (FABS(new-old) >tol ) {
fprintf(stdout," *");
}
fprintf(stdout,"\n");
};
i++;
};
fprintf(stdout,"\n");
}

View File

@ -16,9 +16,9 @@ CKTop(CKTcircuit *ckt, long int firstmode, long int continuemode, int iterlim)
{
int converged;
int i;
CKTnode *n; /* AlansFixes */
double raise, ConvFact, NumNodes; /* AlansFixes */
double *OldRhsOld, *OldCKTstate0; /* AlansFixes */
CKTnode *n;
double raise, ConvFact, NumNodes;
double *OldRhsOld, *OldCKTstate0;
int iters;
ckt->CKTmode = firstmode;

View File

@ -33,7 +33,9 @@ DCop(CKTcircuit *ckt)
(ckt->CKTmode & MODEUIC) | MODEDCOP | MODEINITFLOAT,
ckt->CKTdcMaxIter);
if(converged != 0) {
fprintf(stdout,"\nDC solution failed -\n");
CKTncDump(ckt);
/*
CKTnode *node;
double new, old, tol;
int i=1;
@ -65,7 +67,8 @@ DCop(CKTcircuit *ckt)
i++;
};
fprintf(stdout,"\n");
(*(SPfrontEnd->OUTendPlot))(plot);
(*(SPfrontEnd->OUTendPlot))(plot); */
return(converged);
};

View File

@ -51,7 +51,7 @@ DCtran(CKTcircuit *ckt,
#endif /* PARALLEL_ARCH */
if(restart || ckt->CKTtime == 0) {
delta=MIN(ckt->CKTfinalTime/100,ckt->CKTstep)/10;
delta=MIN(ckt->CKTfinalTime/200,ckt->CKTstep)/10;
/* begin LTRA code addition */
if (ckt->CKTtimePoints != NULL)
@ -100,8 +100,9 @@ DCtran(CKTcircuit *ckt,
ckt->CKTdcMaxIter);
if(converged != 0) {
CKTnode *node;
fprintf(stdout,"\nTransient solution failed -\n");
CKTncDump(ckt);
/* CKTnode *node;
double new, old, tol;
int i=1;
@ -130,7 +131,7 @@ DCtran(CKTcircuit *ckt,
fprintf(stdout,"\n");
};
i++;
}
} */
} else {
fprintf(stdout,"\nInitial Transient Solution\n");
fprintf(stdout,"--------------------------\n\n");

View File

@ -6,6 +6,7 @@
/**********
Copyright 1990 Regents of the University of California. All rights reserved.
Author: 1987 Gary W. Ng
Modified: 2001 AlansFixes
**********/
#include "ngspice.h"
@ -18,6 +19,9 @@ Author: 1987 Gary W. Ng
#include "vsrc/vsrcdefs.h"
#include "isrc/isrcdefs.h"
extern int CKTnoise( CKTcircuit *, int, int, Ndata * );
int
NOISEan (CKTcircuit *ckt, int restart)
{

View File

@ -40,7 +40,7 @@ int TRANinit(CKTcircuit *ckt, JOB *job)
#else
/* The original spice code */
if(ckt->CKTmaxStep == 0) {
ckt->CKTmaxStep = (ckt->CKTfinalTime-ckt->CKTinitTime)/100;
ckt->CKTmaxStep = (ckt->CKTfinalTime-ckt->CKTinitTime)/200;
}
#endif

View File

@ -3,6 +3,7 @@
SUBDIRS = \
asrc \
bjt \
bjt2 \
bsim1 \
bsim2 \
bsim3 \
@ -27,6 +28,7 @@ SUBDIRS = \
mos2 \
mos3 \
mos6 \
mos9 \
res \
sw \
tra \

View File

@ -35,7 +35,7 @@
#include "dev.h"
#define DEVICES_USED "asrc bjt bsim1 bsim2 bsim3 bsim3v2 bsim3v1 bsim4 bsim3soipd bsim3soifd bsim3soidd cap cccs ccvs csw dio ind isrc jfet ltra mes mos1 mos2 mos3 mos6 res sw tra urc vccs vcvs vsrc"
#define DEVICES_USED "asrc bjt bjt2 bsim1 bsim2 bsim3 bsim3v2 bsim3v1 bsim4 bsim3soipd bsim3soifd bsim3soidd cap cccs ccvs csw dio ind isrc jfet ltra mes mos1 mos2 mos3 mos6 mos9 res sw tra urc vccs vcvs vsrc"
/*
* Analyses
@ -55,6 +55,7 @@
#include "asrc/asrcitf.h"
#include "bjt/bjtitf.h"
#include "bjt2/bjt2itf.h"
#include "bsim1/bsim1itf.h"
#include "bsim2/bsim2itf.h"
#include "bsim3/bsim3itf.h"
@ -79,6 +80,7 @@
#include "mos2/mos2itf.h"
#include "mos3/mos3itf.h"
#include "mos6/mos6itf.h"
#include "mos9/mos9itf.h"
#include "res/resitf.h"
#include "sw/switf.h"
#include "tra/traitf.h"
@ -88,7 +90,7 @@
#include "vsrc/vsrcitf.h"
#define DEVNUM 34
#define DEVNUM 36
SPICEdev *DEVices[DEVNUM];
@ -100,38 +102,40 @@ spice_init_devices(void)
DEVices[ 0] = get_urc_info();
DEVices[ 1] = get_asrc_info();
DEVices[ 2] = get_bjt_info();
DEVices[ 3] = get_bsim1_info();
DEVices[ 4] = get_bsim2_info();
DEVices[ 5] = get_bsim3_info();
DEVices[ 6] = get_bsim3v1_info();
DEVices[ 7] = get_bsim3v2_info();
DEVices[ 8] = get_bsim4_info();
DEVices[ 9] = get_b3soipd_info();
DEVices[10] = get_b3soifd_info();
DEVices[11] = get_b3soidd_info();
DEVices[12] = get_cap_info();
DEVices[13] = get_cccs_info();
DEVices[14] = get_ccvs_info();
DEVices[15] = get_csw_info();
DEVices[16] = get_dio_info();
DEVices[17] = get_ind_info();
DEVices[18] = get_mut_info();
DEVices[19] = get_isrc_info();
DEVices[20] = get_jfet_info();
DEVices[21] = get_jfet2_info();
DEVices[22] = get_ltra_info();
DEVices[23] = get_mes_info();
DEVices[24] = get_mos1_info();
DEVices[25] = get_mos2_info();
DEVices[26] = get_mos3_info();
DEVices[27] = get_mos6_info();
DEVices[28] = get_res_info();
DEVices[29] = get_sw_info();
DEVices[30] = get_tra_info();
DEVices[31] = get_vccs_info();
DEVices[32] = get_vcvs_info();
DEVices[33] = get_vsrc_info();
assert(34 == DEVNUM);
DEVices[ 3] = get bjt2_info();
DEVices[ 4] = get_bsim1_info();
DEVices[ 5] = get_bsim2_info();
DEVices[ 6] = get_bsim3_info();
DEVices[ 7] = get_bsim3v1_info();
DEVices[ 8] = get_bsim3v2_info();
DEVices[ 9] = get_bsim4_info();
DEVices[10] = get_b3soipd_info();
DEVices[11] = get_b3soifd_info();
DEVices[12] = get_b3soidd_info();
DEVices[13] = get_cap_info();
DEVices[14] = get_cccs_info();
DEVices[15] = get_ccvs_info();
DEVices[16] = get_csw_info();
DEVices[17] = get_dio_info();
DEVices[18] = get_ind_info();
DEVices[19] = get_mut_info();
DEVices[20] = get_isrc_info();
DEVices[21] = get_jfet_info();
DEVices[22] = get_jfet2_info();
DEVices[23] = get_ltra_info();
DEVices[24] = get_mes_info();
DEVices[25] = get_mos1_info();
DEVices[26] = get_mos2_info();
DEVices[27] = get_mos3_info();
DEVices[28] = get_mos6_info();
DEVices[29] = get_mos9_info();
DEVices[30] = get_res_info();
DEVices[31] = get_sw_info();
DEVices[32] = get_tra_info();
DEVices[33] = get_vccs_info();
DEVices[34] = get_vcvs_info();
DEVices[35] = get_vsrc_info();
assert(36 == DEVNUM);
}

View File

@ -155,6 +155,7 @@ INP2M (void *ckt, INPtables * tab, card * current)
&& thismodel->INPmodType != INPtypelook ("Mos5")
&& thismodel->INPmodType != INPtypelook ("Mos6")
&& thismodel->INPmodType != INPtypelook ("Mos8")
&& thismodel->INPmodType != INPtypelook ("Mos9")
&& thismodel->INPmodType != INPtypelook ("BSIM1")
&& thismodel->INPmodType != INPtypelook ("BSIM2")
&& thismodel->INPmodType != INPtypelook ("BSIM3")

View File

@ -66,12 +66,13 @@ void INP2Q(void *ckt, INPtables * tab, card * current, void *gnode)
INPinsert(&model, tab);
current->error = INPgetMod(ckt, model, &thismodel, tab);
if (thismodel != NULL) {
if (mytype != thismodel->INPmodType) {
LITERR("incorrect model type");
return;
}
type = mytype;
mdfast = (thismodel->INPmodfast);
if(thismodel->INPmodType != INPtypelook("BJT") &&
thismodel->INPmodType != INPtypelook("BJT2")) {
LITERR("incorrect model type")
return;
}
type = (thismodel->INPmodType);
mdfast = (thismodel->INPmodfast);
} else {
type = mytype;
if (!tab->defQmod) {

View File

@ -26,12 +26,29 @@ char *INPdomodel(void *ckt, card * image, INPtables * tab)
INPinsert(&modname, tab);
INPgetTok(&line, &typename, 1);
if ((strcmp(typename, "npn") == 0) || (strcmp(typename, "pnp") == 0)) {
type = INPtypelook("BJT");
if (type < 0) {
err =
INPmkTemp
("Device type BJT not available in this binary\n");
}
err = INPfindLev(line,&lev);
switch(lev) {
case 0:
case 1:
type = INPtypelook("BJT");
if (type < 0) {
err = INPmkTemp(
"Device type BJT not available in this binary\n");
}
break;
case 2:
type = INPtypelook("BJT2");
if(type < 0) {
err = INPmkTemp(
"Device type BJT2 not available in this binary\n");
}
break;
default: /* placeholder; use level 3 for the next model */
err = INPmkTemp(
"Only BJT levels 1 and 2 are supported in this binary\n");
break;
}
INPmakeMod(modname, type, image);
} else if (strcmp(typename, "d") == 0) {
type = INPtypelook("Diode");
@ -155,7 +172,15 @@ char *INPdomodel(void *ckt, card * image, INPtables * tab)
("Device type BSIM3 not available in this binary\n");
}
break;
case 9:
case 9:
type = INPtypelook("Mos9");
if(type < 0) {
err = INPmkTemp(
"Device type MOS9 not available in this binary\n");
}
break;
case 10:
type = INPtypelook("B3SOIPD");
if (type < 0) {
err =
@ -163,7 +188,7 @@ char *INPdomodel(void *ckt, card * image, INPtables * tab)
("Device type B3SOIPD not available in this binary\n");
}
break;
case 10:
case 11:
type = INPtypelook("B3SOIFD");
if (type < 0) {
err =
@ -171,7 +196,7 @@ char *INPdomodel(void *ckt, card * image, INPtables * tab)
("Device type B3SOIFD not available in this binary\n");
}
break;
case 11:
case 12:
type = INPtypelook("B3SOIDD");
if (type < 0) {
err =