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"
This commit is contained in:
rlar 2014-01-03 12:05:55 +01:00
parent 23ffcbf7d1
commit 8803edc16b
2 changed files with 44 additions and 46 deletions

View File

@ -32,45 +32,44 @@ NOISEan (CKTcircuit *ckt, int restart)
int error;
int posOutNode;
int negOutNode;
int code;
int step;
IFuid freqUid;
GENinstance *inst;
double freqTol; /* tolerence parameter for finding final frequency; hack */
NOISEAN *job = (NOISEAN *) ckt->CKTcurJob;
static char *noacinput = "noise input source has no AC value";
posOutNode = (job->output) -> number;
negOutNode = (job->outputRef) -> number;
/* 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,
"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 */

View File

@ -33,8 +33,6 @@ TFanal(CKTcircuit *ckt, int restart)
runDesc *plotptr = NULL; /* pointer to out plot */
GENinstance *ptr = NULL;
IFuid uids[3];
int Itype;
int Vtype;
char *name;
#define tfuid (uids[0]) /* unique id for the transfer function output */
#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->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->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);