Browse Source

comments added

pre-master-46
h_vogt 17 years ago
parent
commit
9282e4e434
  1. 7
      ChangeLog
  2. 83
      src/frontend/inp.c
  3. 35
      src/frontend/subckt.c

7
ChangeLog

@ -1,7 +1,10 @@
2009-08-17 Holger Vogt
* inp.c: some comments added
2009-08-15 Holger Vogt 2009-08-15 Holger Vogt
* cpitf.c: MS Windows: search for spinit also in local (ngspice.exe) directory * cpitf.c: MS Windows: search for spinit also in local (ngspice.exe) directory
cpextern.h: function parameters added in declaration
com_alias.h, init.c, cpitf.c, main.c: comments added
* cpextern.h: function parameters added in declaration
* com_alias.h, init.c, cpitf.c, main.c: comments added
2009-08-08 Paolo Nenzi 2009-08-08 Paolo Nenzi
* src/frontend/resource.c: applied patch from Thomas D. Dean to remove * src/frontend/resource.c: applied patch from Thomas D. Dean to remove

83
src/frontend/inp.c

@ -4,12 +4,6 @@ Author: 1985 Wayne A. Christopher
$Id$ $Id$
**********/ **********/
/*
* SJB 22 May 2001
* Fixed memory leaks accociated with freeing memory used by lines in the input deck
* in inp_spsource(). New line_free() routine added to help with this.
*/
/* /*
* Stuff for dealing with spice input decks and command scripts, and * Stuff for dealing with spice input decks and command scripts, and
* the listing routines. * the listing routines.
@ -42,10 +36,10 @@ $Id$
#include "../misc/util.h" /* dirname() */ #include "../misc/util.h" /* dirname() */
#ifdef XSPICE #ifdef XSPICE
/* gtri - add - 12/12/90 - wbk - include new stuff */
/* include new stuff */
#include "ipctiein.h" #include "ipctiein.h"
#include "enh.h" #include "enh.h"
/* gtri - end - 12/12/90 */
/* */
#endif #endif
#include "numparam/numpaif.h" #include "numparam/numpaif.h"
@ -403,7 +397,8 @@ inp_spsource(FILE *fp, bool comfile, char *filename)
} /* end if(comfile) */ } /* end if(comfile) */
else { /* must be regular deck . . . . */ else { /* must be regular deck . . . . */
for (dd = deck->li_next; dd; dd = ld->li_next) { /* loop through deck and handle control cards */
/* loop through deck and handle control cards */
for (dd = deck->li_next; dd; dd = ld->li_next) {
/* Ignore comment lines, but not lines begining with '*#' */ /* Ignore comment lines, but not lines begining with '*#' */
s = dd->li_line; s = dd->li_line;
@ -413,6 +408,7 @@ inp_spsource(FILE *fp, bool comfile, char *filename)
continue; continue;
} }
/* Put the first token from line into s */
strncpy(name, dd->li_line, BSIZE_SP); strncpy(name, dd->li_line, BSIZE_SP);
for (s = name; *s && isspace(*s); s++) for (s = name; *s && isspace(*s); s++)
; ;
@ -442,7 +438,7 @@ inp_spsource(FILE *fp, bool comfile, char *filename)
controls = wl; controls = wl;
} else } else
controls = wl; controls = wl;
/* more control lines */
if (prefix("*#", dd->li_line)) if (prefix("*#", dd->li_line))
wl->wl_word = copy(dd->li_line + 2); wl->wl_word = copy(dd->li_line + 2);
else { else {
@ -473,7 +469,9 @@ inp_spsource(FILE *fp, bool comfile, char *filename)
ld->li_next = dd->li_next; ld->li_next = dd->li_next;
line_free(dd,FALSE); /* SJB - free this line's memory */ line_free(dd,FALSE); /* SJB - free this line's memory */
} else { } else {
inp_casefix(s);
/* lines .width, .four, .plot, .print,. save added to wl_first, removed from deck */
/* lines .op, .meas, .tf added to wl_first */
inp_casefix(s); /* s: first token from line */
inp_casefix(dd->li_line); inp_casefix(dd->li_line);
if (eq(s, ".width") if (eq(s, ".width")
|| ciprefix(".four", s) || ciprefix(".four", s)
@ -482,7 +480,6 @@ inp_spsource(FILE *fp, bool comfile, char *filename)
|| eq(s, ".save") || eq(s, ".save")
|| eq(s, ".op") || eq(s, ".op")
|| ciprefix(".meas", s) || ciprefix(".meas", s)
// || eq(s, ".measure")
|| eq(s, ".tf")) || eq(s, ".tf"))
{ {
if (end) { if (end) {
@ -493,9 +490,9 @@ inp_spsource(FILE *fp, bool comfile, char *filename)
wl_first = end = alloc(struct wordlist); wl_first = end = alloc(struct wordlist);
end->wl_word = copy(dd->li_line); end->wl_word = copy(dd->li_line);
if (!eq(s, ".op") && !eq(s, ".tf") && !ciprefix(".meas", s)/*eq(s, ".measure")*/) {
if (!eq(s, ".op") && !eq(s, ".tf") && !ciprefix(".meas", s)) {
ld->li_next = dd->li_next; ld->li_next = dd->li_next;
line_free(dd,FALSE); /* SJB - free this line's memory */
line_free(dd,FALSE);
} else } else
ld = dd; ld = dd;
} else } else
@ -504,42 +501,32 @@ inp_spsource(FILE *fp, bool comfile, char *filename)
} /* end for(dd=deck->li_next . . . . */ } /* end for(dd=deck->li_next . . . . */
/* we are done handling the control stuff. Now process remainder of deck */
/* We are done handling the control stuff. Now process remainder of deck.
Go on if there is something left after the controls.*/
if (deck->li_next) { if (deck->li_next) {
/* There is something left after the controls. */
fprintf(cp_out, "\nCircuit: %s\n\n", tt); fprintf(cp_out, "\nCircuit: %s\n\n", tt);
#ifdef HAS_WINDOWS #ifdef HAS_WINDOWS
SetAnalyse( "Circuit", 0); SetAnalyse( "Circuit", 0);
#endif #endif
/* 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. */
/* Now expand subcircuit macros and substitute numparams.*/
if (!cp_getvar("nosubckt", VT_BOOL, (char *) &nosubckts)) if (!cp_getvar("nosubckt", VT_BOOL, (char *) &nosubckts))
if( (deck->li_next = inp_subcktexpand(deck->li_next)) == NULL ){ if( (deck->li_next = inp_subcktexpand(deck->li_next)) == NULL ){
line_free(realdeck,TRUE); line_free(realdeck,TRUE);
line_free(deck->li_actual, TRUE); line_free(deck->li_actual, TRUE);
return; return;
} /* done expanding subcircuit macros */
}
/* Now handle translation of spice2c6 POLYs. */ /* 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 #ifdef XSPICE
/* gtri - wbk - Translate all SPICE 2G6 polynomial type sources */
/* Translate all SPICE 2G6 polynomial type sources */
deck->li_next = ENHtranslate_poly(deck->li_next); deck->li_next = ENHtranslate_poly(deck->li_next);
/* gtri - end - Translate all SPICE 2G6 polynomial type sources */
#endif #endif
line_free(deck->li_actual,FALSE); /* SJB - free memory used by old li_actual (if any) */
line_free(deck->li_actual,FALSE);
deck->li_actual = realdeck; deck->li_actual = realdeck;
/* now call inp_dodeck, which loads deck into ft_curckt -- the current circuit. */
/* now load deck into ft_curckt -- the current circuit. */
inp_dodeck(deck, tt, wl_first, FALSE, options, filename); inp_dodeck(deck, tt, wl_first, FALSE, options, filename);
} /* if (deck->li_next) */ } /* if (deck->li_next) */
@ -636,10 +623,10 @@ inp_spsource(FILE *fp, bool comfile, char *filename)
} }
/* Hitoshi Tanaka */ /* Hitoshi Tanaka */
if(dbs) tfree(dbs); /* Added */
if(dbs) tfree(dbs);
/*saj, to process save commands always, not just in batch mode /*saj, to process save commands always, not just in batch mode
*(breaks encapsulation of frountend and parsing commands slightly)*/
*(breaks encapsulation of frontend and parsing commands slightly)*/
ft_dotsaves(); ft_dotsaves();
/* Now reset everything. Pop the control stack, and fix up the IO /* Now reset everything. Pop the control stack, and fix up the IO
@ -663,17 +650,15 @@ inp_spsource(FILE *fp, bool comfile, char *filename)
* to the current circuit (ft_curckt). * to the current circuit (ft_curckt).
*-----------------------------------------------------------------*/ *-----------------------------------------------------------------*/
void 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
*/
{
inp_dodeck(
struct line *deck, /*in: the spice deck */
char *tt, /*in: the title of the deck */
wordlist *end, /*in: all lines with .width, .plot, .print, .save, .op, .meas, .tf */
bool reuse, /*in: TRUE if called from runcoms2.c com_rset,
FALSE if called from inp_spsource() */
struct line *options, /*in: all .option lines from deck */
char *filename /*in: input file of deck */
) {
struct circ *ct; struct circ *ct;
struct line *dd; struct line *dd;
char *ckt, *s; char *ckt, *s;
@ -686,7 +671,7 @@ inp_dodeck(struct line *deck, char *tt, wordlist *end, bool reuse,
static int one; static int one;
/* First throw away any old error messages there might be and fix /* First throw away any old error messages there might be and fix
* the case of the lines. */
the case of the lines. */
for (dd = deck; dd; dd = dd->li_next) { for (dd = deck; dd; dd = dd->li_next) {
if (dd->li_error) { if (dd->li_error) {
tfree(dd->li_error); tfree(dd->li_error);
@ -773,11 +758,9 @@ inp_dodeck(struct line *deck, char *tt, wordlist *end, bool reuse,
char *p, *q; char *p, *q;
#ifdef XSPICE #ifdef XSPICE
/* gtri - modify - 12/12/90 - wbk - add setting of ipc syntax error flag */
/* add setting of ipc syntax error flag */
g_ipc.syntax_error = IPC_TRUE; g_ipc.syntax_error = IPC_TRUE;
#endif #endif
/* gtri - end - 12/12/90 */
p = dd->li_error; p = dd->li_error;
do { do {
q =strchr(p, '\n'); q =strchr(p, '\n');
@ -884,7 +867,7 @@ inp_dodeck(struct line *deck, char *tt, wordlist *end, bool reuse,
} }
} /* if (!noparse) . . . */ } /* if (!noparse) . . . */
/* add title of deck to data base */
cp_addkword(CT_CKTNAMES, tt); cp_addkword(CT_CKTNAMES, tt);
return; return;
} }

35
src/frontend/subckt.c

@ -118,21 +118,26 @@ static char start[32], sbend[32], invoke[32], model[32];
static char node[128][128]; static char node[128][128];
static int numgnode; static int numgnode;
/*-------------------------------------------------------------------*/
/* 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. */
/*-------------------------------------------------------------------
inp_subcktexpand is the top level function which translates
.subckts into mainlined code. Note that there are several 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.
3. Do parameter substitution.
The algorithm is as follows:
1. Define some aliases for .subckt, .ends, etc.
2. First numparam pass: substitute paramterized tokens by
intermediate values 1000000001 etc.
3. Make a list node[] of global nodes
4. Clean up parens around netnames
5. Call doit, which does the actual translation.
6. Second numparam pass: Do final substitution
7. 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 * struct line *
inp_subcktexpand(struct line *deck) inp_subcktexpand(struct line *deck)

Loading…
Cancel
Save