prevent program crash by misusing thermal model

This commit is contained in:
dwarning 2020-01-26 08:35:30 +01:00
parent 379cafde45
commit 24b70c8682
5 changed files with 25 additions and 12 deletions

View File

@ -35,7 +35,7 @@ VDMOSacLoad(GENmodel *inModel, CKTcircuit *ckt)
for(here = VDMOSinstances(model); here!= NULL;
here = VDMOSnextInstance(here)) {
selfheat = (here->VDMOStnodeoutGiven) && (model->VDMOSrthjc != 0.0);
selfheat = (here->VDMOStnodeoutGiven) && (model->VDMOSrthjcGiven);
if (here->VDMOSmode < 0) {
xnrm=0;
xrev=1;

View File

@ -42,8 +42,8 @@ typedef struct sVDMOSinstance {
const int VDMOSdNode; /* number of the gate node of the mosfet */
const int VDMOSgNode; /* number of the gate node of the mosfet */
const int VDMOSsNode; /* number of the source node of the mosfet */
const int VDMOStempNode; /* number of the temperature node of the mosfet */
const int VDMOStcaseNode; /* number of the 2nd temperature node of the mosfet */
int VDMOStempNode; /* number of the temperature node of the mosfet */
int VDMOStcaseNode; /* number of the 2nd temperature node of the mosfet */
int VDMOSdNodePrime; /* number of the internal drain node of the mosfet */
int VDMOSsNodePrime; /* number of the internal source node of the mosfet */
int VDMOSgNodePrime; /* number of the internal gate node of the mosfet */

View File

@ -104,7 +104,7 @@ VDMOSload(GENmodel *inModel, CKTcircuit *ckt)
for (here = VDMOSinstances(model); here != NULL;
here = VDMOSnextInstance(here)) {
selfheat = (here->VDMOStnodeoutGiven) && (model->VDMOSrthjc != 0.0);
selfheat = (here->VDMOStnodeoutGiven) && (model->VDMOSrthjcGiven);
if (selfheat)
Check_mos = 1;
else

View File

@ -91,7 +91,7 @@ VDMOSnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt,
switch (mode) {
case N_DENS:
if ((inst->VDMOStnodeoutGiven) && (model->VDMOSrthjc != 0.0))
if ((inst->VDMOStnodeoutGiven) && (model->VDMOSrthjcGiven))
tempRatioSH = inst->VDMOSTempSH / ckt->CKTtemp;
else
tempRatioSH = 1.0;

View File

@ -119,7 +119,7 @@ VDMOSsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt,
model->VDMOSeg = 1.11;
if (!model->VDMOSrthjcGiven)
model->VDMOSrthjc = 0;
model->VDMOSrthjc = 1.0e-03;
if (!model->VDMOSrthcaGiven)
model->VDMOSrthca = 100;
@ -312,17 +312,30 @@ VDMOSsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt,
here->VDIOposPrimeNode = here->VDMOSsNode;
}
if ((here->VDMOStnodeoutGiven) && (model->VDMOSrthjc!=0.0)) {
if(here->VDMOSvcktTbranch == 0) {
if ((here->VDMOStnodeoutGiven) && (model->VDMOSrthjcGiven)) {
if (here->VDMOStempNode == -1) {
error = CKTmkVolt(ckt,&tmp,here->VDMOSname,"Tj");
if (error) return(error);
here->VDMOStempNode = tmp->number;
}
if (here->VDMOStcaseNode == -1) {
error = CKTmkVolt(ckt,&tmp,here->VDMOSname,"Tc");
if (error) return(error);
here->VDMOStcaseNode = tmp->number;
}
if(here->VDMOSvcktTbranch == 0) {
error = CKTmkCur(ckt,&tmp,here->VDMOSname,"VcktTemp");
if(error) return(error);
here->VDMOSvcktTbranch = tmp->number;
}
}
if (here->VDMOStNodePrime == 0) {
error = CKTmkVolt(ckt, &tmp, here->VDMOSname, "thermal node");
error = CKTmkVolt(ckt, &tmp, here->VDMOSname, "cktTemp");
if (error) return(error);
here->VDMOStNodePrime = tmp->number;
}
} else {
here->VDMOStempNode = 0;
here->VDMOStcaseNode = 0;
}
/* macro to make elements with built in test for out of memory */
@ -331,7 +344,7 @@ do { if((here->ptr = SMPmakeElt(matrix, here->first, here->second)) == NULL){\
return(E_NOMEM);\
} } while(0)
if ((here->VDMOStnodeoutGiven) && (model->VDMOSrthjc!=0.0)) {
if ((here->VDMOStnodeoutGiven) && (model->VDMOSrthjcGiven)) {
TSTALLOC(VDMOSTemptempPtr, VDMOStempNode, VDMOStempNode);
TSTALLOC(VDMOSTempdpPtr, VDMOStempNode, VDMOSdNodePrime);
TSTALLOC(VDMOSTempspPtr, VDMOStempNode, VDMOSsNodePrime);
@ -415,7 +428,7 @@ VDMOSunsetup(GENmodel *inModel, CKTcircuit *ckt)
CKTdltNNum(ckt, here->VDIOposPrimeNode);
here->VDIOposPrimeNode = 0;
if ((here->VDMOStnodeoutGiven) && (model->VDMOSrthjc!=0.0)) {
if ((here->VDMOStnodeoutGiven) && (model->VDMOSrthjcGiven)) {
if (here->VDMOStNodePrime > 0)
CKTdltNNum(ckt, here->VDMOStNodePrime);
here->VDMOStNodePrime = 0;