diff --git a/src/spicelib/devices/dev.c b/src/spicelib/devices/dev.c index 0b79e6717..d49bd21e3 100644 --- a/src/spicelib/devices/dev.c +++ b/src/spicelib/devices/dev.c @@ -170,6 +170,12 @@ int DEVflag(int type){ #include "ngspice/cktdefs.h" /* for DEVmaxnum */ #include +int +is_adms_type_(int type) +{ + return !strcmp("hicum0", DEVices[type]->DEVpublic.name); +} + int is_adms_type(const char *type_name) { diff --git a/src/spicelib/parser/inp2u.c b/src/spicelib/parser/inp2u.c index 0cb8d0c78..257736748 100644 --- a/src/spicelib/parser/inp2u.c +++ b/src/spicelib/parser/inp2u.c @@ -16,8 +16,121 @@ Author: 1988 Thomas L. Quarles void INP2U(CKTcircuit *ckt, INPtables * tab, card * current) { + /* Uname [l=] [n=] */ + + int mytype; /* the type my lookup says URC is */ + int type; /* the type the model says it is */ + char *line; /* the part of the current line left to parse */ + char *name; /* the resistor's name */ + char *nname1; /* the first node's name */ + char *nname2; /* the second node's name */ + char *nname3; /* the third node's name */ + CKTnode *node1; /* the first node's node pointer */ + CKTnode *node2; /* the second node's node pointer */ + CKTnode *node3; /* the third node's node pointer */ + int error; /* error code temporary */ + GENinstance *fast; /* pointer to the actual instance */ + int waslead; /* flag to indicate that funny unlabeled number was found */ + double leadval; /* actual value of unlabeled number */ + char *model; /* name of the model */ + INPmodel *thismodel; /* pointer to our model descriptor */ + GENmodel *mdfast; /* pointer to the actual model */ + IFuid uid; /* uid for default model */ + + mytype = INPtypelook("URC"); + if (mytype < 0) { + LITERR("Device type URC not supported by this binary\n"); + return; + } + line = current->line; + INPgetTok(&line, &name, 1); + INPinsert(&name, tab); + INPgetNetTok(&line, &nname1, 1); + INPtermInsert(ckt, &nname1, tab, &node1); + INPgetNetTok(&line, &nname2, 1); + INPtermInsert(ckt, &nname2, tab, &node2); + INPgetNetTok(&line, &nname3, 1); + INPtermInsert(ckt, &nname3, tab, &node3); + INPgetTok(&line, &model, 1); + INPinsert(&model, tab); + current->error = INPgetMod(ckt, model, &thismodel, tab); + if (thismodel != NULL) { + if (mytype != thismodel->INPmodType) { + LITERR("incorrect model type"); + return; + } + type = mytype; + mdfast = (thismodel->INPmodfast); + } else { + type = mytype; + if (!tab->defUmod) { + /* create deafult U model */ + IFnewUid(ckt, &uid, NULL, "U", UID_MODEL, + NULL); + IFC(newModel, (ckt, type, &(tab->defUmod), uid)); + } + mdfast = tab->defUmod; + } + IFC(newInstance, (ckt, mdfast, &fast, name)); + IFC(bindNode, (ckt, fast, 1, node1)); + IFC(bindNode, (ckt, fast, 2, node2)); + IFC(bindNode, (ckt, fast, 3, node3)); + PARSECALL((&line, ckt, type, fast, &leadval, &waslead, tab)); +} + + #if ADMS >= 3 || 1 +extern int is_adms_type_(int type); +#define Breakpoint do { __asm__ __volatile__ ("int $03"); } while(0) + +/* + * examine a part instanciation, looking like + * Uname ... [param1=] [param1=] ... + * try to grab from that, + * and query INPlookMod() for it + * if found, then query is_adms_type_() + */ + +int +INP2tryadms(CKTcircuit *ckt, INPtables * tab, card * current) +{ + char *line; /* the part of the current line left to parse */ + char *xline; + char *iname; /* the instance's name */ + char *name; + + NG_IGNORE(ckt); + NG_IGNORE(tab); + + printf("%s: <-- '%s'\n", __func__, current->line); + + xline = line = strdup(current->line); + + INPgetTok(&line, &iname, 1); + + while(*line != '\0') { + INPmodel *thismodel; + int type; + INPgetNetTok(&line, &name, 1); + thismodel = INPlookMod(name); + if(!thismodel) + continue; + type = thismodel->INPmodType; + printf("%s: --> INPmodType = %d\n", __func__, type); + free(xline); + return is_adms_type_(type); + } + + printf("%s: --> INPmodType = \n", __func__); + free(xline); + return 0; +} + + +void +INP2tryadms_do(CKTcircuit *ckt, INPtables * tab, card * current) +{ /* Uname ... [param1=] [param1=] ... */ char *line; /* the part of the current line left to parse */ @@ -82,67 +195,5 @@ void INP2U(CKTcircuit *ckt, INPtables * tab, card * current) fprintf(stderr, "Unable to find definition of model %s\n", name); controlled_exit(EXIT_BAD); } - -#else - /* Uname [l=] [n=] */ - - int mytype; /* the type my lookup says URC is */ - int type; /* the type the model says it is */ - char *line; /* the part of the current line left to parse */ - char *name; /* the resistor's name */ - char *nname1; /* the first node's name */ - char *nname2; /* the second node's name */ - char *nname3; /* the third node's name */ - CKTnode *node1; /* the first node's node pointer */ - CKTnode *node2; /* the second node's node pointer */ - CKTnode *node3; /* the third node's node pointer */ - int error; /* error code temporary */ - GENinstance *fast; /* pointer to the actual instance */ - int waslead; /* flag to indicate that funny unlabeled number was found */ - double leadval; /* actual value of unlabeled number */ - char *model; /* name of the model */ - INPmodel *thismodel; /* pointer to our model descriptor */ - GENmodel *mdfast; /* pointer to the actual model */ - IFuid uid; /* uid for default model */ - - mytype = INPtypelook("URC"); - if (mytype < 0) { - LITERR("Device type URC not supported by this binary\n"); - return; - } - line = current->line; - INPgetTok(&line, &name, 1); - INPinsert(&name, tab); - INPgetNetTok(&line, &nname1, 1); - INPtermInsert(ckt, &nname1, tab, &node1); - INPgetNetTok(&line, &nname2, 1); - INPtermInsert(ckt, &nname2, tab, &node2); - INPgetNetTok(&line, &nname3, 1); - INPtermInsert(ckt, &nname3, tab, &node3); - INPgetTok(&line, &model, 1); - INPinsert(&model, tab); - current->error = INPgetMod(ckt, model, &thismodel, tab); - if (thismodel != NULL) { - if (mytype != thismodel->INPmodType) { - LITERR("incorrect model type"); - return; - } - type = mytype; - mdfast = (thismodel->INPmodfast); - } else { - type = mytype; - if (!tab->defUmod) { - /* create deafult U model */ - IFnewUid(ckt, &uid, NULL, "U", UID_MODEL, - NULL); - IFC(newModel, (ckt, type, &(tab->defUmod), uid)); - } - mdfast = tab->defUmod; - } - IFC(newInstance, (ckt, mdfast, &fast, name)); - IFC(bindNode, (ckt, fast, 1, node1)); - IFC(bindNode, (ckt, fast, 2, node2)); - IFC(bindNode, (ckt, fast, 3, node3)); - PARSECALL((&line, ckt, type, fast, &leadval, &waslead, tab)); -#endif } +#endif diff --git a/src/spicelib/parser/inplkmod.c b/src/spicelib/parser/inplkmod.c index 7bec493d1..4840c9378 100644 --- a/src/spicelib/parser/inplkmod.c +++ b/src/spicelib/parser/inplkmod.c @@ -26,3 +26,22 @@ INPlookMod(const char *name) return NULL; } + +/*----------------------------------------------------------------- + * This fcn accepts a pointer to the model name, and returns 1 if + * the model exists in the model table, and returns 0 if hte model + * doesn't exist in the model table. + *----------------------------------------------------------------*/ +#if 0 +INPmodel *INPlookMod_(char *name) +{ + INPmodel *i; + + for (i = modtab; i; i = i->INPnextModel) + if (strcmp(i->INPmodName, name) == 0) + return i; + + return NULL; +} +#endif + diff --git a/src/spicelib/parser/inppas2.c b/src/spicelib/parser/inppas2.c index c16b879fa..271cb857b 100644 --- a/src/spicelib/parser/inppas2.c +++ b/src/spicelib/parser/inppas2.c @@ -25,6 +25,8 @@ extern void SetAnalyse( char * Analyse, int Percent); /* pass 2 - Scan through the lines. ".model" cards have processed in * pass1 and are ignored here. */ +int INP2tryadms(CKTcircuit *ckt, INPtables * tab, card * current); +void INP2tryadms_do(CKTcircuit *ckt, INPtables * tab, card * current); void INPpas2(CKTcircuit *ckt, card * data, INPtables * tab, TSKtask *task) { @@ -221,7 +223,10 @@ void INPpas2(CKTcircuit *ckt, card * data, INPtables * tab, TSKtask *task) case 'U': /* Uname [l=] [n=] */ - INP2U(ckt, tab, current); + if(INP2tryadms(ckt, tab, current)) + INP2tryadms_do(ckt, tab, current); + else + INP2U(ckt, tab, current); break; /* Kspice addition - saj */