From 816f43dd368e01a3f401d96df084e977cec22d15 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Fri, 16 Aug 2024 12:21:12 +0200 Subject: [PATCH 1/4] Improve debugging using shared ngspice: print out each command received. --- src/sharedspice.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sharedspice.c b/src/sharedspice.c index 291f87070..a7d858414 100644 --- a/src/sharedspice.c +++ b/src/sharedspice.c @@ -1114,6 +1114,9 @@ int ngSpice_Command(char* comexec) return 1; } + if (ft_ngdebug) + fprintf(stdout, "\nngSpiceCommand: received command '%s'\n", comexec); + if ( ! setjmp(errbufc) ) { immediate = FALSE; From b03dd906949f18042992d945f886f8625e76936b Mon Sep 17 00:00:00 2001 From: Giles Atkinson <“gatk555@gmail.com”> Date: Mon, 12 Aug 2024 08:58:35 +0100 Subject: [PATCH 2/4] Fix #686: "XSpice Verilog Vector Input Bug". Bug report and fix by Aodhan Murray. --- src/xspice/verilog/verilator_shim.cpp | 54 +++++++++++++-------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/xspice/verilog/verilator_shim.cpp b/src/xspice/verilog/verilator_shim.cpp index df508658d..19506f559 100644 --- a/src/xspice/verilog/verilator_shim.cpp +++ b/src/xspice/verilog/verilator_shim.cpp @@ -40,18 +40,18 @@ static unsigned char previous_output[outs + inouts]; /* The input function: it should ignore out-of-range values of index. */ -#define VL_DATA(size, name, msb, lsb) \ - if (index >= msb - lsb + 1) { \ - index -= msb - lsb + 1; \ - } else if (msb == 0 && lsb == 0) { \ - topp->name = val ? 1 : 0; \ - return; \ - } else { \ - if (val) \ - topp->name |= (1 << (msb - index)); \ - else \ - topp->name &= (1 << (msb - index)); \ - return; \ +#define VL_DATA(size, name, msb, lsb) \ + if (index >= msb - lsb + 1) { \ + index -= msb - lsb + 1; \ + } else if (msb == 0 && lsb == 0) { \ + topp->name = val ? 1 : 0; \ + return; \ + } else { \ + if (val) \ + topp->name |= (1 << (msb - index)); \ + else \ + topp->name &= ~(1 << (msb - index)); \ + return; \ } static void accept_input(struct co_info *pinfo, @@ -70,21 +70,21 @@ static void accept_input(struct co_info *pinfo, offset = outs; #undef VL_DATA -#define VL_DATA(size, name, msb, lsb) \ - if (index >= msb - lsb + 1) { \ - index -= msb - lsb + 1; \ - offset += msb - lsb + 1; \ - } else if (msb == 0 && lsb == 0) { \ - topp->name = val ? 1 : 0; \ - previous_output[index + offset] = val; \ - return; \ - } else { \ - if (val) \ - topp->name | (1 << (msb - index)); \ - else \ - topp->name &= (1 << (msb - index)); \ - previous_output[index + offset] = val; \ - return; \ +#define VL_DATA(size, name, msb, lsb) \ + if (index >= msb - lsb + 1) { \ + index -= msb - lsb + 1; \ + offset += msb - lsb + 1; \ + } else if (msb == 0 && lsb == 0) { \ + topp->name = val ? 1 : 0; \ + previous_output[index + offset] = val; \ + return; \ + } else { \ + if (val) \ + topp->name | (1 << (msb - index)); \ + else \ + topp->name &= ~(1 << (msb - index)); \ + previous_output[index + offset] = val; \ + return; \ } #include "inouts.h" From 413382bd5642ce3a58a2b569b7c17a45fc35f79c Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Sun, 18 Aug 2024 14:16:42 +0200 Subject: [PATCH 3/4] Add simulator version info to raw file in batch mode, using the line 'Command:...' --- src/frontend/outitf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/frontend/outitf.c b/src/frontend/outitf.c index 38cff9194..c04a91c62 100644 --- a/src/frontend/outitf.c +++ b/src/frontend/outitf.c @@ -36,6 +36,8 @@ extern char *spice_analysis_get_name(int index); extern char *spice_analysis_get_description(int index); extern int EVTsetup_plot(CKTcircuit* ckt, char* plotname); +extern IFsimulator SIMinfo; +extern char Spice_Build_Date[]; static int beginPlot(JOB *analysisPtr, CKTcircuit *circuitPtr, char *cktName, char *analName, char *refName, int refType, int numNames, char **dataNames, int dataType, @@ -915,6 +917,9 @@ fileInit(runDesc *run) sprintf(buf, "Date: %s\n", datestring()); n += strlen(buf); fputs(buf, run->fp); + sprintf(buf, "Command: %s-%s, Build %s\n", ft_sim->simulator, ft_sim->version, Spice_Build_Date); + n += strlen(buf); + fputs(buf, run->fp); sprintf(buf, "Plotname: %s\n", run->type); n += strlen(buf); fputs(buf, run->fp); @@ -933,7 +938,6 @@ fileInit(runDesc *run) run->pointPos = (long) n; fprintf(run->fp, "0 \n"); /* Save 8 spaces here. */ - /*fprintf(run->fp, "Command: version %s\n", ft_sim->version);*/ fprintf(run->fp, "Variables:\n"); printf("No. of Data Columns : %d \n", run->numData); From 4a8000cad9c51a8fc37d791c33504f4b64540147 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Sun, 18 Aug 2024 14:21:03 +0200 Subject: [PATCH 4/4] Add simulator version info to raw file ('write' commad) using an extra line 'Command: ...'). The old sequence (adding commands manually to raw file) is still available. The 'Command: anycommand' will not be executed if loading an ngspice-generated raw file. Raw files from other simulators may generate a warning that the command is not available. --- src/frontend/rawfile.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/frontend/rawfile.c b/src/frontend/rawfile.c index 1b5ed8e1e..75bfe7060 100644 --- a/src/frontend/rawfile.c +++ b/src/frontend/rawfile.c @@ -21,6 +21,8 @@ Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group #include "ngspice/compatmode.h" +extern IFsimulator SIMinfo; +extern char Spice_Build_Date[]; static void fixdims(struct dvec *v, char *s); @@ -112,6 +114,7 @@ void raw_write(char *name, struct plot *pl, bool app, bool binary) fprintf(fp, "Title: %s\n", pl->pl_title); fprintf(fp, "Date: %s\n", pl->pl_date); + fprintf(fp, "Command: %s-%s, Build %s\n", ft_sim->simulator, ft_sim->version, Spice_Build_Date); fprintf(fp, "Plotname: %s\n", pl->pl_name); fprintf(fp, "Flags: %s%s\n", realflag ? "real" : "complex", raw_padding ? "" : " unpadded"); @@ -121,11 +124,11 @@ void raw_write(char *name, struct plot *pl, bool app, bool binary) dimstring(dims, numdims, buf); fprintf(fp, "Dimensions: %s\n", buf); } - - for (wl = pl->pl_commands; wl; wl = wl->wl_next) { - fprintf(fp, "Command: %s\n", wl->wl_word); + if (pl->pl_commands) { + for (wl = pl->pl_commands; wl; wl = wl->wl_next) { + fprintf(fp, "Command: %s\n", wl->wl_word); + } } - for (vv = pl->pl_env; vv; vv = vv->va_next) { wl = cp_varwl(vv); if (vv->va_type == CP_BOOL) { @@ -451,15 +454,19 @@ raw_read(char *name) { } else if (ciprefix("command:", buf)) { /* Note that we reverse these commands eventually... */ s = SKIP(buf); - NONL(s); - if (curpl) { - curpl->pl_commands = wl_cons(copy(s), curpl->pl_commands); - wl = curpl->pl_commands; - } else { - fprintf(cp_err, "Error: misplaced Command: line\n"); + /* Exec command only if not ngspice simulator info */ + if (!ciprefix(ft_sim->simulator, s)) { + NONL(s); + if (curpl) { + curpl->pl_commands = wl_cons(copy(s), curpl->pl_commands); + wl = curpl->pl_commands; + } + else { + fprintf(cp_err, "Error: misplaced Command: line\n"); + } + /* Now execute the command if we can. */ + (void)cp_evloop(s); } - /* Now execute the command if we can. */ - (void) cp_evloop(s); } else if (ciprefix("option:", buf)) { s = SKIP(buf); NONL(s);