static int dot_sens2(char *line, CKTcircuit *ckt, INPtables *tab, struct card *current, TSKtask *task, CKTnode *gnode, JOB *foo) { int error; /* error code temporary */ IFvalue ptemp; /* a value structure to package resistance into */ IFvalue *parm; /* a pointer to a value struct for function returns */ int which; /* which analysis we are performing */ char *token; /* a token from the line */ NG_IGNORE(gnode); /* .sens {AC} {DC} {TRAN} [dev=nnn parm=nnn]* */ which = ft_find_analysis("SENS2"); if (which == -1) { LITERR("Sensitivity-2 analysis unsupported\n"); return (0); } IFC(newAnalysis, (ckt, which, "Sensitivity-2 Analysis", &foo, task)); while (*line) { IFparm *if_parm; /* read the entire line */ INPgetTok(&line, &token, 1); if_parm = ft_find_analysis_parm(which, token); if (!if_parm) { /* didn't find it! */ LITERR(" Error: unknown parameter on .sens-ignored \n"); continue; } /* found it, analysis which, parameter i */ if (if_parm->dataType & IF_FLAG) { /* one of the keywords! */ ptemp.iValue = 1; error = ft_sim->setAnalysisParm (ckt, foo, if_parm->id, &ptemp, NULL); if (error) current->error = INPerrCat(current->error, INPerror(error)); } else { parm = INPgetValue(ckt, &line, if_parm->dataType, tab); error = ft_sim->setAnalysisParm (ckt, foo, if_parm->id, parm, NULL); if (error) current->error = INPerrCat(current->error, INPerror(error)); } } return (0); }
static int dot_noise(char *line, CKTcircuit *ckt, INPtables *tab, struct card *current, TSKtask *task, CKTnode *gnode, JOB *foo) { int which; /* which analysis we are performing */ int error; /* error code temporary */ char *name; /* the resistor's name */ char *nname1; /* the first node's name */ char *nname2; /* the second node's name */ CKTnode *node1; /* the first node's node pointer */ CKTnode *node2; /* the second node's node pointer */ IFvalue ptemp; /* a value structure to package resistance into */ IFvalue *parm; /* a pointer to a value struct for function returns */ char *steptype; /* ac analysis, type of stepping function */ int found; char *point; /* .noise V(OUTPUT,REF) SRC {DEC OCT LIN} NP FSTART FSTOP <PTSPRSUM> */ which = ft_find_analysis("NOISE"); if (which == -1) { LITERR("Noise analysis unsupported.\n"); return (0); } IFC(newAnalysis, (ckt, which, "Noise Analysis", &foo, task)); INPgetTok(&line, &name, 1); /* Make sure the ".noise" command is followed by V(xxxx). If it is, extract 'xxxx'. If not, report an error. */ if (name != NULL) { if ((*name == 'V' || *name == 'v') && !name[1]) { INPgetNetTok(&line, &nname1, 0); INPtermInsert(ckt, &nname1, tab, &node1); ptemp.nValue = node1; GCA(INPapName, (ckt, which, foo, "output", &ptemp)); if (*line != ')') { INPgetNetTok(&line, &nname2, 1); INPtermInsert(ckt, &nname2, tab, &node2); ptemp.nValue = node2; } else { ptemp.nValue = gnode; } GCA(INPapName, (ckt, which, foo, "outputref", &ptemp)); tfree(name); INPgetTok(&line, &name, 1); INPinsert(&name, tab); ptemp.uValue = name; GCA(INPapName, (ckt, which, foo, "input", &ptemp)); INPgetTok(&line, &steptype, 1); ptemp.iValue = 1; error = INPapName(ckt, which, foo, steptype, &ptemp); tfree(steptype); if (error) current->error = INPerrCat(current->error, INPerror(error)); parm = INPgetValue(ckt, &line, IF_INTEGER, tab); error = INPapName(ckt, which, foo, "numsteps", parm); if (error) current->error = INPerrCat(current->error, INPerror(error)); parm = INPgetValue(ckt, &line, IF_REAL, tab); error = INPapName(ckt, which, foo, "start", parm); if (error) current->error = INPerrCat(current->error, INPerror(error)); parm = INPgetValue(ckt, &line, IF_REAL, tab); error = INPapName(ckt, which, foo, "stop", parm); if (error) current->error = INPerrCat(current->error, INPerror(error)); /* now see if "ptspersum" has been specified by the user */ for (found = 0, point = line; (!found) && (*point != '\0'); found = ((*point != ' ') && (*(point++) != '\t'))) ; if (found) { parm = INPgetValue(ckt, &line, IF_INTEGER, tab); error = INPapName(ckt, which, foo, "ptspersum", parm); if (error) current->error = INPerrCat(current->error, INPerror(error)); } else { ptemp.iValue = 0; error = INPapName(ckt, which, foo, "ptspersum", &ptemp); if (error) current->error = INPerrCat(current->error, INPerror(error)); } } else LITERR("bad syntax " "[.noise v(OUT) SRC {DEC OCT LIN} " "NP FSTART FSTOP <PTSPRSUM>]\n"); } else { LITERR("bad syntax " "[.noise v(OUT) SRC {DEC OCT LIN} " "NP FSTART FSTOP <PTSPRSUM>]\n"); } return 0; }
static int dot_noise(char *line, void *ckt, INPtables *tab, card *current, void *task, void *gnode, void *foo) { int which; /* which analysis we are performing */ int i; /* generic loop variable */ int error; /* error code temporary */ char *name; /* the resistor's name */ char *nname1; /* the first node's name */ char *nname2; /* the second node's name */ void *node1; /* the first node's node pointer */ void *node2; /* the second node's node pointer */ IFvalue ptemp; /* a value structure to package resistance into */ IFvalue *parm; /* a pointer to a value struct for function returns */ char *steptype; /* ac analysis, type of stepping function */ int found; char *point; /* .noise V(OUTPUT,REF) SRC {DEC OCT LIN} NP FSTART FSTOP <PTSPRSUM> */ which = -1; for (i = 0; i < ft_sim->numAnalyses; i++) { if (strcmp(ft_sim->analyses[i]->name, "NOISE") == 0) { which = i; break; } } if (which == -1) { LITERR("Noise analysis unsupported.\n"); return (0); } IFC(newAnalysis, (ckt, which, "Noise Analysis", &foo, task)); INPgetTok(&line, &name, 1); /* Make sure the ".noise" command is followed by V(xxxx). If it is, extract 'xxxx'. If not, report an error. */ if (name != NULL) { int length; length = strlen(name); if (((*name == 'V') || (*name == 'v')) && (length == 1)) { INPgetNetTok(&line, &nname1, 0); INPtermInsert(ckt, &nname1, tab, &node1); ptemp.nValue = (IFnode) node1; GCA(INPapName, (ckt, which, foo, "output", &ptemp)) if (*line != ')') { INPgetNetTok(&line, &nname2, 1); INPtermInsert(ckt, &nname2, tab, &node2); ptemp.nValue = (IFnode) node2; } else { ptemp.nValue = (IFnode) gnode; } GCA(INPapName, (ckt, which, foo, "outputref", &ptemp)) INPgetTok(&line, &name, 1); INPinsert(&name, tab); ptemp.uValue = name; GCA(INPapName, (ckt, which, foo, "input", &ptemp)) INPgetTok(&line, &steptype, 1); ptemp.iValue = 1; error = INPapName(ckt, which, foo, steptype, &ptemp); if (error) current->error = INPerrCat(current->error, INPerror(error)); parm = INPgetValue(ckt, &line, IF_INTEGER, tab); error = INPapName(ckt, which, foo, "numsteps", parm); if (error) current->error = INPerrCat(current->error, INPerror(error)); parm = INPgetValue(ckt, &line, IF_REAL, tab); error = INPapName(ckt, which, foo, "start", parm); if (error) current->error = INPerrCat(current->error, INPerror(error)); parm = INPgetValue(ckt, &line, IF_REAL, tab); error = INPapName(ckt, which, foo, "stop", parm); if (error) current->error = INPerrCat(current->error, INPerror(error)); /* now see if "ptspersum" has been specified by the user */ for (found = 0, point = line; (!found) && (*point != '\0'); found = ((*point != ' ') && (*(point++) != '\t'))); if (found) { parm = INPgetValue(ckt, &line, IF_INTEGER, tab); error = INPapName(ckt, which, foo, "ptspersum", parm); if (error) current->error = INPerrCat(current->error, INPerror(error)); } else { ptemp.iValue = 0; error = INPapName(ckt, which, foo, "ptspersum", &ptemp); if (error) current->error = INPerrCat(current->error, INPerror(error)); } } else
char *MIFgetMod( CKTcircuit *ckt, /* The circuit structure */ char *name, /* The name of the model to look for */ INPmodel **model, /* The model found/created */ INPtables *tab /* Table of model info from first pass */ ) { INPmodel *modtmp; IFvalue * val; register int j; char * line; char *parm; char *err = NULL; int error; int i; char *err1; char *err2; MIFmodel *mdfast; /* Mif_Param_Info_t *param_info;*/ /* =========== First locate the named model in the modtab list ================= */ #ifdef TRACE /* SDB debug statement */ printf("In MIFgetMod, looking for model name = %s . . .\n", name); #endif /* maschmann : remove : from name * char *pos; * if((pos=strstr(name,":"))!=NULL) *pos=0; */ /*------------------------------------ for (i = &modtab; *i != NULL; i = &((*i)->INPnextModel)) { if (strcmp((*i)->INPmodName, token) == 0) { return (OK); } } --------------------------*/ /* loop through modtable looking for this model (*name) */ for (modtmp = modtab; modtmp != NULL; modtmp = modtmp->INPnextModel) { #ifdef TRACE /* SDB debug statement */ printf("In MIFgetMod, checking model against stored model = %s . . .\n", modtmp->INPmodName); #endif if (strcmp(modtmp->INPmodName, name) == 0) { #ifdef TRACE /* SDB debug statement */ printf("In MIFgetMod, found model!!!\n"); #endif /* ========= found the model in question - now instantiate if necessary ========== */ /* ============== and return an appropriate pointer to it ===================== */ /* make sure the type is valid before proceeding */ if(modtmp->INPmodType < 0) { /* illegal device type, so can't handle */ *model = NULL; return tprintf("MIF: Unknown device type for model %s\n", name); } /* check to see if this model's parameters have been processed */ if(! modtmp->INPmodfast) { /* not already processed, so create data struct */ error = ft_sim->newModel ( ckt, modtmp->INPmodType, &(modtmp->INPmodfast), modtmp->INPmodName); if(error) return(INPerror(error)); /* gtri modification: allocate and initialize MIF specific model struct items */ mdfast = (MIFmodel*) modtmp->INPmodfast; mdfast->num_param = DEVices[modtmp->INPmodType]->DEVpublic.num_param; mdfast->param = TMALLOC(Mif_Param_Data_t *, mdfast->num_param); for(i = 0; i < mdfast->num_param; i++) { mdfast->param[i] = TMALLOC(Mif_Param_Data_t, 1); mdfast->param[i]->is_null = MIF_TRUE; mdfast->param[i]->size = 0; mdfast->param[i]->element = NULL; } /* remaining initializations will be done by MIFmParam() and MIFsetup() */ /* parameter isolation, identification, binding */ line = modtmp->INPmodLine->line; INPgetTok(&line,&parm,1); /* throw away '.model' */ tfree(parm); INPgetTok(&line,&parm,1); /* throw away 'modname' */ tfree(parm); /* throw away the modtype - we don't treat it as a parameter */ /* like SPICE does */ INPgetTok(&line,&parm,1); /* throw away 'modtype' */ tfree(parm); while(*line != '\0') { INPgetTok(&line,&parm,1); for(j=0 ; j < *(ft_sim->devices[modtmp->INPmodType]->numModelParms); j++) { if (strcmp(parm, ft_sim->devices[modtmp->INPmodType]->modelParms[j].keyword) == 0) { /* gtri modification: call MIFgetValue instead of INPgetValue */ err1 = NULL; val = MIFgetValue(ckt,&line, ft_sim->devices[modtmp->INPmodType]->modelParms[j].dataType, tab, &err1); if(err1) { err2 = tprintf("MIF-ERROR - model: %s - %s\n", name, err1); return(err2); } error = ft_sim->setModelParm (ckt, modtmp->INPmodfast, ft_sim->devices[modtmp->INPmodType]->modelParms[j].id, val, NULL); if(error) return(INPerror(error)); break; } } /* gtri modification: processing of special parameter "level" removed */ if(j >= *(ft_sim->devices[modtmp->INPmodType]->numModelParms)) { char *temp = tprintf("MIF: unrecognized parameter (%s) - ignored", parm); err = INPerrCat(err, temp); } FREE(parm); } /* end while end of line not reached */ modtmp->INPmodLine->error = err; } /* end if model parameters not processed yet */ *model = modtmp; return(NULL); } /* end if name matches */
///<param name = "*ckt"> THe current circuit </param> ///<param name = "*name"> The name of the model </param> ///<param name = "**model"> The parse model structure </param> ///<param name = "*tab"> The current symbol table </param> char *INPgetMod(GENERIC * ckt, char *name, INPmodel **model, INPtables *tab) { INPmodel *modtmp; IFvalue * val; register int j; char * line; char *parm; char *err = NULL; char *temp; int error; for (modtmp = modtab; modtmp != (INPmodel *)NULL; modtmp = ((modtmp)->INPnextModel)) { if (strcmp((modtmp)->INPmodName, name) == 0) { /* found the model in question - now instantiate if necessary */ /* and return an appropriate pointer to it */ if (modtmp->INPmodType < 0) { /* illegal device type, so can't handle */ *model = (INPmodel *)NULL; err = (char *)MALLOC((35 + strlen(name)) * sizeof(char)); (void)sprintf(err, "Unknown device type for model %s \n", name); return(err); } if (!((modtmp)->INPmodUsed)) { /* not already defined, so create & give parameters */ error = (*(ft_sim->newModel))(ckt, (modtmp)->INPmodType, &((modtmp)->INPmodfast), (modtmp)->INPmodName); if (error) return(INPerror(error)); /* parameter isolation, identification, binding */ line = ((modtmp)->INPmodLine)->line; INPgetTok(&line, &parm, 1); /* throw away '.model' */ INPgetTok(&line, &parm, 1); /* throw away 'modname' */ while (*line != 0) { INPgetTok(&line, &parm, 1); if (!*parm) continue; for (j = 0; j < (*(*(ft_sim->devices)[(modtmp)->INPmodType]).numModelParms); j++) { if (strcmp(parm, ((*(ft_sim->devices)[(modtmp)->INPmodType]).modelParms[j].keyword)) == 0) { val = INPgetValue(ckt, &line, ((*(ft_sim->devices)[(modtmp)->INPmodType]).modelParms[j].dataType), tab); error = (*(ft_sim->setModelParm))(ckt, ((modtmp)->INPmodfast), (*(ft_sim->devices)[(modtmp)->INPmodType]).modelParms[j].id, val, (IFvalue*)NULL); if (error) return(INPerror(error)); break; } } if (strcmp(parm, "level") == 0) { /* just grab the level number and throw away */ /* since we already have that info from pass1 */ val = INPgetValue(ckt, &line, IF_REAL, tab); } else if (j >= (*(*(ft_sim->devices)[(modtmp)->INPmodType]).numModelParms)) { temp = (char *)MALLOC((40 + strlen(parm)) * sizeof(char)); (void)sprintf(temp, "unrecognized parameter (%s) - ignored\n", parm); err = INPerrCat(err, temp); } FREE(parm); } (modtmp)->INPmodUsed = 1; (modtmp)->INPmodLine->error = err; } *model = modtmp; return((char *)NULL); } } /* didn't find model - ERROR - return model */ *model = (INPmodel *)NULL; err = (char *)MALLOC((60 + strlen(name)) * sizeof(char)); (void)sprintf(err, " unable to find definition of model %s - default assumed \n", name); return(err); }