collect info for dyn. mem arrays in numparam

This commit is contained in:
h_vogt 2009-03-07 15:49:51 +00:00
parent 3b2d896f5c
commit 0e61b7ccc0
7 changed files with 82 additions and 42 deletions

View File

@ -1,3 +1,9 @@
2009-03-07 Holger Vogt
* spicenum.c inpcom.c subckt.c xpressn.c numpaif.h numparam.h general.h
Collect information to allow dynamic memory allocation for numparam
( Still to be implementd ! )
Defined in inpcom.c: dynmaxline dynnLen dynMaxckt dynsubst
2009-03-03 Dietmar Warning
* tests/bsim3/*_sim/*.out: adapt output format to spice3 numdgt convention, most
tests are running except tran tests and op-amp ac test.

View File

@ -90,6 +90,16 @@ static char *func_macro[5000];
static int num_functions;
static int num_parameters[1000];
/* Collect information for dynamic allocation of numparam arrays */
/* number of lines in input deck */
int dynmaxline; /* inpcom.c 1524 */
/* max. line length in input deck */
int dynnLen; /* inpcom.c 1526 */
/* number of lines in deck after expansion */
int dynMaxckt = 0; /* subckt.c 307 */
/* number of parameter substitutions */
long dynsubst; /* spicenum.c 221 */
/* static declarations */
static char * readline(FILE *fd);
static int get_number_terminals( char *c );
@ -990,8 +1000,9 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name)
FILE *newfp;
#if defined(TRACE) || defined(OUTDECK)
FILE *fdo;
#endif
struct line *tmp_ptr1 = NULL;
#endif
int i, j;
bool found_library, found_lib_name, found_end = FALSE, shell_eol_continuation = FALSE;
bool dir_name_flag = FALSE;
@ -1510,15 +1521,25 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name)
inp_add_control_section(working, &line_number);
}
*data = cc;
/* get max. line length and number of lines in input deck*/
dynmaxline = 0;
dynnLen = 0;
for(tmp_ptr1 = cc; tmp_ptr1 != NULL; tmp_ptr1 = tmp_ptr1->li_next) {
dynmaxline++;
if (dynnLen < strlen(tmp_ptr1->li_line))
dynnLen = strlen(tmp_ptr1->li_line);
}
#if defined(TRACE) || defined(OUTDECK)
/*debug: print into file*/
if (tmp_ptr1) tfree(tmp_ptr1);
fdo = fopen("debug-out.txt", "w");
/*debug: print into file*/
fdo = fopen("debug-out.txt", "w");
for(tmp_ptr1 = cc; tmp_ptr1 != NULL; tmp_ptr1 = tmp_ptr1->li_next)
fprintf(fdo, "%s\n", tmp_ptr1->li_line);
;
(void) fclose(fdo);
fprintf(stdout, "lLen %d, maxline %d\n", dynnLen, dynmaxline);
#endif
return;
}

View File

@ -22,4 +22,6 @@ extern void nupa_add_param(char *param_name, double value);
extern void nupa_add_inst_param(char *param_name, double value);
extern void nupa_copy_inst_dico();
extern int dynMaxckt; /* number of lines in deck after expansion */
#endif /* NUMPAIF_H */

View File

@ -29,7 +29,7 @@ typedef enum {Llen=40000} _nLlen;
typedef char str50 [54];
typedef char str80 [84];
typedef enum {Maxline=20000} _nMaxline; /* Size of initial unexpanded circuit code */
typedef enum {Maxline=70000} _nMaxline; /* Size of initial unexpanded circuit code */
typedef enum {Maxckt=40000} _nMaxckt; /* Size of expanded circuit code */

View File

@ -32,6 +32,8 @@ extern void txfree (void *ptr);
char *nupa_inst_name;
static tdico *inst_dico;
extern long dynsubst; /* inpcom.c */
/* Uncomment this line to allow debug tracing */
/* #define TRACE_NUMPARAMS */
@ -216,7 +218,7 @@ stripbraces (char *s)
ls = length (s);
}
dynsubst = placeholder;
return n;
}
@ -702,43 +704,43 @@ nupa_copy (char *s, int linenum)
dico->srcline = linenum;
if ((!inexpansion) && (linenum >= 0) && (linenum < Maxline))
{
linecount++;
dico->refptr[linenum] = s;
c = transform (dico, u, incontrol, keywd);
if (c == 'C')
incontrol = 1;
else if (c == 'E')
incontrol = 0;
{
linecount++;
dico->refptr[linenum] = s;
c = transform (dico, u, incontrol, keywd);
if (c == 'C')
incontrol = 1;
else if (c == 'E')
incontrol = 0;
if (incontrol)
c = 'C'; /* force it */
if (incontrol)
c = 'C'; /* force it */
d = dico->category[linenum]; /* warning if already some strategic line! */
d = dico->category[linenum]; /* warning if already some strategic line! */
if ((d == 'P') || (d == 'S') || (d == 'X'))
fprintf (stderr,
" Numparam warning: overwriting P,S or X line (linenum == %d).\n",
linenum);
if ((d == 'P') || (d == 'S') || (d == 'X'))
fprintf (stderr,
" Numparam warning: overwriting P,S or X line (linenum == %d).\n",
linenum);
dico->category[linenum] = c;
} /* keep a local copy and mangle the string */
dico->category[linenum] = c;
} /* keep a local copy and mangle the string */
ls = length (u);
t = strdup (u);
if (t == NULL)
{
fputs ("Fatal: String malloc crash in nupa_copy()\n", stderr);
exit (-1);
}
{
fputs ("Fatal: String malloc crash in nupa_copy()\n", stderr);
exit (-1);
}
else
{
if (!inexpansion)
{
if (!inexpansion)
{
putlogfile (dico->category[linenum], linenum, t);
};
}
putlogfile (dico->category[linenum], linenum, t);
};
}
return t;
}

View File

@ -20,6 +20,7 @@ static Str (150, keys); /* all my keywords */
static Str (150, fmath); /* all math functions */
extern char *nupa_inst_name; /* see spicenum.c */
extern long dynsubst; /* see inpcom.c */
static double
ternary_fcn (int conditional, double if_value, double else_value)
@ -1676,7 +1677,7 @@ insertnumber (tdico * dico, int i, char *s, char *u)
if (found)
{
accu = accu - 1000000000L; /* plausibility test */
found = (accu > 0) && (accu < 40000);
found = (accu > 0) && (accu < dynsubst + 1); /* dynsubst numbers have been allocated */
}
i++;
}

View File

@ -300,16 +300,24 @@ inp_subcktexpand(struct line *deck)
modnames = NULL;
}
/* Count numbers of line in deck after expansion */
if (ll!=NULL) {
dynMaxckt = 0; /* number of lines in deck after expansion */
for (c = ll; c; c = c->li_next)
dynMaxckt++;
}
/* Now check to see if there are still subckt instances undefined... */
if (ll!=NULL) for (c = ll; c; c = c->li_next)
if (ciprefix(invoke, c->li_line)) {
fprintf(cp_err, "Error: unknown subckt: %s\n", c->li_line);
if ( use_numparams ) {
ok= ok && nupa_signal(NUPAEVALDONE, NULL);
}
return NULL;
}
if (ll!=NULL) {
for (c = ll; c; c = c->li_next) {
if (ciprefix(invoke, c->li_line)) {
fprintf(cp_err, "Error: unknown subckt: %s\n", c->li_line);
if ( use_numparams ) {
ok= ok && nupa_signal(NUPAEVALDONE, NULL);
}
return NULL;
}
}
}
if ( use_numparams ) {
/* the NUMPARAM final line translation pass */
ok= ok && nupa_signal(NUPASUBDONE, NULL);