frontend/subckt.c, do not put model names into numparam hash table

nobody seems to make use of these entries.
see nupa_type which shrinks to four enum's
This commit is contained in:
h_vogt 2016-04-17 16:34:20 +02:00 committed by rlar
parent b803b294b4
commit 3dd2115291
5 changed files with 13 additions and 26 deletions

View File

@ -16,7 +16,7 @@ struct card;
extern char *nupa_copy(struct card *c); extern char *nupa_copy(struct card *c);
extern int nupa_eval(struct card *card); extern int nupa_eval(struct card *card);
extern void nupa_signal(int sig); extern void nupa_signal(int sig);
extern void nupa_scan(struct card *card, int is_subckt); extern void nupa_scan(struct card *card);
extern void nupa_list_params(FILE *cp_out); extern void nupa_list_params(FILE *cp_out);
extern double nupa_get_param(char *param_name, int *found); extern double nupa_get_param(char *param_name, int *found);
extern void nupa_add_param(char *param_name, double value); extern void nupa_add_param(char *param_name, double value);

View File

@ -19,13 +19,11 @@ extern const struct nupa_type S_nupa_real;
extern const struct nupa_type S_nupa_string; extern const struct nupa_type S_nupa_string;
extern const struct nupa_type S_nupa_subckt; extern const struct nupa_type S_nupa_subckt;
extern const struct nupa_type S_nupa_unknown; extern const struct nupa_type S_nupa_unknown;
extern const struct nupa_type S_nupa_model;
#define NUPA_REAL (&S_nupa_real) #define NUPA_REAL (&S_nupa_real)
#define NUPA_STRING (&S_nupa_string) #define NUPA_STRING (&S_nupa_string)
#define NUPA_SUBCKT (&S_nupa_subckt) #define NUPA_SUBCKT (&S_nupa_subckt)
#define NUPA_UNKNOWN (&S_nupa_unknown) #define NUPA_UNKNOWN (&S_nupa_unknown)
#define NUPA_MODEL (&S_nupa_model)
typedef const struct nupa_type *nupa_type; typedef const struct nupa_type *nupa_type;
@ -59,7 +57,7 @@ typedef struct { /* the input scanner data structure */
void initdico(dico_t *); void initdico(dico_t *);
int donedico(dico_t *); int donedico(dico_t *);
void dico_free_entry(entry_t *); void dico_free_entry(entry_t *);
bool defsubckt(dico_t *, struct card *, nupa_type categ); bool defsubckt(dico_t *, struct card *);
int findsubckt(dico_t *, const char *s); int findsubckt(dico_t *, const char *s);
bool nupa_substitute(dico_t *, const char *s, char *r); bool nupa_substitute(dico_t *, const char *s, char *r);
bool nupa_assignment(dico_t *, const char *s, char mode); bool nupa_assignment(dico_t *, const char *s, char mode);

View File

@ -382,12 +382,9 @@ nupa_done(void)
/* SJB - Scan the line for subcircuits */ /* SJB - Scan the line for subcircuits */
void void
nupa_scan(struct card *card, int is_subckt) nupa_scan(struct card *card)
{ {
if (is_subckt) defsubckt(dicoS, card);
defsubckt(dicoS, card, NUPA_SUBCKT);
else
defsubckt(dicoS, card, NUPA_MODEL);
} }

View File

@ -472,7 +472,7 @@ nupa_define(dico_t *dico,
c = entry->tp; c = entry->tp;
if ((c == NUPA_REAL) || (c == NUPA_STRING) || (c == NUPA_UNKNOWN)) { if (c != NUPA_SUBCKT) {
entry->vl = z; entry->vl = z;
entry->tp = tpe; entry->tp = tpe;
@ -487,13 +487,9 @@ nupa_define(dico_t *dico,
warn = message(dico, "%s:%d overwritten.\n", t, entry->level); warn = message(dico, "%s:%d overwritten.\n", t, entry->level);
} else { } else {
/* suppress error message, resulting from multiple definition of /* error message for redefinition of subcircuits */
symbols (devices) in .model lines with same name, but in different subcircuits.
Subcircuit expansion is o.k., we have to deal with this numparam
behaviour later. (H. Vogt 090426)
*/
if (0) if (0)
message(dico, "%s: cannot redefine\n", t); message(dico, "subckt %s is already used,\n cannot be redefined\n", t);
} }
return 0; return 0;
@ -501,9 +497,9 @@ nupa_define(dico_t *dico,
bool bool
defsubckt(dico_t *dico, struct card *card, nupa_type categ) defsubckt(dico_t *dico, struct card *card)
/* called on 1st pass of spice source code, /* called on 1st pass of spice source code,
to enter subcircuit (categ=U) and model (categ=O) names to enter subcircuit names
*/ */
{ {
const char *s = card->line; const char *s = card->line;
@ -531,7 +527,7 @@ defsubckt(dico_t *dico, struct card *card, nupa_type categ)
SPICE_DSTRING ustr; /* temp user string */ SPICE_DSTRING ustr; /* temp user string */
spice_dstring_init(&ustr); spice_dstring_init(&ustr);
pscopy(&ustr, s, s_end); pscopy(&ustr, s, s_end);
err = nupa_define(dico, spice_dstring_value(&ustr), ' ', categ, 0.0, w, NULL); err = nupa_define(dico, spice_dstring_value(&ustr), ' ', NUPA_SUBCKT, 0.0, w, NULL);
spice_dstring_free(&ustr); spice_dstring_free(&ustr);
} else { } else {
err = message(dico, "Subcircuit or Model without name.\n"); err = message(dico, "Subcircuit or Model without name.\n");
@ -1589,4 +1585,3 @@ const struct nupa_type S_nupa_real = { "NUPA_REAL" };
const struct nupa_type S_nupa_string = { "NUPA_STRING" }; const struct nupa_type S_nupa_string = { "NUPA_STRING" };
const struct nupa_type S_nupa_subckt = { "NUPA_SUBCKT" }; const struct nupa_type S_nupa_subckt = { "NUPA_SUBCKT" };
const struct nupa_type S_nupa_unknown = { "NUPA_UNKNOWN" }; const struct nupa_type S_nupa_unknown = { "NUPA_UNKNOWN" };
const struct nupa_type S_nupa_model = { "NUPA_MODEL" };

View File

@ -232,13 +232,10 @@ inp_subcktexpand(struct card *deck) {
#endif #endif
nupa_signal(NUPADECKCOPY); nupa_signal(NUPADECKCOPY);
/* get the subckt/model names from the deck */ /* get the subckt names from the deck */
for (c = deck; c; c = c->nextcard) { /* first Numparam pass */ for (c = deck; c; c = c->nextcard) /* first Numparam pass */
if (ciprefix(".subckt", c->line)) if (ciprefix(".subckt", c->line))
nupa_scan(c, TRUE); nupa_scan(c);
if (ciprefix(".model", c->line))
nupa_scan(c, FALSE);
}
/* now copy instances */ /* now copy instances */
for (c = deck; c; c = c->nextcard) /* first Numparam pass */ for (c = deck; c; c = c->nextcard) /* first Numparam pass */
c->line = nupa_copy(c); c->line = nupa_copy(c);