Browse Source

tfanal.c noisean.c, bug fix which was introduced in "CKTfndDev(), rewrite"

the original CKTfndDev() was able to limit its search
  for an instance with given name
  to instances of a certain "type"
(this was a speed optimisation which is of no use anymore,
  because we use a hashtable now)

the new CKTfndDev() does not consider "type"

thus, here in tfanal.c and noisean.c we have to check the "type"
  after CKTfndDev() since we no longer can limit its search
  to the given "type"
pre-master-46
rlar 12 years ago
parent
commit
8803edc16b
  1. 53
      src/spicelib/analysis/noisean.c
  2. 37
      src/spicelib/analysis/tfanal.c

53
src/spicelib/analysis/noisean.c

@ -32,45 +32,44 @@ NOISEan (CKTcircuit *ckt, int restart)
int error; int error;
int posOutNode; int posOutNode;
int negOutNode; int negOutNode;
int code;
int step; int step;
IFuid freqUid; IFuid freqUid;
GENinstance *inst;
double freqTol; /* tolerence parameter for finding final frequency; hack */ double freqTol; /* tolerence parameter for finding final frequency; hack */
NOISEAN *job = (NOISEAN *) ckt->CKTcurJob; NOISEAN *job = (NOISEAN *) ckt->CKTcurJob;
static char *noacinput = "noise input source has no AC value";
posOutNode = (job->output) -> number; posOutNode = (job->output) -> number;
negOutNode = (job->outputRef) -> number; negOutNode = (job->outputRef) -> number;
/* see if the source specified is AC */ /* see if the source specified is AC */
inst = NULL;
code = CKTtypelook("Vsource");
if (code != -1) {
inst = CKTfndDev(ckt, job->input);
if (inst && !((VSRCinstance *)inst)->VSRCacGiven) {
errMsg = TMALLOC(char, strlen(noacinput) + 1);
strcpy(errMsg,noacinput);
return (E_NOACINPUT);
}
}
{
GENinstance *inst = CKTfndDev(ckt, job->input);
bool ac_given = FALSE;
code = CKTtypelook("Isource");
if (code != -1 && inst==NULL) {
inst = CKTfndDev(ckt, job->input);
if (!inst) {
/* XXX ??? */
if (!inst || inst->GENmodPtr->GENmodType < 0) {
SPfrontEnd->IFerror (ERR_WARNING, SPfrontEnd->IFerror (ERR_WARNING,
"Noise input source %s not in circuit",
&job->input);
return (E_NOTFOUND);
}
if (!((ISRCinstance *)inst)->ISRCacGiven) {
errMsg = TMALLOC(char, strlen(noacinput) + 1);
strcpy(errMsg,noacinput);
return (E_NOACINPUT);
}
"Noise input source %s not in circuit",
&job->input);
return E_NOTFOUND;
}
if (inst->GENmodPtr->GENmodType == CKTtypelook("Vsource")) {
ac_given = ((VSRCinstance *)inst) -> VSRCacGiven;
} else if(inst->GENmodPtr->GENmodType == CKTtypelook("Isource")) {
ac_given = ((ISRCinstance *)inst) -> ISRCacGiven;
} else {
SPfrontEnd->IFerror (ERR_WARNING,
"Noise input source %s is not of proper type",
&job->input);
return E_NOTFOUND;
}
if (!ac_given) {
SPfrontEnd->IFerror (ERR_WARNING,
"Noise input source %s has no AC value",
&job->input);
return E_NOACINPUT;
}
} }
if ( (job->NsavFstp == 0.0) || restart) { /* va, NsavFstp is double */ if ( (job->NsavFstp == 0.0) || restart) { /* va, NsavFstp is double */

37
src/spicelib/analysis/tfanal.c

@ -33,8 +33,6 @@ TFanal(CKTcircuit *ckt, int restart)
runDesc *plotptr = NULL; /* pointer to out plot */ runDesc *plotptr = NULL; /* pointer to out plot */
GENinstance *ptr = NULL; GENinstance *ptr = NULL;
IFuid uids[3]; IFuid uids[3];
int Itype;
int Vtype;
char *name; char *name;
#define tfuid (uids[0]) /* unique id for the transfer function output */ #define tfuid (uids[0]) /* unique id for the transfer function output */
#define inuid (uids[1]) /* unique id for the transfer function input imp. */ #define inuid (uids[1]) /* unique id for the transfer function input imp. */
@ -48,27 +46,28 @@ TFanal(CKTcircuit *ckt, int restart)
(ckt->CKTmode & MODEUIC) | MODEDCOP | MODEINITFLOAT, (ckt->CKTmode & MODEUIC) | MODEDCOP | MODEINITFLOAT,
ckt->CKTdcMaxIter); ckt->CKTdcMaxIter);
Itype = CKTtypelook("Isource");
Vtype = CKTtypelook("Vsource");
if(Itype != -1) {
ptr = CKTfndDev(ckt, job->TFinSrc);
if (ptr) {
job->TFinIsI = 1;
job->TFinIsV = 0;
}
ptr = CKTfndDev(ckt, job->TFinSrc);
if (!ptr || ptr->GENmodPtr->GENmodType < 0) {
SPfrontEnd->IFerror (ERR_WARNING,
"Transfer function source %s not in circuit",
&job->TFinSrc);
job->TFinIsV = 0;
job->TFinIsI = 0;
return E_NOTFOUND;
} }
if( (Vtype != -1) && (ptr==NULL) ) {
ptr = CKTfndDev(ckt, job->TFinSrc);
if (ptr->GENmodPtr->GENmodType == CKTtypelook("Vsource")) {
job->TFinIsV = 1; job->TFinIsV = 1;
job->TFinIsI = 0; job->TFinIsI = 0;
if (!ptr) {
SPfrontEnd->IFerror (ERR_WARNING,
"Transfer function source %s not in circuit",
&(job->TFinSrc));
job->TFinIsV = 0;
return(E_NOTFOUND);
}
} else if (ptr->GENmodPtr->GENmodType == CKTtypelook("Isource")) {
job->TFinIsV = 0;
job->TFinIsI = 1;
} else {
SPfrontEnd->IFerror (ERR_WARNING,
"Transfer function source %s not of proper type",
&job->TFinSrc);
return E_NOTFOUND;
} }
size = SMPmatSize(ckt->CKTmatrix); size = SMPmatSize(ckt->CKTmatrix);

Loading…
Cancel
Save