undo sime INPU2 stuff, and using model load in spinit
This commit is contained in:
parent
9f76b7d4a6
commit
fea860ae85
|
|
@ -170,6 +170,12 @@ int DEVflag(int type){
|
|||
#include "ngspice/cktdefs.h" /* for DEVmaxnum */
|
||||
#include <dlfcn.h>
|
||||
|
||||
int
|
||||
is_adms_type_(int type)
|
||||
{
|
||||
return !strcmp("hicum0", DEVices[type]->DEVpublic.name);
|
||||
}
|
||||
|
||||
int
|
||||
is_adms_type(const char *type_name)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,8 +16,121 @@ Author: 1988 Thomas L. Quarles
|
|||
|
||||
void INP2U(CKTcircuit *ckt, INPtables * tab, card * current)
|
||||
{
|
||||
/* Uname <node> <node> <model> [l=<val>] [n=<val>] */
|
||||
|
||||
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 <node> <node> ... <model> [param1=<val1>] [param1=<val2>] ...
|
||||
* try to grab <model> 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 = <not found>\n", __func__);
|
||||
free(xline);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
INP2tryadms_do(CKTcircuit *ckt, INPtables * tab, card * current)
|
||||
{
|
||||
/* Uname <node> <node> ... <model> [param1=<val1>] [param1=<val2>] ... */
|
||||
|
||||
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 <node> <node> <model> [l=<val>] [n=<val>] */
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <node> <node> <model> [l=<val>] [n=<val>] */
|
||||
INP2U(ckt, tab, current);
|
||||
if(INP2tryadms(ckt, tab, current))
|
||||
INP2tryadms_do(ckt, tab, current);
|
||||
else
|
||||
INP2U(ckt, tab, current);
|
||||
break;
|
||||
|
||||
/* Kspice addition - saj */
|
||||
|
|
|
|||
Loading…
Reference in New Issue