diff --git a/ChangeLog b/ChangeLog index 4409a9506..563b60386 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2003-05-02 Stuart Brorson + + * Added #define TRACE to main.c for use in debugging. Added lots + of printf's in the code which are turned on by defining TRACE. + This is used to help figure out what the program is doing at each + step . . . . . + + * Added lots of comments all over the source tree. This should + help explain what the prog is doing for future hackers. + + * Fixed parser to allow POLY attributes in dependent sources + (major changes in src/frontend/subckt.c, as well as move location + of call to ENHtranslate_poly in src/frontend/inp.c) + + * Fixed bug in device init files (src/spicelib/devices/*init.c) + so that Deviceinfo structures operated with XSPICE. + + * Fixed nasty malloc problem in src/xspice/mif/mifgetmod.c which + casuedfrequent segfaults (when compiled with XSPICE). + 2003-04-14 Stefan Jones * configure.in: Made Tcl disable-shared and print info at end of configure diff --git a/src/frontend/ChangeLog b/src/frontend/ChangeLog index 8b4291ce0..e86093135 100644 --- a/src/frontend/ChangeLog +++ b/src/frontend/ChangeLog @@ -1,4 +1,13 @@ -2003.4.10 Stuart Brorson +2003-05-02 Stuart Brorson + * Major changes in subckt.c to handle POLY attributes in + dependent sources. Added new case to switch in "translate" to + handle E, F, G, H sources. Many other fixes. + + * Moved location of call to ENHtranslate_poly in inp.c. This was + necessary to correctly process POLY attributes and the associated + netlists and voltage sources. + +2003-04-10 Stuart Brorson * modified inp_readall (inpcom.c) to ignore blank lines terminated by \r\n *and * \n. This fixes problems associated with importing files from Windozeland. diff --git a/src/frontend/inp.c b/src/frontend/inp.c index 8642d4f01..fdea25e6c 100644 --- a/src/frontend/inp.c +++ b/src/frontend/inp.c @@ -50,7 +50,7 @@ com_listing(wordlist *wl) bool expand = FALSE; char *s; - if (ft_curckt) { + if (ft_curckt) { /* if there is a current circuit . . . . */ while (wl) { s = wl->wl_word; switch (*s) { @@ -285,9 +285,15 @@ line_free(struct line * deck, bool recurse) { /* The routine to source a spice input deck. We read the deck in, take * out the front-end commands, and create a CKT structure. Also we * filter out the following cards: .save, .width, .four, .print, and - * .plot, to perform after the run is over. */ + * .plot, to perform after the run is over. + * Then, we run dodeck, which parses up the deck. */ void inp_spsource(FILE *fp, bool comfile, char *filename) + /* arguments: + * *fp = pointer to the input file + * comfile = whether it is a command file. Values are TRUE/FALSE + * *filename = + */ { struct line *deck, *dd, *ld; struct line *realdeck, *options = NULL; @@ -298,8 +304,10 @@ inp_spsource(FILE *fp, bool comfile, char *filename) FILE *lastin, *lastout, *lasterr; char c; + /* read in the deck from a file */ inp_readall(fp, &deck); - + + /* if nothing came back from inp_readall, just close fp and return to caller */ if (!deck) { /* MW. We must close fp always when returning */ fclose(fp); return; @@ -354,8 +362,10 @@ inp_spsource(FILE *fp, bool comfile, char *filename) /* tfree(dd->li_line); tfree(dd); */ } - } else { - for (dd = deck->li_next; dd; dd = ld->li_next) { + } /* end if(comfile) */ + + else { /* must be regular deck . . . . */ + for (dd = deck->li_next; dd; dd = ld->li_next) { /* loop through deck and handle control cards */ for (s = dd->li_line; (c = *s) && c <= ' '; s++) ; if (c == '*' && (s != deck->li_line || s[1] != '#')) { @@ -372,8 +382,10 @@ inp_spsource(FILE *fp, bool comfile, char *filename) if (ciprefix(".control", dd->li_line)) { ld->li_next = dd->li_next; line_free(dd,FALSE); /* SJB - free this line's memory */ + /* tfree(dd->li_line); tfree(dd); */ + if (commands) fprintf(cp_err, "Warning: redundant .control card\n"); @@ -382,8 +394,10 @@ inp_spsource(FILE *fp, bool comfile, char *filename) } else if (ciprefix(".endc", dd->li_line)) { ld->li_next = dd->li_next; line_free(dd,FALSE); /* SJB - free this line's memory */ + /* tfree(dd->li_line); tfree(dd); */ + if (commands) commands = FALSE; else @@ -442,38 +456,61 @@ inp_spsource(FILE *fp, bool comfile, char *filename) } else ld = dd; } - } - if (deck->li_next) { + } /* end for(dd=deck->li_next . . . . */ + + + /* we are done handling the control stuff. Now process remainder of deck */ + if (deck->li_next) { /* There is something left after the controls. */ fprintf(cp_out, "\nCircuit: %s\n\n", tt); + /* Old location of ENHtranslate_poly. This didn't work, because it + * didn't handle models in .SUBCKTs correctly. Moved to new location below + * by SDB on 4.13.2003 + */ + + /* Now expand subcircuit macros. Note that we have to fix + * the case before we do this but after we deal with the + * commands. */ + if (!cp_getvar("nosubckt", VT_BOOL, (char *) &nosubckts)) + if( (deck->li_next = inp_subcktexpand(deck->li_next)) == NULL ){ + line_free(realdeck,TRUE); + line_free(deck->li_actual, TRUE); + return; + } /* done expanding subcircuit macros */ + + + /* Now handle translation of spice2c6 POLYs. */ +/* New location of ENHtranslate_poly. This should handle .SUBCKTs better . . . . + * SDB 4.13.2003. Comments? mailto:sdb@cloud9.net + */ #ifdef XSPICE /* gtri - wbk - Translate all SPICE 2G6 polynomial type sources */ deck->li_next = ENHtranslate_poly(deck->li_next); /* gtri - end - Translate all SPICE 2G6 polynomial type sources */ #endif - /* Now expand subcircuit macros. Note that we have to fix - * the case before we do this but after we deal with the - * commands. */ - if (!cp_getvar("nosubckt", VT_BOOL, (char *) &nosubckts)) - if((deck->li_next = inp_subcktexpand(deck->li_next)) == NULL){ - line_free(realdeck,TRUE); - line_free(deck->li_actual, TRUE); - return; - } line_free(deck->li_actual,FALSE); /* SJB - free memory used by old li_actual (if any) */ deck->li_actual = realdeck; - inp_dodeck(deck, tt, wl_first, FALSE, options, filename); - } - /* Now that the deck is loaded, do the commands */ - if (controls) { + /* now call inp_dodeck, which loads deck into ft_curckt -- the current circuit. */ + inp_dodeck(deck, tt, wl_first, FALSE, options, filename); + + } /* if (deck->li_next) */ + + +#ifdef TRACE + /* SDB debug statement */ + printf("In inp_spsource, done with dodeck.\n"); +#endif + + /* Now that the deck is loaded, do the commands if there are any */ + if (controls) { for (end = wl = wl_reverse(controls); wl; wl = wl->wl_next) cp_evloop(wl->wl_word); wl_free(end); - } + } } /*saj, to process save commands always, not just in batch mode @@ -495,9 +532,21 @@ inp_spsource(FILE *fp, bool comfile, char *filename) * follows also. End is the list of commands we execute when the job * is finished: we only bother with this if we might be running in * batch mode, since it isn't much use otherwise. */ +/*------------------------------------------------------------------ + * It appears that inp_dodeck adds the circuit described by *deck + * to the current circuit (ft_curckt). + *-----------------------------------------------------------------*/ void inp_dodeck(struct line *deck, char *tt, wordlist *end, bool reuse, struct line *options, char *filename) + /*fcn arguments: + * *deck = the spice deck + * *tt = the title of the deck + * *end = pointer to the wordlist + * reuse + * *options + * *filename + */ { struct circ *ct; struct line *dd; @@ -527,23 +576,39 @@ inp_dodeck(struct line *deck, char *tt, wordlist *end, bool reuse, ft_curckt = ct = alloc(struct circ); } cp_getvar("noparse", VT_BOOL, (char *) &noparse); + + /*---------------------------------------------------- + * Now assuming that we wanna parse this deck, we call + * if_inpdeck which takes the deck and returns a + * a pointer to the circuit ckt. + *---------------------------------------------------*/ if (!noparse) ckt = if_inpdeck(deck, &tab); else ckt = NULL; out_init(); + + /*---------------------------------------------------- + * Now run throuh the deck and look to see if there are + * errors on any line. + *---------------------------------------------------*/ for (dd = deck; dd; dd = dd->li_next) { - - /* debug statement */ - /* printf("In inp_dodeck, examining line %s . . . \n", dd->li_line); */ - + +#ifdef TRACE + /* SDB debug statement */ + printf("In inp_dodeck, looking for errors and examining line %s . . . \n", dd->li_line); +#endif + if (dd->li_error) { - char *p, *q; + char *p, *q; + #ifdef XSPICE -/* gtri - modify - 12/12/90 - wbk - add setting of ipc syntax error flag */ g_ipc.syntax_error = IPC_TRUE; + /* gtri - modify - 12/12/90 - wbk - add setting of ipc syntax error flag */ + g_ipc.syntax_error = IPC_TRUE; #endif /* gtri - end - 12/12/90 */ + p = dd->li_error; do { q =strchr(p, '\n'); @@ -576,7 +641,7 @@ inp_dodeck(struct line *deck, char *tt, wordlist *end, bool reuse, cp_kwswitch(CT_NODENAMES, ft_curckt->ci_nodes); ft_newcirc(ct); /* Assign current circuit */ - ft_curckt = ct; + ft_curckt = ct; } ct->ci_name = tt; ct->ci_deck = deck; @@ -585,7 +650,7 @@ inp_dodeck(struct line *deck, char *tt, wordlist *end, bool reuse, ct->ci_origdeck = deck->li_actual; else ct->ci_origdeck = ct->ci_deck; - ct->ci_ckt = ckt; + ct->ci_ckt = ckt; /* attach the input ckt to the list of circuits */ ct->ci_symtab = tab; ct->ci_inprogress = FALSE; ct->ci_runonce = FALSE; @@ -616,24 +681,24 @@ inp_dodeck(struct line *deck, char *tt, wordlist *end, bool reuse, static int one = 1; switch (eev->va_type) { case VT_BOOL: - if_option(ct->ci_ckt, eev->va_name, - eev->va_type, &one); - break; + if_option(ct->ci_ckt, eev->va_name, + eev->va_type, &one); + break; case VT_NUM: - if_option(ct->ci_ckt, eev->va_name, - eev->va_type, (char *) &eev->va_num); - break; + if_option(ct->ci_ckt, eev->va_name, + eev->va_type, (char *) &eev->va_num); + break; case VT_REAL: - if_option(ct->ci_ckt, eev->va_name, - eev->va_type, (char *) &eev->va_real); - break; + if_option(ct->ci_ckt, eev->va_name, + eev->va_type, (char *) &eev->va_real); + break; case VT_STRING: - if_option(ct->ci_ckt, eev->va_name, - eev->va_type, eev->va_string); - break; - } + if_option(ct->ci_ckt, eev->va_name, + eev->va_type, eev->va_string); + break; + } /* switch . . . */ } - } + } /* if (!noparse) . . . */ cp_addkword(CT_CKTNAMES, tt); return; diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c index c68cd92c3..5641699f6 100644 --- a/src/frontend/inpcom.c +++ b/src/frontend/inpcom.c @@ -174,8 +174,10 @@ inp_readall(FILE *fp, struct line **data) while ((buffer = readline(fp))) { #endif - /* debug statement */ - /* printf ("in inp_readall, just read %s . . .\n", buffer); */ +#ifdef TRACE + /* SDB debug statement */ + printf ("in inp_readall, just read %s . . .\n", buffer); +#endif /* OK -- now we have loaded the next line into 'buffer'. Process it. */ /* If input line is blank, ignore it & continue looping. */ @@ -199,8 +201,9 @@ inp_readall(FILE *fp, struct line **data) fprintf(cp_err, "Warning: premature EOF\n"); } *s = '\0'; /* Zap the newline. */ - if ( s > buffer && s[-1] == '\r') /* Zap the carriage return under windows */ - s[-1] = '\0'; + + if(*(s-1) == '\r') /* Zop the carriage return under windows */ + *(s-1) = '\0'; /* now handle .include statements */ if (ciprefix(".include", buffer)) { @@ -304,8 +307,10 @@ inp_readall(FILE *fp, struct line **data) for (s = working->li_line; (c = *s) && c <= ' '; s++) ; - /* debug statement */ - /* printf("Now processing linked list, at s = %s . . . \n", s); */ +#ifdef TRACE + /* SDB debug statement */ + printf("In inp_readall, processing linked list element s = %s . . . \n", s); +#endif switch (c) { case '#': diff --git a/src/frontend/resource.c b/src/frontend/resource.c index d9fa08414..33e734722 100644 --- a/src/frontend/resource.c +++ b/src/frontend/resource.c @@ -326,6 +326,7 @@ baseaddr(void) if (getenv("SPICE_NO_DATASEG_CHECK")) return 0; + low = 0; high = (char *) ((unsigned long) sbrk(0) & ~((1 << LOG2_PAGESIZE) - 1)); diff --git a/src/frontend/spiceif.c b/src/frontend/spiceif.c index 34d6566c5..679325775 100644 --- a/src/frontend/spiceif.c +++ b/src/frontend/spiceif.c @@ -110,12 +110,8 @@ if_inpdeck(struct line *deck, INPtables **tab) ft_curckt->ci_curTask = ft_curckt->ci_defTask; - /* Debug statement */ - /* printf("In if_inpdeck, about to call INPpas1. . . \n"); */ INPpas1((void *) ckt, (card *) deck->li_next,(INPtables *)*tab); - /* Debug statement */ - /* printf("In if_inpdeck, about to call INPpas2. . . \n"); */ INPpas2((void *) ckt, (card *) deck->li_next, (INPtables *) *tab,ft_curckt->ci_defTask); INPkillMods(); diff --git a/src/frontend/subckt.c b/src/frontend/subckt.c index 46baaf888..f645e06bc 100644 --- a/src/frontend/subckt.c +++ b/src/frontend/subckt.c @@ -4,11 +4,39 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group Modified: 2000 AlansFixes **********/ +/*------------------------------------------------------------------------------ + * re-written by SDB during 4.2003 to enable SPICE2 POLY statements to be processed + * properly. This is particularly important for dependent sources, whose argument + * list changes when POLY is used. + * Major changes include: + * -- Added lots of comments which (hopefully) elucidate the steps taken + * by the program during its processing. + * -- Re-wrote translate, which does the processing of each card. + * Please direct comments/questions/complaints to Stuart Brorson: + * mailto:sdb@cloud9.net + *-----------------------------------------------------------------------------*/ + /* * Expand subcircuits. This is very spice-dependent. Bug fixes by Norbert * Jeske on 10/5/85. */ +/*======================================================================* + * Expand all subcircuits in the deck. This handles imbedded .subckt + * definitions. The variables substart, subend, and subinvoke can be used + * to redefine the controls used. The syntax is invariant though. + * NOTE: the deck must be passed without the title line. + * What we do is as follows: first make one pass through the circuit + * and collect all of the subcircuits. Then, whenever a line that starts + * with 'x' is found, copy the subcircuit associated with that name and + * splice it in. A few of the problems: the nodes in the spliced-in + * stuff must be unique, so when we copy it, append "subcktname:" to + * each node. If we are in a nested subcircuit, use foo:bar:...:node. + * Then we have to systematically change all references to the renamed + * nodes. On top of that, we have to know how many args BJT's have, + * so we have to keep track of model names. + *======================================================================*/ + #include "ngspice.h" #include "cpdefs.h" #include "ftedefs.h" @@ -23,7 +51,8 @@ Modified: 2000 AlansFixes #include "subckt.h" #include "variable.h" -/* static declarations */ + +/* ----- static declarations ----- */ static struct line * doit(struct line *deck); static int translate(struct line *deck, char *formal, char *actual, char *scname, char *subname); @@ -35,30 +64,29 @@ static int numdevs(char *s); static bool modtranslate(struct line *deck, char *subname); static void devmodtranslate(struct line *deck, char *subname); +/*--------------------------------------------------------------------- + * table is used in settrans and gettrans -- it holds the netnames used + * in the .subckt definition (t_old), and in the subcircuit invocation + * (t_new) + *--------------------------------------------------------------------*/ +static struct tab { + char *t_old; + char *t_new; +} table[512]; /* That had better be enough. */ +/*--------------------------------------------------------------------- + * subs is the linked list which holds the .subckt definitions + * found during processing. + *--------------------------------------------------------------------*/ struct subs { - char *su_name; /* The name. */ - char *su_args; /* The arguments, space seperated. */ + char *su_name; /* The .subckt name. */ + char *su_args; /* The .subckt arguments, space seperated. */ int su_numargs; - struct line *su_def; /* The deck that is to be substituted. */ + struct line *su_def; /* Pointer to the .subckt definition. */ struct subs *su_next; } ; -/* Expand all subcircuits in the deck. This handles imbedded .subckt - * definitions. The variables substart, subend, and subinvoke can be used - * to redefine the controls used. The syntax is invariant though. - * NOTE: the deck must be passed without the title line. - * What we do is as follows: first make one pass through the circuit - * and collect all of the subcircuits. Then, whenever a line that starts - * with 'x' is found, copy the subcircuit associated with that name and - * splice it in. A few of the problems: the nodes in the spliced-in - * stuff must be unique, so when we copy it, append "subcktname:" to - * each node. If we are in a nested subcircuit, use foo:bar:...:node. - * Then we have to systematically change all references to the renamed - * nodes. On top of that, we have to know how many args BJT's have, - * so we have to keep track of model names. - */ static wordlist *modnames, *submod; static struct subs *subs = NULL; @@ -66,6 +94,22 @@ static bool nobjthack = FALSE; static char start[32], sbend[32], invoke[32], model[32]; +/*-------------------------------------------------------------------*/ +/* inp_subcktexpand is the top level function which translates */ +/* .subckts into mainlined code. Note that there are two things */ +/* we need to do: 1. Find all .subckt definitions & stick them */ +/* into a list. 2. Find all subcircuit invocations (refdes X) */ +/* and replace them with the .subckt definition stored earlier. */ +/* */ +/* The algorithm is as follows: */ +/* 1. Define some aliases for .subckt, .ends, etc. */ +/* 2. Clean up parens around netnames */ +/* 3. Call doit, which does the actual translation. */ +/* 4. Check the results & return. */ +/* inp_subcktexpand takes as argument a pointer to deck, and */ +/* it returns a pointer to the same deck after the new subcircuits */ +/* are spliced in. */ +/*-------------------------------------------------------------------*/ struct line * inp_subcktexpand(struct line *deck) { @@ -87,38 +131,40 @@ inp_subcktexpand(struct line *deck) /* Let's do a few cleanup things first... Get rid of ( ) around node * lists... */ - for (c = deck; c; c = c->li_next) { - if (prefix(start, c->li_line)) { - for (s = c->li_line; *s && (*s != '('); s++) - ; - if (*s) { - while (s[0] && (s[1] != ')')) { - s[0] = s[1]; - s++; - } - while (s[1]) { - s[0] = s[2]; - s++; - } - } - } else { - for (s = c->li_line; *s && !isspace(*s); s++) - ; - while (isspace(*s)) - s++; - if (*s == '(') { - while (s[0] && (s[1] != ')')) { - s[0] = s[1]; - s++; - } - while (s[1]) { - s[0] = s[2]; - s++; - } - } - } - } + for (c = deck; c; c = c->li_next) { /* iterate on lines in deck */ + if (prefix(start, c->li_line)) { /* if we find .subckt . . . */ + for (s = c->li_line; *s && (*s != '('); s++) /* Iterate charwise along line until ( is found */ + ; + if (*s) { + while (s[0] && (s[1] != ')')) { + s[0] = s[1]; + s++; + } + while (s[1]) { + s[0] = s[2]; + s++; + } + } /* if (*s) . . . */ + } else { + for (s = c->li_line; *s && !isspace(*s); s++) /* Iterate charwise along line until space is found */ + ; + while (isspace(*s)) + s++; + if (*s == '(') { + while (s[0] && (s[1] != ')')) { + s[0] = s[1]; + s++; + } + while (s[1]) { + s[0] = s[2]; + s++; + } /* while */ + } /* if (*s == '(' . . . */ + } + } /* for (c = deck . . . */ + + /* doit does the actual splicing in of the .subckt . . . */ ll = doit(deck); /* Now check to see if there are still subckt instances undefined... */ @@ -129,16 +175,26 @@ inp_subcktexpand(struct line *deck) return NULL; } - return (ll); + return (ll); /* return the spliced deck. */ } -#define MAXNEST 21 +#define MAXNEST 21 +/*-------------------------------------------------------------------*/ +/* doit does the actual substitution of .subckts. */ +/* It takes two passes: the first extracts .subckts */ +/* and sticks pointer to them into the linked list sss. It does */ +/* the extraction recursively. Then, it look for subcircuit */ +/* invocations and substitutes the stored .subckt into */ +/* the main circuit file. */ +/* It takes as argument a pointer to the deck, and returns a */ +/* pointer to the deck after the subcircuit has been spliced in. */ +/*-------------------------------------------------------------------*/ static struct line * doit(struct line *deck) { struct line *c, *last, *lc, *lcc; - struct subs *sss = (struct subs *) NULL, *ks; + struct subs *sss = (struct subs *) NULL, *ks; /* *sss and *ks temporarily hold decks to substitute */ char *s, *t, *scname, *subname; int nest, numpasses = MAXNEST, i; bool gotone; @@ -153,51 +209,68 @@ doit(struct line *deck) subs = NULL; submod = NULL; - /* Extract all the .subckts */ - for (last = deck, lc = NULL; last; ) { - if (prefix(sbend, last->li_line)) { + /* First pass: xtract all the .subckts and stick pointers to them into sss. */ + for (last = deck, lc = NULL; last; ) { + if (prefix(sbend, last->li_line)) { /* if line == .ends */ fprintf(cp_err, "Error: misplaced %s line: %s\n", sbend, last->li_line); return (NULL); - } else if (prefix(start, last->li_line)) { - if (last->li_next == NULL) { + } + else if (prefix(start, last->li_line)) { /* if line == .subckt */ + if (last->li_next == NULL) { /* first check that next line is non null */ fprintf(cp_err, "Error: no %s line.\n", sbend); return (NULL); } - lcc = NULL; + lcc = NULL; wl_free(submod); submod = NULL; gotone = FALSE; - for (nest = 0, c = last->li_next; c; c = c->li_next) { - if (prefix(sbend, c->li_line)) { + + /* Here we loop through the deck looking for .subckt and .ends cards. + * At the end of this section, last will point to the location of the + * .subckt card, and lcc will point to the location of the .ends card. + */ + for (nest = 0, c = last->li_next; c; c = c->li_next) { + if (prefix(sbend, c->li_line)) { /* found a .ends */ if (!nest) - break; + break; /* nest = 0 means we have balanced .subckt and .ends */ else { - nest--; - lcc = c; - continue; + nest--; /* decrement nesting, and assign lcc to the current card */ + lcc = c; /* (lcc points to the position of the .ends) */ + continue; /* then continue looping */ } - } else if (prefix(start, c->li_line)) + } else if (prefix(start, c->li_line)) /* if .subckt, increment nesting */ nest++; - lcc = c; - } - if (!c) { + lcc = c; /* lcc points to current pos of c */ + } /* for (nest = 0 . . . */ + + /* Check to see if we have looped through remainder of deck without finding .ends */ + if (!c) { fprintf(cp_err, "Error: no %s line.\n", sbend); - return (NULL); + return (NULL); } + + sss = alloc(struct subs); - if (!lcc) + if (!lcc) /* if lcc is null, then no .ends was found. */ lcc = last; - lcc->li_next = NULL; + lcc->li_next = NULL; /* shouldn't we free some memory here????? */ + + /* At this point, last points to the .subckt card, and lcc points to the .ends card */ + + /* what does this do!??!?! */ if (lc) lc->li_next = c->li_next; else deck = c->li_next; - sss->su_def = last->li_next; - s = last->li_line; + + /* Now put the .subckt definition found into sss */ + sss->su_def = last->li_next; + s = last->li_line; (void) gettok(&s); sss->su_name = gettok(&s); sss->su_args = copy(s); + /* count the number of args in the .subckt line */ for (sss->su_numargs = 0, i = 0; s[i]; ) { while (isspace(s[i])) i++; @@ -207,26 +280,40 @@ doit(struct line *deck) i++; } } - sss->su_next = subs; - subs = sss; + sss->su_next = subs; + subs = sss; /* Now that sss is built, assign it to subs */ last = c->li_next; lcc = subs->su_def; - } else { - lc = last; + + } + else { /* line is neither .ends nor .subckt. */ + /* make lc point to this card, and advance last to next card. */ + lc = last; last = last->li_next; } - } + } /* for (last = deck . . . . */ - if (!sss) + + /* At this point, sss holds the .subckt definition found, subs holds + * all .subckt defs found, including this one, + * last points to the NULL at the end of the deck, + * lc points to the last non-.subckt or .ends card, + * and lcc points to the .ends card + */ + + if (!sss) /* if sss == FALSE, we have found no subckts. Just return. */ return (deck); - /* Expand sub-subcircuits. */ - for (ks = sss = subs; sss; sss = sss->su_next) + /* Otherwise, expand sub-subcircuits recursively. */ + for (ks = sss = subs; sss; sss = sss->su_next) /* iterate through the list of subcircuits */ if (!(sss->su_def = doit(sss->su_def))) return (NULL); - subs = ks; + subs = ks; /* ks has held pointer to start of subcircuits list. */ - /* Get all the model names so we can deal with BJT's. */ + + /* Get all the model names so we can deal with BJT's. + * Stick all the model names into the doubly-linked wordlist wl. + */ for (c = deck; c; c = c->li_next) if (prefix(model, c->li_line)) { s = c->li_line; @@ -236,22 +323,30 @@ doit(struct line *deck) if (modnames) modnames->wl_prev = wl; modnames = wl; - wl->wl_word = gettok(&s); + wl->wl_word = gettok(&s); /* wl->wl_word now holds name of model */ } error = 0; - /* Now do the replacements. */ - do { + /* Second pass: do the replacements. */ + do { /* while (!error && numpasses-- && gotone) */ gotone = FALSE; for (c = deck, lc = NULL; c; ) { - if (ciprefix(invoke, c->li_line)) { + if (ciprefix(invoke, c->li_line)) { /* found reference to .subckt (i.e. component with refdes X) */ gotone = TRUE; - t = s = copy(c->li_line); - scname = gettok(&s); - scname += strlen(invoke); + t = s = copy(c->li_line); /* s & t hold copy of component line */ + + /* make scname point to first non-whitepace chars after refdes invocation + * e.g. if invocation is Xreference, *scname = reference + */ + scname = gettok(&s); + scname += strlen(invoke); while ((*scname == ' ') || (*scname == '\t') || (*scname == ':')) scname++; + + /* Now set s to point to last non-space chars in line (i.e. + * the name of the model invoked + */ while(*s) s++; s--; @@ -260,30 +355,46 @@ doit(struct line *deck) while ((*s != ' ') && (*s != '\t')) s--; s++; - for (sss = subs; sss; sss = sss->su_next) + + /* iterate through .subckt list and look for .subckt name invoked */ + for (sss = subs; sss; sss = sss->su_next) if (eq(sss->su_name, s)) break; - /* Don't complain -- this might be an - * instance of a subckt that is defined above. + + + /* At this point, sss points to the .subckt invoked, + * and scname points to the netnames + * involved. + */ + + + /* If no .subckt is found, don't complain -- this might be an + * instance of a subckt that is defined above at higher level. */ if (!sss) { lc = c; c = c->li_next; continue; } + /* Now we have to replace this line with the * macro definition. */ - subname = copy(sss->su_name); - lcc = inp_deckcopy(sss->su_def); + subname = copy(sss->su_name); - /* Change the names of the models... */ - if (modtranslate(lcc, scname)) + /* make lcc point to a copy of the .subckt definition */ + lcc = inp_deckcopy(sss->su_def); + + /* Change the names of .models found in .subckts . . . */ + if (modtranslate(lcc, scname)) devmodtranslate(lcc, scname); s = sss->su_args; - (void) gettok(&t); /* Throw out the name. */ + (void) gettok(&t); /* Throw out the subcircuit refdes */ + /* now invoke translate, which handles the remainder of the + * translation. + */ if (!translate(lcc, s, t, scname, subname)) error = 1; @@ -297,13 +408,15 @@ doit(struct line *deck) lcc->li_next = c->li_next; c = lcc->li_next; lc = lcc; - } else { + } /* if (ciprefix(invoke, c->li_line)) . . . */ + else { lc = c; c = c->li_next; } } } while (!error && numpasses-- && gotone); + if (!numpasses) { fprintf(cp_err, "Error: infinite subckt recursion\n"); return (NULL); @@ -320,8 +433,11 @@ doit(struct line *deck) return (deck); } -/* Copy a deck, including the actual lines. */ + +/*-------------------------------------------------------------------*/ +/* Copy a deck, including the actual lines. */ +/*-------------------------------------------------------------------*/ struct line * inp_deckcopy(struct line *deck) { @@ -343,28 +459,28 @@ inp_deckcopy(struct line *deck) return (nd); } -/* Translate all of the device names and node names in the deck. They are +/*------------------------------------------------------------------------------------------* + * Translate all of the device names and node names in the .subckt deck. They are * pre-pended with subname:, unless they are in the formal list, in which case * they are replaced with the corresponding entry in the actual list. * The one special case is node 0 -- this is always ground and we don't * touch it. - */ - + * + * Variable name meanings: + * *deck = pointer to subcircuit definition (lcc) (struct line) + * formal = copy of the .subckt definition line (e.g. ".subckt subcircuitname 1 2 3") (string) + * actual = copy of the .subcircuit invocation line (e.g. "Xexample 4 5 6 subcircuitname") (string) + * scname = refdes (- first letter) used at invocation (e.g. "example") (string) + * subname = copy of the subcircuit name + *-------------------------------------------------------------------------------------------*/ static int translate(struct line *deck, char *formal, char *actual, char *scname, char *subname) { struct line *c; - char *buffer, *name, *s, *t, ch; - int nnodes, i; - -#ifdef XSPICE - /* gtri - add - wbk - 10/23/90 - add new local variables */ - - char *next_name; /* for look-ahead during tokenizing */ - - /* gtri - end - wbk - 10/23/90 */ -#endif + char *buffer, *next_name, dev_type, *name, *s, *t, ch; + int nnodes, i, dim; + /* settrans builds the table holding the translated netnames. */ i = settrans(formal, actual, subname); if (i < 0) { fprintf(stderr, @@ -378,16 +494,30 @@ translate(struct line *deck, char *formal, char *actual, char *scname, char *sub return 0; } - for (c = deck; c; c = c->li_next) { - /* Rename the device. */ - switch (*c->li_line) { + /* now iterate through the .subckt deck and translate the cards. */ + for (c = deck; c; c = c->li_next) { + +#ifdef TRACE + /* SDB debug statement */ + printf("\nIn translate, examining line %s \n", c->li_line); +#endif + + + dev_type = *(c->li_line); + + /* Rename the device. */ + switch (dev_type) { case '\0': case '*': case '.': - /* Nothing any good here. */ - continue; + /* Just a pointer to the line into s and then break */ + buffer = tmalloc(2000); /* XXXXX */ + s = c->li_line; + break; + #ifdef XSPICE +/*=================== case A ====================*/ /* gtri - add - wbk - 10/23/90 - process A devices specially */ /* since they have a more involved and variable length node syntax */ @@ -396,7 +526,7 @@ translate(struct line *deck, char *formal, char *actual, char *scname, char *sub /* translate the instance name according to normal rules */ - buffer = tmalloc(10000); /* XXXXX */ + buffer = tmalloc(2000); /* XXXXX */ s = c->li_line; name = MIFgettok(&s); @@ -477,81 +607,289 @@ translate(struct line *deck, char *formal, char *actual, char *scname, char *sub /* after switch statement */ s = ""; - break; /* gtri - end - wbk - 10/23/90 */ #endif - default: - s = c->li_line; - name = gettok(&s); - if (!name) - continue; - if (!*name) { - tfree(name); - continue; - } - ch = *name; - buffer = tmalloc(10000); /* XXXXX */ - name++; - if (*name == ':') - name++; - if (*name) - (void) sprintf(buffer, "%c:%s:%s ", ch, scname, - name); - else - (void) sprintf(buffer, "%c:%s ", ch, scname); +/*================ case E, F, G, H ================*/ +/* This section handles controlled sources and allows for SPICE2 POLY attributes. + * This is a new section, added by SDB to handle POLYs in sources. Significant + * changes were made in here. + * 4.21.2003 -- SDB. mailto:sdb@cloud9.net + */ + case 'E': case 'e': + case 'F': case 'f': + case 'G': case 'g': + case 'H': case 'h': - nnodes = numnodes(c->li_line); - while (nnodes-- > 0) { - name = gettok(&s); - if (name == NULL) { - fprintf(cp_err, "Error: too few nodes: %s\n", - c->li_line); - return 0; - } - t = gettrans(name); - if (t) - (void) sprintf(buffer + strlen(buffer), "%s ", - t); - else - (void) sprintf(buffer + strlen(buffer), - "%s:%s ", scname, name); - } - nnodes = numdevs(c->li_line); - while (nnodes-- > 0) { - name = gettok(&s); - if (name == NULL) { - fprintf(cp_err, "Error: too few devs: %s\n", - c->li_line); - return 0; - } - ch = *name; - name++; - if (*name == ':') - name++; - if (*name) - (void) sprintf(buffer + strlen(buffer), - "%c:%s:%s ", ch, scname, name); - else - (void) sprintf(buffer + strlen(buffer), - "%c:%s ", ch, scname); - } - /* Now scan through the line for v(something) and - * i(something)... - */ - finishLine(buffer + strlen(buffer), s, scname); - s = ""; - } - (void) strcat(buffer, s); + + s = c->li_line; /* s now holds the SPICE line */ + name = gettok(&s); /* name points to the refdes */ + if (!name) + continue; + if (!*name) { + tfree(name); + continue; + } + +/* Here's where we translate the refdes to e.g. F:subcircuitname:57 + * and stick the translated name into buffer. + */ + ch = *name; /* ch identifies the type of component */ + buffer = tmalloc(2000); /* XXXXX */ + name++; + if (*name == ':') + name++; /* now name point to the rest of the refdes */ + + + if (*name) + (void) sprintf(buffer, "%c:%s:%s ", ch, scname, /* F:subcircuitname:refdesname */ + name); + else + (void) sprintf(buffer, "%c:%s ", ch, scname); /* F:subcircuitname */ + + +/* Next iterate over all nodes (netnames) found and translate them. */ + nnodes = numnodes(c->li_line); + + while (nnodes-- > 0) { + name = gettok(&s); + if (name == NULL) { + fprintf(cp_err, "Error: too few nodes: %s\n", + c->li_line); + return 0; + } + + /* call gettrans and see if netname was used in the invocation */ + t = gettrans(name); + + if (t) { /* the netname was used during the invocation; print it into the buffer */ + (void) sprintf(buffer + strlen(buffer), "%s ", t); + } + else { /* net netname was not used during the invocation; place a + * translated name into the buffer. + */ + (void) sprintf(buffer + strlen(buffer), + "%s:%s ", scname, name); + } + } /* while (nnodes-- . . . . */ + + +/* Next we handle the POLY (if any) */ + /* get next token */ + t = s; + next_name = (char *)gettok_noparens(&t); + if ( (strcmp(next_name, "POLY") == 0) || + (strcmp(next_name, "poly") == 0)) { /* found POLY . . . . */ + +#ifdef TRACE + /* SDB debug statement */ + printf("In translate, looking at e, f, g, h found poly\n"); +#endif + + /* move pointer ahead of paren */ + if( get_l_paren(&s) == 1 ) { + fprintf(cp_err, "Error: no left paren after POLY %s\n", + c->li_line); + return 0; + } + + dim = (int *) atoi( (char *)gettok_noparens(&s) ); /* convert returned string to int */ + + /* move pointer ahead of ) */ + if( get_r_paren(&s) == 1 ) { + fprintf(cp_err, "Error: no right paren after POLY %s\n", + c->li_line); + return 0; + } + + /* Write POLY(dim) into buffer */ + (void) sprintf(buffer + strlen(buffer), + "POLY( %d ) ", dim); + + + } /* if ( (strcmp(next_name, "POLY") == 0) . . . */ + else + dim = 1; /* only one controlling source . . . */ + +/* Now translate the controlling source/nodes */ + nnodes = dim * numdevs(c->li_line); + while (nnodes-- > 0) { + name = gettok(&s); /* name points to the returned token */ + if (name == NULL) { + fprintf(cp_err, "Error: too few devs: %s\n", + c->li_line); + return 0; + } + + if ( (dev_type == 'f') || + (dev_type == 'F') || + (dev_type == 'h') || + (dev_type == 'H') ) { + + /* + if ( (strcmp(&dev_type, "f") == 0) || + (strcmp(&dev_type, "F") == 0) || + (strcmp(&dev_type, "h") == 0) || + (strcmp(&dev_type, "H") == 0) ) { + */ + + /* Handle voltage source name */ + +#ifdef TRACE + /* SDB debug statement */ + printf("In translate, found type f or h\n"); +#endif + + ch = *name; /* ch is the first char of the token. */ + name++; + if (*name == ':') + name++; /* name now points to the remainder of the token */ + (void) sprintf(buffer + strlen(buffer), + "%c:%s:%s ", ch, scname, name); + /* From Vsense and Urefdes creates V:Urefdes:sense */ + } + else { /* Handle netname */ + +#ifdef TRACE + /* SDB debug statement */ + printf("In translate, found type e or g\n"); +#endif + + /* call gettrans and see if netname was used in the invocation */ + t = gettrans(name); + + if (t) { /* the netname was used during the invocation; print it into the buffer */ + (void) sprintf(buffer + strlen(buffer), "%s ", t); + } + else { /* net netname was not used during the invocation; place a + * translated name into the buffer. + */ + (void) sprintf(buffer + strlen(buffer), + "%s:%s ", scname, name); + /* From netname and Urefdes creates Urefdes:netname */ + } + } + } /* while (nnodes--. . . . */ + +/* Now write out remainder of line (polynomial coeffs) */ + finishLine(buffer + strlen(buffer), s, scname); + s = ""; + break; + + +/*================= Default case ===================*/ + default: /* this section handles ordinary components */ + s = c->li_line; + name = gettok(&s); + if (!name) + continue; + if (!*name) { + tfree(name); + continue; + } + +/* Here's where we translate the refdes to e.g. R:subcircuitname:57 + * and stick the translated name into buffer. + */ + ch = *name; + buffer = tmalloc(2000); /* XXXXX */ + name++; + if (*name == ':') + name++; + + if (*name) + (void) sprintf(buffer, "%c:%s:%s ", ch, scname, + name); + else + (void) sprintf(buffer, "%c:%s ", ch, scname); + + + +/* Next iterate over all nodes (netnames) found and translate them. */ + nnodes = numnodes(c->li_line); + + while (nnodes-- > 0) { + name = gettok(&s); + if (name == NULL) { + fprintf(cp_err, "Error: too few nodes: %s\n", + c->li_line); + return 0; + } + + /* call gettrans and see if netname was used in the invocation */ + t = gettrans(name); + + if (t) { /* the netname was used during the invocation; print it into the buffer */ + (void) sprintf(buffer + strlen(buffer), "%s ", t); + } + else { /* net netname was not used during the invocation; place a + * translated name into the buffer. + */ + (void) sprintf(buffer + strlen(buffer), + "%s:%s ", scname, name); + } + } /* while (nnodes-- . . . . */ + +/* Now translate any devices (i.e. controlling sources). + * This may be supurfluous because we handle dependent + * source devices above . . . . + */ + nnodes = numdevs(c->li_line); + while (nnodes-- > 0) { + name = gettok(&s); + if (name == NULL) { + fprintf(cp_err, "Error: too few devs: %s\n", + c->li_line); + return 0; + } + ch = *name; + name++; + if (*name == ':') + name++; + + if (*name) + (void) sprintf(buffer + strlen(buffer), + "%c:%s:%s ", ch, scname, name); + else + (void) sprintf(buffer + strlen(buffer), + "%c:%s ", ch, scname); + + } /* while (nnodes--. . . . */ + + +/* Now we finish off the line. For most components (R, C, etc), + * this involves adding the component value to the buffer. + * We also scan through the line for v(something) and + * i(something)... + */ + finishLine(buffer + strlen(buffer), s, scname); + s = ""; + + } /* switch(c->li_line . . . . */ + + (void) strcat(buffer, s); tfree(c->li_line); c->li_line = copy(buffer); + +#ifdef TRACE + /* SDB debug statement */ + printf("In translate, translated line = %s \n", c->li_line); +#endif + tfree(buffer); - } + } /* for (c = deck . . . . */ return 1; } + + +/*-------------------------------------------------------------------* + * finishLine now doesn't handle current or voltage sources. + * Therefore, it just writes out the final netnames, if required. + * Changes made by SDB on 4.29.2003. + *-------------------------------------------------------------------*/ static void finishLine(char *dst, char *src, char *scname) { @@ -600,10 +938,10 @@ finishLine(char *dst, char *src, char *scname) if (s) { while (*s) *dst++ = *s++; - } else { + } + else { /* just a normal netname . . . . */ /* - * i(vname) -> i(v:subckt:name) - * i(v:other:name) -> i(v:subckt:other:name) + * */ if (buf[0] == 'v' || buf[0] == 'V') { *dst++ = buf[0]; @@ -648,11 +986,17 @@ finishLine(char *dst, char *src, char *scname) return; } -static struct tab { - char *t_old; - char *t_new; -} table[512]; /* That had better be enough. */ - +/*------------------------------------------------------------------------------* + * settrans builds the table which holds the old and new netnames. + * it also compares the number of nets present in the .subckt definition against + * the number of nets present in the subcircuit invocation. It returns 0 if they + * match, otherwise, it returns an error. + * + * Variable definitions: + * formal = copy of the .subckt definition line (e.g. ".subckt subcircuitname 1 2 3") (string) + * actual = copy of the .subcircuit invocation line (e.g. "Xexample 4 5 6 subcircuitname") (string) + * subname = copy of the subcircuit name + *------------------------------------------------------------------------------*/ static int settrans(char *formal, char *actual, char *subname) { @@ -674,6 +1018,11 @@ settrans(char *formal, char *actual, char *subname) return 0; } + +/*------------------------------------------------------------------------------* + * gettrans returns the name of the top level net if it is in the list, + * otherwise it returns NULL. + *------------------------------------------------------------------------------*/ static char * gettrans(char *name) { @@ -694,6 +1043,8 @@ gettrans(char *name) return (NULL); } +/*-------------------------------------------------------------------*/ +/*-------------------------------------------------------------------*/ static int numnodes(char *name) { @@ -702,7 +1053,6 @@ numnodes(char *name) /* nodes even if they know how many there are. Modify the callers */ /* instead. */ /* gtri - end - wbk - 10/23/90 */ - char c; struct subs *sss; char *s, *t, buf[4 * BSIZE_SP]; @@ -734,6 +1084,7 @@ numnodes(char *name) } return (sss->su_numargs); } + n = inp_numnodes(c); /* Added this code for variable number of nodes on BSIM3SOI devices */ @@ -744,75 +1095,101 @@ numnodes(char *name) /* I hope that works, this code is very very untested */ - if (c=='m') { /* IF this is a mos */ + if (c=='m') { /* IF this is a mos */ - i = 0; + i = 0; s = buf; gotit = 0; - t = gettok(&s); /* Skip component name */ + t = gettok(&s); /* Skip component name */ while ((i < n) && (*s) && !gotit) { - t = gettok(&s); - for (wl = modnames; wl; wl = wl->wl_next) - if (eq(t, wl->wl_word)) - gotit = 1; - i++; - } + t = gettok(&s); + for (wl = modnames; wl; wl = wl->wl_next) + if (eq(t, wl->wl_word)) + gotit = 1; + i++; + } /* while . . . . */ - /* Note: node checks must be done on #_of_node-1 because the */ - /* "while" cicle increments the counter even when a model is */ - /* recognized. This code may be better! */ + /* Note: node checks must be done on #_of_node-1 because the */ + /* "while" cicle increments the counter even when a model is */ + /* recognized. This code may be better! */ - if (i < 5) { - fprintf(cp_err, "Error: too few nodes for MOS: %s\n", name); - return(0); - } - return(i-1); /* compesate the unnecessary inrement in the while cicle */ - } + if (i < 5) { + fprintf(cp_err, "Error: too few nodes for MOS: %s\n", name); + return(0); + } + return(i-1); /* compesate the unnecessary inrement in the while cicle */ + } /* if (c=='m' . . . */ if (nobjthack || (c != 'q')) return (n); + for (s = buf, i = 0; *s && (i < 4); i++) (void) gettok(&s); + if (i == 3) return (3); + else if (i < 4) { fprintf(cp_err, "Error: too few nodes for BJT: %s\n", name); return (0); } + /* Now, is this a model? */ t = gettok(&s); for (wl = modnames; wl; wl = wl->wl_next) - if (eq(t, wl->wl_word)) - return (3); + if (eq(t, wl->wl_word)) + return (3); return (4); } + +/*-------------------------------------------------------------------* + * This function returns the number of controlling voltage sources + * (for F, H) or controlling nodes (for G, E) attached to a dependent + * source. + *-------------------------------------------------------------------*/ static int numdevs(char *s) { - while (*s && isspace(*s)) - s++; - switch (*s) { - case 'K': - case 'k': - return (2); + while (*s && isspace(*s)) + s++; + switch (*s) { + case 'K': + case 'k': + return (2); - case 'F': - case 'f': - case 'H': - case 'h': + /* two nodes per voltage controlled source */ + case 'G': + case 'g': + case 'E': + case 'e': + return(2); + + /* one source per current controlled source */ + case 'F': + case 'f': + case 'H': + case 'h': /* 2 lines here added to fix w bug, NCF 1/31/95 */ - case 'W': - case 'w': - return (1); + case 'W': + case 'w': + return (1); default: return (0); } } +/*----------------------------------------------------------------------* + * modtranslate -- translates .model liness found in subckt definitions. + * Calling arguments are: + * *deck = pointer to the .subckt definition (linked list) + * *subname = pointer to the subcircuit name used at the subcircuit invocation (string) + * Modtranslate returns TRUE if it translated a model name, FALSE + * otherwise. + *----------------------------------------------------------------------*/ static bool modtranslate(struct line *deck, char *subname) { @@ -823,23 +1200,23 @@ modtranslate(struct line *deck, char *subname) (void) strcpy(model, ".model"); gotone = FALSE; - for (c = deck; c; c = c->li_next) { + for (c = deck; c; c = c->li_next) { /* iterate through model def . . . */ if (prefix(model, c->li_line)) { gotone = TRUE; t = c->li_line; - name = gettok(&t); + name = gettok(&t); /* at this point, name = .model */ buffer = tmalloc(strlen(name) + strlen(t) + strlen(subname) + 4); - (void) sprintf(buffer, "%s ",name); - name = gettok(&t); + (void) sprintf(buffer, "%s ",name); /* at this point, buffer = ".model " */ + name = gettok(&t); /* name now holds model name */ wlsub = alloc(struct wordlist); wlsub->wl_next = submod; if (submod) submod->wl_prev = wlsub; submod = wlsub; wlsub->wl_word = name; - (void) sprintf(buffer + strlen(buffer), "%s:%s ", - subname, name); + (void) sprintf(buffer + strlen(buffer), "%s:%s ", + subname, name); /* buffer = "model subname:modelname " */ (void) strcat(buffer, t); tfree(c->li_line); c->li_line = buffer; @@ -856,6 +1233,11 @@ modtranslate(struct line *deck, char *subname) return(gotone); } + +/*-------------------------------------------------------------------* + * Devmodtranslate translates ?????? + * + *-------------------------------------------------------------------*/ static void devmodtranslate(struct line *deck, char *subname) { @@ -1060,11 +1442,13 @@ devmodtranslate(struct line *deck, char *subname) return; } -/* This is a spice-dependent thing. It should probably go somewhere +/*----------------------------------------------------------------------* + * inp_numnodes returns the number of nodes (netnames) attached to the + * component. + * This is a spice-dependent thing. It should probably go somewhere * else, but... Note that we pretend that dependent sources and mutual * inductors have more nodes than they really do... - */ - + *----------------------------------------------------------------------*/ int inp_numnodes(char c) { @@ -1081,9 +1465,9 @@ inp_numnodes(char c) case 'b': return (2); case 'c': return (2); case 'd': return (2); - case 'e': return (4); + case 'e': return (2); /* changed from 4 to 2 by SDB on 4.22.2003 to enable POLY */ case 'f': return (2); - case 'g': return (4); + case 'g': return (2); /* changed from 4 to 2 by SDB on 4.22.2003 to enable POLY */ case 'h': return (2); case 'i': return (2); case 'j': return (3); @@ -1107,3 +1491,10 @@ inp_numnodes(char c) } } + + + + + + + diff --git a/src/include/fteinp.h b/src/include/fteinp.h index 0efc28c43..22eabc40c 100644 --- a/src/include/fteinp.h +++ b/src/include/fteinp.h @@ -13,6 +13,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "inpdefs.h" +/* This struct defines a linked list of lines from a SPICE file. */ struct line { int li_linenum; char *li_line; diff --git a/src/include/ngspice.h b/src/include/ngspice.h index b4b61392f..e9fb9bdaa 100644 --- a/src/include/ngspice.h +++ b/src/include/ngspice.h @@ -3,6 +3,18 @@ * 1999 E. Rouat ************/ +/* Uncomment this to get trace of program operation for + * debugging + */ +/* #define TRACE */ + +/* This was also added by SDB to aid in + * debugging. Remove when finished. + */ + +/* #include "memwatch.h" + #define MEMWATCH */ + /* * This file will eventually replace spice.h and lots of other * files in src/include diff --git a/src/main.c b/src/main.c index 3980d9e0b..b04d6bd46 100644 --- a/src/main.c +++ b/src/main.c @@ -5,6 +5,7 @@ Author: 1985 Wayne A. Christopher The main routine for ngspice */ + #include #include @@ -326,6 +327,22 @@ main(int argc, char **argv) FILE *circuit_file; + +#ifdef TRACE + /* this is used to detect memory leaks during debugging */ + /* added by SDB during debug . . . . */ + /* mtrace(); */ +#endif + +#ifdef TRACE + /* this is also used for memory leak plugging . . . */ + /* added by SDB during debug . . . . */ + /* mwDoFlush(1); */ +#endif + + + + /* MFB tends to jump to 0 on errors. This tends to catch it. */ if (started) { fprintf(cp_err, "main: Internal Error: jump to zero\n"); diff --git a/src/misc/string.c b/src/misc/string.c index e0c9a7642..ccba3b4e4 100644 --- a/src/misc/string.c +++ b/src/misc/string.c @@ -159,6 +159,76 @@ gettok(char **s) return (copy(buf)); } +/*-------------------------------------------------------------------------* + * gettok_noparens was added by SDB on 4.21.2003. + * It acts like gettok, except that it stops parsing when it hits a paren + * (i.e. it treats parens like whitespace). It is used in translate (subckt.c) + * while looking for the POLY token. + *-------------------------------------------------------------------------*/ +char * +gettok_noparens(char **s) +{ + char buf[BSIZE_SP]; + int i = 0; + char c; + + while (isspace(**s)) + (*s)++; + if (!**s) + return (NULL); + while ((c = **s) && !isspace(c) && + ( **s != '(' ) && ( **s != ')' ) ) { + buf[i++] = *(*s)++; + } + buf[i] = '\0'; + while (isspace(**s)) + (*s)++; + return (copy(buf)); +} + +/*-------------------------------------------------------------------------* + * get_l_paren iterates the pointer forward in a string until it hits + * the position after the next left paren "(". It returns 0 if it found a left + * paren, and 1 if no left paren is found. + *-------------------------------------------------------------------------*/ +int +get_l_paren(char **s) +{ + while (**s && ( **s != '(' ) ) + (*s)++; + if (!**s) + return (1); + + (*s)++; + + if (!**s) + return (1); + else + return 0; +} + + +/*-------------------------------------------------------------------------* + * get_r_paren iterates the pointer forward in a string until it hits + * the position after the next right paren ")". It returns 0 if it found a right + * paren, and 1 if no right paren is found. + *-------------------------------------------------------------------------*/ +int +get_r_paren(char **s) +{ + while (**s && ( **s != ')' ) ) + (*s)++; + if (!**s) + return (1); + + (*s)++; + + if (!**s) + return (1); + else + return 0; +} + #ifndef HAVE_BCOPY diff --git a/src/spicelib/analysis/cktmcrt.c b/src/spicelib/analysis/cktmcrt.c index abe7a9ea2..b1b210fed 100644 --- a/src/spicelib/analysis/cktmcrt.c +++ b/src/spicelib/analysis/cktmcrt.c @@ -27,7 +27,7 @@ CKTmodCrt(void *ckt, int type, void **modfast, IFuid name) error = CKTfndMod(ckt,&type,(void**)&mymodfast,name); if(error == E_NOMOD) { - mymodfast = (GENmodel *)MALLOC(*DEVices[type]->DEVmodSize); + mymodfast = (GENmodel *)MALLOC(*(DEVices[type]->DEVmodSize)); if(mymodfast == (GENmodel *)NULL) return(E_NOMEM); mymodfast->GENmodType = type; mymodfast->GENmodName = name; diff --git a/src/spicelib/analysis/cktsens.c b/src/spicelib/analysis/cktsens.c index ec6331147..2422231d7 100644 --- a/src/spicelib/analysis/cktsens.c +++ b/src/spicelib/analysis/cktsens.c @@ -71,7 +71,7 @@ int sens_sens(CKTcircuit *ckt, int restart) int (*fn)( ); static int is_dc; int k, j, n; - int num_vars, branch_eq; + int num_vars, branch_eq=0; char *sen_data=NULL; char namebuf[513]; IFuid *output_names, freq_name; @@ -601,7 +601,7 @@ inc_freq(double freq, int type, double step_size) double next_freq(int type, double freq, double stepsize) { - double s; + double s=0; switch (type) { case SENS_DC: diff --git a/src/spicelib/analysis/cktterr.c b/src/spicelib/analysis/cktterr.c index 611c413de..ef45889fd 100644 --- a/src/spicelib/analysis/cktterr.c +++ b/src/spicelib/analysis/cktterr.c @@ -20,7 +20,7 @@ CKTterr(int qcap, CKTcircuit *ckt, double *timeStep) double del; double diff[8]; double deltmp[8]; - double factor; + double factor=0; int i; int j; static double gearCoeff[] = { diff --git a/src/spicelib/devices/ChangeLog b/src/spicelib/devices/ChangeLog index 0e1975836..278120a05 100644 --- a/src/spicelib/devices/ChangeLog +++ b/src/spicelib/devices/ChangeLog @@ -1,3 +1,8 @@ +5.2.2003 -- Stuart Brorson * asrc/asrcset.c, bjt/bjtsetup.c, bsim1/b1set.c, bsim2/b2set.c, diff --git a/src/spicelib/devices/asrc/asrcinit.c b/src/spicelib/devices/asrc/asrcinit.c index 85abf9816..d2110fbbf 100644 --- a/src/spicelib/devices/asrc/asrcinit.c +++ b/src/spicelib/devices/asrc/asrcinit.c @@ -21,6 +21,23 @@ SPICEdev ASRCinfo = { 0, NULL, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + + DEV_DEFAULT }, diff --git a/src/spicelib/devices/bjt/bjtdisto.c b/src/spicelib/devices/bjt/bjtdisto.c index a5bfc39bd..9810f72ec 100644 --- a/src/spicelib/devices/bjt/bjtdisto.c +++ b/src/spicelib/devices/bjt/bjtdisto.c @@ -24,21 +24,21 @@ BJTdisto(int mode, GENmodel *genmodel, CKTcircuit *ckt) DISTOAN* job = (DISTOAN*) ckt->CKTcurJob; double td; DpassStr pass; - double r1h1x,i1h1x; - double r1h1y,i1h1y; - double r1h1z, i1h1z; - double r1h2x, i1h2x; - double r1h2y, i1h2y; - double r1h2z, i1h2z; - double r1hm2x,i1hm2x; - double r1hm2y,i1hm2y; - double r1hm2z, i1hm2z; - double r2h11x,i2h11x; - double r2h11y,i2h11y; - double r2h11z, i2h11z; - double r2h1m2x,i2h1m2x; - double r2h1m2y,i2h1m2y; - double r2h1m2z, i2h1m2z; + double r1h1x = 0, i1h1x = 0; + double r1h1y = 0, i1h1y = 0; + double r1h1z = 0, i1h1z = 0; + double r1h2x = 0, i1h2x = 0; + double r1h2y = 0, i1h2y = 0; + double r1h2z = 0, i1h2z = 0; + double r1hm2x = 0, i1hm2x = 0; + double r1hm2y = 0, i1hm2y = 0; + double r1hm2z = 0, i1hm2z = 0; + double r2h11x = 0, i2h11x = 0; + double r2h11y = 0, i2h11y = 0; + double r2h11z = 0, i2h11z = 0; + double r2h1m2x = 0, i2h1m2x = 0; + double r2h1m2y = 0, i2h1m2y = 0; + double r2h1m2z = 0, i2h1m2z = 0; double temp, itemp; BJTinstance *here; #ifdef DISTODEBUG diff --git a/src/spicelib/devices/bjt/bjtdset.c b/src/spicelib/devices/bjt/bjtdset.c index 884c95390..89c4af610 100644 --- a/src/spicelib/devices/bjt/bjtdset.c +++ b/src/spicelib/devices/bjt/bjtdset.c @@ -28,9 +28,9 @@ BJTdSetup(GENmodel *inModel, CKTcircuit *ckt) double arg; double c2; double c4; - double lcapbe1,lcapbe2,lcapbe3; - double lcapbx1,lcapbx2,lcapbx3; - double cb; + double lcapbe1, lcapbe2, lcapbe3; + double lcapbx1, lcapbx2, lcapbx3; + double cb = 0; double cbc; double cbcn; double cbe; @@ -54,16 +54,16 @@ BJTdSetup(GENmodel *inModel, CKTcircuit *ckt) double f3; double fcpc; double fcpe; - double gbb1; + double gbb1 = 0; double gbc; double gbcn; double gbe; - double gbe2,gbe3; + double gbe2, gbe3; double gbc2,gbc3; double gben2,gben3; double gbcn2,gbcn3; double gben; - double gbb2, gbb3; + double gbb2 = 0, gbb3 = 0; double oik; double oikr; double ovtf; diff --git a/src/spicelib/devices/bjt/bjtinit.c b/src/spicelib/devices/bjt/bjtinit.c index ffd8ecca3..3cab0bcbd 100644 --- a/src/spicelib/devices/bjt/bjtinit.c +++ b/src/spicelib/devices/bjt/bjtinit.c @@ -7,23 +7,39 @@ #include "bjtinit.h" -SPICEdev BJTinfo = { +SPICEdev BJTinfo = { /* description from struct IFdevice */ { - "BJT", - "Bipolar Junction Transistor", + "BJT", /* char *name */ + "Bipolar Junction Transistor", /* char *description */ + + &BJTnSize, /* int *terms */ + &BJTnSize, /* int *numNames */ + BJTnames, /* char **termnames */ + + &BJTpTSize, /* int *numInstanceparms */ + BJTpTable, /* IFparm *instanceParms */ + + &BJTmPTSize, /* int *numModelparms */ + BJTmPTable, /* IFparm *modelParms */ - &BJTnSize, - &BJTnSize, - BJTnames, +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ - &BJTpTSize, - BJTpTable, + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ - &BJTmPTSize, - BJTmPTable, - DEV_DEFAULT + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + + DEV_DEFAULT /* int flags */ }, - + DEVparam : BJTparam, DEVmodParam : BJTmParam, DEVload : BJTload, diff --git a/src/spicelib/devices/bjt/bjtload.c b/src/spicelib/devices/bjt/bjtload.c index 8868fa7b4..226547ea2 100644 --- a/src/spicelib/devices/bjt/bjtload.c +++ b/src/spicelib/devices/bjt/bjtload.c @@ -114,9 +114,9 @@ BJTload(inModel,ckt) double tr; double vbc; double vbe; - double vbx; + double vbx=0; double vce; - double vcs; + double vcs=0; double vt; double vtc; double vte; diff --git a/src/spicelib/devices/bsim1/bsim1init.c b/src/spicelib/devices/bsim1/bsim1init.c index 2a23bc028..b0ae16bbe 100644 --- a/src/spicelib/devices/bsim1/bsim1init.c +++ b/src/spicelib/devices/bsim1/bsim1init.c @@ -21,6 +21,22 @@ SPICEdev B1info = { &B1mPTSize, B1mPTable, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + DEV_DEFAULT }, diff --git a/src/spicelib/devices/bsim2/bsim2init.c b/src/spicelib/devices/bsim2/bsim2init.c index 92c44dc35..8d139fe57 100644 --- a/src/spicelib/devices/bsim2/bsim2init.c +++ b/src/spicelib/devices/bsim2/bsim2init.c @@ -21,6 +21,22 @@ SPICEdev B2info = { &B2mPTSize, B2mPTable, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + DEV_DEFAULT }, diff --git a/src/spicelib/devices/bsim3/bsim3init.c b/src/spicelib/devices/bsim3/bsim3init.c index 9afd8ee9f..5efbcbcb1 100644 --- a/src/spicelib/devices/bsim3/bsim3init.c +++ b/src/spicelib/devices/bsim3/bsim3init.c @@ -20,6 +20,22 @@ SPICEdev BSIM3info = { &BSIM3mPTSize, BSIM3mPTable, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + DEV_DEFAULT }, diff --git a/src/spicelib/devices/bsim3soi_dd/b3soiddinit.c b/src/spicelib/devices/bsim3soi_dd/b3soiddinit.c index f88fe5149..e84560ab1 100644 --- a/src/spicelib/devices/bsim3soi_dd/b3soiddinit.c +++ b/src/spicelib/devices/bsim3soi_dd/b3soiddinit.c @@ -19,6 +19,22 @@ SPICEdev B3SOIDDinfo = { &B3SOIDDmPTSize, B3SOIDDmPTable, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + DEV_DEFAULT} , diff --git a/src/spicelib/devices/bsim3soi_fd/b3soifdinit.c b/src/spicelib/devices/bsim3soi_fd/b3soifdinit.c index fe82c2624..67211c731 100644 --- a/src/spicelib/devices/bsim3soi_fd/b3soifdinit.c +++ b/src/spicelib/devices/bsim3soi_fd/b3soifdinit.c @@ -19,6 +19,22 @@ SPICEdev B3SOIFDinfo = { &B3SOIFDmPTSize, B3SOIFDmPTable, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + DEV_DEFAULT} , diff --git a/src/spicelib/devices/bsim3soi_pd/b3soipdinit.c b/src/spicelib/devices/bsim3soi_pd/b3soipdinit.c index 3c8d65916..58148348b 100644 --- a/src/spicelib/devices/bsim3soi_pd/b3soipdinit.c +++ b/src/spicelib/devices/bsim3soi_pd/b3soipdinit.c @@ -20,6 +20,22 @@ SPICEdev B3SOIPDinfo = { &B3SOIPDmPTSize, B3SOIPDmPTable, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + DEV_DEFAULT} , diff --git a/src/spicelib/devices/bsim3v1/bsim3v1init.c b/src/spicelib/devices/bsim3v1/bsim3v1init.c index 5adacdfea..60af2d9a2 100644 --- a/src/spicelib/devices/bsim3v1/bsim3v1init.c +++ b/src/spicelib/devices/bsim3v1/bsim3v1init.c @@ -21,6 +21,22 @@ SPICEdev BSIM3V1info = { &BSIM3V1mPTSize, BSIM3V1mPTable, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + DEV_DEFAULT, }, diff --git a/src/spicelib/devices/bsim3v2/bsim3v2init.c b/src/spicelib/devices/bsim3v2/bsim3v2init.c index 4a82a3901..e47c492cd 100644 --- a/src/spicelib/devices/bsim3v2/bsim3v2init.c +++ b/src/spicelib/devices/bsim3v2/bsim3v2init.c @@ -20,7 +20,23 @@ SPICEdev BSIM3V2info = { &BSIM3V2mPTSize, BSIM3V2mPTable, - DEV_DEFAULT + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + + DEV_DEFAULT }, DEVparam : BSIM3V2param, diff --git a/src/spicelib/devices/bsim4/bsim4init.c b/src/spicelib/devices/bsim4/bsim4init.c index 6d906ef90..35f7a01ee 100644 --- a/src/spicelib/devices/bsim4/bsim4init.c +++ b/src/spicelib/devices/bsim4/bsim4init.c @@ -21,6 +21,22 @@ SPICEdev BSIM4info = { &BSIM4mPTSize, BSIM4mPTable, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + DEV_DEFAULT }, diff --git a/src/spicelib/devices/cap/capinit.c b/src/spicelib/devices/cap/capinit.c index 4954d563b..ec9352318 100644 --- a/src/spicelib/devices/cap/capinit.c +++ b/src/spicelib/devices/cap/capinit.c @@ -20,6 +20,22 @@ SPICEdev CAPinfo = { &CAPmPTSize, CAPmPTable, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + 0 }, diff --git a/src/spicelib/devices/cccs/cccsinit.c b/src/spicelib/devices/cccs/cccsinit.c index f061a39f2..b00123636 100644 --- a/src/spicelib/devices/cccs/cccsinit.c +++ b/src/spicelib/devices/cccs/cccsinit.c @@ -20,6 +20,22 @@ SPICEdev CCCSinfo = { 0, NULL, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + DEV_DEFAULT }, diff --git a/src/spicelib/devices/ccvs/ccvsinit.c b/src/spicelib/devices/ccvs/ccvsinit.c index 1df05d896..03f643bbf 100644 --- a/src/spicelib/devices/ccvs/ccvsinit.c +++ b/src/spicelib/devices/ccvs/ccvsinit.c @@ -21,6 +21,22 @@ SPICEdev CCVSinfo = { 0, NULL, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + DEV_DEFAULT }, diff --git a/src/spicelib/devices/cktcrte.c b/src/spicelib/devices/cktcrte.c index 7afd64893..ba90b713c 100644 --- a/src/spicelib/devices/cktcrte.c +++ b/src/spicelib/devices/cktcrte.c @@ -17,16 +17,19 @@ Author: 1985 Thomas L. Quarles int CKTcrtElt(void *ckt, void *inModPtr, void **inInstPtr, IFuid name) { - GENinstance *instPtr = NULL; - GENmodel *modPtr=(GENmodel*)inModPtr; + GENinstance *instPtr = NULL; /* instPtr points to the data struct for per-instance data */ + GENmodel *modPtr = (GENmodel*)inModPtr; /* modPtr points to the data struct for per-model data */ + SPICEdev **DEVices; int error; int type; DEVices = devices(); - if((GENmodel *)modPtr==(GENmodel*)NULL) + + if( (GENmodel *)modPtr == (GENmodel*)NULL ) return E_NOMOD; - type = ((GENmodel*)modPtr)->GENmodType; + + type = ((GENmodel*)modPtr)->GENmodType; error = CKTfndDev(ckt, &type, (void**)&instPtr, name, inModPtr, (char *)NULL ); @@ -37,13 +40,21 @@ CKTcrtElt(void *ckt, void *inModPtr, void **inInstPtr, IFuid name) } else if (error != E_NODEV) return error; +#ifdef TRACE + /*------ SDB debug statement -------*/ + printf("about to tmalloc, type = %d. . . \n", type); +#endif + instPtr = (GENinstance *) tmalloc(*DEVices[type]->DEVinstSize); if (instPtr == (GENinstance *)NULL) return E_NOMEM; instPtr->GENname = name; - instPtr->GENmodPtr = modPtr; - instPtr->GENnextInstance = modPtr->GENinstances; + + instPtr->GENmodPtr = modPtr; + + instPtr->GENnextInstance = modPtr->GENinstances; + modPtr->GENinstances = instPtr; if(inInstPtr != NULL) diff --git a/src/spicelib/devices/cpl/cplinit.c b/src/spicelib/devices/cpl/cplinit.c index 8e45b21f0..d9891f9a4 100644 --- a/src/spicelib/devices/cpl/cplinit.c +++ b/src/spicelib/devices/cpl/cplinit.c @@ -20,6 +20,22 @@ SPICEdev CPLinfo = { &CPLmPTSize, CPLmPTable, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + 0 }, diff --git a/src/spicelib/devices/csw/cswinit.c b/src/spicelib/devices/csw/cswinit.c index ee8d05852..bdb43009c 100644 --- a/src/spicelib/devices/csw/cswinit.c +++ b/src/spicelib/devices/csw/cswinit.c @@ -23,6 +23,22 @@ SPICEdev CSWinfo = { &CSWmPTSize, CSWmPTable, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + 0 }, diff --git a/src/spicelib/devices/dio/dioinit.c b/src/spicelib/devices/dio/dioinit.c index b1d673ac8..f1df1ff4e 100644 --- a/src/spicelib/devices/dio/dioinit.c +++ b/src/spicelib/devices/dio/dioinit.c @@ -23,6 +23,22 @@ SPICEdev DIOinfo = { &DIOmPTSize, DIOmPTable, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + DEV_DEFAULT }, diff --git a/src/spicelib/devices/hfet1/hfetinit.c b/src/spicelib/devices/hfet1/hfetinit.c index 345ce7047..eab29cdb0 100644 --- a/src/spicelib/devices/hfet1/hfetinit.c +++ b/src/spicelib/devices/hfet1/hfetinit.c @@ -21,6 +21,22 @@ SPICEdev HFETAinfo = { &HFETAmPTSize, HFETAmPTable, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + DEV_DEFAULT }, diff --git a/src/spicelib/devices/hfet2/hfet2init.c b/src/spicelib/devices/hfet2/hfet2init.c index 55bfb6dd9..1c141a19d 100644 --- a/src/spicelib/devices/hfet2/hfet2init.c +++ b/src/spicelib/devices/hfet2/hfet2init.c @@ -21,6 +21,22 @@ SPICEdev HFET2info = { &HFET2mPTSize, HFET2mPTable, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + DEV_DEFAULT }, diff --git a/src/spicelib/devices/ind/indinit.c b/src/spicelib/devices/ind/indinit.c index 7847de3e5..3bb334cad 100644 --- a/src/spicelib/devices/ind/indinit.c +++ b/src/spicelib/devices/ind/indinit.c @@ -21,6 +21,21 @@ SPICEdev INDinfo = { 0, NULL, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif 0 }, @@ -71,6 +86,22 @@ SPICEdev MUTinfo = { 0, NULL, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + 0 }, diff --git a/src/spicelib/devices/isrc/isrcinit.c b/src/spicelib/devices/isrc/isrcinit.c index 903288a80..535187d29 100644 --- a/src/spicelib/devices/isrc/isrcinit.c +++ b/src/spicelib/devices/isrc/isrcinit.c @@ -21,6 +21,22 @@ SPICEdev ISRCinfo = { 0, NULL, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + DEV_DEFAULT }, diff --git a/src/spicelib/devices/jfet/jfetinit.c b/src/spicelib/devices/jfet/jfetinit.c index 77d169a56..805a3305c 100644 --- a/src/spicelib/devices/jfet/jfetinit.c +++ b/src/spicelib/devices/jfet/jfetinit.c @@ -21,6 +21,22 @@ SPICEdev JFETinfo = { &JFETmPTSize, JFETmPTable, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + DEV_DEFAULT }, diff --git a/src/spicelib/devices/jfet2/jfet2init.c b/src/spicelib/devices/jfet2/jfet2init.c index 0b4f1ee84..506ba4779 100644 --- a/src/spicelib/devices/jfet2/jfet2init.c +++ b/src/spicelib/devices/jfet2/jfet2init.c @@ -21,6 +21,22 @@ SPICEdev JFET2info = { &JFET2mPTSize, JFET2mPTable, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + DEV_DEFAULT }, diff --git a/src/spicelib/devices/ltra/ltrainit.c b/src/spicelib/devices/ltra/ltrainit.c index 5c62e3573..bd9e658fe 100644 --- a/src/spicelib/devices/ltra/ltrainit.c +++ b/src/spicelib/devices/ltra/ltrainit.c @@ -21,6 +21,22 @@ SPICEdev LTRAinfo = { <RAmPTSize, LTRAmPTable, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + 0 }, diff --git a/src/spicelib/devices/mes/mesinit.c b/src/spicelib/devices/mes/mesinit.c index 18abd8deb..fa100c20e 100644 --- a/src/spicelib/devices/mes/mesinit.c +++ b/src/spicelib/devices/mes/mesinit.c @@ -21,6 +21,22 @@ SPICEdev MESinfo = { &MESmPTSize, MESmPTable, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + DEV_DEFAULT }, diff --git a/src/spicelib/devices/mesa/mesainit.c b/src/spicelib/devices/mesa/mesainit.c index 5e1cc38ad..cd0b7f8b0 100644 --- a/src/spicelib/devices/mesa/mesainit.c +++ b/src/spicelib/devices/mesa/mesainit.c @@ -21,6 +21,22 @@ SPICEdev MESAinfo = { &MESAmPTSize, MESAmPTable, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + DEV_DEFAULT }, diff --git a/src/spicelib/devices/mos1/mos1init.c b/src/spicelib/devices/mos1/mos1init.c index 915b65af0..23e10f624 100644 --- a/src/spicelib/devices/mos1/mos1init.c +++ b/src/spicelib/devices/mos1/mos1init.c @@ -21,6 +21,22 @@ SPICEdev MOS1info = { &MOS1mPTSize, MOS1mPTable, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + DEV_DEFAULT }, diff --git a/src/spicelib/devices/mos2/mos2init.c b/src/spicelib/devices/mos2/mos2init.c index 70fd535b0..3f58f6b14 100644 --- a/src/spicelib/devices/mos2/mos2init.c +++ b/src/spicelib/devices/mos2/mos2init.c @@ -21,6 +21,22 @@ SPICEdev MOS2info = { &MOS2mPTSize, MOS2mPTable, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + DEV_DEFAULT }, diff --git a/src/spicelib/devices/mos3/mos3init.c b/src/spicelib/devices/mos3/mos3init.c index 4c847b5f5..2f4a564f9 100644 --- a/src/spicelib/devices/mos3/mos3init.c +++ b/src/spicelib/devices/mos3/mos3init.c @@ -21,6 +21,22 @@ SPICEdev MOS3info = { &MOS3mPTSize, MOS3mPTable, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + DEV_DEFAULT }, diff --git a/src/spicelib/devices/mos6/mos6init.c b/src/spicelib/devices/mos6/mos6init.c index 06c6e908f..3d7340bb9 100644 --- a/src/spicelib/devices/mos6/mos6init.c +++ b/src/spicelib/devices/mos6/mos6init.c @@ -21,6 +21,22 @@ SPICEdev MOS6info = { &MOS6mPTSize, MOS6mPTable, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + DEV_DEFAULT }, diff --git a/src/spicelib/devices/mos9/mos9init.c b/src/spicelib/devices/mos9/mos9init.c index 7f5b9a6ac..b6bd91d50 100644 --- a/src/spicelib/devices/mos9/mos9init.c +++ b/src/spicelib/devices/mos9/mos9init.c @@ -21,6 +21,22 @@ SPICEdev MOS9info = { &MOS9mPTSize, MOS9mPTable, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + DEV_DEFAULT }, diff --git a/src/spicelib/devices/res/resinit.c b/src/spicelib/devices/res/resinit.c index d7780225e..d731b07b8 100644 --- a/src/spicelib/devices/res/resinit.c +++ b/src/spicelib/devices/res/resinit.c @@ -21,6 +21,22 @@ SPICEdev RESinfo = { &RESmPTSize, RESmPTable, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + 0 }, diff --git a/src/spicelib/devices/soi3/soi3init.c b/src/spicelib/devices/soi3/soi3init.c index 3a9744878..730055f6b 100644 --- a/src/spicelib/devices/soi3/soi3init.c +++ b/src/spicelib/devices/soi3/soi3init.c @@ -21,6 +21,22 @@ SPICEdev SOI3info = { &SOI3mPTSize, SOI3mPTable, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + DEV_DEFAULT }, diff --git a/src/spicelib/devices/sw/swinit.c b/src/spicelib/devices/sw/swinit.c index 0e2bdd381..1162d738c 100644 --- a/src/spicelib/devices/sw/swinit.c +++ b/src/spicelib/devices/sw/swinit.c @@ -22,6 +22,22 @@ SPICEdev SWinfo = { &SWmPTSize, SWmPTable, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + 0 }, diff --git a/src/spicelib/devices/tra/trainit.c b/src/spicelib/devices/tra/trainit.c index 8159d0b6e..fc5fc932b 100644 --- a/src/spicelib/devices/tra/trainit.c +++ b/src/spicelib/devices/tra/trainit.c @@ -21,6 +21,22 @@ SPICEdev TRAinfo = { 0, NULL, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + 0 }, diff --git a/src/spicelib/devices/txl/txlinit.c b/src/spicelib/devices/txl/txlinit.c index ffbd446f2..052420b20 100644 --- a/src/spicelib/devices/txl/txlinit.c +++ b/src/spicelib/devices/txl/txlinit.c @@ -26,6 +26,23 @@ SPICEdev TXLinfo = { &TXLmPTSize, TXLmPTable, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + + 0 }, TXLparam, diff --git a/src/spicelib/devices/urc/urcinit.c b/src/spicelib/devices/urc/urcinit.c index b28c413db..938331f93 100644 --- a/src/spicelib/devices/urc/urcinit.c +++ b/src/spicelib/devices/urc/urcinit.c @@ -21,6 +21,22 @@ SPICEdev URCinfo = { &URCmPTSize, URCmPTable, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + 0 }, diff --git a/src/spicelib/devices/vccs/vccsinit.c b/src/spicelib/devices/vccs/vccsinit.c index 65b5504ac..5c008b9ed 100644 --- a/src/spicelib/devices/vccs/vccsinit.c +++ b/src/spicelib/devices/vccs/vccsinit.c @@ -21,6 +21,22 @@ SPICEdev VCCSinfo = { 0, NULL, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + DEV_DEFAULT }, diff --git a/src/spicelib/devices/vcvs/vcvsinit.c b/src/spicelib/devices/vcvs/vcvsinit.c index 6d3e29dae..7ae22f51c 100644 --- a/src/spicelib/devices/vcvs/vcvsinit.c +++ b/src/spicelib/devices/vcvs/vcvsinit.c @@ -21,6 +21,22 @@ SPICEdev VCVSinfo = { 0, NULL, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + DEV_DEFAULT }, diff --git a/src/spicelib/devices/vsrc/vsrcinit.c b/src/spicelib/devices/vsrc/vsrcinit.c index 672ce4baa..055bda1e3 100644 --- a/src/spicelib/devices/vsrc/vsrcinit.c +++ b/src/spicelib/devices/vsrc/vsrcinit.c @@ -21,6 +21,22 @@ SPICEdev VSRCinfo = { 0, NULL, + +#ifdef XSPICE +/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ + + 0, /* This is a SPICE device, it has no MIF info data */ + NULL, /* This is a SPICE device, it has no MIF info data */ +/*--------------------------- End of SDB fix -------------------------*/ +#endif + DEV_DEFAULT }, diff --git a/src/spicelib/parser/inp2q.c b/src/spicelib/parser/inp2q.c index 192db7696..de39eb50a 100644 --- a/src/spicelib/parser/inp2q.c +++ b/src/spicelib/parser/inp2q.c @@ -83,6 +83,12 @@ void INP2Q(void *ckt, INPtables * tab, card * current, void *gnode) } mdfast = tab->defQmod; } + +#ifdef TRACE + /* --- SDB debug statement --- */ + printf ("In INP2Q, just about to dive into newInstance\n"); +#endif + IFC(newInstance, (ckt, mdfast, &fast, name)); IFC(bindNode, (ckt, fast, 1, node1)); IFC(bindNode, (ckt, fast, 2, node2)); diff --git a/src/spicelib/parser/inpdomod.c b/src/spicelib/parser/inpdomod.c index f826bcb3f..85f43d3d2 100644 --- a/src/spicelib/parser/inpdomod.c +++ b/src/spicelib/parser/inpdomod.c @@ -28,8 +28,10 @@ char *INPdomodel(void *ckt, card * image, INPtables * tab) line = image->line; - /* debug statement */ - /* printf("In INPdomodel, examining line %s . . . \n", line); */ +#ifdef TRACE + /* SDB debug statement */ + printf("In INPdomodel, examining line %s . . . \n", line); +#endif INPgetTok(&line, &modname, 1); /* throw away '.model' */ INPgetTok(&line, &modname, 1); /* get model name */ @@ -471,6 +473,21 @@ char *INPdomodel(void *ckt, card * image, INPtables * tab) } + /* type poly added by SDB . . . */ +#ifdef XSPICE + /* -------- Check if model is a poly (specific to xspice) --------- */ + else if (strcmp(typename, "poly") == 0) { + type = INPtypelook("POLY"); + if (type < 0) { + err = + INPmkTemp + ("Device type POLY not available in this binary\n"); + } + INPmakeMod(modname, type, image); + } +#endif + + /* -------- Default action --------- */ else { #ifndef XSPICE @@ -478,18 +495,35 @@ char *INPdomodel(void *ckt, card * image, INPtables * tab) err = (char *) MALLOC(35 + strlen(typename)); (void) sprintf(err, "unknown model type %s - ignored\n", typename); #else + /* gtri - modify - wbk - 10/23/90 - modify to look for code models */ - - /* add new code */ - + +#ifdef TRACE + /* SDB debug statement */ + printf("In INPdomodel, found unknown model type, typename = %s . . .\n", typename); +#endif + /* look for this model type and put it in the table of models */ type = INPtypelook(typename); if(type < 0) { err = (char *) MALLOC(35 + strlen(typename)); sprintf(err,"Unknown model type %s - ignored\n",typename); + +#ifdef TRACE + /* SDB debug statement */ + printf("In INPdomodel, ignoring unknown model typ typename = %s . . .\n", typename); +#endif + } - else + else { + +#ifdef TRACE + /* SDB debug statement */ + printf("In INPdomodel, adding model typename = %s to model list. . .\n", typename); +#endif + INPmakeMod(modname,type,image); + } /* gtri - end - wbk - 10/23/90 */ #endif diff --git a/src/spicelib/parser/inpfindl.c b/src/spicelib/parser/inpfindl.c index 52aed3be5..e3c8baead 100644 --- a/src/spicelib/parser/inpfindl.c +++ b/src/spicelib/parser/inpfindl.c @@ -20,7 +20,9 @@ char *INPfindLev(char *line, int *level) { char *where; - where = line; + /* + *where = line; + */ where = strstr(line, "level"); @@ -58,7 +60,7 @@ char *INPfindLev(char *line, int *level) else { /* no level on the line => default */ *level = 1; - printf("Level not specified: Using level 1.\n"); + printf("Warning -- Level not specified on line \"%s\"\nUsing level 1.\n", line); return ((char *) NULL); } diff --git a/src/spicelib/parser/inpgmod.c b/src/spicelib/parser/inpgmod.c index 6864e4f03..74bb33761 100644 --- a/src/spicelib/parser/inpgmod.c +++ b/src/spicelib/parser/inpgmod.c @@ -24,21 +24,40 @@ char *INPgetMod(void *ckt, char *name, INPmodel ** model, INPtables * tab) char *temp; int error; +#ifdef TRACE + /* SDB debug statement */ + printf("In INPgetMod, examining model %s . . . \n", name); +#endif + for (modtmp = modtab; modtmp != (INPmodel *) NULL; modtmp = ((modtmp)->INPnextModel)) { + +#ifdef TRACE + /* SDB debug statement */ + printf("In INPgetMod, comparing against stored model %s . . . \n", (modtmp)->INPmodName); +#endif + 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) { + + if (modtmp->INPmodType < 0) { /* First check for illegal model type */ /* 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); + +#ifdef TRACE + /* SDB debug statement */ + printf("In INPgetMod, illegal device type for model %s . . . \n", name); +#endif + return (err); - } - if (!((modtmp)->INPmodUsed)) { + } /* end of checking for illegal model */ + + if (!((modtmp)->INPmodUsed)) { /* Check if model is already defined */ /* not already defined, so create & give parameters */ error = (*(ft_sim->newModel)) (ckt, (modtmp)->INPmodType, &((modtmp)->INPmodfast), @@ -47,12 +66,20 @@ char *INPgetMod(void *ckt, char *name, INPmodel ** model, INPtables * tab) return (INPerror(error)); /* parameter isolation, identification, binding */ line = ((modtmp)->INPmodLine)->line; + +#ifdef TRACE + /* SDB debug statement */ + printf("In INPgetMod, inserting new model into table. line = %s . . . \n", line); +#endif + + 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, "txl") == 0) { @@ -72,7 +99,8 @@ char *INPgetMod(void *ckt, char *name, INPmodel ** model, INPtables * tab) return (INPerror(error)); break; } - } + } /* end for(j = 0 . . .*/ + if (strcmp(parm, "level") == 0) { /* just grab the level number and throw away */ /* since we already have that info from pass1 */ @@ -104,5 +132,11 @@ char *INPgetMod(void *ckt, char *name, INPmodel ** model, INPtables * tab) (void) sprintf(err, " unable to find definition of model %s - default assumed \n", name); + +#ifdef TRACE + /* SDB debug statement */ + printf("In INPgetMod, didn't find model for %s, using default . . . \n", name); +#endif + return (err); } diff --git a/src/spicelib/parser/inpgtok.c b/src/spicelib/parser/inpgtok.c index 706a145f0..ba6e92f7a 100644 --- a/src/spicelib/parser/inpgtok.c +++ b/src/spicelib/parser/inpgtok.c @@ -117,8 +117,12 @@ int INPgetTok(char **line, char **token, int gobble) continue; break; } - /* debug statement */ + +#ifdef TRACE + /* SDB debug statement */ /* printf("found generic token (%s) and rest of line (%s)\n", *token, *line); */ +#endif + return (OK); } @@ -198,8 +202,12 @@ int INPgetNetTok(char **line, char **token, int gobble) continue; break; } - /* debug statement */ + +#ifdef TRACE + /* SDB debug statement */ /* printf("found netname token (%s) and rest of line (%s)\n", *token, *line); */ +#endif + return (OK); } @@ -313,7 +321,11 @@ int INPgetUTok(char **line, char **token, int gobble) break; } *line = point; - /* debug statement */ + +#ifdef TRACE + /* SDB debug statement */ /* printf("found refdes token (%s) and rest of line (%s)\n",*token,*line); */ +#endif + return (OK); } diff --git a/src/spicelib/parser/inpmkmod.c b/src/spicelib/parser/inpmkmod.c index eff8626ca..e86e92e25 100644 --- a/src/spicelib/parser/inpmkmod.c +++ b/src/spicelib/parser/inpmkmod.c @@ -32,6 +32,12 @@ int INPmakeMod(char *token, int type, card * line) /* Model name was not already in model table. Therefore stick it in the model table. Then reutrn. */ + +#ifdef TRACE + /* debug statement */ + printf("In INPmakeMod, about to insert new model name = %s . . .\n", token); +#endif + *i = (INPmodel *) MALLOC(sizeof(INPmodel)); if (*i == NULL) return (E_NOMEM); diff --git a/src/spicelib/parser/inppas1.c b/src/spicelib/parser/inppas1.c index 9d8f77d28..96d6f5af8 100644 --- a/src/spicelib/parser/inppas1.c +++ b/src/spicelib/parser/inppas1.c @@ -32,8 +32,10 @@ void INPpas1(void *ckt, card * deck, INPtables * tab) /* First check to see if model is multi-line. If so, read in all lines & stick them into tab. */ - /* debug statement */ - /* printf("In INPpas1, about to call INPdomodel\n"); */ +#ifdef TRACE + /* SDB debug statement */ + printf("In INPpas1, handling line = %s \n", thisline); +#endif /* Now invoke INPdomodel to stick model into model table. */ temp = INPdomodel(ckt, current, tab); diff --git a/src/spicelib/parser/inppas2.c b/src/spicelib/parser/inppas2.c index 5595c366d..11c58c3df 100644 --- a/src/spicelib/parser/inppas2.c +++ b/src/spicelib/parser/inppas2.c @@ -29,6 +29,11 @@ void INPpas2(void *ckt, card * data, INPtables * tab, void *task) void *gnode; int error; /* used by the macros defined above */ +#ifdef TRACE + /* SDB debug statement */ + printf("Entered INPpas2 . . . .\n"); +#endif + error = INPgetTok(&groundname, &gname, 1); if (error) data->error = @@ -45,6 +50,11 @@ void INPpas2(void *ckt, card * data, INPtables * tab, void *task) for (current = data; current != NULL; current = current->nextcard) { +#ifdef TRACE + /* SDB debug statement */ + printf("In INPpas2, examining card %s . . .\n", current->line); +#endif + c = *(current->line); c = islower(c) ? toupper(c) : c; diff --git a/src/spicelib/parser/inppas3.c b/src/spicelib/parser/inppas3.c index db8b2bf1d..3f04dbaa8 100644 --- a/src/spicelib/parser/inppas3.c +++ b/src/spicelib/parser/inppas3.c @@ -39,6 +39,11 @@ INPpas3(void *ckt, card *data, INPtables *tab, void *task, int length; /* length of a name */ void *node1; /* the first node's node pointer */ +#ifdef TRACE + /* SDB debug statement */ + printf("In INPpas3 . . . \n"); +#endif + for(current = data; current != NULL; current = current->nextcard) { line = current->line; INPgetTok(&line,&token,1); diff --git a/src/spicelib/parser/inptyplk.c b/src/spicelib/parser/inptyplk.c index 13efc98c3..339191728 100644 --- a/src/spicelib/parser/inptyplk.c +++ b/src/spicelib/parser/inptyplk.c @@ -18,7 +18,19 @@ int INPtypelook(char *type) { int i; + +#ifdef TRACE + /* SDB debug statement */ + /* printf("In INPtypelook, examining model type = %s . . .\n", type); */ +#endif + for (i = 0; i < ft_sim->numDevices; i++) { + +#ifdef TRACE + /* SDB debug statemnet */ + /* printf("In INPtypelook, checking model against = %s . . .\n", (*(ft_sim->devices)[i]).name ); */ +#endif + if (strcmp(type, (*(ft_sim->devices)[i]).name) == 0) { /*found the device - return it */ return i; diff --git a/src/tcl/ChangeLog b/src/tcl/ChangeLog index b79826225..e16f6a0d0 100755 --- a/src/tcl/ChangeLog +++ b/src/tcl/ChangeLog @@ -1,3 +1,9 @@ +05/05/2003: + * Added latest patch from Stuart Brorson , + http://www.brorson.com/gEDA/ngspice/ngspice.html ; + Spice POLY works + Fixes XSPICE integration bugs + Comments in parser code and debug printfs 14/04/2003: * loadsnap / savesnap commands added * Improved spice Tcl GUI diff --git a/src/xspice/enh/enhtrans.c b/src/xspice/enh/enhtrans.c index a76ce2ea0..ad9a33447 100755 --- a/src/xspice/enh/enhtrans.c +++ b/src/xspice/enh/enhtrans.c @@ -65,13 +65,10 @@ NON-STANDARD FEATURES static int needs_translating(char *card); static int count_tokens(char *card); -static char *translate(char *orig_card, char **inst_card, +static char *two2three_translate(char *orig_card, char **inst_card, char **mod_card); static int get_poly_dimension(char *card); -// added as a quick bug fix, a lot of standard models have a linear poly(1) which -// fails in this code, Kevin Aylward April 15th 2000 -char * (*FPConvertSpicePoly1ToBsource)(char *card); // this is so I can use the MFC class libary /* ENHtranslate_poly() @@ -79,7 +76,14 @@ Translate all 2G6 style polynomial controlled sources in the deck to new polynomial controlled source code model syntax. */ - +/*---------------------------------------------------------------------*/ +/* ENHtranslate_poly takes (a pointer to) the SPICE deck as argument. */ +/* It loops through the deck, and translates all POLY statements */ +/* in dependent sources into a .model conformant with the needs of */ +/* XSPICE. It splices the new statements in the deck, and comments */ +/* out the old dependent source. */ +/* It returns (a pointer to) the processed deck. */ +/*---------------------------------------------------------------------*/ struct line * ENHtranslate_poly( struct line *deck) /* Linked list of lines in input deck */ { @@ -91,65 +95,65 @@ struct line * ENHtranslate_poly( int poly_dimension; char *buff; - /* Iterate through each card in the deck and translate as needed */ for(d = deck; d; d = d->li_next) { - /* If doesn't need to be translated, continue to next card */ - if(! needs_translating(d->li_line)) - continue; +#ifdef TRACE + /* SDB debug statement */ + printf("In ENHtranslate_poly, now examining card %s . . . \n", d->li_line); +#endif -// Start added as a quick fix to a xspice translation bug in poly(1) code -// Kevin Aylward April 15th 2000, fuck knows where it is - poly_dimension = get_poly_dimension(d->li_line); + /* If doesn't need to be translated, continue to next card */ + if(! needs_translating(d->li_line)) { - if(poly_dimension == 1)// - { - buff = (FPConvertSpicePoly1ToBsource)(d->li_line); +#ifdef TRACE + /* SDB debug statement */ + /* printf("Card doesn't need translating. Continuing . . . .\n"); */ +#endif - if(buff) - { - FREE(d->li_line); + continue; + } - d->li_line = buff; - } +#ifdef TRACE + /* SDB debug statement */ + printf("Found a card to translate . . . .\n"); +#endif - continue; - } -// End added as a quick fix to a xspice translation bug in poly(1) code -// Kevin Aylward April 15th 2000 - - - /* Create two new line structs and splice into deck */ +/* Create two new line structs and splice into deck */ /* l1 = alloc(line); */ /* jgroves */ /* l2 = alloc(line); */ /* jgroves */ - l1 = alloc(struct line); - l2 = alloc(struct line); - l2->li_next = d->li_next; - l1->li_next = l2; - d->li_next = l1; + l1 = alloc(struct line); + l2 = alloc(struct line); + l2->li_next = d->li_next; + l1->li_next = l2; + d->li_next = l1; + + /* Create the translated cards */ + d->li_error = two2three_translate(d->li_line, &(l1->li_line), &(l2->li_line)); + + /* Comment out the original line */ + card = (void *) MALLOC(strlen(d->li_line) + 2); + strcpy(card,"*"); + strcat(card, d->li_line); + d->li_line = card; - /* Create the translated cards */ - d->li_error = translate(d->li_line, &(l1->li_line), &(l2->li_line)); +#ifdef TRACE + /* SDB debug statement */ + printf("In ENHtranslate_poly, translated card = %s . . . \n", card); +#endif - /* Comment out the original line */ - card = (void *) MALLOC(strlen(d->li_line) + 2); - strcpy(card,"*"); - strcat(card, d->li_line); - d->li_line = card; - - /* Advance deck pointer to last line added */ - d = l2; + /* Advance deck pointer to last line added */ + d = l2; } - + /* Return head of deck */ return(deck); } /* ENHtranslate_poly */ - +/*---------------------------------------------------------------------*/ /* needs_translating() @@ -160,9 +164,14 @@ a simple linear dependent source. Otherwise return false. static int needs_translating( - char *card) /* the card text to check */ + char *card) /* the card text to check */ { +#ifdef TRACE + /* SDB debug statement */ + /* printf("In needs_translating, examining card %s . . . \n", card); */ +#endif + switch(*card) { case 'e': @@ -187,14 +196,12 @@ static int needs_translating( - +/*---------------------------------------------------------------------*/ /* count_tokens() Count and return the number of tokens on the card. */ - - static int count_tokens( char *card) /* the card text on which to count tokens */ { @@ -210,13 +217,19 @@ static int count_tokens( + +/*--------------------------------------------------------------------*/ /* -translate() +two2three_translate() Do the syntax translation of the 2G6 source to the new code model syntax. + +Renamed by SDB to eliminate clash with translate fcn defined in subckt.c +4.17.2003 -- SDB + */ -static char *translate( +static char *two2three_translate( char *orig_card, /* the original untranslated card */ char **inst_card, /* the instance card created by the translation */ char **mod_card) /* the model card created by the translation */ @@ -241,6 +254,11 @@ static char *translate( char *card; +#ifdef TRACE + /* SDB debug statement */ + printf("In two2three_translate, card to translate = %s . . .\n", orig_card); +#endif + /* Get the first character into local storage for checking type */ type = *orig_card; @@ -249,12 +267,16 @@ static char *translate( /* Determine the dimension of the poly source */ dim = get_poly_dimension(orig_card); - if(dim <= 0) + if(dim <= 0) { + printf("ERROR in two2three_translate -- Argument to poly() is not an integer\n"); return("ERROR - Argument to poly() is not an integer\n"); + } /* Compute number of input connections based on type and dimension */ switch(type) { + case 'E': case 'e': + case 'G': case 'g': num_conns = 2 * dim; break; @@ -318,7 +340,8 @@ static char *translate( strcpy(*inst_card, "a$poly$"); sprintf(*inst_card + strlen(*inst_card), "%s ", name); - if((type == 'e') || (type == 'g')) + if((type == 'e') || (type == 'g') || + (type == 'E') || (type == 'G')) sprintf(*inst_card + strlen(*inst_card), "%%vd [ "); else sprintf(*inst_card + strlen(*inst_card), "%%vnam [ "); @@ -328,7 +351,8 @@ static char *translate( sprintf(*inst_card + strlen(*inst_card), "] "); - if((type == 'e') || (type == 'h')) + if((type == 'e') || (type == 'h') || + (type == 'E') || (type == 'H')) sprintf(*inst_card + strlen(*inst_card), "%%vd "); else sprintf(*inst_card + strlen(*inst_card), "%%id "); @@ -344,6 +368,10 @@ static char *translate( sprintf(*mod_card + strlen(*mod_card), "%s ", coef[i]); sprintf(*mod_card + strlen(*mod_card), "]"); +#ifdef TRACE + /* SDB debug statement */ + printf("In two2three_translate, translated statements:\n%s \n%s \n", *inst_card, *mod_card); +#endif /* Free the temporary space */ FREE(name); @@ -352,30 +380,26 @@ static char *translate( for(i = 0; i < 2; i++) { FREE(out_conn[i]); - - out_conn[i] = NULL; - } + out_conn[i] = NULL; + } FREE(out_conn); - out_conn = NULL; for(i = 0; i < num_conns; i++) { FREE(in_conn[i]); - - in_conn[i] = NULL; - } + in_conn[i] = NULL; + } FREE(in_conn); - in_conn = NULL; for(i = 0; i < num_coefs; i++) { - FREE(coef[i]); - coef[i] = NULL; - } + FREE(coef[i]); + coef[i] = NULL; + } FREE(coef); @@ -384,9 +408,11 @@ static char *translate( /* Return NULL to indicate no error */ return(NULL); -} /* translate */ +} /* two2three_translate */ + +/*--------------------------------------------------------------------*/ /* get_poly_dimension() diff --git a/src/xspice/icm/poly/cfunc.c b/src/xspice/icm/poly/cfunc.c index d0484d9da..c529d3851 100755 --- a/src/xspice/icm/poly/cfunc.c +++ b/src/xspice/icm/poly/cfunc.c @@ -94,6 +94,8 @@ void icm_poly (Mif_Private_t *private) double *acgains; /* Static variable holding AC gains for AC analysis */ + /* debug statement */ + printf("In icm_poly!!! . . . .\n"); /* Get number of input values */ diff --git a/src/xspice/mif/mif_inp2.c b/src/xspice/mif/mif_inp2.c index 7c5f55f2a..b85ef0947 100755 --- a/src/xspice/mif/mif_inp2.c +++ b/src/xspice/mif/mif_inp2.c @@ -158,6 +158,10 @@ card *current; /* the card we are to parse */ Mif_Status_t status; /* return status */ Mif_Token_Type_t next_token_type; /* the type of the next token */ +#ifdef TRACE + /* SDB debug statement */ + printf("In MIF_INP2A, line to process = %s . . . \n", current->line); +#endif /* get the line text from the card struct */ @@ -169,7 +173,6 @@ card *current; /* the card we are to parse */ name = MIFgettok(&line); INPinsert(&name, tab); - /* locate the last token on the line and put it into "model" */ while(*line != '\0') @@ -190,6 +193,13 @@ card *current; /* the card we are to parse */ return; } +#ifdef TRACE + /* SDB debug statement */ + printf("In MIF_INP2A, after tokenizing, name = %s, model = %s\n", + name, model); +#endif + + /* get the integer index into the DEVices data array for this */ /* model */ @@ -883,3 +893,12 @@ MIFget_port( *status = MIF_OK; return; } + + + + + + + + + diff --git a/src/xspice/mif/mifgetmod.c b/src/xspice/mif/mifgetmod.c index dda0a3176..cd243af4e 100755 --- a/src/xspice/mif/mifgetmod.c +++ b/src/xspice/mif/mifgetmod.c @@ -85,12 +85,14 @@ defaulted later by MIFsetup(). The function returns NULL when successful, and an error string on failure. */ +/* char *MIFgetMod(ckt,name,model,tab) */ /* former buggy calling method */ -char *MIFgetMod(ckt,name,model,tab) - void *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 */ +char *MIFgetMod( + void *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; @@ -111,6 +113,10 @@ char *MIFgetMod(ckt,name,model,tab) /* locate the named model in the modtab list */ +#ifdef TRACE + /* SDB debug statement */ + printf("In MIFgetMod, model name = %s . . .\n", name); +#endif /* maschmann : remove : from name */ @@ -120,6 +126,11 @@ char *MIFgetMod(ckt,name,model,tab) 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) { @@ -131,7 +142,12 @@ char *MIFgetMod(ckt,name,model,tab) if(modtmp->INPmodType<0) { /* illegal device type, so can't handle */ *model = NULL; - err = (char *)tmalloc((35+strlen(name)) * sizeof(char)); + + /* fixed by SDB -- magic number is 39, not 35. + * Also needed parens to correctly compute # of bytes to malloc + */ + err = (char *)tmalloc( (39+strlen(name)) * sizeof(char) ); + sprintf(err, "MIF: Unknown device type for model %s \n",name); return(err); } @@ -233,3 +249,4 @@ char *MIFgetMod(ckt,name,model,tab) return(err); } +