Merge branch 'pre-master-43' into bt_dev
This commit is contained in:
commit
b19c9539a9
|
|
@ -584,8 +584,7 @@ cx_fft(void *data, short int type, int length, int *newlength, short int *newtyp
|
|||
double *datax = NULL;
|
||||
#endif
|
||||
|
||||
if (grouping == 0)
|
||||
grouping = length;
|
||||
NG_IGNORE(grouping);
|
||||
|
||||
/* First do some sanity checks. */
|
||||
if (!pl || !pl->pl_scale || !newpl || !newpl->pl_scale) {
|
||||
|
|
@ -847,8 +846,7 @@ cx_ifft(void *data, short int type, int length, int *newlength, short int *newty
|
|||
double scale;
|
||||
#endif
|
||||
|
||||
if (grouping == 0)
|
||||
grouping = length;
|
||||
NG_IGNORE(grouping);
|
||||
|
||||
/* First do some sanity checks. */
|
||||
if (!pl || !pl->pl_scale || !newpl || !newpl->pl_scale) {
|
||||
|
|
|
|||
|
|
@ -62,7 +62,6 @@ NevalSrc(double* noise, double* lnNoise, CKTcircuit* ckt, int type, int node1, i
|
|||
case N_GAIN:
|
||||
inoise = 0.0;
|
||||
*noise = cmodu(csubco(ckt->CKTadjointRHS->d[0][node1], ckt->CKTadjointRHS->d[0][node2]));
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
|
@ -92,8 +91,8 @@ NevalSrc(double* noise, double* lnNoise, CKTcircuit* ckt, int type, int node1, i
|
|||
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
double realVal;
|
||||
double imagVal;
|
||||
double gain;
|
||||
|
|
@ -180,7 +179,6 @@ NevalSrc2(
|
|||
|
||||
case THERMNOISE:
|
||||
knoise = 4 * CONSTboltz * ckt->CKTtemp; /* param is the conductance of a resistor */
|
||||
// For this simulation we are not collecting any statistics on output nodes. Force noise to 0
|
||||
*noise = knoise;
|
||||
*lnNoise = log(MAX(*noise, N_MINLOG));
|
||||
break;
|
||||
|
|
@ -216,7 +214,6 @@ NevalSrc2(
|
|||
iNoise->d[0][d] = in;
|
||||
}
|
||||
|
||||
|
||||
for (int d = 0; d < ckt->CKTportCount; d++)
|
||||
for (int s = 0; s < ckt->CKTportCount; s++)
|
||||
ckt->CKTNoiseCYmat->d[d][s] = caddco(ckt->CKTNoiseCYmat->d[d][s], cmultco(iNoise->d[0][d], conju(iNoise->d[0][s])));
|
||||
|
|
@ -225,7 +222,6 @@ NevalSrc2(
|
|||
}
|
||||
#endif
|
||||
|
||||
|
||||
realVal1 = ckt->CKTrhs[node1] - ckt->CKTrhs[node2];
|
||||
imagVal1 = ckt->CKTirhs[node1] - ckt->CKTirhs[node2];
|
||||
realVal2 = ckt->CKTrhs[node3] - ckt->CKTrhs[node4];
|
||||
|
|
@ -270,10 +266,7 @@ NevalSrcInstanceTemp(double* noise, double* lnNoise, CKTcircuit* ckt, int type,
|
|||
int node1, int node2, double param, double param2)
|
||||
{
|
||||
|
||||
|
||||
#ifdef RFSPICE
|
||||
// For this simulation we are not collecting any statistics on output nodes. Force noise to 0
|
||||
|
||||
if (ckt->CKTcurrentAnalysis & DOING_SP)
|
||||
{
|
||||
double inoise = 0.0;
|
||||
|
|
@ -282,14 +275,12 @@ NevalSrcInstanceTemp(double* noise, double* lnNoise, CKTcircuit* ckt, int type,
|
|||
|
||||
case SHOTNOISE:
|
||||
inoise = 2 * CHARGE * fabs(param); /* param is the dc current in a semiconductor */
|
||||
// For this simulation we are not collecting any statistics on output nodes. Force noise to 0
|
||||
*noise = inoise;
|
||||
*lnNoise = log(MAX(*noise, N_MINLOG));
|
||||
break;
|
||||
|
||||
case THERMNOISE:
|
||||
inoise = 4.0 * CONSTboltz * (ckt->CKTtemp + param2) * param; /* param is the conductance of a resistor */
|
||||
// For this simulation we are not collecting any statistics on output nodes. Force noise to 0
|
||||
*noise = inoise;
|
||||
*lnNoise = log(MAX(*noise, N_MINLOG));
|
||||
break;
|
||||
|
|
@ -297,7 +288,7 @@ NevalSrcInstanceTemp(double* noise, double* lnNoise, CKTcircuit* ckt, int type,
|
|||
case N_GAIN:
|
||||
inoise = 0.0;
|
||||
*noise = cmodu(csubco(ckt->CKTadjointRHS->d[0][node1], ckt->CKTadjointRHS->d[0][node2]));
|
||||
return;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -320,7 +311,6 @@ NevalSrcInstanceTemp(double* noise, double* lnNoise, CKTcircuit* ckt, int type,
|
|||
iNoise->d[0][d] = in;
|
||||
}
|
||||
|
||||
|
||||
for (int d = 0; d < ckt->CKTportCount; d++)
|
||||
for (int s = 0; s < ckt->CKTportCount; s++)
|
||||
ckt->CKTNoiseCYmat->d[d][s] = caddco(ckt->CKTNoiseCYmat->d[d][s], cmultco(iNoise->d[0][d], conju(iNoise->d[0][s])));
|
||||
|
|
@ -328,12 +318,14 @@ NevalSrcInstanceTemp(double* noise, double* lnNoise, CKTcircuit* ckt, int type,
|
|||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
double realVal;
|
||||
double imagVal;
|
||||
double gain;
|
||||
realVal = ckt->CKTrhs[node1] - ckt->CKTrhs[node2];
|
||||
imagVal = ckt->CKTirhs[node1] - ckt->CKTirhs[node2];
|
||||
gain = (realVal * realVal) + (imagVal * imagVal);
|
||||
|
||||
switch (type) {
|
||||
|
||||
case SHOTNOISE:
|
||||
|
|
@ -343,7 +335,7 @@ NevalSrcInstanceTemp(double* noise, double* lnNoise, CKTcircuit* ckt, int type,
|
|||
|
||||
case THERMNOISE:
|
||||
*noise = gain * 4 * CONSTboltz * (ckt->CKTtemp + param2) /* param2 is the instance temperature difference */
|
||||
* param; /* param is the conductance of a resistor */
|
||||
* param; /* param is the conductance of a resistor */
|
||||
*lnNoise = log(MAX(*noise, N_MINLOG));
|
||||
break;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,23 +11,22 @@ Author: 1987 Gary W. Ng
|
|||
#include "ngspice/suffix.h"
|
||||
|
||||
/*
|
||||
* BJTnoise (mode, operation, firstModel, ckt, data, OnDens)
|
||||
*BJTnoise (mode, operation, firstModel, ckt, data, OnDens)
|
||||
*
|
||||
* This routine names and evaluates all of the noise sources
|
||||
* associated with BJT's. It starts with the model *firstModel and
|
||||
* traverses all of its insts. It then proceeds to any other models
|
||||
* on the linked list. The total output noise density generated by
|
||||
* all of the BJT's is summed with the variable "OnDens".
|
||||
* This routine names and evaluates all of the noise sources
|
||||
* associated with BJT's. It starts with the model *firstModel and
|
||||
* traverses all of its insts. It then proceeds to any other models
|
||||
* on the linked list. The total output noise density generated by
|
||||
* all of the BJT's is summed with the variable "OnDens".
|
||||
*/
|
||||
|
||||
|
||||
int
|
||||
BJTnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt,
|
||||
Ndata *data, double *OnDens)
|
||||
BJTnoise(int mode, int operation, GENmodel*genmodel, CKTcircuit *ckt,
|
||||
Ndata *data, double *OnDens)
|
||||
{
|
||||
NOISEAN *job = (NOISEAN *) ckt->CKTcurJob;
|
||||
NOISEAN *job = (NOISEAN*) ckt->CKTcurJob;
|
||||
|
||||
BJTmodel *firstModel = (BJTmodel *) genmodel;
|
||||
BJTmodel *firstModel = (BJTmodel*) genmodel;
|
||||
BJTmodel *model;
|
||||
BJTinstance *inst;
|
||||
double tempOnoise;
|
||||
|
|
@ -35,163 +34,170 @@ BJTnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt,
|
|||
double noizDens[BJTNSRCS];
|
||||
double lnNdens[BJTNSRCS];
|
||||
int i;
|
||||
double dtemp;
|
||||
|
||||
/* define the names of the noise sources */
|
||||
|
||||
static char *BJTnNames[BJTNSRCS] = {
|
||||
/* Note that we have to keep the order consistent with the
|
||||
strchr definitions in BJTdefs.h */
|
||||
"_rc", /* noise due to rc */
|
||||
"_rb", /* noise due to rb */
|
||||
"_re", /* noise due to re */
|
||||
"_ic", /* noise due to ic */
|
||||
"_ib", /* noise due to ib */
|
||||
"_1overf", /* flicker (1/f) noise */
|
||||
"" /* total transistor noise */
|
||||
/* Note that we have to keep the order consistent with the
|
||||
strchr definitions in BJTdefs.h */
|
||||
"_rc", /* noise due to rc */
|
||||
"_rb", /* noise due to rb */
|
||||
"_re", /* noise due to re */
|
||||
"_ic", /* noise due to ic */
|
||||
"_ib", /* noise due to ib */
|
||||
"_1overf", /* flicker (1/f) noise */
|
||||
"" /* total transistor noise */
|
||||
};
|
||||
|
||||
for (model=firstModel; model != NULL; model=BJTnextModel(model)) {
|
||||
for (inst=BJTinstances(model); inst != NULL;
|
||||
inst=BJTnextInstance(inst)) {
|
||||
for (model = firstModel; model != NULL; model = BJTnextModel(model)) {
|
||||
for (inst = BJTinstances(model); inst != NULL; inst = BJTnextInstance(inst)) {
|
||||
|
||||
switch (operation) {
|
||||
switch (operation) {
|
||||
|
||||
case N_OPEN:
|
||||
case N_OPEN:
|
||||
|
||||
/* see if we have to to produce a summary report */
|
||||
/* if so, name all the noise generators */
|
||||
/* see if we have to to produce a summary report */
|
||||
/* if so, name all the noise generators */
|
||||
|
||||
if (job->NStpsSm != 0) {
|
||||
switch (mode) {
|
||||
if (job->NStpsSm != 0) {
|
||||
switch (mode) {
|
||||
|
||||
case N_DENS:
|
||||
for (i=0; i < BJTNSRCS; i++) {
|
||||
NOISE_ADD_OUTVAR(ckt, data, "onoise_%s%s", inst->BJTname, BJTnNames[i]);
|
||||
}
|
||||
break;
|
||||
case N_DENS:
|
||||
for (i = 0; i < BJTNSRCS; i++) {
|
||||
NOISE_ADD_OUTVAR(ckt, data, "onoise_%s%s", inst->BJTname, BJTnNames[i]);
|
||||
}
|
||||
break;
|
||||
|
||||
case INT_NOIZ:
|
||||
for (i=0; i < BJTNSRCS; i++) {
|
||||
NOISE_ADD_OUTVAR(ckt, data, "onoise_total_%s%s", inst->BJTname, BJTnNames[i]);
|
||||
NOISE_ADD_OUTVAR(ckt, data, "inoise_total_%s%s", inst->BJTname, BJTnNames[i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case INT_NOIZ:
|
||||
for (i = 0; i < BJTNSRCS; i++) {
|
||||
NOISE_ADD_OUTVAR(ckt, data, "onoise_total_%s%s", inst->BJTname, BJTnNames[i]);
|
||||
NOISE_ADD_OUTVAR(ckt, data, "inoise_total_%s%s", inst->BJTname, BJTnNames[i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case N_CALC:
|
||||
switch (mode) {
|
||||
case N_CALC:
|
||||
switch (mode) {
|
||||
|
||||
case N_DENS:
|
||||
NevalSrc(&noizDens[BJTRCNOIZ],&lnNdens[BJTRCNOIZ],
|
||||
ckt,THERMNOISE,inst->BJTcollCXNode,inst->BJTcolNode,
|
||||
inst->BJTtcollectorConduct * inst->BJTm);
|
||||
case N_DENS:
|
||||
|
||||
NevalSrc(&noizDens[BJTRBNOIZ],&lnNdens[BJTRBNOIZ],
|
||||
ckt,THERMNOISE,inst->BJTbasePrimeNode,inst->BJTbaseNode,
|
||||
*(ckt->CKTstate0 + inst->BJTgx) * inst->BJTm);
|
||||
if (inst->BJTtempGiven)
|
||||
dtemp = inst->BJTtemp - ckt->CKTtemp + (model->BJTtnom-CONSTCtoK);
|
||||
else
|
||||
dtemp = inst->BJTdtemp;
|
||||
|
||||
NevalSrc(&noizDens[BJT_RE_NOISE],&lnNdens[BJT_RE_NOISE],
|
||||
ckt,THERMNOISE,inst->BJTemitPrimeNode,inst->BJTemitNode,
|
||||
inst->BJTtemitterConduct * inst-> BJTm);
|
||||
NevalSrcInstanceTemp(&noizDens[BJTRCNOIZ],&lnNdens[BJTRCNOIZ],
|
||||
ckt, THERMNOISE, inst->BJTcollCXNode, inst->BJTcolNode,
|
||||
inst->BJTtcollectorConduct * inst->BJTm, dtemp);
|
||||
|
||||
NevalSrc(&noizDens[BJTICNOIZ],&lnNdens[BJTICNOIZ],
|
||||
ckt,SHOTNOISE,inst->BJTcolPrimeNode, inst->BJTemitPrimeNode,
|
||||
*(ckt->CKTstate0 + inst->BJTcc) * inst->BJTm);
|
||||
NevalSrcInstanceTemp(&noizDens[BJTRBNOIZ],&lnNdens[BJTRBNOIZ],
|
||||
ckt, THERMNOISE, inst->BJTbasePrimeNode, inst->BJTbaseNode,
|
||||
*(ckt->CKTstate0 + inst->BJTgx) * inst->BJTm, dtemp);
|
||||
|
||||
NevalSrc(&noizDens[BJTIBNOIZ],&lnNdens[BJTIBNOIZ],
|
||||
ckt,SHOTNOISE,inst->BJTbasePrimeNode, inst->BJTemitPrimeNode,
|
||||
*(ckt->CKTstate0 + inst->BJTcb) * inst->BJTm);
|
||||
NevalSrcInstanceTemp(&noizDens[BJT_RE_NOISE],&lnNdens[BJT_RE_NOISE],
|
||||
ckt, THERMNOISE, inst->BJTemitPrimeNode, inst->BJTemitNode,
|
||||
inst->BJTtemitterConduct * inst->BJTm, dtemp);
|
||||
|
||||
NevalSrc(&noizDens[BJTFLNOIZ], NULL, ckt,
|
||||
N_GAIN,inst->BJTbasePrimeNode, inst->BJTemitPrimeNode,
|
||||
(double)0.0);
|
||||
noizDens[BJTFLNOIZ] *= inst->BJTm * model->BJTfNcoef *
|
||||
exp(model->BJTfNexp *
|
||||
log(MAX(fabs(*(ckt->CKTstate0 + inst->BJTcb)),N_MINLOG))) /
|
||||
data->freq;
|
||||
lnNdens[BJTFLNOIZ] =
|
||||
log(MAX(noizDens[BJTFLNOIZ],N_MINLOG));
|
||||
NevalSrc(&noizDens[BJTICNOIZ],&lnNdens[BJTICNOIZ],
|
||||
ckt, SHOTNOISE, inst->BJTcolPrimeNode, inst->BJTemitPrimeNode,
|
||||
*(ckt->CKTstate0 + inst->BJTcc) * inst->BJTm);
|
||||
|
||||
noizDens[BJTTOTNOIZ] = noizDens[BJTRCNOIZ] +
|
||||
noizDens[BJTRBNOIZ] +
|
||||
noizDens[BJT_RE_NOISE] +
|
||||
noizDens[BJTICNOIZ] +
|
||||
noizDens[BJTIBNOIZ] +
|
||||
noizDens[BJTFLNOIZ];
|
||||
lnNdens[BJTTOTNOIZ] =
|
||||
log(noizDens[BJTTOTNOIZ]);
|
||||
NevalSrc(&noizDens[BJTIBNOIZ],&lnNdens[BJTIBNOIZ],
|
||||
ckt, SHOTNOISE, inst->BJTbasePrimeNode, inst->BJTemitPrimeNode,
|
||||
*(ckt->CKTstate0 + inst->BJTcb) * inst->BJTm);
|
||||
|
||||
*OnDens += noizDens[BJTTOTNOIZ];
|
||||
NevalSrc(&noizDens[BJTFLNOIZ], NULL, ckt,
|
||||
N_GAIN, inst->BJTbasePrimeNode, inst->BJTemitPrimeNode,
|
||||
(double) 0.0);
|
||||
noizDens[BJTFLNOIZ] *= inst->BJTm * model->BJTfNcoef *
|
||||
exp(model->BJTfNexp *
|
||||
log(MAX(fabs(*(ckt->CKTstate0 + inst->BJTcb)), N_MINLOG))) /
|
||||
data->freq;
|
||||
lnNdens[BJTFLNOIZ] =
|
||||
log(MAX(noizDens[BJTFLNOIZ], N_MINLOG));
|
||||
|
||||
if (data->delFreq == 0.0) {
|
||||
noizDens[BJTTOTNOIZ] = noizDens[BJTRCNOIZ] +
|
||||
noizDens[BJTRBNOIZ] +
|
||||
noizDens[BJT_RE_NOISE] +
|
||||
noizDens[BJTICNOIZ] +
|
||||
noizDens[BJTIBNOIZ] +
|
||||
noizDens[BJTFLNOIZ];
|
||||
lnNdens[BJTTOTNOIZ] =
|
||||
log(noizDens[BJTTOTNOIZ]);
|
||||
|
||||
/* if we haven't done any previous integration, we need to */
|
||||
/* initialize our "history" variables */
|
||||
*OnDens += noizDens[BJTTOTNOIZ];
|
||||
|
||||
for (i=0; i < BJTNSRCS; i++) {
|
||||
inst->BJTnVar[LNLSTDENS][i] = lnNdens[i];
|
||||
}
|
||||
if (data->delFreq == 0.0) {
|
||||
|
||||
/* clear out our integration variables if it's the first pass */
|
||||
/* if we haven't done any previous integration, we need to */
|
||||
/* initialize our "history" variables */
|
||||
|
||||
if (data->freq == job->NstartFreq) {
|
||||
for (i=0; i < BJTNSRCS; i++) {
|
||||
inst->BJTnVar[OUTNOIZ][i] = 0.0;
|
||||
inst->BJTnVar[INNOIZ][i] = 0.0;
|
||||
}
|
||||
}
|
||||
} else { /* data->delFreq != 0.0 (we have to integrate) */
|
||||
for (i = 0; i < BJTNSRCS; i++) {
|
||||
inst->BJTnVar[LNLSTDENS][i] = lnNdens[i];
|
||||
}
|
||||
|
||||
/* In order to get the best curve fit, we have to integrate each component separately */
|
||||
/* clear out our integration variables if it's the first pass */
|
||||
|
||||
for (i=0; i < BJTNSRCS; i++) {
|
||||
if (i != BJTTOTNOIZ) {
|
||||
tempOnoise = Nintegrate(noizDens[i], lnNdens[i],
|
||||
inst->BJTnVar[LNLSTDENS][i], data);
|
||||
tempInoise = Nintegrate(noizDens[i] * data->GainSqInv ,
|
||||
lnNdens[i] + data->lnGainInv,
|
||||
inst->BJTnVar[LNLSTDENS][i] + data->lnGainInv,
|
||||
data);
|
||||
inst->BJTnVar[LNLSTDENS][i] = lnNdens[i];
|
||||
data->outNoiz += tempOnoise;
|
||||
data->inNoise += tempInoise;
|
||||
if (job->NStpsSm != 0) {
|
||||
inst->BJTnVar[OUTNOIZ][i] += tempOnoise;
|
||||
inst->BJTnVar[OUTNOIZ][BJTTOTNOIZ] += tempOnoise;
|
||||
inst->BJTnVar[INNOIZ][i] += tempInoise;
|
||||
inst->BJTnVar[INNOIZ][BJTTOTNOIZ] += tempInoise;
|
||||
if (data->freq == job->NstartFreq) {
|
||||
for (i = 0; i < BJTNSRCS; i++) {
|
||||
inst->BJTnVar[OUTNOIZ][i] = 0.0;
|
||||
inst->BJTnVar[INNOIZ][i] = 0.0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* data->delFreq != 0.0 (we have to integrate) */
|
||||
|
||||
/* In order to get the best curve fit, we have to integrate each component separately */
|
||||
|
||||
for (i = 0; i < BJTNSRCS; i++) {
|
||||
if (i != BJTTOTNOIZ) {
|
||||
tempOnoise = Nintegrate(noizDens[i], lnNdens[i],
|
||||
inst->BJTnVar[LNLSTDENS][i], data);
|
||||
tempInoise = Nintegrate(noizDens[i] * data->GainSqInv,
|
||||
lnNdens[i] + data->lnGainInv,
|
||||
inst->BJTnVar[LNLSTDENS][i] + data->lnGainInv,
|
||||
data);
|
||||
inst->BJTnVar[LNLSTDENS][i] = lnNdens[i];
|
||||
data->outNoiz += tempOnoise;
|
||||
data->inNoise += tempInoise;
|
||||
if (job->NStpsSm != 0) {
|
||||
inst->BJTnVar[OUTNOIZ][i] += tempOnoise;
|
||||
inst->BJTnVar[OUTNOIZ][BJTTOTNOIZ] += tempOnoise;
|
||||
inst->BJTnVar[INNOIZ][i] += tempInoise;
|
||||
inst->BJTnVar[INNOIZ][BJTTOTNOIZ] += tempInoise;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (data->prtSummary) {
|
||||
for (i=0; i < BJTNSRCS; i++) { /* print a summary report */
|
||||
data->outpVector[data->outNumber++] = noizDens[i];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (data->prtSummary) {
|
||||
for (i = 0; i < BJTNSRCS; i++) {
|
||||
/* print a summary report */
|
||||
data->outpVector[data->outNumber++] = noizDens[i];
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case INT_NOIZ: /* already calculated, just output */
|
||||
if (job->NStpsSm != 0) {
|
||||
for (i=0; i < BJTNSRCS; i++) {
|
||||
data->outpVector[data->outNumber++] = inst->BJTnVar[OUTNOIZ][i];
|
||||
data->outpVector[data->outNumber++] = inst->BJTnVar[INNOIZ][i];
|
||||
}
|
||||
} /* if */
|
||||
break;
|
||||
} /* switch (mode) */
|
||||
break;
|
||||
case INT_NOIZ:
|
||||
/* already calculated, just output */
|
||||
if (job->NStpsSm != 0) {
|
||||
for (i = 0; i < BJTNSRCS; i++) {
|
||||
data->outpVector[data->outNumber++] = inst->BJTnVar[OUTNOIZ][i];
|
||||
data->outpVector[data->outNumber++] = inst->BJTnVar[INNOIZ][i];
|
||||
}
|
||||
} /* if */
|
||||
break;
|
||||
} /* switch (mode) */
|
||||
break;
|
||||
|
||||
case N_CLOSE:
|
||||
return (OK); /* do nothing, the main calling routine will close */
|
||||
break; /* the plots */
|
||||
} /* switch (operation) */
|
||||
} /* for inst */
|
||||
} /* for model */
|
||||
|
||||
return(OK);
|
||||
}
|
||||
|
||||
case N_CLOSE:
|
||||
return (OK); /* do nothing, the main calling routine will close */
|
||||
break; /* the plots */
|
||||
} /* switch (operation) */
|
||||
} /* for inst */
|
||||
} /* for model */
|
||||
|
||||
return (OK);
|
||||
}
|
||||
|
|
@ -12,23 +12,22 @@ Modified by Dietmar Warning 2003
|
|||
#include "ngspice/suffix.h"
|
||||
|
||||
/*
|
||||
* DIOnoise (mode, operation, firstModel, ckt, data, OnDens)
|
||||
* This routine names and evaluates all of the noise sources
|
||||
* associated with diodes. It starts with the model *firstModel and
|
||||
* traverses all of its instancess. It then proceeds to any other
|
||||
* models on the linked list. The total output noise density
|
||||
* generated by all of the diodes is summed with the variable
|
||||
* "OnDens".
|
||||
*DIOnoise (mode, operation, firstModel, ckt, data, OnDens)
|
||||
* This routine names and evaluates all of the noise sources
|
||||
* associated with diodes. It starts with the model *firstModel and
|
||||
* traverses all of its instancess. It then proceeds to any other
|
||||
* models on the linked list. The total output noise density
|
||||
* generated by all of the diodes is summed with the variable
|
||||
* "OnDens".
|
||||
*/
|
||||
|
||||
|
||||
int
|
||||
DIOnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt,
|
||||
Ndata *data, double *OnDens)
|
||||
DIOnoise(int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt,
|
||||
Ndata *data, double *OnDens)
|
||||
{
|
||||
NOISEAN *job = (NOISEAN *) ckt->CKTcurJob;
|
||||
NOISEAN *job = (NOISEAN*) ckt->CKTcurJob;
|
||||
|
||||
DIOmodel *firstModel = (DIOmodel *) genmodel;
|
||||
DIOmodel *firstModel = (DIOmodel*) genmodel;
|
||||
DIOmodel *model;
|
||||
DIOinstance *inst;
|
||||
double tempOnoise;
|
||||
|
|
@ -36,141 +35,152 @@ DIOnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt,
|
|||
double noizDens[DIONSRCS];
|
||||
double lnNdens[DIONSRCS];
|
||||
int i;
|
||||
double dtemp;
|
||||
|
||||
/* define the names of the noise sources */
|
||||
|
||||
static char *DIOnNames[DIONSRCS] = { /* Note that we have to keep the order */
|
||||
"_rs", /* noise due to rs */ /* consistent with thestrchr definitions */
|
||||
"_id", /* noise due to id */ /* in DIOdefs.h */
|
||||
"_1overf", /* flicker (1/f) noise */
|
||||
"" /* total diode noise */
|
||||
static char *DIOnNames[DIONSRCS] = {
|
||||
/* Note that we have to keep the order
|
||||
consistent with thestrchr definitions in DIOdefs.h */
|
||||
"_rs", /* noise due to rs */
|
||||
"_id", /* noise due to id */
|
||||
"_1overf", /* flicker (1/f) noise */
|
||||
"" /* total diode noise */
|
||||
};
|
||||
|
||||
for (model=firstModel; model != NULL; model=DIOnextModel(model)) {
|
||||
for (inst=DIOinstances(model); inst != NULL; inst=DIOnextInstance(inst)) {
|
||||
for (model = firstModel; model != NULL; model = DIOnextModel(model)) {
|
||||
for (inst = DIOinstances(model); inst != NULL; inst = DIOnextInstance(inst)) {
|
||||
|
||||
switch (operation) {
|
||||
switch (operation) {
|
||||
|
||||
case N_OPEN:
|
||||
case N_OPEN:
|
||||
|
||||
/* see if we have to to produce a summary report */
|
||||
/* if so, name all the noise generators */
|
||||
/* see if we have to to produce a summary report */
|
||||
/* if so, name all the noise generators */
|
||||
|
||||
if (job->NStpsSm != 0) {
|
||||
switch (mode) {
|
||||
if (job->NStpsSm != 0) {
|
||||
switch (mode) {
|
||||
|
||||
case N_DENS:
|
||||
for (i=0; i < DIONSRCS; i++) {
|
||||
NOISE_ADD_OUTVAR(ckt, data, "onoise_%s%s", inst->DIOname, DIOnNames[i]);
|
||||
}
|
||||
break;
|
||||
case N_DENS:
|
||||
for (i = 0; i < DIONSRCS; i++) {
|
||||
NOISE_ADD_OUTVAR(ckt, data, "onoise_%s%s", inst->DIOname, DIOnNames[i]);
|
||||
}
|
||||
break;
|
||||
|
||||
case INT_NOIZ:
|
||||
for (i=0; i < DIONSRCS; i++) {
|
||||
NOISE_ADD_OUTVAR(ckt, data, "onoise_total_%s%s", inst->DIOname, DIOnNames[i]);
|
||||
NOISE_ADD_OUTVAR(ckt, data, "inoise_total_%s%s", inst->DIOname, DIOnNames[i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case INT_NOIZ:
|
||||
for (i = 0; i < DIONSRCS; i++) {
|
||||
NOISE_ADD_OUTVAR(ckt, data, "onoise_total_%s%s", inst->DIOname, DIOnNames[i]);
|
||||
NOISE_ADD_OUTVAR(ckt, data, "inoise_total_%s%s", inst->DIOname, DIOnNames[i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case N_CALC:
|
||||
switch (mode) {
|
||||
case N_CALC:
|
||||
switch (mode) {
|
||||
|
||||
case N_DENS:
|
||||
NevalSrc(&noizDens[DIORSNOIZ],&lnNdens[DIORSNOIZ],
|
||||
ckt,THERMNOISE,inst->DIOposPrimeNode,inst->DIOposNode,
|
||||
inst->DIOtConductance * inst->DIOarea * inst->DIOm);
|
||||
NevalSrc(&noizDens[DIOIDNOIZ],&lnNdens[DIOIDNOIZ],
|
||||
ckt,SHOTNOISE,inst->DIOposPrimeNode, inst->DIOnegNode,
|
||||
*(ckt->CKTstate0 + inst->DIOcurrent));
|
||||
case N_DENS:
|
||||
|
||||
NevalSrc(&noizDens[DIOFLNOIZ], NULL, ckt,
|
||||
N_GAIN,inst->DIOposPrimeNode, inst->DIOnegNode,
|
||||
(double)0.0);
|
||||
noizDens[DIOFLNOIZ] *= model->DIOfNcoef *
|
||||
exp(model->DIOfNexp *
|
||||
log(MAX(fabs(*(ckt->CKTstate0 + inst->DIOcurrent)/inst->DIOm),N_MINLOG))) /
|
||||
data->freq * inst->DIOm;
|
||||
lnNdens[DIOFLNOIZ] =
|
||||
log(MAX(noizDens[DIOFLNOIZ],N_MINLOG));
|
||||
if (inst->DIOtempGiven)
|
||||
dtemp = inst->DIOtemp - ckt->CKTtemp + (model->DIOnomTemp-CONSTCtoK);
|
||||
else
|
||||
dtemp = inst->DIOdtemp;
|
||||
|
||||
noizDens[DIOTOTNOIZ] = noizDens[DIORSNOIZ] +
|
||||
noizDens[DIOIDNOIZ] +
|
||||
noizDens[DIOFLNOIZ];
|
||||
lnNdens[DIOTOTNOIZ] =
|
||||
log(MAX(noizDens[DIOTOTNOIZ], N_MINLOG));
|
||||
NevalSrcInstanceTemp(&noizDens[DIORSNOIZ],&lnNdens[DIORSNOIZ],
|
||||
ckt, THERMNOISE, inst->DIOposPrimeNode, inst->DIOposNode,
|
||||
inst->DIOtConductance * inst->DIOarea * inst->DIOm, dtemp);
|
||||
|
||||
*OnDens += noizDens[DIOTOTNOIZ];
|
||||
NevalSrc(&noizDens[DIOIDNOIZ],&lnNdens[DIOIDNOIZ],
|
||||
ckt, SHOTNOISE, inst->DIOposPrimeNode, inst->DIOnegNode,
|
||||
*(ckt->CKTstate0 + inst->DIOcurrent));
|
||||
|
||||
if (data->delFreq == 0.0) {
|
||||
NevalSrc(&noizDens[DIOFLNOIZ], NULL, ckt,
|
||||
N_GAIN, inst->DIOposPrimeNode, inst->DIOnegNode,
|
||||
(double) 0.0);
|
||||
noizDens[DIOFLNOIZ] *= model->DIOfNcoef *
|
||||
exp(model->DIOfNexp *
|
||||
log(MAX(fabs(*(ckt->CKTstate0 + inst->DIOcurrent) / inst->DIOm), N_MINLOG))) /
|
||||
data->freq * inst->DIOm;
|
||||
lnNdens[DIOFLNOIZ] =
|
||||
log(MAX(noizDens[DIOFLNOIZ], N_MINLOG));
|
||||
|
||||
/* if we haven't done any previous integration, we need to */
|
||||
/* initialize our "history" variables */
|
||||
noizDens[DIOTOTNOIZ] = noizDens[DIORSNOIZ] +
|
||||
noizDens[DIOIDNOIZ] +
|
||||
noizDens[DIOFLNOIZ];
|
||||
lnNdens[DIOTOTNOIZ] =
|
||||
log(MAX(noizDens[DIOTOTNOIZ], N_MINLOG));
|
||||
|
||||
for (i=0; i < DIONSRCS; i++) {
|
||||
inst->DIOnVar[LNLSTDENS][i] = lnNdens[i];
|
||||
}
|
||||
*OnDens += noizDens[DIOTOTNOIZ];
|
||||
|
||||
/* clear out our integration variables if it's the first pass */
|
||||
if (data->delFreq == 0.0) {
|
||||
|
||||
if (data->freq == job->NstartFreq) {
|
||||
for (i=0; i < DIONSRCS; i++) {
|
||||
inst->DIOnVar[OUTNOIZ][i] = 0.0;
|
||||
inst->DIOnVar[INNOIZ][i] = 0.0;
|
||||
}
|
||||
}
|
||||
} else { /* data->delFreq != 0.0 (we have to integrate) */
|
||||
/* if we haven't done any previous integration, we need to */
|
||||
/* initialize our "history" variables */
|
||||
|
||||
/* To insure accurracy, we have to integrate each component separately */
|
||||
for (i = 0; i < DIONSRCS; i++) {
|
||||
inst->DIOnVar[LNLSTDENS][i] = lnNdens[i];
|
||||
}
|
||||
|
||||
for (i=0; i < DIONSRCS; i++) {
|
||||
if (i != DIOTOTNOIZ) {
|
||||
tempOnoise = Nintegrate(noizDens[i], lnNdens[i],
|
||||
inst->DIOnVar[LNLSTDENS][i], data);
|
||||
tempInoise = Nintegrate(noizDens[i] * data->GainSqInv ,
|
||||
lnNdens[i] + data->lnGainInv,
|
||||
inst->DIOnVar[LNLSTDENS][i] + data->lnGainInv,
|
||||
data);
|
||||
inst->DIOnVar[LNLSTDENS][i] = lnNdens[i];
|
||||
data->outNoiz += tempOnoise;
|
||||
data->inNoise += tempInoise;
|
||||
if (job->NStpsSm != 0) {
|
||||
inst->DIOnVar[OUTNOIZ][i] += tempOnoise;
|
||||
inst->DIOnVar[OUTNOIZ][DIOTOTNOIZ] += tempOnoise;
|
||||
inst->DIOnVar[INNOIZ][i] += tempInoise;
|
||||
inst->DIOnVar[INNOIZ][DIOTOTNOIZ] += tempInoise;
|
||||
/* clear out our integration variables if it's the first pass */
|
||||
|
||||
if (data->freq == job->NstartFreq) {
|
||||
for (i = 0; i < DIONSRCS; i++) {
|
||||
inst->DIOnVar[OUTNOIZ][i] = 0.0;
|
||||
inst->DIOnVar[INNOIZ][i] = 0.0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* data->delFreq != 0.0 (we have to integrate) */
|
||||
|
||||
/* To insure accurracy, we have to integrate each component separately */
|
||||
|
||||
for (i = 0; i < DIONSRCS; i++) {
|
||||
if (i != DIOTOTNOIZ) {
|
||||
tempOnoise = Nintegrate(noizDens[i], lnNdens[i],
|
||||
inst->DIOnVar[LNLSTDENS][i], data);
|
||||
tempInoise = Nintegrate(noizDens[i] * data->GainSqInv,
|
||||
lnNdens[i] + data->lnGainInv,
|
||||
inst->DIOnVar[LNLSTDENS][i] + data->lnGainInv,
|
||||
data);
|
||||
inst->DIOnVar[LNLSTDENS][i] = lnNdens[i];
|
||||
data->outNoiz += tempOnoise;
|
||||
data->inNoise += tempInoise;
|
||||
if (job->NStpsSm != 0) {
|
||||
inst->DIOnVar[OUTNOIZ][i] += tempOnoise;
|
||||
inst->DIOnVar[OUTNOIZ][DIOTOTNOIZ] += tempOnoise;
|
||||
inst->DIOnVar[INNOIZ][i] += tempInoise;
|
||||
inst->DIOnVar[INNOIZ][DIOTOTNOIZ] += tempInoise;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (data->prtSummary) {
|
||||
for (i=0; i < DIONSRCS; i++) { /* print a summary report */
|
||||
data->outpVector[data->outNumber++] = noizDens[i];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (data->prtSummary) {
|
||||
for (i = 0; i < DIONSRCS; i++) {
|
||||
/* print a summary report */
|
||||
data->outpVector[data->outNumber++] = noizDens[i];
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case INT_NOIZ: /* already calculated, just output */
|
||||
if (job->NStpsSm != 0) {
|
||||
for (i=0; i < DIONSRCS; i++) {
|
||||
data->outpVector[data->outNumber++] = inst->DIOnVar[OUTNOIZ][i];
|
||||
data->outpVector[data->outNumber++] = inst->DIOnVar[INNOIZ][i];
|
||||
}
|
||||
} /* if */
|
||||
break;
|
||||
} /* switch (mode) */
|
||||
break;
|
||||
case INT_NOIZ:
|
||||
/* already calculated, just output */
|
||||
if (job->NStpsSm != 0) {
|
||||
for (i = 0; i < DIONSRCS; i++) {
|
||||
data->outpVector[data->outNumber++] = inst->DIOnVar[OUTNOIZ][i];
|
||||
data->outpVector[data->outNumber++] = inst->DIOnVar[INNOIZ][i];
|
||||
}
|
||||
} /* if */
|
||||
break;
|
||||
} /* switch (mode) */
|
||||
break;
|
||||
|
||||
case N_CLOSE:
|
||||
return (OK); /* do nothing, the main calling routine will close */
|
||||
break; /* the plots */
|
||||
} /* switch (operation) */
|
||||
} /* for inst */
|
||||
} /* for model */
|
||||
|
||||
return(OK);
|
||||
}
|
||||
|
||||
case N_CLOSE:
|
||||
return (OK); /* do nothing, the main calling routine will close */
|
||||
break; /* the plots */
|
||||
} /* switch (operation) */
|
||||
} /* for inst */
|
||||
} /* for model */
|
||||
|
||||
return (OK);
|
||||
}
|
||||
|
|
@ -35,6 +35,7 @@ HICUMnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata
|
|||
double noizDens[HICUMNSRCS];
|
||||
double lnNdens[HICUMNSRCS];
|
||||
int i;
|
||||
double dtemp;
|
||||
|
||||
double Ibbp_Vbbp;
|
||||
double Icic_Vcic;
|
||||
|
|
@ -125,25 +126,31 @@ HICUMnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata
|
|||
switch (mode) {
|
||||
|
||||
case N_DENS:
|
||||
NevalSrc(&noizDens[HICUMRCNOIZ],&lnNdens[HICUMRCNOIZ],
|
||||
|
||||
if (here->HICUMtempGiven)
|
||||
dtemp = here->HICUMtemp - ckt->CKTtemp + (model->HICUMtnom-CONSTCtoK);
|
||||
else
|
||||
dtemp = here->HICUMdtemp;
|
||||
|
||||
NevalSrcInstanceTemp(&noizDens[HICUMRCNOIZ],&lnNdens[HICUMRCNOIZ],
|
||||
ckt,THERMNOISE,here->HICUMcollCINode,here->HICUMcollNode,
|
||||
Icic_Vcic);
|
||||
Icic_Vcic, dtemp);
|
||||
|
||||
NevalSrc(&noizDens[HICUMRBNOIZ],&lnNdens[HICUMRBNOIZ],
|
||||
NevalSrcInstanceTemp(&noizDens[HICUMRBNOIZ],&lnNdens[HICUMRBNOIZ],
|
||||
ckt,THERMNOISE,here->HICUMbaseNode,here->HICUMbaseBPNode,
|
||||
Ibbp_Vbbp);
|
||||
Ibbp_Vbbp, dtemp);
|
||||
|
||||
NevalSrc(&noizDens[HICUMRBINOIZ],&lnNdens[HICUMRBINOIZ],
|
||||
NevalSrcInstanceTemp(&noizDens[HICUMRBINOIZ],&lnNdens[HICUMRBINOIZ],
|
||||
ckt,THERMNOISE,here->HICUMbaseBPNode,here->HICUMbaseBINode,
|
||||
Ibpbi_Vbpbi);
|
||||
Ibpbi_Vbpbi, dtemp);
|
||||
|
||||
NevalSrc(&noizDens[HICUMRENOIZ],&lnNdens[HICUMRENOIZ],
|
||||
NevalSrcInstanceTemp(&noizDens[HICUMRENOIZ],&lnNdens[HICUMRENOIZ],
|
||||
ckt,THERMNOISE,here->HICUMemitEINode,here->HICUMemitNode,
|
||||
Ieie_Veie);
|
||||
Ieie_Veie, dtemp);
|
||||
|
||||
NevalSrc(&noizDens[HICUMRSNOIZ],&lnNdens[HICUMRSNOIZ],
|
||||
NevalSrcInstanceTemp(&noizDens[HICUMRSNOIZ],&lnNdens[HICUMRSNOIZ],
|
||||
ckt,THERMNOISE,here->HICUMsubsSINode,here->HICUMsubsNode,
|
||||
Isis_Vsis);
|
||||
Isis_Vsis, dtemp);
|
||||
|
||||
|
||||
NevalSrc(&noizDens[HICUMIAVLNOIZ],&lnNdens[HICUMIAVLNOIZ],
|
||||
|
|
|
|||
|
|
@ -11,22 +11,21 @@ Author: 1987 Gary W. Ng
|
|||
#include "ngspice/suffix.h"
|
||||
|
||||
/*
|
||||
* JFETnoise (mode, operation, firstModel, ckt, data, OnDens)
|
||||
* This routine names and evaluates all of the noise sources
|
||||
* associated with JFET's. It starts with the model *firstModel and
|
||||
* traverses all of its insts. It then proceeds to any other models
|
||||
* on the linked list. The total output noise density generated by
|
||||
* all of the JFET's is summed with the variable "OnDens".
|
||||
*JFETnoise (mode, operation, firstModel, ckt, data, OnDens)
|
||||
* This routine names and evaluates all of the noise sources
|
||||
* associated with JFET's. It starts with the model *firstModel and
|
||||
* traverses all of its insts. It then proceeds to any other models
|
||||
* on the linked list. The total output noise density generated by
|
||||
* all of the JFET's is summed with the variable "OnDens".
|
||||
*/
|
||||
|
||||
|
||||
int
|
||||
JFETnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *data,
|
||||
double *OnDens)
|
||||
JFETnoise(int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *data,
|
||||
double *OnDens)
|
||||
{
|
||||
NOISEAN *job = (NOISEAN *) ckt->CKTcurJob;
|
||||
NOISEAN *job = (NOISEAN*) ckt->CKTcurJob;
|
||||
|
||||
JFETmodel *firstModel = (JFETmodel *) genmodel;
|
||||
JFETmodel *firstModel = (JFETmodel*) genmodel;
|
||||
JFETmodel *model;
|
||||
JFETinstance *inst;
|
||||
double tempOnoise;
|
||||
|
|
@ -35,19 +34,22 @@ JFETnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *
|
|||
double lnNdens[JFETNSRCS];
|
||||
int i;
|
||||
double vgs, vds, vgst, alpha, beta;
|
||||
double dtemp;
|
||||
|
||||
/* define the names of the noise sources */
|
||||
|
||||
static char *JFETnNames[JFETNSRCS] = { /* Note that we have to keep the order */
|
||||
"_rd", /* noise due to rd */ /* consistent with thestrchr definitions */
|
||||
"_rs", /* noise due to rs */ /* in JFETdefs.h */
|
||||
"_id", /* noise due to id */
|
||||
"_1overf", /* flicker (1/f) noise */
|
||||
"" /* total transistor noise */
|
||||
static char *JFETnNames[JFETNSRCS] = {
|
||||
/* Note that we have to keep the order
|
||||
consistent with the strchr definitions in JFETdefs.h */
|
||||
"_rd", /* noise due to rd */
|
||||
"_rs", /* noise due to rs */
|
||||
"_id", /* noise due to id */
|
||||
"_1overf", /* flicker (1/f) noise */
|
||||
"" /* total transistor noise */
|
||||
};
|
||||
|
||||
for (model=firstModel; model != NULL; model=JFETnextModel(model)) {
|
||||
for (inst=JFETinstances(model); inst != NULL; inst=JFETnextInstance(inst)) {
|
||||
for (model = firstModel; model != NULL; model = JFETnextModel(model)) {
|
||||
for (inst = JFETinstances(model); inst != NULL; inst = JFETnextInstance(inst)) {
|
||||
|
||||
switch (operation) {
|
||||
|
||||
|
|
@ -60,13 +62,13 @@ JFETnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *
|
|||
switch (mode) {
|
||||
|
||||
case N_DENS:
|
||||
for (i=0; i < JFETNSRCS; i++) {
|
||||
for (i = 0; i < JFETNSRCS; i++) {
|
||||
NOISE_ADD_OUTVAR(ckt, data, "onoise_%s%s", inst->JFETname, JFETnNames[i]);
|
||||
}
|
||||
break;
|
||||
|
||||
case INT_NOIZ:
|
||||
for (i=0; i < JFETNSRCS; i++) {
|
||||
for (i = 0; i < JFETNSRCS; i++) {
|
||||
NOISE_ADD_OUTVAR(ckt, data, "onoise_total_%s%s", inst->JFETname, JFETnNames[i]);
|
||||
NOISE_ADD_OUTVAR(ckt, data, "inoise_total_%s%s", inst->JFETname, JFETnNames[i]);
|
||||
}
|
||||
|
|
@ -79,81 +81,88 @@ JFETnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *
|
|||
switch (mode) {
|
||||
|
||||
case N_DENS:
|
||||
NevalSrc(&noizDens[JFETRDNOIZ],&lnNdens[JFETRDNOIZ],
|
||||
ckt,THERMNOISE,inst->JFETdrainPrimeNode,inst->JFETdrainNode,
|
||||
model->JFETdrainConduct * inst->JFETarea * inst->JFETm);
|
||||
|
||||
NevalSrc(&noizDens[JFETRSNOIZ],&lnNdens[JFETRSNOIZ],
|
||||
ckt,THERMNOISE,inst->JFETsourcePrimeNode,
|
||||
inst->JFETsourceNode,model->JFETsourceConduct
|
||||
* inst->JFETarea * inst->JFETm);
|
||||
if (inst->JFETtempGiven)
|
||||
dtemp = inst->JFETtemp - ckt->CKTtemp + (model->JFETtnom-CONSTCtoK);
|
||||
else
|
||||
dtemp = inst->JFETdtemp;
|
||||
|
||||
NevalSrcInstanceTemp(&noizDens[JFETRDNOIZ],&lnNdens[JFETRDNOIZ],
|
||||
ckt, THERMNOISE, inst->JFETdrainPrimeNode, inst->JFETdrainNode,
|
||||
model->JFETdrainConduct * inst->JFETarea * inst->JFETm, dtemp);
|
||||
|
||||
NevalSrcInstanceTemp(&noizDens[JFETRSNOIZ],&lnNdens[JFETRSNOIZ],
|
||||
ckt, THERMNOISE, inst->JFETsourcePrimeNode,
|
||||
inst->JFETsourceNode, model->JFETsourceConduct *
|
||||
inst->JFETarea * inst->JFETm, inst->JFETdtemp);
|
||||
|
||||
if (model->JFETnlev < 3) {
|
||||
NevalSrc(&noizDens[JFETIDNOIZ],&lnNdens[JFETIDNOIZ],
|
||||
ckt,THERMNOISE,inst->JFETdrainPrimeNode,
|
||||
inst->JFETsourcePrimeNode,
|
||||
(2.0/3.0 * inst->JFETm * fabs(*(ckt->CKTstate0 + inst->JFETgm))));
|
||||
NevalSrcInstanceTemp(&noizDens[JFETIDNOIZ],&lnNdens[JFETIDNOIZ],
|
||||
ckt, THERMNOISE, inst->JFETdrainPrimeNode,
|
||||
inst->JFETsourcePrimeNode,
|
||||
(2.0 / 3.0 * inst->JFETm * fabs(*(ckt->CKTstate0 + inst->JFETgm))), inst->JFETdtemp);
|
||||
} else {
|
||||
vgs = *(ckt->CKTstate0 + inst->JFETvgs);
|
||||
vds = vgs - *(ckt->CKTstate0 + inst->JFETvgd);
|
||||
vgst = vgs - inst->JFETtThreshold;
|
||||
if (vgst >= vds)
|
||||
alpha = 1 - vds/vgst; /* linear region */
|
||||
alpha = 1 - vds / vgst; /* linear region */
|
||||
else
|
||||
alpha = 0; /* saturation region */
|
||||
alpha = 0; /* saturation region */
|
||||
beta = inst->JFETtBeta * inst->JFETarea * inst->JFETm;
|
||||
|
||||
NevalSrc(&noizDens[JFETIDNOIZ],&lnNdens[JFETIDNOIZ],
|
||||
ckt,THERMNOISE,inst->JFETdrainPrimeNode,
|
||||
inst->JFETsourcePrimeNode,
|
||||
(2.0/3.0 * beta*vgst*(1+alpha+alpha*alpha)/(1+alpha)*model->JFETgdsnoi));
|
||||
NevalSrcInstanceTemp(&noizDens[JFETIDNOIZ],&lnNdens[JFETIDNOIZ],
|
||||
ckt, THERMNOISE, inst->JFETdrainPrimeNode,
|
||||
inst->JFETsourcePrimeNode,
|
||||
(2.0 / 3.0*beta*vgst*(1 + alpha + alpha*alpha) / (1 + alpha) * model->JFETgdsnoi), inst->JFETdtemp);
|
||||
}
|
||||
|
||||
NevalSrc(&noizDens[JFETFLNOIZ], NULL, ckt,
|
||||
N_GAIN,inst->JFETdrainPrimeNode,
|
||||
inst->JFETsourcePrimeNode, (double)0.0);
|
||||
N_GAIN, inst->JFETdrainPrimeNode,
|
||||
inst->JFETsourcePrimeNode, (double) 0.0);
|
||||
noizDens[JFETFLNOIZ] *= inst->JFETm * model->JFETfNcoef *
|
||||
exp(model->JFETfNexp *
|
||||
log(MAX(fabs(*(ckt->CKTstate0 + inst->JFETcd)),N_MINLOG))) /
|
||||
data->freq;
|
||||
exp(model->JFETfNexp *
|
||||
log(MAX(fabs(*(ckt->CKTstate0 + inst->JFETcd)), N_MINLOG))) /
|
||||
data->freq;
|
||||
lnNdens[JFETFLNOIZ] =
|
||||
log(MAX(noizDens[JFETFLNOIZ],N_MINLOG));
|
||||
log(MAX(noizDens[JFETFLNOIZ], N_MINLOG));
|
||||
|
||||
noizDens[JFETTOTNOIZ] = noizDens[JFETRDNOIZ] +
|
||||
noizDens[JFETRSNOIZ] +
|
||||
noizDens[JFETIDNOIZ] +
|
||||
noizDens[JFETFLNOIZ];
|
||||
noizDens[JFETRSNOIZ] +
|
||||
noizDens[JFETIDNOIZ] +
|
||||
noizDens[JFETFLNOIZ];
|
||||
lnNdens[JFETTOTNOIZ] =
|
||||
log(MAX(noizDens[JFETTOTNOIZ], N_MINLOG));
|
||||
log(MAX(noizDens[JFETTOTNOIZ], N_MINLOG));
|
||||
|
||||
*OnDens += noizDens[JFETTOTNOIZ];
|
||||
*OnDens += noizDens[JFETTOTNOIZ];
|
||||
|
||||
if (data->delFreq == 0.0) {
|
||||
|
||||
/* if we haven't done any previous integration, we need to */
|
||||
/* initialize our "history" variables */
|
||||
|
||||
for (i=0; i < JFETNSRCS; i++) {
|
||||
for (i = 0; i < JFETNSRCS; i++) {
|
||||
inst->JFETnVar[LNLSTDENS][i] = lnNdens[i];
|
||||
}
|
||||
|
||||
/* clear out our integration variables if it's the first pass */
|
||||
|
||||
if (data->freq == job->NstartFreq) {
|
||||
for (i=0; i < JFETNSRCS; i++) {
|
||||
for (i = 0; i < JFETNSRCS; i++) {
|
||||
inst->JFETnVar[OUTNOIZ][i] = 0.0;
|
||||
inst->JFETnVar[INNOIZ][i] = 0.0;
|
||||
}
|
||||
}
|
||||
} else { /* data->delFreq != 0.0 (we have to integrate) */
|
||||
for (i=0; i < JFETNSRCS; i++) {
|
||||
} else {
|
||||
/* data->delFreq != 0.0 (we have to integrate) */
|
||||
for (i = 0; i < JFETNSRCS; i++) {
|
||||
if (i != JFETTOTNOIZ) {
|
||||
tempOnoise = Nintegrate(noizDens[i], lnNdens[i],
|
||||
inst->JFETnVar[LNLSTDENS][i], data);
|
||||
tempInoise = Nintegrate(noizDens[i] * data->GainSqInv ,
|
||||
lnNdens[i] + data->lnGainInv,
|
||||
inst->JFETnVar[LNLSTDENS][i] + data->lnGainInv,
|
||||
data);
|
||||
inst->JFETnVar[LNLSTDENS][i], data);
|
||||
tempInoise = Nintegrate(noizDens[i] * data->GainSqInv,
|
||||
lnNdens[i] + data->lnGainInv,
|
||||
inst->JFETnVar[LNLSTDENS][i] + data->lnGainInv,
|
||||
data);
|
||||
inst->JFETnVar[LNLSTDENS][i] = lnNdens[i];
|
||||
data->outNoiz += tempOnoise;
|
||||
data->inNoise += tempInoise;
|
||||
|
|
@ -167,29 +176,31 @@ JFETnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *
|
|||
}
|
||||
}
|
||||
if (data->prtSummary) {
|
||||
for (i=0; i < JFETNSRCS; i++) { /* print a summary report */
|
||||
for (i = 0; i < JFETNSRCS; i++) {
|
||||
/* print a summary report */
|
||||
data->outpVector[data->outNumber++] = noizDens[i];
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case INT_NOIZ: /* already calculated, just output */
|
||||
case INT_NOIZ:
|
||||
/* already calculated, just output */
|
||||
if (job->NStpsSm != 0) {
|
||||
for (i=0; i < JFETNSRCS; i++) {
|
||||
for (i = 0; i < JFETNSRCS; i++) {
|
||||
data->outpVector[data->outNumber++] = inst->JFETnVar[OUTNOIZ][i];
|
||||
data->outpVector[data->outNumber++] = inst->JFETnVar[INNOIZ][i];
|
||||
}
|
||||
} /* if */
|
||||
} /* if */
|
||||
break;
|
||||
} /* switch (mode) */
|
||||
} /* switch (mode) */
|
||||
break;
|
||||
|
||||
case N_CLOSE:
|
||||
return (OK); /* do nothing, the main calling routine will close */
|
||||
break; /* the plots */
|
||||
} /* switch (operation) */
|
||||
} /* for inst */
|
||||
} /* for model */
|
||||
return (OK); /* do nothing, the main calling routine will close */
|
||||
break; /* the plots */
|
||||
} /* switch (operation) */
|
||||
} /* for inst */
|
||||
} /* for model */
|
||||
|
||||
return(OK);
|
||||
}
|
||||
return (OK);
|
||||
}
|
||||
|
|
@ -36,6 +36,7 @@ MOS1noise(int mode, int operation, GENmodel * genmodel, CKTcircuit * ckt,
|
|||
double lnNdens[MOS1NSRCS];
|
||||
int i;
|
||||
double vgs, vds, vgd, vgst, alpha, beta, Sid;
|
||||
double dtemp;
|
||||
|
||||
/* define the names of the noise sources */
|
||||
|
||||
|
|
@ -95,13 +96,19 @@ MOS1noise(int mode, int operation, GENmodel * genmodel, CKTcircuit * ckt,
|
|||
switch (mode) {
|
||||
|
||||
case N_DENS:
|
||||
NevalSrc( & noizDens[MOS1RDNOIZ], & lnNdens[MOS1RDNOIZ],
|
||||
ckt, THERMNOISE, inst->MOS1dNodePrime, inst->MOS1dNode,
|
||||
inst->MOS1drainConductance);
|
||||
|
||||
NevalSrc( & noizDens[MOS1RSNOIZ], & lnNdens[MOS1RSNOIZ],
|
||||
if (inst->MOS1tempGiven)
|
||||
dtemp = inst->MOS1temp - ckt->CKTtemp + (model->MOS1tnom-CONSTCtoK);
|
||||
else
|
||||
dtemp = inst->MOS1dtemp;
|
||||
|
||||
NevalSrcInstanceTemp( & noizDens[MOS1RDNOIZ], & lnNdens[MOS1RDNOIZ],
|
||||
ckt, THERMNOISE, inst->MOS1dNodePrime, inst->MOS1dNode,
|
||||
inst->MOS1drainConductance, dtemp);
|
||||
|
||||
NevalSrcInstanceTemp( & noizDens[MOS1RSNOIZ], & lnNdens[MOS1RSNOIZ],
|
||||
ckt, THERMNOISE, inst->MOS1sNodePrime, inst->MOS1sNode,
|
||||
inst->MOS1sourceConductance);
|
||||
inst->MOS1sourceConductance, dtemp);
|
||||
|
||||
if (model->MOS1nlev < 3) {
|
||||
|
||||
|
|
@ -127,9 +134,9 @@ MOS1noise(int mode, int operation, GENmodel * genmodel, CKTcircuit * ckt,
|
|||
Sid = 2.0 / 3.0 * beta * vgst * (1.0+alpha+alpha*alpha) / (1.0+alpha) * model->MOS1gdsnoi;
|
||||
}
|
||||
|
||||
NevalSrc( & noizDens[MOS1IDNOIZ], & lnNdens[MOS1IDNOIZ],
|
||||
NevalSrcInstanceTemp( & noizDens[MOS1IDNOIZ], & lnNdens[MOS1IDNOIZ],
|
||||
ckt, THERMNOISE, inst->MOS1dNodePrime, inst->MOS1sNodePrime,
|
||||
Sid);
|
||||
Sid, dtemp);
|
||||
|
||||
NevalSrc( & noizDens[MOS1FLNOIZ], NULL, ckt,
|
||||
N_GAIN, inst->MOS1dNodePrime, inst->MOS1sNodePrime,
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ MOS2noise(int mode, int operation, GENmodel * genmodel, CKTcircuit * ckt,
|
|||
double lnNdens[MOS2NSRCS];
|
||||
int i;
|
||||
double vgs, vds, vgd, vgst, alpha, beta, Sid;
|
||||
double dtemp;
|
||||
|
||||
/* define the names of the noise sources */
|
||||
|
||||
|
|
@ -84,13 +85,19 @@ MOS2noise(int mode, int operation, GENmodel * genmodel, CKTcircuit * ckt,
|
|||
switch (mode) {
|
||||
|
||||
case N_DENS:
|
||||
NevalSrc( & noizDens[MOS2RDNOIZ], & lnNdens[MOS2RDNOIZ],
|
||||
ckt, THERMNOISE, inst->MOS2dNodePrime, inst->MOS2dNode,
|
||||
inst->MOS2drainConductance);
|
||||
|
||||
NevalSrc( & noizDens[MOS2RSNOIZ], & lnNdens[MOS2RSNOIZ],
|
||||
if (inst->MOS2tempGiven)
|
||||
dtemp = inst->MOS2temp - ckt->CKTtemp + (model->MOS2tnom-CONSTCtoK);
|
||||
else
|
||||
dtemp = inst->MOS2dtemp;
|
||||
|
||||
NevalSrcInstanceTemp( & noizDens[MOS2RDNOIZ], & lnNdens[MOS2RDNOIZ],
|
||||
ckt, THERMNOISE, inst->MOS2dNodePrime, inst->MOS2dNode,
|
||||
inst->MOS2drainConductance, dtemp);
|
||||
|
||||
NevalSrcInstanceTemp( & noizDens[MOS2RSNOIZ], & lnNdens[MOS2RSNOIZ],
|
||||
ckt, THERMNOISE, inst->MOS2sNodePrime, inst->MOS2sNode,
|
||||
inst->MOS2sourceConductance);
|
||||
inst->MOS2sourceConductance, dtemp);
|
||||
|
||||
if (model->MOS2nlev < 3) {
|
||||
|
||||
|
|
@ -116,9 +123,9 @@ MOS2noise(int mode, int operation, GENmodel * genmodel, CKTcircuit * ckt,
|
|||
Sid = 2.0 / 3.0 * beta * vgst * (1.0+alpha+alpha*alpha) / (1.0+alpha) * model->MOS2gdsnoi;
|
||||
}
|
||||
|
||||
NevalSrc( & noizDens[MOS2IDNOIZ], & lnNdens[MOS2IDNOIZ],
|
||||
NevalSrcInstanceTemp( & noizDens[MOS2IDNOIZ], & lnNdens[MOS2IDNOIZ],
|
||||
ckt, THERMNOISE, inst->MOS2dNodePrime, inst->MOS2sNodePrime,
|
||||
Sid);
|
||||
Sid, dtemp);
|
||||
|
||||
NevalSrc( & noizDens[MOS2FLNOIZ], NULL, ckt,
|
||||
N_GAIN, inst->MOS2dNodePrime, inst->MOS2sNodePrime,
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ MOS3noise(int mode, int operation, GENmodel * genmodel, CKTcircuit * ckt,
|
|||
double lnNdens[MOS3NSRCS];
|
||||
int i;
|
||||
double vgs, vds, vgd, vgst, alpha, beta, Sid;
|
||||
double dtemp;
|
||||
|
||||
/* define the names of the noise sources */
|
||||
|
||||
|
|
@ -84,13 +85,19 @@ MOS3noise(int mode, int operation, GENmodel * genmodel, CKTcircuit * ckt,
|
|||
switch (mode) {
|
||||
|
||||
case N_DENS:
|
||||
NevalSrc( & noizDens[MOS3RDNOIZ], & lnNdens[MOS3RDNOIZ],
|
||||
ckt, THERMNOISE, inst->MOS3dNodePrime, inst->MOS3dNode,
|
||||
inst->MOS3drainConductance);
|
||||
|
||||
NevalSrc( & noizDens[MOS3RSNOIZ], & lnNdens[MOS3RSNOIZ],
|
||||
if (inst->MOS3tempGiven)
|
||||
dtemp = inst->MOS3temp - ckt->CKTtemp + (model->MOS3tnom-CONSTCtoK);
|
||||
else
|
||||
dtemp = inst->MOS3dtemp;
|
||||
|
||||
NevalSrcInstanceTemp( & noizDens[MOS3RDNOIZ], & lnNdens[MOS3RDNOIZ],
|
||||
ckt, THERMNOISE, inst->MOS3dNodePrime, inst->MOS3dNode,
|
||||
inst->MOS3drainConductance, dtemp);
|
||||
|
||||
NevalSrcInstanceTemp( & noizDens[MOS3RSNOIZ], & lnNdens[MOS3RSNOIZ],
|
||||
ckt, THERMNOISE, inst->MOS3sNodePrime, inst->MOS3sNode,
|
||||
inst->MOS3sourceConductance);
|
||||
inst->MOS3sourceConductance, dtemp);
|
||||
|
||||
if (model->MOS3nlev < 3) {
|
||||
|
||||
|
|
@ -116,9 +123,9 @@ MOS3noise(int mode, int operation, GENmodel * genmodel, CKTcircuit * ckt,
|
|||
Sid = 2.0 / 3.0 * beta * vgst * (1.0+alpha+alpha*alpha) / (1.0+alpha) * model->MOS3gdsnoi;
|
||||
}
|
||||
|
||||
NevalSrc( & noizDens[MOS3IDNOIZ], & lnNdens[MOS3IDNOIZ],
|
||||
NevalSrcInstanceTemp( & noizDens[MOS3IDNOIZ], & lnNdens[MOS3IDNOIZ],
|
||||
ckt, THERMNOISE, inst->MOS3dNodePrime, inst->MOS3sNodePrime,
|
||||
Sid);
|
||||
Sid, dtemp);
|
||||
|
||||
NevalSrc( & noizDens[MOS3FLNOIZ], NULL, ckt,
|
||||
N_GAIN, inst->MOS3dNodePrime, inst->MOS3sNodePrime,
|
||||
|
|
|
|||
|
|
@ -11,28 +11,27 @@ Modified: Apr 2000 - Paolo Nenzi
|
|||
#include "ngspice/noisedef.h"
|
||||
|
||||
/*
|
||||
* RESnoise (mode, operation, firstModel, ckt, data, OnDens)
|
||||
* This routine names and evaluates all of the noise sources
|
||||
* associated with resistors. It starts with the model *firstModel
|
||||
* and traverses all of its instances. It then proceeds to any other
|
||||
* models on the linked list. The total output noise density
|
||||
* generated by all the resistors is summed in the variable "OnDens".
|
||||
*RESnoise (mode, operation, firstModel, ckt, data, OnDens)
|
||||
* This routine names and evaluates all of the noise sources
|
||||
* associated with resistors. It starts with the model *firstModel
|
||||
* and traverses all of its instances. It then proceeds to any other
|
||||
* models on the linked list. The total output noise density
|
||||
* generated by all the resistors is summed in the variable "OnDens".
|
||||
*
|
||||
* Paolo Nenzi 2003:
|
||||
* Added flicker noise (Kf-Af) calculation to simulate
|
||||
* carbon resistors.
|
||||
*Paolo Nenzi 2003:
|
||||
* Added flicker noise (Kf-Af) calculation to simulate
|
||||
* carbon resistors.
|
||||
*
|
||||
* Added "noisy" switch to simulate noiseless resistors.
|
||||
* Added "noisy" switch to simulate noiseless resistors.
|
||||
*/
|
||||
|
||||
|
||||
int
|
||||
RESnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt,
|
||||
Ndata *data, double *OnDens)
|
||||
RESnoise(int mode, int operation, GENmodel*genmodel, CKTcircuit *ckt,
|
||||
Ndata *data, double *OnDens)
|
||||
{
|
||||
NOISEAN *job = (NOISEAN *) ckt->CKTcurJob;
|
||||
NOISEAN *job = (NOISEAN*) ckt->CKTcurJob;
|
||||
|
||||
RESmodel *firstModel = (RESmodel *) genmodel;
|
||||
RESmodel *firstModel = (RESmodel*) genmodel;
|
||||
RESmodel *model;
|
||||
RESinstance *inst;
|
||||
double tempOutNoise;
|
||||
|
|
@ -40,24 +39,23 @@ RESnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt,
|
|||
double noizDens[RESNSRCS];
|
||||
double lnNdens[RESNSRCS];
|
||||
int i;
|
||||
double dtemp;
|
||||
|
||||
/* define the names of the noise sources */
|
||||
/* define the names of the noise sources */
|
||||
|
||||
static char *RESnNames[RESNSRCS] = {
|
||||
/* Note that we have to keep the order consistent with the
|
||||
* strchr definitions in RESdefs.h */
|
||||
"_thermal", /* Thermal noise */
|
||||
"_1overf", /* flicker (1/f) noise */
|
||||
"" /* total resistor noise */
|
||||
strchr definitions in RESdefs.h */
|
||||
"_thermal", /* Thermal noise */
|
||||
"_1overf", /* flicker (1/f) noise */
|
||||
"" /* total resistor noise */
|
||||
};
|
||||
|
||||
|
||||
for (model = firstModel; model != NULL; model = RESnextModel(model)) {
|
||||
for (inst = RESinstances(model); inst != NULL;
|
||||
inst = RESnextInstance(inst)) {
|
||||
for (inst = RESinstances(model); inst != NULL; inst = RESnextInstance(inst)) {
|
||||
|
||||
if (!inst->RESnoisy) continue; /* Quiet resistors are skipped */
|
||||
|
||||
if(!inst->RESnoisy) continue; /* Quiet resistors are skipped */
|
||||
|
||||
switch (operation) {
|
||||
|
||||
case N_OPEN:
|
||||
|
|
@ -71,13 +69,13 @@ RESnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt,
|
|||
switch (mode) {
|
||||
|
||||
case N_DENS:
|
||||
for (i=0; i < RESNSRCS; i++) {
|
||||
for (i = 0; i < RESNSRCS; i++) {
|
||||
NOISE_ADD_OUTVAR(ckt, data, "onoise_%s%s", inst->RESname, RESnNames[i]);
|
||||
}
|
||||
break;
|
||||
|
||||
case INT_NOIZ:
|
||||
for (i=0; i < RESNSRCS; i++) {
|
||||
for (i = 0; i < RESNSRCS; i++) {
|
||||
NOISE_ADD_OUTVAR(ckt, data, "onoise_total_%s%s", inst->RESname, RESnNames[i]);
|
||||
NOISE_ADD_OUTVAR(ckt, data, "inoise_total_%s%s", inst->RESname, RESnNames[i]);
|
||||
}
|
||||
|
|
@ -90,99 +88,105 @@ RESnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt,
|
|||
switch (mode) {
|
||||
|
||||
case N_DENS:
|
||||
|
||||
NevalSrcInstanceTemp(&noizDens[RESTHNOIZ],&lnNdens[RESTHNOIZ],
|
||||
ckt,THERMNOISE, inst->RESposNode,inst->RESnegNode,
|
||||
inst->RESconduct, inst->RESdtemp);
|
||||
|
||||
NevalSrcInstanceTemp(&noizDens[RESFLNOIZ], NULL, ckt,
|
||||
N_GAIN,inst->RESposNode, inst->RESnegNode,
|
||||
(double)0.0, (double)0.0);
|
||||
|
||||
if (inst->REStempGiven)
|
||||
dtemp = inst->REStemp - ckt->CKTtemp + (model->REStnom-CONSTCtoK);
|
||||
else
|
||||
dtemp = inst->RESdtemp;
|
||||
|
||||
NevalSrcInstanceTemp(&noizDens[RESTHNOIZ],&lnNdens[RESTHNOIZ],
|
||||
ckt, THERMNOISE, inst->RESposNode, inst->RESnegNode,
|
||||
inst->RESconduct, dtemp);
|
||||
|
||||
NevalSrc(&noizDens[RESFLNOIZ], NULL, ckt,
|
||||
N_GAIN, inst->RESposNode, inst->RESnegNode,
|
||||
(double) 0.0);
|
||||
|
||||
#if 0
|
||||
printf("DC current in resistor %s: %e\n",inst->RESname, inst->REScurrent);
|
||||
printf("DC current in resistor %s: %e\n", inst->RESname, inst->REScurrent);
|
||||
#endif
|
||||
|
||||
noizDens[RESFLNOIZ] *= inst->RESm * model->RESfNcoef *
|
||||
pow(fabs(inst->REScurrent / inst->RESm), model->RESfNexp)
|
||||
/ (inst->RESeffNoiseArea * pow(data->freq, model->RESef));
|
||||
lnNdens[RESFLNOIZ] = log(MAX(noizDens[RESFLNOIZ],N_MINLOG));
|
||||
|
||||
noizDens[RESTOTNOIZ] = noizDens[RESTHNOIZ] + noizDens[RESFLNOIZ];
|
||||
lnNdens[RESTOTNOIZ] = log(noizDens[RESTOTNOIZ]);
|
||||
noizDens[RESFLNOIZ] *= inst->RESm * model->RESfNcoef *
|
||||
pow(fabs(inst->REScurrent / inst->RESm), model->RESfNexp) /
|
||||
(inst->RESeffNoiseArea * pow(data->freq, model->RESef));
|
||||
lnNdens[RESFLNOIZ] = log(MAX(noizDens[RESFLNOIZ], N_MINLOG));
|
||||
|
||||
*OnDens += noizDens[RESTOTNOIZ];
|
||||
noizDens[RESTOTNOIZ] = noizDens[RESTHNOIZ] + noizDens[RESFLNOIZ];
|
||||
lnNdens[RESTOTNOIZ] = log(noizDens[RESTOTNOIZ]);
|
||||
|
||||
if (data->delFreq == 0.0) {
|
||||
*OnDens += noizDens[RESTOTNOIZ];
|
||||
|
||||
if (data->delFreq == 0.0) {
|
||||
|
||||
/* if we haven't done any previous integration, we need to */
|
||||
/* initialize our "history" variables */
|
||||
|
||||
for (i=0; i < RESNSRCS; i++) {
|
||||
inst->RESnVar[LNLSTDENS][i] = lnNdens[i];
|
||||
for (i = 0; i < RESNSRCS; i++) {
|
||||
inst->RESnVar[LNLSTDENS][i] = lnNdens[i];
|
||||
}
|
||||
|
||||
|
||||
/* clear out our integration variable if it's the first pass */
|
||||
|
||||
if (data->freq == job->NstartFreq) {
|
||||
for (i=0; i < RESNSRCS; i++) {
|
||||
inst->RESnVar[OUTNOIZ][i] = 0.0; /* Clear output noise */
|
||||
inst->RESnVar[INNOIZ][i] = 0.0; /* Clear input noise */
|
||||
for (i = 0; i < RESNSRCS; i++) {
|
||||
inst->RESnVar[OUTNOIZ][i] = 0.0; /* Clear output noise */
|
||||
inst->RESnVar[INNOIZ][i] = 0.0; /* Clear input noise */
|
||||
}
|
||||
}
|
||||
} else { /* data->delFreq != 0.0 (we have to integrate) */
|
||||
|
||||
/* In order to get the best curve fit, we have to integrate each component separately */
|
||||
} else {
|
||||
/* data->delFreq != 0.0 (we have to integrate) */
|
||||
|
||||
for (i = 0; i < RESNSRCS; i++) {
|
||||
if (i != RESTOTNOIZ) {
|
||||
tempOutNoise = Nintegrate(noizDens[i], lnNdens[i],
|
||||
inst->RESnVar[LNLSTDENS][i], data);
|
||||
tempInNoise = Nintegrate(noizDens[i] *
|
||||
data->GainSqInv ,lnNdens[i]
|
||||
+ data->lnGainInv,
|
||||
inst->RESnVar[LNLSTDENS][i]
|
||||
+ data->lnGainInv,
|
||||
data);
|
||||
inst->RESnVar[LNLSTDENS][i] = lnNdens[i];
|
||||
data->outNoiz += tempOutNoise;
|
||||
data->inNoise += tempInNoise;
|
||||
if (job->NStpsSm != 0) {
|
||||
inst->RESnVar[OUTNOIZ][i] += tempOutNoise;
|
||||
inst->RESnVar[OUTNOIZ][RESTOTNOIZ] += tempOutNoise;
|
||||
inst->RESnVar[INNOIZ][i] += tempInNoise;
|
||||
inst->RESnVar[INNOIZ][RESTOTNOIZ] += tempInNoise;
|
||||
/* In order to get the best curve fit, we have to integrate each component separately */
|
||||
|
||||
for (i = 0; i < RESNSRCS; i++) {
|
||||
if (i != RESTOTNOIZ) {
|
||||
tempOutNoise = Nintegrate(noizDens[i], lnNdens[i],
|
||||
inst->RESnVar[LNLSTDENS][i], data);
|
||||
tempInNoise = Nintegrate(noizDens[i] *
|
||||
data->GainSqInv, lnNdens[i] +
|
||||
data->lnGainInv,
|
||||
inst->RESnVar[LNLSTDENS][i] +
|
||||
data->lnGainInv,
|
||||
data);
|
||||
inst->RESnVar[LNLSTDENS][i] = lnNdens[i];
|
||||
data->outNoiz += tempOutNoise;
|
||||
data->inNoise += tempInNoise;
|
||||
if (job->NStpsSm != 0) {
|
||||
inst->RESnVar[OUTNOIZ][i] += tempOutNoise;
|
||||
inst->RESnVar[OUTNOIZ][RESTOTNOIZ] += tempOutNoise;
|
||||
inst->RESnVar[INNOIZ][i] += tempInNoise;
|
||||
inst->RESnVar[INNOIZ][RESTOTNOIZ] += tempInNoise;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
if (data->prtSummary) {
|
||||
for (i=0; i < RESNSRCS; i++) { /* print a summary report */
|
||||
for (i = 0; i < RESNSRCS; i++) {
|
||||
/* print a summary report */
|
||||
data->outpVector[data->outNumber++] = noizDens[i];
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case INT_NOIZ: /* already calculated, just output */
|
||||
case INT_NOIZ:
|
||||
/* already calculated, just output */
|
||||
if (job->NStpsSm != 0) {
|
||||
for (i=0; i < RESNSRCS; i++) {
|
||||
for (i = 0; i < RESNSRCS; i++) {
|
||||
data->outpVector[data->outNumber++] = inst->RESnVar[OUTNOIZ][i];
|
||||
data->outpVector[data->outNumber++] = inst->RESnVar[INNOIZ][i];
|
||||
}
|
||||
} /* if */
|
||||
} /* if */
|
||||
break;
|
||||
} /* switch (mode) */
|
||||
} /* switch (mode) */
|
||||
break;
|
||||
|
||||
case N_CLOSE:
|
||||
return (OK); /* do nothing, the main calling routine will close */
|
||||
break; /* the plots */
|
||||
} /* switch (operation) */
|
||||
} /* for inst */
|
||||
} /* for model */
|
||||
|
||||
return(OK);
|
||||
}
|
||||
|
||||
return (OK); /* do nothing, the main calling routine will close */
|
||||
break; /* the plots */
|
||||
} /* switch (operation) */
|
||||
} /* for inst */
|
||||
} /* for model */
|
||||
|
||||
return (OK);
|
||||
}
|
||||
|
|
@ -36,6 +36,7 @@ VBICnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *
|
|||
double noizDens[VBICNSRCS];
|
||||
double lnNdens[VBICNSRCS];
|
||||
int i;
|
||||
double dtemp;
|
||||
|
||||
/* define the names of the noise sources */
|
||||
|
||||
|
|
@ -92,33 +93,39 @@ VBICnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *
|
|||
switch (mode) {
|
||||
|
||||
case N_DENS:
|
||||
NevalSrc(&noizDens[VBICRCNOIZ],&lnNdens[VBICRCNOIZ],
|
||||
|
||||
if (inst->VBICtempGiven)
|
||||
dtemp = inst->VBICtemp - ckt->CKTtemp + (model->VBICtnom-CONSTCtoK);
|
||||
else
|
||||
dtemp = inst->VBICdtemp;
|
||||
|
||||
NevalSrcInstanceTemp(&noizDens[VBICRCNOIZ],&lnNdens[VBICRCNOIZ],
|
||||
ckt,THERMNOISE,inst->VBICcollCXNode,inst->VBICcollNode,
|
||||
*(ckt->CKTstate0 + inst->VBICircx_Vrcx));
|
||||
*(ckt->CKTstate0 + inst->VBICircx_Vrcx), dtemp);
|
||||
|
||||
NevalSrc(&noizDens[VBICRCINOIZ],&lnNdens[VBICRCINOIZ],
|
||||
NevalSrcInstanceTemp(&noizDens[VBICRCINOIZ],&lnNdens[VBICRCINOIZ],
|
||||
ckt,THERMNOISE,inst->VBICcollCXNode,inst->VBICcollCINode,
|
||||
*(ckt->CKTstate0 + inst->VBICirci_Vrci));
|
||||
*(ckt->CKTstate0 + inst->VBICirci_Vrci), dtemp);
|
||||
|
||||
NevalSrc(&noizDens[VBICRBNOIZ],&lnNdens[VBICRBNOIZ],
|
||||
NevalSrcInstanceTemp(&noizDens[VBICRBNOIZ],&lnNdens[VBICRBNOIZ],
|
||||
ckt,THERMNOISE,inst->VBICbaseBXNode,inst->VBICbaseNode,
|
||||
*(ckt->CKTstate0 + inst->VBICirbx_Vrbx));
|
||||
*(ckt->CKTstate0 + inst->VBICirbx_Vrbx), dtemp);
|
||||
|
||||
NevalSrc(&noizDens[VBICRBINOIZ],&lnNdens[VBICRBINOIZ],
|
||||
NevalSrcInstanceTemp(&noizDens[VBICRBINOIZ],&lnNdens[VBICRBINOIZ],
|
||||
ckt,THERMNOISE,inst->VBICbaseBXNode,inst->VBICbaseBINode,
|
||||
*(ckt->CKTstate0 + inst->VBICirbi_Vrbi));
|
||||
*(ckt->CKTstate0 + inst->VBICirbi_Vrbi), dtemp);
|
||||
|
||||
NevalSrc(&noizDens[VBICRENOIZ],&lnNdens[VBICRENOIZ],
|
||||
NevalSrcInstanceTemp(&noizDens[VBICRENOIZ],&lnNdens[VBICRENOIZ],
|
||||
ckt,THERMNOISE,inst->VBICemitEINode,inst->VBICemitNode,
|
||||
*(ckt->CKTstate0 + inst->VBICire_Vre));
|
||||
*(ckt->CKTstate0 + inst->VBICire_Vre), dtemp);
|
||||
|
||||
NevalSrc(&noizDens[VBICRBPNOIZ],&lnNdens[VBICRBPNOIZ],
|
||||
NevalSrcInstanceTemp(&noizDens[VBICRBPNOIZ],&lnNdens[VBICRBPNOIZ],
|
||||
ckt,THERMNOISE,inst->VBICemitEINode,inst->VBICemitNode,
|
||||
*(ckt->CKTstate0 + inst->VBICirbp_Vrbp));
|
||||
*(ckt->CKTstate0 + inst->VBICirbp_Vrbp), dtemp);
|
||||
|
||||
NevalSrc(&noizDens[VBICRSNOIZ],&lnNdens[VBICRSNOIZ],
|
||||
NevalSrcInstanceTemp(&noizDens[VBICRSNOIZ],&lnNdens[VBICRSNOIZ],
|
||||
ckt,THERMNOISE,inst->VBICsubsSINode,inst->VBICsubsNode,
|
||||
*(ckt->CKTstate0 + inst->VBICirs_Vrs));
|
||||
*(ckt->CKTstate0 + inst->VBICirs_Vrs), dtemp);
|
||||
|
||||
|
||||
NevalSrc(&noizDens[VBICICNOIZ],&lnNdens[VBICICNOIZ],
|
||||
|
|
|
|||
Loading…
Reference in New Issue