From 9e432838c081948f27a45056ad868b48aff8ed61 Mon Sep 17 00:00:00 2001 From: holger Date: Sun, 5 Feb 2023 11:25:42 +0100 Subject: [PATCH 01/29] Patch by Robert Turnbull: remove warning messages --- src/xspice/icm/digital/d_osc/cfunc.mod | 3 ++- src/xspice/icm/digital/d_pwm/cfunc.mod | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/xspice/icm/digital/d_osc/cfunc.mod b/src/xspice/icm/digital/d_osc/cfunc.mod index b76386132..567b405cf 100644 --- a/src/xspice/icm/digital/d_osc/cfunc.mod +++ b/src/xspice/icm/digital/d_osc/cfunc.mod @@ -20,6 +20,7 @@ MODIFICATIONS 23 Aug 1991 Jeffrey P. Murray 30 Sep 1991 Jeffrey P. Murray 09 Nov 2022 Holger Vogt + 05 Jan 2023 Robert Turnbull SUMMARY @@ -54,7 +55,7 @@ NON-STANDARD FEATURES #include "d_osc.h" /* ...contains macros & type defns. for this model. 7/24/91 - JPM */ - +#include /*=== CONSTANTS ========================*/ diff --git a/src/xspice/icm/digital/d_pwm/cfunc.mod b/src/xspice/icm/digital/d_pwm/cfunc.mod index e64d6efcd..3d73e4ced 100644 --- a/src/xspice/icm/digital/d_pwm/cfunc.mod +++ b/src/xspice/icm/digital/d_pwm/cfunc.mod @@ -20,6 +20,7 @@ MODIFICATIONS 23 Aug 1991 Jeffrey P. Murray 30 Sep 1991 Jeffrey P. Murray 06 Oct 2022 Holger Vogt + 05 Jan 2023 Robert Turnbull SUMMARY @@ -54,6 +55,7 @@ NON-STANDARD FEATURES #include "d_pwm.h" /* ...contains macros & type defns. for this model. 7/24/91 - JPM */ +#include From 7fdd3d9b4dde372f67f82aa39fbaf67afb77fd97 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Mon, 6 Feb 2023 12:05:59 +0100 Subject: [PATCH 02/29] Patch 112 by Robert Turnbull Remove compiler warning. --- src/misc/string.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/misc/string.c b/src/misc/string.c index 147fe3648..1374607da 100644 --- a/src/misc/string.c +++ b/src/misc/string.c @@ -88,7 +88,7 @@ char *dup_string(const char *str, size_t n_char) char *tvprintf(const char *fmt, va_list args) { - char buf[1024]; + static char buf[1024]; char *p = buf; int size = sizeof(buf); int nchars; From 408c763c340a1be9b8fabb34afb951a30fd9dae6 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Tue, 7 Feb 2023 11:03:10 +0100 Subject: [PATCH 03/29] really run a dc simulation --- examples/osdi/bsimcmg/simple_inverter_dc.sp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/osdi/bsimcmg/simple_inverter_dc.sp b/examples/osdi/bsimcmg/simple_inverter_dc.sp index 13b164094..71ad6aa53 100644 --- a/examples/osdi/bsimcmg/simple_inverter_dc.sp +++ b/examples/osdi/bsimcmg/simple_inverter_dc.sp @@ -12,10 +12,10 @@ NP1 vout vin supply supply BSIMCMG_osdi_P NN1 vout vin 0 0 BSIMCMG_osdi_N * --- DC Analysis --- -*.dc vsig 0 1 0.01 +.dc vsig 0 1 0.01 * --- Transient Analysis --- -.tran 10n 2u +*.tran 10n 2u .control * pre_osdi ../osdi_libs/bsimcmg.osdi From 8d924225e3b728199fddd779a5f3b50268a27f7b Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Tue, 7 Feb 2023 11:04:09 +0100 Subject: [PATCH 04/29] Remove the obsolete RETSIGTYPE, replace by void --- configure.ac | 1 - src/frontend/aspice.c | 4 ++-- src/frontend/evaluate.c | 4 ++-- src/frontend/parser/unixcom.c | 2 +- src/frontend/resource.c | 4 ++-- src/frontend/signal_handler.c | 18 +++++++++--------- src/frontend/signal_handler.h | 18 +++++++++--------- src/include/ngspice/defines.h | 4 ++-- visualc/src/include/ngspice/config.h | 3 --- 9 files changed, 27 insertions(+), 31 deletions(-) diff --git a/configure.ac b/configure.ac index 5492f6bf0..a72f08971 100644 --- a/configure.ac +++ b/configure.ac @@ -888,7 +888,6 @@ AM_CONDITIONAL([OLDAPPS], [test "x$enable_oldapps" = xyes]) # Check for a few typdefs: AC_TYPE_PID_T -AC_TYPE_SIGNAL # sighandler_t is the type of the signal handler on GNU variants, # sig_t is the type of a signal handler on 4.4BSD's, diff --git a/src/frontend/aspice.c b/src/frontend/aspice.c index 671708b38..7125d64ea 100644 --- a/src/frontend/aspice.c +++ b/src/frontend/aspice.c @@ -52,7 +52,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group # define SEEK_SET 0 #endif -static RETSIGTYPE sigchild(void); +static void sigchild(void); struct proc { int pr_pid; /* The pid of the spice job. */ @@ -163,7 +163,7 @@ com_jobs(wordlist *wl) } -static RETSIGTYPE +static void sigchild(void) { numchanged++; diff --git a/src/frontend/evaluate.c b/src/frontend/evaluate.c index 044f85d51..f38aff246 100644 --- a/src/frontend/evaluate.c +++ b/src/frontend/evaluate.c @@ -20,7 +20,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "ngspice/sim.h" /* To get SV_VOLTAGE definition */ -static RETSIGTYPE sig_matherr(void); +static void sig_matherr(void); static struct dvec *apply_func(struct func *func, struct pnode *arg); static struct dvec *ft_ternary(struct pnode *node); static char *mkcname(char what, char *v1, char *v2); @@ -33,7 +33,7 @@ static char *mkcname(char what, char *v1, char *v2); static JMP_BUF matherrbuf; -static RETSIGTYPE +static void sig_matherr(void) { fprintf(cp_err, "Error: argument out of range for math function\n"); diff --git a/src/frontend/parser/unixcom.c b/src/frontend/parser/unixcom.c index 6186acae2..6cbc46da7 100644 --- a/src/frontend/parser/unixcom.c +++ b/src/frontend/parser/unixcom.c @@ -187,7 +187,7 @@ tryexec(char *name, char *argv[]) # endif int pid, j; - RETSIGTYPE (*svint)(), (*svquit)(), (*svtstp)(); + void (*svint)(), (*svquit)(), (*svtstp)(); pid = vfork(); if (pid == 0) { diff --git a/src/frontend/resource.c b/src/frontend/resource.c index b8013eec9..09b40863b 100644 --- a/src/frontend/resource.c +++ b/src/frontend/resource.c @@ -570,7 +570,7 @@ static int get_sysmem(struct sys_mem *memall) static JMP_BUF env; -static RETSIGTYPE +static void fault(void) { signal(SIGSEGV, (SIGNAL_FUNCTION) fault); /* SysV style */ @@ -586,7 +586,7 @@ baseaddr(void) #else char *low, *high, *at; long x; - RETSIGTYPE (*orig_signal)(); + void (*orig_signal)(); if (getenv("SPICE_NO_DATASEG_CHECK")) return 0; diff --git a/src/frontend/signal_handler.c b/src/frontend/signal_handler.c index 5b414e8d0..058c3c352 100644 --- a/src/frontend/signal_handler.c +++ b/src/frontend/signal_handler.c @@ -70,7 +70,7 @@ ft_sigintr_cleanup(void) /* invoke this function upon keyboard interrupt */ -RETSIGTYPE +void ft_sigintr(void) { static int interrupt_counter = 0; @@ -103,7 +103,7 @@ ft_sigintr(void) } -RETSIGTYPE +void sigfloat(int code) { fperror("Error", code); @@ -117,7 +117,7 @@ sigfloat(int code) #ifdef SIGTSTP -RETSIGTYPE +void sigstop(void) { gr_clean(); @@ -127,7 +127,7 @@ sigstop(void) } -RETSIGTYPE +void sigcont(void) { (void) signal(SIGTSTP, (SIGNAL_FUNCTION) sigstop); @@ -141,7 +141,7 @@ sigcont(void) /* Special (void) signal handlers. */ -RETSIGTYPE +void sigill(void) { fprintf(cp_err, "\ninternal error -- illegal instruction\n"); @@ -149,7 +149,7 @@ sigill(void) } -RETSIGTYPE +void sigbus(void) { fprintf(cp_err, "\ninternal error -- bus error\n"); @@ -157,7 +157,7 @@ sigbus(void) } -RETSIGTYPE +void sigsegv(void) { fprintf(cp_err, "\ninternal error -- segmentation violation\n"); @@ -167,7 +167,7 @@ sigsegv(void) fatal(); } -RETSIGTYPE +void sigsegvsh(void) { fprintf(cp_err, "\ninternal error -- segmentation violation\n"); @@ -175,7 +175,7 @@ sigsegvsh(void) } -RETSIGTYPE +void sig_sys(void) { fprintf(cp_err, "\ninternal error -- bad argument to system call\n"); diff --git a/src/frontend/signal_handler.h b/src/frontend/signal_handler.h index cfe1eca46..7ef02c6da 100644 --- a/src/frontend/signal_handler.h +++ b/src/frontend/signal_handler.h @@ -6,15 +6,15 @@ #ifndef ngspice_SIGNAL_HANDLER_H #define ngspice_SIGNAL_HANDLER_H -RETSIGTYPE ft_sigintr(void); -RETSIGTYPE sigfloat(int code); -RETSIGTYPE sigstop(void); -RETSIGTYPE sigcont(void); -RETSIGTYPE sigill(void); -RETSIGTYPE sigbus(void); -RETSIGTYPE sigsegv(void); -RETSIGTYPE sigsegvsh(void); -RETSIGTYPE sig_sys(void); +void ft_sigintr(void); +void sigfloat(int code); +void sigstop(void); +void sigcont(void); +void sigill(void); +void sigbus(void); +void sigsegv(void); +void sigsegvsh(void); +void sig_sys(void); extern JMP_BUF jbuf; diff --git a/src/include/ngspice/defines.h b/src/include/ngspice/defines.h index d5dadd650..62e2737bd 100644 --- a/src/include/ngspice/defines.h +++ b/src/include/ngspice/defines.h @@ -101,7 +101,7 @@ #define HAS_TIME_H #define HAS_RLIMIT_ - +#define void void #ifndef SIGNAL_FUNCTION # ifdef HAVE_SIGHANDLER_T @@ -111,7 +111,7 @@ # elif HAVE___SIGHANDLER_T # define SIGNAL_FUNCTION __sighandler_t # else -# define SIGNAL_FUNCTION RETSIGTYPE (*)(int) +# define SIGNAL_FUNCTION void (*)(int) # endif #endif diff --git a/visualc/src/include/ngspice/config.h b/visualc/src/include/ngspice/config.h index 47a327dcc..0381179f1 100644 --- a/visualc/src/include/ngspice/config.h +++ b/visualc/src/include/ngspice/config.h @@ -499,9 +499,6 @@ /* Define if you want to debug pole-zero analysis */ /* #undef PZDEBUG */ -/* Define as the return type of signal handlers (`int' or `void'). */ -#define RETSIGTYPE void - /* Define to the type of arg 1 for `select'. */ /* #undef SELECT_TYPE_ARG1 */ From 3ccc4d4af5b80f2aa6700b5b9764f4030392b028 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Tue, 7 Feb 2023 14:46:22 +0100 Subject: [PATCH 05/29] Remove obsolete macros, replace other by newer versions --- configure.ac | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/configure.ac b/configure.ac index a72f08971..9cf63f46e 100644 --- a/configure.ac +++ b/configure.ac @@ -31,7 +31,7 @@ AC_REVISION([$Revision: ngspice_version$]) AC_CONFIG_SRCDIR([src/ngspice.c]) # Create a configuration header -AC_CONFIG_HEADER([src/include/ngspice/config.h]) +AC_CONFIG_HEADERS([src/include/ngspice/config.h]) # Initialize automake stuff AM_INIT_AUTOMAKE([-Wall -Werror nostdinc serial-tests]) @@ -360,19 +360,11 @@ if test "x$enable_gprof" = xyes; then fi # Checks for ANSI-C header files. -AC_HEADER_STDC + AC_CHECK_HEADERS([strings.h]) if test "x$enable_ansi" = xyes; then - AC_PROG_CC() - AC_DIAGNOSE([obsolete], [AM_PROG_CC_STDC: - your code should no longer depend upon `am_cv_prog_cc_stdc', but upon - `ac_cv_prog_cc_stdc'. Remove this warning and the assignment when - you adjust the code. You can also remove the above call to - AC_PROG_CC if you already called it elsewhere.]) - am_cv_prog_cc_stdc=$ac_cv_prog_cc_stdc - - if test "x$am_cv_prog_cc_stdc" != xyes ; then + if test "x$ac_cv_prog_cc_stdc" != xyes ; then AC_MSG_WARN([Failed to find Ansi flag!]) fi fi @@ -652,15 +644,8 @@ AC_SUBST([TCL_LIB_SPEC]) # ################################################################# - - # Checks for programs -AC_LIBTOOL_WIN32_DLL -AC_LIBTOOL_DLOPEN AM_PROG_CC_C_O -## AM_PROG_LIBTOOL -AC_PROG_LIBTOOL - # --with-windows : the user wants to use generate the MS WINDOWS GUI executable # old command version, deprecated, use --with-wingui @@ -759,7 +744,6 @@ AC_TYPE_SIZE_T # Checks for library functions. AC_FUNC_CLOSEDIR_VOID AC_FUNC_SELECT_ARGTYPES -AC_FUNC_SETVBUF_REVERSED AC_FUNC_VPRINTF # Check if the user wants to use the appropriate rpath commands to compile in @@ -906,7 +890,6 @@ AC_CHECK_HEADERS([arpa/inet.h netdb.h netinet/in.h stddef.h sys/file.h sys/param # Check time and resources headers and functions: -AC_HEADER_TIME AC_STRUCT_TM AC_STRUCT_TIMEZONE AC_CHECK_FUNCS([localtime]) From 5c797c5f78f4b2afb4c9e521d64bae65acc58f3f Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Sat, 11 Feb 2023 13:57:44 +0100 Subject: [PATCH 06/29] bug report 619 by Hanspeter Niederstrasser remove double inclusion of stdlib.h Correction of commit 9e432838c ("Patch by Robert Turnbull: remove warning messages", 2023-02-05) --- src/xspice/icm/digital/d_osc/cfunc.mod | 1 - src/xspice/icm/digital/d_pwm/cfunc.mod | 1 - 2 files changed, 2 deletions(-) diff --git a/src/xspice/icm/digital/d_osc/cfunc.mod b/src/xspice/icm/digital/d_osc/cfunc.mod index 567b405cf..6f16a93e4 100644 --- a/src/xspice/icm/digital/d_osc/cfunc.mod +++ b/src/xspice/icm/digital/d_osc/cfunc.mod @@ -181,7 +181,6 @@ static void cm_d_osc_callback(ARGS, * * *************************************************************/ -#include void cm_d_osc(ARGS) { diff --git a/src/xspice/icm/digital/d_pwm/cfunc.mod b/src/xspice/icm/digital/d_pwm/cfunc.mod index 3d73e4ced..4aa5ec6be 100644 --- a/src/xspice/icm/digital/d_pwm/cfunc.mod +++ b/src/xspice/icm/digital/d_pwm/cfunc.mod @@ -184,7 +184,6 @@ static void cm_d_pwm_callback(ARGS, * * *************************************************************/ -#include void cm_d_pwm(ARGS) { From 69ccefe09259201da9e0ba5e095c50d7c73406f5 Mon Sep 17 00:00:00 2001 From: dwarning Date: Sun, 12 Feb 2023 08:35:29 +0100 Subject: [PATCH 07/29] ret variable only used for openMP enabled --- src/osdi/osdiload.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/osdi/osdiload.c b/src/osdi/osdiload.c index 6612323d4..43d20a05d 100644 --- a/src/osdi/osdiload.c +++ b/src/osdi/osdiload.c @@ -174,13 +174,13 @@ extern int OSDIload(GENmodel *inModel, CKTcircuit *ckt) { sim_info.flags |= CALC_NOISE | ANALYSIS_NOISE; } - int ret = OK; - OsdiRegistryEntry *entry = osdi_reg_entry_model(inModel); const OsdiDescriptor *descr = entry->descriptor; uint32_t eval_flags = 0; #ifdef USE_OMP + int ret = OK; + /* use openmp 3.0 tasks to parallelize linked list transveral */ #pragma omp parallel #pragma omp single From 6726489f4a8006361057d141504c6a9eaeff0ff1 Mon Sep 17 00:00:00 2001 From: dwarning Date: Wed, 15 Feb 2023 15:24:55 +0100 Subject: [PATCH 08/29] correct fft dc scaling bug #620 --- src/frontend/com_fft.c | 6 ++++-- src/maths/cmaths/cmath4.c | 14 ++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/frontend/com_fft.c b/src/frontend/com_fft.c index 0dc42ddc6..2d592525b 100644 --- a/src/frontend/com_fft.c +++ b/src/frontend/com_fft.c @@ -179,7 +179,9 @@ com_fft(wordlist *wl) fftw_execute(plan_forward); scale = (double) fpts - 1.0; - for (j = 0; j < fpts; j++) { + fdvec[i][0].cx_real = out[0][0]/scale/2.0; + fdvec[i][0].cx_imag = 0.0; + for (j = 1; j < fpts; j++) { fdvec[i][j].cx_real = out[j][0]/scale; fdvec[i][j].cx_imag = out[j][1]/scale; } @@ -212,7 +214,7 @@ com_fft(wordlist *wl) scale = (double) fpts - 1.0; /* Re(x[0]), Re(x[N/2]), Re(x[1]), Im(x[1]), Re(x[2]), Im(x[2]), ... Re(x[N/2-1]), Im(x[N/2-1]). */ - fdvec[i][0].cx_real = in[0]/scale; + fdvec[i][0].cx_real = in[0]/scale/2.0; fdvec[i][0].cx_imag = 0.0; for (j = 1; j < fpts-1; j++) { fdvec[i][j].cx_real = in[2*j]/scale; diff --git a/src/maths/cmaths/cmath4.c b/src/maths/cmaths/cmath4.c index b3dd42f9a..11d7bf8f7 100644 --- a/src/maths/cmaths/cmath4.c +++ b/src/maths/cmaths/cmath4.c @@ -713,7 +713,9 @@ cx_fft(void *data, short int type, int length, int *newlength, short int *newtyp outdata = alloc_c(fpts); scale = (double) fpts; - for (i = 0; i < fpts; i++) { + outdata[0].cx_real = out[0][0]/scale/2.0; + outdata[0].cx_imag = out[0][1]/scale/2.0; + for (i = 1; i < fpts; i++) { outdata[i].cx_real = out[i][0]/scale; outdata[i].cx_imag = out[i][1]/scale; } @@ -744,7 +746,9 @@ cx_fft(void *data, short int type, int length, int *newlength, short int *newtyp outdata = alloc_c(N); scale = (double) N; - for (i = 0; i < N; i++) { + outdata[0].cx_real = datax[0]/scale/2.0; + outdata[0].cx_imag = datax[1]/scale/2.0; + for (i = 1; i < N; i++) { outdata[i].cx_real = datax[2*i]/scale; outdata[i].cx_imag = datax[2*i+1]/scale; } @@ -773,7 +777,9 @@ cx_fft(void *data, short int type, int length, int *newlength, short int *newtyp fftw_execute(plan_forward); scale = (double) fpts - 1.0; - for (i = 0; i < fpts; i++) { + outdata[0].cx_real = out[0][0]/scale/2.0; + outdata[0].cx_imag = 0.0; + for (i = 1; i < fpts; i++) { outdata[i].cx_real = out[i][0]/scale; outdata[i].cx_imag = out[i][1]/scale; } @@ -798,7 +804,7 @@ cx_fft(void *data, short int type, int length, int *newlength, short int *newtyp scale = (double) fpts - 1.0; /* Re(x[0]), Re(x[N/2]), Re(x[1]), Im(x[1]), Re(x[2]), Im(x[2]), ... Re(x[N/2-1]), Im(x[N/2-1]). */ - outdata[0].cx_real = datax[0]/scale; + outdata[0].cx_real = datax[0]/scale/2.0; outdata[0].cx_imag = 0.0; for (i = 1; i < fpts-1; i++) { outdata[i].cx_real = datax[2*i]/scale; From b780201eeca5256926b8dfac9456251b80437de7 Mon Sep 17 00:00:00 2001 From: dwarning Date: Sat, 18 Feb 2023 17:14:13 +0100 Subject: [PATCH 09/29] partly revert last commit: only real input vector get special scaling for dc component --- src/maths/cmaths/cmath4.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/maths/cmaths/cmath4.c b/src/maths/cmaths/cmath4.c index 11d7bf8f7..fa2b7cb6f 100644 --- a/src/maths/cmaths/cmath4.c +++ b/src/maths/cmaths/cmath4.c @@ -713,9 +713,7 @@ cx_fft(void *data, short int type, int length, int *newlength, short int *newtyp outdata = alloc_c(fpts); scale = (double) fpts; - outdata[0].cx_real = out[0][0]/scale/2.0; - outdata[0].cx_imag = out[0][1]/scale/2.0; - for (i = 1; i < fpts; i++) { + for (i = 0; i < fpts; i++) { outdata[i].cx_real = out[i][0]/scale; outdata[i].cx_imag = out[i][1]/scale; } @@ -746,9 +744,7 @@ cx_fft(void *data, short int type, int length, int *newlength, short int *newtyp outdata = alloc_c(N); scale = (double) N; - outdata[0].cx_real = datax[0]/scale/2.0; - outdata[0].cx_imag = datax[1]/scale/2.0; - for (i = 1; i < N; i++) { + for (i = 0; i < N; i++) { outdata[i].cx_real = datax[2*i]/scale; outdata[i].cx_imag = datax[2*i+1]/scale; } From e06ad94eb641e28fc396f4ad8bc9edf2e4c1c25f Mon Sep 17 00:00:00 2001 From: dwarning Date: Sat, 18 Feb 2023 18:28:59 +0100 Subject: [PATCH 10/29] Revert "implement typedpnjlim as optional limiter for verilog-a models" This reverts commit f73d3b20a07cd206db8d7c7dd8679e6eecb02391. --- src/osdi/osdicallbacks.c | 12 ------------ src/osdi/osdidefs.h | 3 +-- src/osdi/osdiregistry.c | 1 - 3 files changed, 1 insertion(+), 15 deletions(-) diff --git a/src/osdi/osdicallbacks.c b/src/osdi/osdicallbacks.c index 1efecf212..de7b1dc97 100644 --- a/src/osdi/osdicallbacks.c +++ b/src/osdi/osdicallbacks.c @@ -50,18 +50,6 @@ double osdi_pnjlim(bool init, bool *check, double vnew, double vold, double vt, return res; } -double osdi_typedpnjlim(bool init, bool *check, double vnew, double vold, double vt, - double vcrit, double type) { - if (init) { - *check = true; - return vcrit; - } - int icheck = 0; - double res = DEVpnjlim(type*vnew, vold, vt, vcrit, &icheck); - *check = icheck != 0; - return res; -} - double osdi_limvds(bool init, bool *check, double vnew, double vold) { if (init) { *check = true; diff --git a/src/osdi/osdidefs.h b/src/osdi/osdidefs.h index d1108b666..6130482ad 100644 --- a/src/osdi/osdidefs.h +++ b/src/osdi/osdidefs.h @@ -96,8 +96,7 @@ typedef void (*osdi_log_ptr)(void *handle, char *msg, uint32_t lvl); double osdi_pnjlim(bool init, bool *icheck, double vnew, double vold, double vt, double vcrit); -double osdi_typedpnjlim(bool init, bool *icheck, double vnew, double vold, double vt, - double vcrit, double type); + double osdi_limvds(bool init, bool *icheck, double vnew, double vold); double osdi_limitlog(bool init, bool *icheck, double vnew, double vold, double LIM_TOL); diff --git a/src/osdi/osdiregistry.c b/src/osdi/osdiregistry.c index 66d14704b..6da846451 100644 --- a/src/osdi/osdiregistry.c +++ b/src/osdi/osdiregistry.c @@ -338,7 +338,6 @@ extern OsdiObjectFile load_object_file(const char *input) { for (uint32_t i = 0; i < lim_table_len; i++) { int expected_args = -1; IS_LIM_FUN("pnjlim", 2, osdi_pnjlim) - IS_LIM_FUN("typedpnjlim", 3, osdi_typedpnjlim) IS_LIM_FUN("limvds", 0, osdi_limvds) IS_LIM_FUN("fetlim", 1, osdi_fetlim) IS_LIM_FUN("limitlog", 1, osdi_limitlog) From 2ff5281b1f160dd8f597efe2063e7778aec7a31b Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Sat, 18 Feb 2023 18:54:54 +0100 Subject: [PATCH 11/29] Definitely exclude A devices from power probing (and others with less than 2 pins). --- src/frontend/inpc_probe.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/frontend/inpc_probe.c b/src/frontend/inpc_probe.c index 112b1208d..8a7a79f47 100644 --- a/src/frontend/inpc_probe.c +++ b/src/frontend/inpc_probe.c @@ -874,6 +874,12 @@ void inp_probe(struct card* deck) else numnodes = get_number_terminals(thisline); + if (numnodes < 2) { + fprintf(stderr, "Warning: Power mesasurement not available,\n .probe %s will be ignored\n", wltmp->wl_word); + tfree(instname); + continue; + } + int err = 0; /* call fcn with power requested */ err = setallvsources(tmpcard, instances, instname, numnodes, haveall, TRUE); @@ -1266,7 +1272,7 @@ void modprobenames(INPtables* tab) { If .probe p(Q1) is found, flag power is true, then do additional power calculations: Define a reference voltage of an n-terminal device as Vref = (V(1) + V(2) +...+ V(n)) / n with terminal (node) voltages V(n). Calculate power PQ1 = (v(1) - Vref) * i1 + (V(2) - Vref) * i2 + ... + (V(n) - Vref) * in) with terminal currents in. - See "Quantities of a Multiterminal Circuit Determined on the Basis of Kirchhoff’s Laws", M. Depenbrock, + See "Quantities of a Multiterminal Circuit Determined on the Basis of Kirchhoff�s Laws", M. Depenbrock, ETEP Vol. 8, No. 4, July/August 1998. probe_int_ is used to trigger supressing the vectors when saving the results. Internal vectors thus are not saved. */ From 8be20729e16681e28ac815c081060e01877ae92c Mon Sep 17 00:00:00 2001 From: dwarning Date: Sun, 19 Feb 2023 19:31:06 +0100 Subject: [PATCH 12/29] diode recombination current emission coefficient default to 2 --- src/spicelib/devices/dio/diosetup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spicelib/devices/dio/diosetup.c b/src/spicelib/devices/dio/diosetup.c index ef0695669..2cae77ca0 100644 --- a/src/spicelib/devices/dio/diosetup.c +++ b/src/spicelib/devices/dio/diosetup.c @@ -180,7 +180,7 @@ DIOsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) model->DIOte_max = 1e99; } if(!model->DIOrecEmissionCoeffGiven) { - model->DIOrecEmissionCoeff = 1; + model->DIOrecEmissionCoeff = 2; } if(!model->DIOrecSatCurGiven) { model->DIOrecSatCur = 1e-14; From 7efa7a83633dd8c2d8de8908595c15a5de4c88bf Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Sun, 19 Feb 2023 23:03:30 +0100 Subject: [PATCH 13/29] Enable potential calls to tprint() for debugging --- src/frontend/inp.c | 1 + src/frontend/subckt.c | 1 + 2 files changed, 2 insertions(+) diff --git a/src/frontend/inp.c b/src/frontend/inp.c index 86652c08e..bf6d954d5 100644 --- a/src/frontend/inp.c +++ b/src/frontend/inp.c @@ -60,6 +60,7 @@ static char *upper(register char *string); static void rem_unused_mos_models(struct card* deck); extern void com_optran(wordlist * wl); +extern void tprint(struct card *deck); //void inp_source_recent(void); diff --git a/src/frontend/subckt.c b/src/frontend/subckt.c index 3d5b7b337..9579784a7 100644 --- a/src/frontend/subckt.c +++ b/src/frontend/subckt.c @@ -77,6 +77,7 @@ Modified: 2000 AlansFixes extern void line_free_x(struct card *deck, bool recurse); extern int get_number_terminals(char* c); +extern void tprint(struct card* deck); #define line_free(line, flag) \ do { \ From 3e433e9ecc01fae6d4b78e3aea9b33a73e83b4ab Mon Sep 17 00:00:00 2001 From: Brian Taylor Date: Sat, 4 Feb 2023 16:33:39 -0800 Subject: [PATCH 14/29] Remove dead code. --- src/frontend/logicexp.c | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/src/frontend/logicexp.c b/src/frontend/logicexp.c index ec4d95d08..b92ea5b28 100644 --- a/src/frontend/logicexp.c +++ b/src/frontend/logicexp.c @@ -1248,30 +1248,8 @@ static BOOL gen_gates(PTABLE gate_tab, SYM_TAB parser_symbols) } ds_cat_printf(&instance, "%s ", get_inst_name()); if (in_count == 1) { - /* If the input name is inv_out_ use the - and instantiate an inverter to avoid an extra buffer. - */ - char *tail = NULL; - SYM_TAB ent; - tail = get_inv_tail(ds_get_buf(&in_names)); - if (tail && strlen(tail) > 0) { - ds_clear(&gate_name); - ds_cat_str(&gate_name, lex_gate_name('~', TRUE)); - ds_cat_printf(&instance, "%s %s ", tail, - ds_get_buf(&out_name)); - ent = member_sym_tab(tail, parser_symbols); - if (!ent) { - goto gen_error; - } - if ((ent->attribute & SYM_INVERTER) == 0) { - goto gen_error; - } - ent->ref_count--; - } else { - ds_cat_printf(&instance, "%s %s ", ds_get_buf(&in_names), - ds_get_buf(&out_name)); - } - + ds_cat_printf(&instance, "%s %s ", ds_get_buf(&in_names), + ds_get_buf(&out_name)); } else { ds_cat_printf(&instance, "[%s ] %s ", ds_get_buf(&in_names), ds_get_buf(&out_name)); From d54ccb5e01ccb2fb9874f16a3f9d8dca8a2a87ec Mon Sep 17 00:00:00 2001 From: Brian Taylor Date: Sat, 11 Feb 2023 10:13:03 -0800 Subject: [PATCH 15/29] Use dstrings where fixed size char buffers should not have been used. --- src/frontend/logicexp.c | 137 +++++++++++++++++++++++----------------- 1 file changed, 78 insertions(+), 59 deletions(-) diff --git a/src/frontend/logicexp.c b/src/frontend/logicexp.c index b92ea5b28..4893792b4 100644 --- a/src/frontend/logicexp.c +++ b/src/frontend/logicexp.c @@ -519,11 +519,10 @@ static TLINE gen_tab_add_line(char *line, BOOL ignore_blank) return t; } -static char *get_temp_from_line(char *line, BOOL begin) +static char *get_temp_from_line(char *line, BOOL begin, DSTRING *pds) { - /* First occurrence of "tmp" on the line */ - /* If begin is TRUE then "tmp" must be at the start of line */ - static char lbuf[64]; + /* First occurrence of "tmpx.." on the line, x is a digit */ + /* If begin is TRUE then "tmpx.." must be at the start of line */ char *p, *q; int j = 0; p = strstr(line, "tmp"); @@ -531,41 +530,47 @@ static char *get_temp_from_line(char *line, BOOL begin) return NULL; if (begin && p != line) return NULL; - for (q = p, j = 0; isalnum(q[j]) || q[j] == '_'; j++) { - if (j >= 63) - return NULL; - lbuf[j] = q[j]; + ds_clear(pds); + p += 3; + if (!isdigit(p[0])) + return NULL; + ds_cat_str(pds, "tmp"); + for (q = p, j = 0; isdigit(q[j]) || q[j] == '_'; j++) { + ds_cat_char(pds, q[j]); } - lbuf[j] = '\0'; - return lbuf; + ds_cat_char(pds, '\0'); + return ds_get_buf(pds); } -static char *find_temp_begin(char *line) +static char *find_temp_begin(char *line, DSTRING *pds) { - return get_temp_from_line(line, TRUE); + return get_temp_from_line(line, TRUE, pds); } -static char *find_temp_anywhere(char *line) +static char *find_temp_anywhere(char *line, DSTRING *pds) { - return get_temp_from_line(line, FALSE); + return get_temp_from_line(line, FALSE, pds); } static int get_temp_depth(char *line) { - char buf[64]; char *p, *endp; - int depth; - p = find_temp_anywhere(line); + int depth = -1; + DS_CREATE(dstr, 128); + p = find_temp_anywhere(line, &dstr); if (p) { + char *buf; + buf = TMALLOC(char, strlen(p) + 1); strcpy(buf, p); p = strstr(buf + strlen("tmp"), "__"); if (p) { p = p + 2; depth = (int) strtol(p, &endp, 10); - return depth; } + tfree(buf); } - return -1; + ds_free(&dstr); + return depth; } static TLINE tab_find(PTABLE pt, char *str, BOOL start_of_line) @@ -606,7 +611,6 @@ static void ptable_print(PTABLE pt) /* Start of logicexp parser */ static char *get_inst_name(void); -static char *get_inverter_output_name(char *input); static void aerror(char *s); static BOOL amatch(int t); static BOOL bexpr(void); @@ -637,34 +641,31 @@ static char *get_inst_name(void) return name; } -static char *get_inverter_output_name(char *input) +static char *get_inverter_output_name(char *input, DSTRING *pds) { - static char buf[LEX_BUF_SZ]; LEXER lx = parse_lexer; // FIX ME keep this name in the symbol table to ensure uniqueness - (void) sprintf(buf, "inv_out__%s", input); - if (member_sym_tab(buf, lx->lexer_sym_tab)) - fprintf(stderr, "ERROR %s is already in use\n", buf); - return buf; + ds_clear(pds); + ds_cat_printf(pds, "inv_out__%s", input); + if (member_sym_tab(ds_get_buf(pds), lx->lexer_sym_tab)) + fprintf(stderr, "ERROR %s is already in use\n", ds_get_buf(pds)); + return ds_get_buf(pds); } -static char *get_inv_tail(char *str) +static char *get_inv_tail(char *str, DSTRING *pds) { - static char lbuf[64]; char *p = NULL, *q = NULL; int j = 0; size_t slen = strlen("inv_out__"); - p = strstr(str, "inv_out__"); if (!p) return NULL; + ds_clear(pds); for (q = p + slen, j = 0; q[j] != '\0' && !isspace(q[j]); j++) { - if (j >= 63) - return NULL; - lbuf[j] = q[j]; + ds_cat_char(pds, q[j]); } - lbuf[j] = '\0'; - return lbuf; + ds_cat_char(pds, '\0'); + return ds_get_buf(pds); } static void gen_models(void) @@ -776,8 +777,11 @@ static BOOL bfactor(void) if (lookahead == LEX_ID) { entry = add_sym_tab_entry(lx->lexer_buf, SYM_ID, &lx->lexer_sym_tab); if (is_not) { + DS_CREATE(dstr, 128); + ds_clear(&dstr); ds_cat_printf(&d_curr_line, "%s ", - get_inverter_output_name(lx->lexer_buf)); + get_inverter_output_name(lx->lexer_buf, &dstr)); + ds_free(&dstr); entry->attribute |= SYM_INVERTER; entry->ref_count++; } else { @@ -953,12 +957,14 @@ static PTABLE optimize_gen_tab(PTABLE pt) DS_CREATE(alias, 64); DS_CREATE(non_tmp_name, 64); DS_CREATE(tmp_name, 64); + DS_CREATE(find_str, 128); if (!pt || !pt->first) { ds_free(&scratch); ds_free(&alias); ds_free(&non_tmp_name); ds_free(&tmp_name); + ds_free(&find_str); return NULL; } t = pt->first; @@ -977,7 +983,7 @@ static PTABLE optimize_gen_tab(PTABLE pt) ds_clear(&alias); entry = NULL; found_tilde = FALSE; - if (find_temp_begin(t->line)) + if (find_temp_begin(t->line, &find_str)) starts_with_temp = TRUE; else starts_with_temp = FALSE; @@ -1041,7 +1047,7 @@ static PTABLE optimize_gen_tab(PTABLE pt) val = lexer_scan(lxr); idnum = 0; entry = NULL; - if (find_temp_begin(t->line)) + if (find_temp_begin(t->line, &find_str)) starts_with_temp = TRUE; else starts_with_temp = FALSE; @@ -1066,12 +1072,12 @@ static PTABLE optimize_gen_tab(PTABLE pt) ds_cat_printf(&scratch, "%s ", lxr->lexer_buf); if (tok_count == 1) { ds_clear(&non_tmp_name); - if (!find_temp_begin(lxr->lexer_buf)) + if (!find_temp_begin(lxr->lexer_buf, &find_str)) ds_cat_str(&non_tmp_name, lxr->lexer_buf); } else if (tok_count == 3) { if (ds_get_length(&non_tmp_name) > 0) { char *str1 = NULL; - str1 = find_temp_begin(lxr->lexer_buf); + str1 = find_temp_begin(lxr->lexer_buf, &find_str); if (str1) { ds_clear(&tmp_name); ds_cat_str(&tmp_name, lxr->lexer_buf); @@ -1138,6 +1144,7 @@ quick_return: ds_free(&scratch); ds_free(&non_tmp_name); ds_free(&tmp_name); + ds_free(&find_str); delete_lexer(lxr); delete_sym_tab(alias_tab); @@ -1189,8 +1196,9 @@ static BOOL gen_gates(PTABLE gate_tab, SYM_TAB parser_symbols) ds_cat_str(&out_name, lxr->lexer_buf); } else { // input name char *tail = NULL; + DS_CREATE(dstr, 64); in_count++; - tail = get_inv_tail(lxr->lexer_buf); + tail = get_inv_tail(lxr->lexer_buf, &dstr); if (tail && strlen(tail) > 0) { ds_cat_printf(&in_names, " ~%s", tail); if (prit) { @@ -1201,6 +1209,7 @@ static BOOL gen_gates(PTABLE gate_tab, SYM_TAB parser_symbols) } else { ds_cat_printf(&in_names, " %s", lxr->lexer_buf); } + ds_free(&dstr); } } else if (val == '~') { found_tilde = TRUE; @@ -1306,10 +1315,13 @@ static void bevaluate(TLINE t, int deep) DS_CREATE(this, 64); DS_CREATE(other, 64); DS_CREATE(new_line, LEX_BUF_SZ); + DS_CREATE(find_str, 128); - s = find_temp_begin(t->line); - if (!s) + s = find_temp_begin(t->line, &find_str); + if (!s) { + ds_free(&find_str); return; + } ds_clear(&other); ds_clear(&new_line); ds_clear(&this); @@ -1325,19 +1337,19 @@ static void bevaluate(TLINE t, int deep) } t = t->next; while (t) { - s = find_temp_anywhere(t->line); + s = find_temp_anywhere(t->line, &find_str); if (s) { if (eq(ds_get_buf(&this), s)) { break; } else { if (down == 0) { - s = find_temp_begin(t->line); + s = find_temp_begin(t->line, &find_str); ds_clear(&other); ds_cat_str(&other, s); down = 1; ds_cat_printf(&new_line, " %s", ds_get_buf(&other)); } else if (down == 1) { - s = find_temp_anywhere(t->line); + s = find_temp_anywhere(t->line, &find_str); if (eq(ds_get_buf(&other), s)) { down = 0; ds_clear(&other); @@ -1345,7 +1357,7 @@ static void bevaluate(TLINE t, int deep) } } } else if (down == 0) { - s = find_temp_anywhere(t->line); + s = find_temp_anywhere(t->line, &find_str); if (!s) { ds_cat_printf(&new_line, " %s", t->line); } @@ -1356,6 +1368,7 @@ static void bevaluate(TLINE t, int deep) ds_free(&this); ds_free(&other); ds_free(&new_line); + ds_free(&find_str); return; } @@ -1850,16 +1863,16 @@ static void gen_pindly_buffers(void) ds_free(&dbuf); } -static char *get_typ_estimate(char *min, char *typ, char *max) +static char *get_typ_estimate(char *min, char *typ, char *max, DSTRING *pds) { char *tmpmax = NULL, *tmpmin = NULL; float valmin, valmax, average; char *units1, *units2; - static char tbuf[128]; + ds_clear(pds); if (typ && strlen(typ) > 0 && typ[0] != '-') { - strcpy(tbuf, typ); - return tbuf; + ds_cat_str(pds, typ); + return ds_get_buf(pds); } if (max && strlen(max) > 0 && max[0] != '-') { tmpmax = max; @@ -1872,25 +1885,25 @@ static char *get_typ_estimate(char *min, char *typ, char *max) valmin = strtof(tmpmin, &units1); valmax = strtof(tmpmax, &units2); average = (valmin + valmax) / (float)2.0; - sprintf(tbuf, "%.2f%s", average, units2); + ds_cat_printf(pds, "%.2f%s", average, units2); if (!eq(units1, units2)) { printf("WARNING units do not match\n"); } - return tbuf; + return ds_get_buf(pds); } } else if (tmpmax && strlen(tmpmax) > 0) { - strcpy(tbuf, tmpmax); - return tbuf; + ds_cat_str(pds, tmpmax); + return ds_get_buf(pds); } else if (tmpmin && strlen(tmpmin) > 0) { - strcpy(tbuf, tmpmin); - return tbuf; + ds_cat_str(pds, tmpmin); + return ds_get_buf(pds); } else { return NULL; } return NULL; } -static char *typical_estimate(char *delay_str) +static char *typical_estimate(char *delay_str, DSTRING *pds) { /* Input string (t1,t2,t2) */ int which = 0; @@ -1924,7 +1937,7 @@ static char *typical_estimate(char *delay_str) } } s = get_typ_estimate(ds_get_buf(&dmin), ds_get_buf(&dtyp), - ds_get_buf(&dmax)); + ds_get_buf(&dmax), pds); ds_free(&dmin); ds_free(&dtyp); ds_free(&dmax); @@ -1949,16 +1962,19 @@ static BOOL extract_delay( char *units; DS_CREATE(dly, 64); DS_CREATE(dtyp_max_str, 16); + DS_CREATE(tmp_ds, 128); if (val != '=') { ds_free(&dly); ds_free(&dtyp_max_str); + ds_free(&tmp_ds); return FALSE; } val = lexer_scan(lx); if (val != '{') { ds_free(&dly); ds_free(&dtyp_max_str); + ds_free(&tmp_ds); return FALSE; } val = lexer_scan(lx); @@ -1978,10 +1994,12 @@ static BOOL extract_delay( ds_cat_printf(&dly, "%c", val); if (val == ')') { char *tmps; + ds_clear(&tmp_ds); in_delay = FALSE; - tmps = typical_estimate(ds_get_buf(&dly)); + tmps = typical_estimate(ds_get_buf(&dly), &tmp_ds); if (!tmps) { ret_val = FALSE; + ds_clear(&tmp_ds); break; } if (prit) { @@ -2029,6 +2047,7 @@ static BOOL extract_delay( } // end while != '}' ds_free(&dly); ds_free(&dtyp_max_str); + ds_free(&tmp_ds); return ret_val; } From 5bdbd83943f7a8e8c994be0cf6b89d26cab887d8 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Mon, 20 Feb 2023 09:44:52 +0100 Subject: [PATCH 16/29] Remove duplicated lines. Remove reference to deprecated ADMS, add OSDI instead --- INSTALL | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/INSTALL b/INSTALL index 67e9f7fe6..ea2bdb479 100644 --- a/INSTALL +++ b/INSTALL @@ -198,12 +198,11 @@ This file describes the procedures to install ngspice from sources. 1.5.1 Most useful options: - --enable-adms - ADMS is an experimental model compiler that translates - Verilog-A compact models into C code that can be compiled into - ngspice. This is (as of ngspice-27) still experimental, some - features (e.g. noise) are missing. If you want to use it, please - refer to the ADMS section on ngspice web site. + --enable-osdi + Add the OSDI interface to ngspice. This interface allow to dynamically + load compiled Veriloag-A compact models. Compiling is done with + OpenVAF. Thus for the first time ngspice has access to modern + device models like BSOMBULK or BSIM_CMG. --enable-cider Cider is a mixed-level simulator that couples Spice3 and DSIM @@ -246,9 +245,6 @@ This file describes the procedures to install ngspice from sources. Enables a 'make check' with strongly reduced runtime. Besides some regression tests only BSIM3 and BSM4 devices are checked. - --enable-shortcheck - Enables a 'make check' with strongly reduced runtime. Besides some - regression tests only BSIM3 and BSM4 devices are checked. 1.5.2 Options Specific to Enable Ngspice as a shared library From 70647c9c300947f1df70851240158e92e5511824 Mon Sep 17 00:00:00 2001 From: Giles Atkinson <“gatk555@gmail.comâ€> Date: Sat, 18 Feb 2023 15:36:01 +0000 Subject: [PATCH 17/29] Fix a crash reported by Thomas Hoffmann when using the "TARG AT=xxxx" variant of "measure", General Form 1. --- src/frontend/com_measure2.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/frontend/com_measure2.c b/src/frontend/com_measure2.c index 91dbffa7b..9db0c14da 100644 --- a/src/frontend/com_measure2.c +++ b/src/frontend/com_measure2.c @@ -1699,7 +1699,10 @@ get_measure2( goto err_ret1; } // measure targ - com_measure_when(measTarg); + if (measTarg->m_at == 1e99) + com_measure_when(measTarg); + else + measTarg->m_measured = measTarg->m_at; if (isnan(measTarg->m_measured)) { sprintf(errbuf, "out of interval\n"); From 8419894db58d1aba0101406ba78c47f7f7cbd79f Mon Sep 17 00:00:00 2001 From: Giles Atkinson <“gatk555@gmail.comâ€> Date: Tue, 21 Feb 2023 15:35:35 +0000 Subject: [PATCH 18/29] Revert "Fixes bug #331" This reverts commit 6d9876229cf0e9e17a436f352345acb95ebff3ca, because it was found to break examples/xspice/various/xspice_c3.cir (see discussion in bug report for February 2023) and an alternative fix is available. --- src/xspice/evt/evtbackup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xspice/evt/evtbackup.c b/src/xspice/evt/evtbackup.c index 1055deced..dc4432a43 100644 --- a/src/xspice/evt/evtbackup.c +++ b/src/xspice/evt/evtbackup.c @@ -577,7 +577,7 @@ static void EVTbackup_output_queue( output = *output_ptr; while(output) { - if (output->posted_time < new_time) + if(output->event_time > new_time) break; output_ptr = &((*output_ptr)->next); output = *output_ptr; From 7bd3ce6477d6003f796e8b5f24332d8848513066 Mon Sep 17 00:00:00 2001 From: Giles Atkinson <“gatk555@gmail.comâ€> Date: Tue, 21 Feb 2023 15:57:20 +0000 Subject: [PATCH 19/29] A new fix for Bug #331: "XSpice skips digital output point". The problem was caused by removing an output queue from the "modified" list when it had been modified by processing one of its events. --- src/xspice/evt/evtbackup.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/xspice/evt/evtbackup.c b/src/xspice/evt/evtbackup.c index dc4432a43..fe1e02784 100644 --- a/src/xspice/evt/evtbackup.c +++ b/src/xspice/evt/evtbackup.c @@ -618,17 +618,26 @@ static void EVTbackup_output_queue( } output_queue->next_time = next_time; - /* Update the modified list by looking for any queued events */ - /* with posted time > last_time */ + /* Update the modified list by looking for events that were processed + * or queued in the current timestep. + */ + for(i = 0, j = 0; i < num_modified; i++) { output_index = output_queue->modified_index[i]; output = *(output_queue->last_step[output_index]); - while(output) { - if(output->posted_time > output_queue->last_time) - break; - output = output->next; + if (output_queue->current[output_index] == + output_queue->last_step[output_index]) { + /* Nothing now removed from the queue, + * but it may have been modified by an addition. + */ + + while(output) { + if(output->posted_time > output_queue->last_time) + break; + output = output->next; + } } if(! output) { From 0d89160f2a94482582ded9e4002a59a19d404750 Mon Sep 17 00:00:00 2001 From: Giles Atkinson <“gatk555@gmail.comâ€> Date: Tue, 21 Feb 2023 16:04:39 +0000 Subject: [PATCH 20/29] Fix a bug reported by Thomas Hoffmann in ngspice-users discussion, 2023-02-18. Incorrect tests were used to detect a crossing in the first two data samples. --- src/frontend/com_measure2.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/frontend/com_measure2.c b/src/frontend/com_measure2.c index 9db0c14da..5b947eacf 100644 --- a/src/frontend/com_measure2.c +++ b/src/frontend/com_measure2.c @@ -491,14 +491,13 @@ com_measure_when( crossCnt = 0; if (value < value2) { section = S_BELOW_VAL; - if ((prevValue <= value2) && (value >= value2)) { + if (prevValue >= prevValue2) { fallCnt = 1; crossCnt = 1; } - } else { section = S_ABOVE_VAL; - if ((prevValue <= value2) && (value >= value2)) { + if (prevValue < prevValue2) { riseCnt = 1; crossCnt = 1; } @@ -509,14 +508,13 @@ com_measure_when( crossCnt = 0; if (value < meas->m_val) { section = S_BELOW_VAL; - if ((prevValue <= meas->m_val) && (value >= meas->m_val)) { + if (prevValue >= meas->m_val) { fallCnt = 1; crossCnt = 1; } - } else { section = S_ABOVE_VAL; - if ((prevValue <= meas->m_val) && (value >= meas->m_val)) { + if (prevValue < meas->m_val) { riseCnt = 1; crossCnt = 1; } From 0f7f6d0730c7db96a345aea00598a7eccb2749af Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Wed, 22 Feb 2023 15:31:47 +0100 Subject: [PATCH 21/29] In the very rare case of pPivot being NULL, prevent a crsh by reordering the matrix. --- src/maths/sparse/spfactor.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/maths/sparse/spfactor.c b/src/maths/sparse/spfactor.c index 337ad2ace..de5de6177 100644 --- a/src/maths/sparse/spfactor.c +++ b/src/maths/sparse/spfactor.c @@ -228,6 +228,11 @@ spOrderAndFactor(MatrixPtr Matrix, RealNumber RHS[], RealNumber RelThreshold, INCRESP; #endif pPivot = Matrix->Diag[Step]; + if (!pPivot) { + fprintf(stderr, "Warning: spfactor.c, 230, Pivot for step = %d not found\n", Step); + ReorderingRequired = YES; + break; /* for loop */ + } LargestInCol = FindLargestInCol(pPivot->NextInCol); if ((LargestInCol * RelThreshold < ELEMENT_MAG(pPivot))) { if (Matrix->Complex) From b5c6fd98ae2fe88114b7cf0c5ef7fe95671e556f Mon Sep 17 00:00:00 2001 From: Markus Mueller Date: Wed, 22 Feb 2023 17:44:33 +0100 Subject: [PATCH 22/29] fix small memory leak in OSDI interface --- src/osdi/osdiregistry.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/osdi/osdiregistry.c b/src/osdi/osdiregistry.c index 6da846451..c3224c294 100644 --- a/src/osdi/osdiregistry.c +++ b/src/osdi/osdiregistry.c @@ -316,6 +316,8 @@ extern OsdiObjectFile load_object_file(const char *input) { return INVALID_OBJECT; } + txfree(path); + GET_CONST(OSDI_NUM_DESCRIPTORS, uint32_t); GET_PTR(OSDI_DESCRIPTORS, OsdiDescriptor); From 00ca87cd862d8a630cd0b54a58aae2fb700ad6f6 Mon Sep 17 00:00:00 2001 From: Markus Mueller Date: Wed, 22 Feb 2023 17:59:32 +0100 Subject: [PATCH 23/29] fix memory leak more rigorously --- src/osdi/osdiregistry.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/osdi/osdiregistry.c b/src/osdi/osdiregistry.c index c3224c294..43336332b 100644 --- a/src/osdi/osdiregistry.c +++ b/src/osdi/osdiregistry.c @@ -288,6 +288,7 @@ extern OsdiObjectFile load_object_file(const char *input) { if (!path) { fprintf(stderr, "Error opening osdi lib \"%s\": No such file or directory!\n", input); + txfree(path); return INVALID_OBJECT; } @@ -302,6 +303,7 @@ extern OsdiObjectFile load_object_file(const char *input) { * nghash_insert returns NULL if the key (handle) was not already in the table * and the data (DUMMYDATA) that was previously insered (!= NULL) otherwise*/ if (nghash_insert(known_object_files, handle, DUMMYDATA)) { + txfree(path); return EMPTY_OBJECT; } @@ -313,11 +315,10 @@ extern OsdiObjectFile load_object_file(const char *input) { printf("NGSPICE only supports OSDI v%d.%d but \"%s\" targets v%d.%d!", OSDI_VERSION_MAJOR_CURR, OSDI_VERSION_MINOR_CURR, path, OSDI_VERSION_MAJOR, OSDI_VERSION_MINOR); + txfree(path); return INVALID_OBJECT; } - txfree(path); - GET_CONST(OSDI_NUM_DESCRIPTORS, uint32_t); GET_PTR(OSDI_DESCRIPTORS, OsdiDescriptor); @@ -385,6 +386,7 @@ extern OsdiObjectFile load_object_file(const char *input) { }; } + txfree(path); return (OsdiObjectFile){ .entrys = dst, .num_entries = (int)OSDI_NUM_DESCRIPTORS, From ac8fb9ecda9fe71a83f21ef018c5f229fe3c0d33 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Sat, 25 Feb 2023 15:40:21 +0100 Subject: [PATCH 24/29] Fix bug 624 also for MS Windows by moving DestroyGraph() from WM_CLOSE to RemoveWindow() --- src/frontend/wdisp/windisp.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/frontend/wdisp/windisp.c b/src/frontend/wdisp/windisp.c index 93716f3e9..33a238fcd 100644 --- a/src/frontend/wdisp/windisp.c +++ b/src/frontend/wdisp/windisp.c @@ -645,14 +645,7 @@ LRESULT CALLBACK PlotWindowProc(HWND hwnd, UINT uMsg, case WM_CLOSE: /* close window */ { - GRAPH *g = pGraph(hwnd); - if (g) { - /* if g equals currentgraph, reset currentgraph. */ - if (g == currentgraph) - currentgraph = NULL; - DestroyGraph(g->graphid); - } } goto WIN_DEFAULT; @@ -1233,6 +1226,13 @@ void RemoveWindow(GRAPH *dgraph) wd = pWindowData(dgraph); if (wd) SendMessage(wd->wnd, WM_CLOSE, (WPARAM) wd->hDC, 0); + + if (dgraph) { + /* if g equals currentgraph, reset currentgraph. */ + if (dgraph == currentgraph) + currentgraph = NULL; + DestroyGraph(dgraph->graphid); + } } From 026c8cca18f5a8c6ff7e74f6d8d2d41e50b8850e Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Sat, 25 Feb 2023 15:40:52 +0100 Subject: [PATCH 25/29] When path is NULL, we don't need to free it. --- src/osdi/osdiregistry.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/osdi/osdiregistry.c b/src/osdi/osdiregistry.c index 43336332b..e3362fa38 100644 --- a/src/osdi/osdiregistry.c +++ b/src/osdi/osdiregistry.c @@ -288,7 +288,6 @@ extern OsdiObjectFile load_object_file(const char *input) { if (!path) { fprintf(stderr, "Error opening osdi lib \"%s\": No such file or directory!\n", input); - txfree(path); return INVALID_OBJECT; } From 9773495e6322a760609b87f8fd910b0bc8a9982c Mon Sep 17 00:00:00 2001 From: Giles Atkinson <“gatk555@gmail.comâ€> Date: Sat, 25 Feb 2023 09:54:04 +0000 Subject: [PATCH 26/29] Fix Bug #624 - "Destroy All Fails with an Open Plot Window" for X11. Move XftDrawDestroy() call to a point where the window still exists. --- src/frontend/plotting/x11.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/frontend/plotting/x11.c b/src/frontend/plotting/x11.c index 0b5d5f5eb..8879328ac 100644 --- a/src/frontend/plotting/x11.c +++ b/src/frontend/plotting/x11.c @@ -1189,6 +1189,9 @@ void RemoveWindow(GRAPH *graph) DEVDEP(graph).isopen = 0; /* MW. Not sure but DestroyGraph might free() too much - try Xt...() first */ XtUnmapWidget(DEVDEP(graph).shell); +#ifdef HAVE_LIBXFT + XftDrawDestroy(DEVDEP(graph).draw); +#endif XtDestroyWidget(DEVDEP(graph).shell); #ifndef HAVE_LIBXFT XFreeFont(display, DEVDEP(graph).font); @@ -1198,7 +1201,6 @@ void RemoveWindow(GRAPH *graph) #ifdef HAVE_LIBXFT XftFontClose( display, DEVDEP(graph).font0); XftFontClose( display, DEVDEP(graph).font90); - XftDrawDestroy(DEVDEP(graph).draw); XftColorFree(display, DefaultVisual(display, 0), DEVDEP(graph).cmap, &DEVDEP(graph).color); #endif } From a0852566ceb01d41c0d3f98a095d3dc3a6152e69 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Mon, 27 Feb 2023 13:29:25 +0100 Subject: [PATCH 27/29] We are developing towards ngspice-40 --- configure.ac | 2 +- src/include/ngspice/sharedspice.h | 2 +- visualc/src/include/ngspice/config.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 9cf63f46e..55da0c74c 100644 --- a/configure.ac +++ b/configure.ac @@ -16,7 +16,7 @@ # problem to the user. AC_PREREQ([2.59]) -m4_define([ngspice_major_version], [39]) +m4_define([ngspice_major_version], [39+]) m4_define([ngspice_minor_version], [0]) m4_define([ngspice_version], [ngspice_major_version]) diff --git a/src/include/ngspice/sharedspice.h b/src/include/ngspice/sharedspice.h index 8c3b3084f..a3b4ffed9 100644 --- a/src/include/ngspice/sharedspice.h +++ b/src/include/ngspice/sharedspice.h @@ -97,7 +97,7 @@ are of type bool if sharedspice.h is used externally. */ #ifndef NGSPICE_PACKAGE_VERSION -#define NGSPICE_PACKAGE_VERSION "39" +#define NGSPICE_PACKAGE_VERSION "39+" #endif /* we have NG_BOOL instead of BOOL */ #ifndef HAS_NG_BOOL diff --git a/visualc/src/include/ngspice/config.h b/visualc/src/include/ngspice/config.h index 0381179f1..91125700e 100644 --- a/visualc/src/include/ngspice/config.h +++ b/visualc/src/include/ngspice/config.h @@ -15,7 +15,7 @@ #define PACKAGE "ngspice" /* Version number of package */ -#define VERSION "39" +#define VERSION "39+" /* Define the directory for executables */ #define NGSPICEBINDIR "../bin" From 7c9f2dff92666f7a58d73aa4ef564f7188331a61 Mon Sep 17 00:00:00 2001 From: Markus Mueller Date: Wed, 1 Mar 2023 13:50:35 +0100 Subject: [PATCH 28/29] (fix) CALC_OP during transient analysis in OSDI interface --- src/osdi/osdiload.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/osdi/osdiload.c b/src/osdi/osdiload.c index 43d20a05d..6fe4b4f40 100644 --- a/src/osdi/osdiload.c +++ b/src/osdi/osdiload.c @@ -137,9 +137,7 @@ extern int OSDIload(GENmodel *inModel, CKTcircuit *ckt) { .flags = CALC_RESIST_JACOBIAN, }; - if (is_init_smsig || is_sweep) { - sim_info.flags |= CALC_OP; - } + sim_info.flags |= CALC_OP; if (is_dc) { sim_info.flags |= ANALYSIS_DC | ANALYSIS_STATIC; From 3443063a85b8b2cb7264810d313bd60873190b4c Mon Sep 17 00:00:00 2001 From: Giles Atkinson <“gatk555@gmail.comâ€> Date: Tue, 28 Feb 2023 17:31:35 +0000 Subject: [PATCH 29/29] Fix plotting bug reported by Robert Turnbull: ngspice-devel 2023-02-10. --- src/frontend/plotting/graf.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/frontend/plotting/graf.c b/src/frontend/plotting/graf.c index 2e9a70797..929a6e5fb 100644 --- a/src/frontend/plotting/graf.c +++ b/src/frontend/plotting/graf.c @@ -485,12 +485,15 @@ void gr_point(struct dvec *dv, case PLOT_RETLIN: /* If it's a linear plot, ignore first point since we don't want to connect with oldx and oldy. */ - if (np) + if (np) { #ifdef LINE_COMPRESSION_CHECKS drawLine(fromx, fromy, tox, toy, dv); #else drawLine(fromx, fromy, tox, toy); #endif + } else { + LC_flush(); // May be retrace with non-monotonic x-axis + } if ((tics = currentgraph->ticdata) != NULL) { for (; *tics < HUGE; tics++)