From 102cf08670a1592ab4de1dd63aa60fbc0c24cff1 Mon Sep 17 00:00:00 2001 From: r29173 Date: Wed, 14 Dec 2011 21:42:02 +0000 Subject: [PATCH] use u instance as dynamically defined models in --adms mode --- src/spicelib/parser/inp2u.c | 71 +++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/src/spicelib/parser/inp2u.c b/src/spicelib/parser/inp2u.c index e292791ec..e87e4a482 100644 --- a/src/spicelib/parser/inp2u.c +++ b/src/spicelib/parser/inp2u.c @@ -10,10 +10,80 @@ Author: 1988 Thomas L. Quarles #include "ngspice/inpmacs.h" #include "ngspice/fteext.h" #include "inp.h" +#ifdef ADMS +#include "error.h" /* controlled_exit() */ +#endif void INP2U(CKTcircuit *ckt, INPtables * tab, card * current) { +#ifdef ADMS + /* Uname ... [param1=] [param1=] ... */ + + char *line; /* the part of the current line left to parse */ + char *iname; /* the instance's name */ + char *name; /* the resistor's name */ + int nsize; /* number of nodes */ + int i; + CKTnode **node; /* the first 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 */ + +#ifdef TRACE + printf("INP2U: Parsing '%s'\n", current->line); +#endif + + nsize = 0; + node=NULL; + line = current->line; + + INPgetTok(&line, &iname, 1); + INPinsert(&iname, tab); + + INPgetNetTok(&line, &name, 1); + while(!INPlookMod(name) && (*line != '\0')) + { +#ifdef TRACE + printf("INP2U: found node %s\n",name); +#endif + nsize++; + node=TREALLOC(CKTnode*,node,nsize); + INPtermInsert(ckt, &name, tab, &node[nsize-1]); + INPgetNetTok(&line, &name, 1); + } + + if (INPlookMod(name)) { + INPmodel *thismodel; /* pointer to model description for user's model */ + thismodel = NULL; + INPinsert(&name, tab); +#ifdef TRACE + printf("INP2U: found dynamic model %s\n",name); +#endif + current->error = INPgetMod(ckt, name, &thismodel, tab); + if (thismodel == NULL) { + fprintf(stderr, "%s\nPlease check model, level or number of terminals!\n", current->error); + controlled_exit(EXIT_BAD); + } + else + { + IFC(newInstance, (ckt, thismodel->INPmodfast, &fast, iname)); + for(i=0;iINPmodType, fast, &leadval, &waslead, tab)); +#ifdef TRACE + printf("INP2U: Looking up model done\n"); +#endif + } + } else { + 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 */ @@ -74,4 +144,5 @@ void INP2U(CKTcircuit *ckt, INPtables * tab, card * current) IFC(bindNode, (ckt, fast, 2, node2)); IFC(bindNode, (ckt, fast, 3, node3)); PARSECALL((&line, ckt, type, fast, &leadval, &waslead, tab)); +#endif }