collect info for dyn. mem arrays in numparam
This commit is contained in:
parent
3b2d896f5c
commit
0e61b7ccc0
|
|
@ -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
|
2009-03-03 Dietmar Warning
|
||||||
* tests/bsim3/*_sim/*.out: adapt output format to spice3 numdgt convention, most
|
* tests/bsim3/*_sim/*.out: adapt output format to spice3 numdgt convention, most
|
||||||
tests are running except tran tests and op-amp ac test.
|
tests are running except tran tests and op-amp ac test.
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,16 @@ static char *func_macro[5000];
|
||||||
static int num_functions;
|
static int num_functions;
|
||||||
static int num_parameters[1000];
|
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 declarations */
|
||||||
static char * readline(FILE *fd);
|
static char * readline(FILE *fd);
|
||||||
static int get_number_terminals( char *c );
|
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;
|
FILE *newfp;
|
||||||
#if defined(TRACE) || defined(OUTDECK)
|
#if defined(TRACE) || defined(OUTDECK)
|
||||||
FILE *fdo;
|
FILE *fdo;
|
||||||
struct line *tmp_ptr1 = NULL;
|
|
||||||
#endif
|
#endif
|
||||||
|
struct line *tmp_ptr1 = NULL;
|
||||||
|
|
||||||
int i, j;
|
int i, j;
|
||||||
bool found_library, found_lib_name, found_end = FALSE, shell_eol_continuation = FALSE;
|
bool found_library, found_lib_name, found_end = FALSE, shell_eol_continuation = FALSE;
|
||||||
bool dir_name_flag = 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);
|
inp_add_control_section(working, &line_number);
|
||||||
}
|
}
|
||||||
*data = cc;
|
*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)
|
#if defined(TRACE) || defined(OUTDECK)
|
||||||
/*debug: print into file*/
|
/*debug: print into file*/
|
||||||
if (tmp_ptr1) tfree(tmp_ptr1);
|
fdo = fopen("debug-out.txt", "w");
|
||||||
fdo = fopen("debug-out.txt", "w");
|
|
||||||
for(tmp_ptr1 = cc; tmp_ptr1 != NULL; tmp_ptr1 = tmp_ptr1->li_next)
|
for(tmp_ptr1 = cc; tmp_ptr1 != NULL; tmp_ptr1 = tmp_ptr1->li_next)
|
||||||
fprintf(fdo, "%s\n", tmp_ptr1->li_line);
|
fprintf(fdo, "%s\n", tmp_ptr1->li_line);
|
||||||
;
|
;
|
||||||
(void) fclose(fdo);
|
(void) fclose(fdo);
|
||||||
|
fprintf(stdout, "lLen %d, maxline %d\n", dynnLen, dynmaxline);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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_add_inst_param(char *param_name, double value);
|
||||||
extern void nupa_copy_inst_dico();
|
extern void nupa_copy_inst_dico();
|
||||||
|
|
||||||
|
extern int dynMaxckt; /* number of lines in deck after expansion */
|
||||||
|
|
||||||
#endif /* NUMPAIF_H */
|
#endif /* NUMPAIF_H */
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ typedef enum {Llen=40000} _nLlen;
|
||||||
typedef char str50 [54];
|
typedef char str50 [54];
|
||||||
typedef char str80 [84];
|
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 */
|
typedef enum {Maxckt=40000} _nMaxckt; /* Size of expanded circuit code */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,8 @@ extern void txfree (void *ptr);
|
||||||
char *nupa_inst_name;
|
char *nupa_inst_name;
|
||||||
static tdico *inst_dico;
|
static tdico *inst_dico;
|
||||||
|
|
||||||
|
extern long dynsubst; /* inpcom.c */
|
||||||
|
|
||||||
/* Uncomment this line to allow debug tracing */
|
/* Uncomment this line to allow debug tracing */
|
||||||
/* #define TRACE_NUMPARAMS */
|
/* #define TRACE_NUMPARAMS */
|
||||||
|
|
||||||
|
|
@ -216,7 +218,7 @@ stripbraces (char *s)
|
||||||
|
|
||||||
ls = length (s);
|
ls = length (s);
|
||||||
}
|
}
|
||||||
|
dynsubst = placeholder;
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -702,43 +704,43 @@ nupa_copy (char *s, int linenum)
|
||||||
dico->srcline = linenum;
|
dico->srcline = linenum;
|
||||||
|
|
||||||
if ((!inexpansion) && (linenum >= 0) && (linenum < Maxline))
|
if ((!inexpansion) && (linenum >= 0) && (linenum < Maxline))
|
||||||
{
|
{
|
||||||
linecount++;
|
linecount++;
|
||||||
dico->refptr[linenum] = s;
|
dico->refptr[linenum] = s;
|
||||||
c = transform (dico, u, incontrol, keywd);
|
c = transform (dico, u, incontrol, keywd);
|
||||||
if (c == 'C')
|
if (c == 'C')
|
||||||
incontrol = 1;
|
incontrol = 1;
|
||||||
else if (c == 'E')
|
else if (c == 'E')
|
||||||
incontrol = 0;
|
incontrol = 0;
|
||||||
|
|
||||||
if (incontrol)
|
if (incontrol)
|
||||||
c = 'C'; /* force it */
|
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'))
|
if ((d == 'P') || (d == 'S') || (d == 'X'))
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
" Numparam warning: overwriting P,S or X line (linenum == %d).\n",
|
" Numparam warning: overwriting P,S or X line (linenum == %d).\n",
|
||||||
linenum);
|
linenum);
|
||||||
|
|
||||||
dico->category[linenum] = c;
|
dico->category[linenum] = c;
|
||||||
} /* keep a local copy and mangle the string */
|
} /* keep a local copy and mangle the string */
|
||||||
|
|
||||||
ls = length (u);
|
ls = length (u);
|
||||||
t = strdup (u);
|
t = strdup (u);
|
||||||
|
|
||||||
if (t == NULL)
|
if (t == NULL)
|
||||||
{
|
{
|
||||||
fputs ("Fatal: String malloc crash in nupa_copy()\n", stderr);
|
fputs ("Fatal: String malloc crash in nupa_copy()\n", stderr);
|
||||||
exit (-1);
|
exit (-1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (!inexpansion)
|
||||||
{
|
{
|
||||||
if (!inexpansion)
|
putlogfile (dico->category[linenum], linenum, t);
|
||||||
{
|
};
|
||||||
putlogfile (dico->category[linenum], linenum, t);
|
}
|
||||||
};
|
|
||||||
}
|
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ static Str (150, keys); /* all my keywords */
|
||||||
static Str (150, fmath); /* all math functions */
|
static Str (150, fmath); /* all math functions */
|
||||||
|
|
||||||
extern char *nupa_inst_name; /* see spicenum.c */
|
extern char *nupa_inst_name; /* see spicenum.c */
|
||||||
|
extern long dynsubst; /* see inpcom.c */
|
||||||
|
|
||||||
static double
|
static double
|
||||||
ternary_fcn (int conditional, double if_value, double else_value)
|
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)
|
if (found)
|
||||||
{
|
{
|
||||||
accu = accu - 1000000000L; /* plausibility test */
|
accu = accu - 1000000000L; /* plausibility test */
|
||||||
found = (accu > 0) && (accu < 40000);
|
found = (accu > 0) && (accu < dynsubst + 1); /* dynsubst numbers have been allocated */
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -300,16 +300,24 @@ inp_subcktexpand(struct line *deck)
|
||||||
modnames = NULL;
|
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... */
|
/* Now check to see if there are still subckt instances undefined... */
|
||||||
if (ll!=NULL) for (c = ll; c; c = c->li_next)
|
if (ll!=NULL) {
|
||||||
if (ciprefix(invoke, c->li_line)) {
|
for (c = ll; c; c = c->li_next) {
|
||||||
fprintf(cp_err, "Error: unknown subckt: %s\n", c->li_line);
|
if (ciprefix(invoke, c->li_line)) {
|
||||||
if ( use_numparams ) {
|
fprintf(cp_err, "Error: unknown subckt: %s\n", c->li_line);
|
||||||
ok= ok && nupa_signal(NUPAEVALDONE, NULL);
|
if ( use_numparams ) {
|
||||||
}
|
ok= ok && nupa_signal(NUPAEVALDONE, NULL);
|
||||||
return NULL;
|
}
|
||||||
}
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if ( use_numparams ) {
|
if ( use_numparams ) {
|
||||||
/* the NUMPARAM final line translation pass */
|
/* the NUMPARAM final line translation pass */
|
||||||
ok= ok && nupa_signal(NUPASUBDONE, NULL);
|
ok= ok && nupa_signal(NUPASUBDONE, NULL);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue