From bc8d2605f9ea57dd76239ef760bfab738f4d3819 Mon Sep 17 00:00:00 2001 From: Brian Taylor Date: Tue, 21 Mar 2023 10:36:02 -0700 Subject: [PATCH] Add a flag to indicate when U* devices are translated to Xspice. The flag is cleared in inp_spsource and set in u_instances. A call to were_devices_translated() has been added to the start of inp_probe, with a comment that the return value can be used for "probe alli" suppression. Code for suppression of alli is not included. --- src/frontend/inp.c | 4 ++++ src/frontend/inpc_probe.c | 4 ++++ src/frontend/inpcom.c | 13 +++++++++++++ src/frontend/inpcom.h | 2 ++ 4 files changed, 23 insertions(+) diff --git a/src/frontend/inp.c b/src/frontend/inp.c index 38118347a..e245009c6 100644 --- a/src/frontend/inp.c +++ b/src/frontend/inp.c @@ -510,6 +510,10 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile) startTime = seconds(); /* inp_source() called with fp: load from file, */ /* called with *fp == NULL and intfile: we want to load circuit from circarray */ + + /* Clear the flag indicating U* devices have been translated to Xspice */ + set_udevices_translated(FALSE); + if (fp || intfile) { deck = inp_readall(fp, dir_name, comfile, intfile, &expr_w_temper); diff --git a/src/frontend/inpc_probe.c b/src/frontend/inpc_probe.c index 7ef70ce93..e68c737b9 100644 --- a/src/frontend/inpc_probe.c +++ b/src/frontend/inpc_probe.c @@ -11,6 +11,7 @@ #include "ngspice/inpdefs.h" #include "ngspice/wordlist.h" #include "ngspice/stringskip.h" +#include "inpcom.h" void inp_probe(struct card* card); void modprobenames(INPtables* tab); @@ -62,6 +63,9 @@ void inp_probe(struct card* deck) if (probes == NULL) return; + /* If were_udevices_translated() returns TRUE, then you can ignore alli */ + (void) were_udevices_translated(); + /* check for '.save' and (in a .control section) 'save'. If not found, add '.save all' */ for (card = deck; card; card = card->nextcard) { diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c index 9c6d67a07..25761a4f9 100644 --- a/src/frontend/inpcom.c +++ b/src/frontend/inpcom.c @@ -79,6 +79,8 @@ static struct library { static int num_libraries; +static bool udevices_translated = FALSE; + struct names { char *names[N_SUBCKT_W_PARAMS]; int num_names; @@ -8350,6 +8352,16 @@ static void rem_double_braces(struct card* newcard) } } +void set_udevices_translated(bool val) +{ + udevices_translated = val; +} + +bool were_udevices_translated(void) +{ + return udevices_translated; +} + #ifdef INTEGRATE_UDEVICES static void list_the_cards(struct card *startcard, char *prefix) { @@ -8454,6 +8466,7 @@ static struct card *u_instances(struct card *startcard) if (last_newcard) { last_newcard->nextcard = card; // the .ends card } + set_udevices_translated(TRUE); } else { models_ok = models_not_ok = 0; udev_ok = udev_not_ok = 0; diff --git a/src/frontend/inpcom.h b/src/frontend/inpcom.h index 3344f8fab..f57894bd6 100644 --- a/src/frontend/inpcom.h +++ b/src/frontend/inpcom.h @@ -9,4 +9,6 @@ struct card *insert_new_line(struct card *card, char *line, int linenum, int linenum_orig); +void set_udevices_translated(bool val); +bool were_udevices_translated(void); #endif