From 69da75f7f03b47d13331447b14e4cdc4de436850 Mon Sep 17 00:00:00 2001 From: dwarning Date: Sun, 3 Nov 2024 10:43:46 +0100 Subject: [PATCH 1/6] intel cc see obsolete }; as empty declaration --- src/maths/ni/niaciter.c | 4 ++-- src/maths/ni/niiter.c | 2 +- src/spicelib/analysis/cktspdum.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/maths/ni/niaciter.c b/src/maths/ni/niaciter.c index 0b14ddd08..eb3291e13 100644 --- a/src/maths/ni/niaciter.c +++ b/src/maths/ni/niaciter.c @@ -85,7 +85,7 @@ retry: } return (OK); -}; +} int NIspSolve(CKTcircuit* ckt) { @@ -107,7 +107,7 @@ int NIspSolve(CKTcircuit* ckt) SWAP(double*, ckt->CKTrhs, ckt->CKTrhsOld); return (OK); -}; +} #endif diff --git a/src/maths/ni/niiter.c b/src/maths/ni/niiter.c index 332926031..85da8ecd7 100644 --- a/src/maths/ni/niiter.c +++ b/src/maths/ni/niiter.c @@ -368,4 +368,4 @@ NIiter(CKTcircuit *ckt, int maxIter) void NIresetwarnmsg(void) { msgcount = 0; -}; +} diff --git a/src/spicelib/analysis/cktspdum.c b/src/spicelib/analysis/cktspdum.c index 661e73140..349647081 100644 --- a/src/spicelib/analysis/cktspdum.c +++ b/src/spicelib/analysis/cktspdum.c @@ -33,7 +33,7 @@ extern double Fmin; int CKTmatrixIndex(CKTcircuit* ckt, int source, int dest) { return source * ckt->CKTportCount + dest; -}; +} int CKTspCalcSMatrix(CKTcircuit* ckt) { From fa310d8da259122c582c3076e4e0d334fa8603f9 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Sun, 3 Nov 2024 10:55:30 +0100 Subject: [PATCH 2/6] Fix a bug: AF and KF had been interchanged. --- src/spicelib/devices/vdmos/vdmosmask.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/spicelib/devices/vdmos/vdmosmask.c b/src/spicelib/devices/vdmos/vdmosmask.c index 67fd12bf6..f1c79ec04 100644 --- a/src/spicelib/devices/vdmos/vdmosmask.c +++ b/src/spicelib/devices/vdmos/vdmosmask.c @@ -49,10 +49,10 @@ VDMOSmAsk(CKTcircuit *ckt, GENmodel *inst, int which, IFvalue *value) value->rValue = model->VDMOStnom-CONSTCtoK; return(OK); case VDMOS_MOD_AF: - value->rValue = model->VDMOSfNcoef; + value->rValue = model->VDMOSfNexp; return(OK); case VDMOS_MOD_KF: - value->rValue = model->VDMOSfNexp; + value->rValue = model->VDMOSfNcoef; return(OK); case VDMOS_MOD_RQ: value->rValue = model->VDMOSqsResistance; From 6f918655168fa22195ce16b2d732a4e6b765cbdb Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Sun, 3 Nov 2024 11:14:04 +0100 Subject: [PATCH 3/6] Add AF and KF: error messages in commands 'showmod' or .sens are gone. --- src/spicelib/devices/mos1/mos1mask.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/spicelib/devices/mos1/mos1mask.c b/src/spicelib/devices/mos1/mos1mask.c index e0c610c56..f0474006e 100644 --- a/src/spicelib/devices/mos1/mos1mask.c +++ b/src/spicelib/devices/mos1/mos1mask.c @@ -111,6 +111,12 @@ MOS1mAsk(CKTcircuit *ckt, GENmodel *inst, int which, IFvalue *value) case MOS1_MOD_GDSNOI: value->rValue = model->MOS1gdsnoi; return(OK); + case MOS1_MOD_AF: + value->rValue = model->MOS1fNexp; + return(OK); + case MOS1_MOD_KF: + value->rValue = model->MOS1fNcoef; + return(OK); case MOS1_MOD_TYPE: if (model->MOS1type > 0) value->sValue = "nmos"; From c790eea4b265f2ce3f5bad1c81f671fe3af0f48a Mon Sep 17 00:00:00 2001 From: dwarning Date: Sun, 3 Nov 2024 09:00:04 +0100 Subject: [PATCH 4/6] unify os dependent time code in one file - rm win_time.c --- src/misc/Makefile.am | 2 - src/misc/misc_time.c | 327 +++++++++++++++++++--------------- src/misc/win_time.c | 32 ---- visualc/sharedspice.vcxproj | 1 - visualc/vngspice-fftw.vcxproj | 1 - visualc/vngspice.vcxproj | 1 - 6 files changed, 179 insertions(+), 185 deletions(-) delete mode 100644 src/misc/win_time.c diff --git a/src/misc/Makefile.am b/src/misc/Makefile.am index efaaf5e24..d20d905ae 100644 --- a/src/misc/Makefile.am +++ b/src/misc/Makefile.am @@ -2,8 +2,6 @@ noinst_LTLIBRARIES = libmisc.la -EXTRA_DIST = win_time.c - libmisc_la_SOURCES = \ getopt_long_bsd.c \ getopt_bsd.h \ diff --git a/src/misc/misc_time.c b/src/misc/misc_time.c index 0f55d9a29..e669198fe 100644 --- a/src/misc/misc_time.c +++ b/src/misc/misc_time.c @@ -1,148 +1,179 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -**********/ - -/* - * Date and time utility functions - */ - -#include "ngspice/ngspice.h" -#include - -#if defined(HAS_WINGUI) || defined(__MINGW32__) || defined(_MSC_VER) -#ifdef HAVE_QUERYPERFORMANCECOUNTER -#define WIN32_LEAN_AND_MEAN - /* - * The ngspice.h file included above defines BOOLEAN (via bool.h) and this - * clashes with the definition obtained from windows.h (via winnt.h). - * However, BOOLEAN is not used by this file so we can work round this problem - * by undefining BOOLEAN before including windows.h - * SJB - April 2005 - */ -#undef BOOLEAN -#include -#endif -#endif - -#include "misc_time.h" - -#ifdef USE_OMP -#include -#endif - -/* Return the date. Return value is static data. */ - -char * -datestring(void) -{ - -#ifdef HAVE_LOCALTIME - static char tbuf[45]; - struct tm *tp; - char *ap; - size_t i; - - time_t tloc; - time(&tloc); - tp = localtime(&tloc); - ap = asctime(tp); - (void) sprintf(tbuf, "%.20s", ap); - (void) strcat(tbuf, ap + 19); - i = strlen(tbuf); - tbuf[i - 1] = '\0'; - return (tbuf); - -#else - - return ("today"); - -#endif -} - -/* return time interval in seconds and milliseconds */ - -PerfTime timebegin; - -void timediff(PerfTime *now, PerfTime *begin, int *sec, int *msec) -{ - - *msec = (int) now->milliseconds - (int) begin->milliseconds; - *sec = (int) now->seconds - (int) begin->seconds; - if (*msec < 0) { - *msec += 1000; - (*sec)--; - } - return; - -} - -/* - * How many seconds have elapsed in running time. - * This is the routine called in IFseconds - */ - -double -seconds(void) -{ -#ifdef USE_OMP - // Usage of OpenMP time function - return omp_get_wtime(); -#elif defined(HAVE_QUERYPERFORMANCECOUNTER) - // Windows (MSC and mingw) specific implementation - LARGE_INTEGER frequency, counter; - QueryPerformanceFrequency(&frequency); - QueryPerformanceCounter(&counter); - return (double)counter.QuadPart / frequency.QuadPart; -#elif defined(HAVE_CLOCK_GETTIME) - struct timespec ts; - clock_gettime(CLOCK_MONOTONIC, &ts); - return ts.tv_sec + ts.tv_nsec / 1e9; -#elif defined(HAVE_GETTIMEOFDAY) - // Usage of gettimeofday - struct timeval tv; - gettimeofday(&tv, NULL); - return tv.tv_sec + tv.tv_usec / 1e6; -#elif defined(HAVE_TIMES) - // Usage of times - struct tms t; - clock_t ticks = times(&t); - return (double)ticks / sysconf(_SC_CLK_TCK); -#elif defined(HAVE_GETRUSAGE) - // Usage of getrusage - struct rusage usage; - getrusage(RUSAGE_SELF, &usage); - return usage.ru_utime.tv_sec + usage.ru_utime.tv_usec / 1e6; -#elif defined(HAVE_FTIME) - // Usage of ftime - struct timeb tb; - ftime(&tb); - return tb.time + tb.millitm / 1000.0; -#else - #error "No timer function available." -#endif -} - -void perf_timer_start(PerfTimer *timer) -{ - timer->start = seconds(); -} - -void perf_timer_stop(PerfTimer *timer) -{ - timer->end = seconds(); -} - -void perf_timer_elapsed_sec_ms(const PerfTimer *timer, int *seconds, int *milliseconds) -{ - double elapsed = timer->end - timer->start; - *seconds = (int)elapsed; - *milliseconds = (int)((elapsed - *seconds) * 1000.0); -} - -void perf_timer_get_time(PerfTime *time) -{ - double secs = seconds(); - time->seconds = (int)secs; - time->milliseconds = (int)((secs - time->seconds) * 1000.0); - -} +/********** +Copyright 1990 Regents of the University of California. All rights reserved. +**********/ + +/* + * Date and time utility functions + */ + +#include "ngspice/ngspice.h" +#include + +#if defined(HAS_WINGUI) || defined(__MINGW32__) || defined(_MSC_VER) +#ifdef HAVE_QUERYPERFORMANCECOUNTER +#define WIN32_LEAN_AND_MEAN + /* + * The ngspice.h file included above defines BOOLEAN (via bool.h) and this + * clashes with the definition obtained from windows.h (via winnt.h). + * However, BOOLEAN is not used by this file so we can work round this problem + * by undefining BOOLEAN before including windows.h + * SJB - April 2005 + */ +#undef BOOLEAN +#include +#ifndef HAVE_GETTIMEOFDAY +#include +#include // portable: uint64_t MSVC: __int64 + +/*/ MSVC defines this in winsock2.h!? +typedef struct timeval { + long tv_sec; + long tv_usec; +} timeval; +*/ +int gettimeofday(struct timeval * tp, void * unused) +{ + // Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's + // This magic number is the number of 100 nanosecond intervals since January 1, 1601 (UTC) + // until 00:00:00 January 1, 1970 + static const uint64_t EPOCH = ((uint64_t) 116444736000000000ULL); + + SYSTEMTIME system_time; + FILETIME file_time; + uint64_t time; + + GetSystemTime( &system_time ); + SystemTimeToFileTime( &system_time, &file_time ); + time = ((uint64_t)file_time.dwLowDateTime ) ; + time += ((uint64_t)file_time.dwHighDateTime) << 32; + + tp->tv_sec = (long) ((time - EPOCH) / 10000000L); + tp->tv_usec = (long) (system_time.wMilliseconds * 1000); + return 0; +} +#endif +#endif +#endif + +#include "misc_time.h" + +#ifdef USE_OMP +#include +#endif + +/* Return the date. Return value is static data. */ + +char * +datestring(void) +{ + +#ifdef HAVE_LOCALTIME + static char tbuf[45]; + struct tm *tp; + char *ap; + size_t i; + + time_t tloc; + time(&tloc); + tp = localtime(&tloc); + ap = asctime(tp); + (void) sprintf(tbuf, "%.20s", ap); + (void) strcat(tbuf, ap + 19); + i = strlen(tbuf); + tbuf[i - 1] = '\0'; + return (tbuf); + +#else + + return ("today"); + +#endif +} + +/* return time interval in seconds and milliseconds */ + +PerfTime timebegin; + +void timediff(PerfTime *now, PerfTime *begin, int *sec, int *msec) +{ + + *msec = (int) now->milliseconds - (int) begin->milliseconds; + *sec = (int) now->seconds - (int) begin->seconds; + if (*msec < 0) { + *msec += 1000; + (*sec)--; + } + return; + +} + +/* + * How many seconds have elapsed in running time. + * This is the routine called in IFseconds + */ + +double +seconds(void) +{ +#ifdef USE_OMP + // Usage of OpenMP time function + return omp_get_wtime(); +#elif defined(HAVE_QUERYPERFORMANCECOUNTER) + // Windows (MSC and mingw) specific implementation + LARGE_INTEGER frequency, counter; + QueryPerformanceFrequency(&frequency); + QueryPerformanceCounter(&counter); + return (double)counter.QuadPart / frequency.QuadPart; +#elif defined(HAVE_CLOCK_GETTIME) + struct timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); + return ts.tv_sec + ts.tv_nsec / 1e9; +#elif defined(HAVE_GETTIMEOFDAY) + // Usage of gettimeofday + struct timeval tv; + gettimeofday(&tv, NULL); + return tv.tv_sec + tv.tv_usec / 1e6; +#elif defined(HAVE_TIMES) + // Usage of times + struct tms t; + clock_t ticks = times(&t); + return (double)ticks / sysconf(_SC_CLK_TCK); +#elif defined(HAVE_GETRUSAGE) + // Usage of getrusage + struct rusage usage; + getrusage(RUSAGE_SELF, &usage); + return usage.ru_utime.tv_sec + usage.ru_utime.tv_usec / 1e6; +#elif defined(HAVE_FTIME) + // Usage of ftime + struct timeb tb; + ftime(&tb); + return tb.time + tb.millitm / 1000.0; +#else + #error "No timer function available." +#endif +} + +void perf_timer_start(PerfTimer *timer) +{ + timer->start = seconds(); +} + +void perf_timer_stop(PerfTimer *timer) +{ + timer->end = seconds(); +} + +void perf_timer_elapsed_sec_ms(const PerfTimer *timer, int *seconds, int *milliseconds) +{ + double elapsed = timer->end - timer->start; + *seconds = (int)elapsed; + *milliseconds = (int)((elapsed - *seconds) * 1000.0); +} + +void perf_timer_get_time(PerfTime *time) +{ + double secs = seconds(); + time->seconds = (int)secs; + time->milliseconds = (int)((secs - time->seconds) * 1000.0); + +} diff --git a/src/misc/win_time.c b/src/misc/win_time.c deleted file mode 100644 index fd1788d7e..000000000 --- a/src/misc/win_time.c +++ /dev/null @@ -1,32 +0,0 @@ -#define WIN32_LEAN_AND_MEAN -//#include "ngspice/ngspice.h" -#include -#include -#include // portable: uint64_t MSVC: __int64 - -/*/ MSVC defines this in winsock2.h!? -typedef struct timeval { - long tv_sec; - long tv_usec; -} timeval; -*/ -int gettimeofday(struct timeval * tp, void * unused) -{ - // Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's - // This magic number is the number of 100 nanosecond intervals since January 1, 1601 (UTC) - // until 00:00:00 January 1, 1970 - static const uint64_t EPOCH = ((uint64_t) 116444736000000000ULL); - - SYSTEMTIME system_time; - FILETIME file_time; - uint64_t time; - - GetSystemTime( &system_time ); - SystemTimeToFileTime( &system_time, &file_time ); - time = ((uint64_t)file_time.dwLowDateTime ) ; - time += ((uint64_t)file_time.dwHighDateTime) << 32; - - tp->tv_sec = (long) ((time - EPOCH) / 10000000L); - tp->tv_usec = (long) (system_time.wMilliseconds * 1000); - return 0; -} diff --git a/visualc/sharedspice.vcxproj b/visualc/sharedspice.vcxproj index c18f68813..c62fafd5e 100644 --- a/visualc/sharedspice.vcxproj +++ b/visualc/sharedspice.vcxproj @@ -1466,7 +1466,6 @@ lib /machine:x64 /def:..\..\fftw-3.3-dll64\libfftw3-3.def /out:$(IntDir)libfftw3 - diff --git a/visualc/vngspice-fftw.vcxproj b/visualc/vngspice-fftw.vcxproj index 04a189e00..ac78cc4b3 100644 --- a/visualc/vngspice-fftw.vcxproj +++ b/visualc/vngspice-fftw.vcxproj @@ -1687,7 +1687,6 @@ lib /machine:x64 /def:..\..\fftw-3.3-dll64\libfftw3-3.def /out:$(IntDir)libfftw3 - diff --git a/visualc/vngspice.vcxproj b/visualc/vngspice.vcxproj index 5281546d0..8e80be4e2 100644 --- a/visualc/vngspice.vcxproj +++ b/visualc/vngspice.vcxproj @@ -1702,7 +1702,6 @@ - From e5bccd06b0d6ac2fa59dbe2eaaefb3c472e316f8 Mon Sep 17 00:00:00 2001 From: dwarning Date: Sun, 3 Nov 2024 09:10:29 +0100 Subject: [PATCH 5/6] suppress compiler warning --- src/misc/misc_time.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/misc/misc_time.c b/src/misc/misc_time.c index e669198fe..180d7e68a 100644 --- a/src/misc/misc_time.c +++ b/src/misc/misc_time.c @@ -33,6 +33,7 @@ typedef struct timeval { */ int gettimeofday(struct timeval * tp, void * unused) { + NG_IGNORE(unused); // Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's // This magic number is the number of 100 nanosecond intervals since January 1, 1601 (UTC) // until 00:00:00 January 1, 1970 From 636ba1e72423a6e38121621516f160ee77a11f44 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Mon, 4 Nov 2024 13:02:50 +0100 Subject: [PATCH 6/6] seconds() no longer supports a time difference, so create it locally. --- src/sharedspice.c | 9 ++++++--- src/winmain.c | 4 +++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/sharedspice.c b/src/sharedspice.c index 381805417..ac69a1dd6 100644 --- a/src/sharedspice.c +++ b/src/sharedspice.c @@ -1930,6 +1930,7 @@ void SetAnalyse( static char OldAn2[128]; /* Previous analysis type */ static char olds2[128]; /* previous output */ static PerfTime timebefore2; /* previous time stamp */ + int sdiffsec, sdiffmillisec; /* differences current time minus start time stamp */ /*set the two thread ids */ unsigned int ng_idl = threadid_self(); @@ -1969,9 +1970,11 @@ void SetAnalyse( if ((DecaPercent == OldPercent) && !strcmp(OldAn, Analyse)) return; - /* get actual time */ + /* get current time */ perf_timer_get_time(&timenow); timediff(&timenow, &timebefore, &diffsec, &diffmillisec); + timediff(&timenow, &timebegin, &sdiffsec, &sdiffmillisec); + s = TMALLOC(char, 128); if (!strcmp(Analyse, "tran")) { @@ -2030,8 +2033,8 @@ void SetAnalyse( } /* info when previous analysis period has finished */ if (strcmp(OldAn, Analyse)) { - if (ft_ngdebug && (strcmp(OldAn, ""))) - printf("%s finished after %4.2f seconds.\n", OldAn, seconds()); + if ((ft_nginfo || ft_ngdebug) && (strcmp(OldAn, ""))) + printf("%s finished after %5.3f seconds.\n", OldAn, (double)sdiffsec + (double)sdiffmillisec / 1000.); if(thread1) strncpy(OldAn1, Analyse, 127); else diff --git a/src/winmain.c b/src/winmain.c index 619ab468a..7ee5dbd36 100644 --- a/src/winmain.c +++ b/src/winmain.c @@ -223,6 +223,7 @@ SetAnalyse(char *Analyse, /* in: analysis type */ static PerfTime timebefore; /* previous time stamp */ PerfTime timenow; /* actual time stamp */ int diffsec, diffmillisec; /* differences actual minus prev. time stamp */ + int sdiffsec, sdiffmillisec; /* differences actual minus start time stamp */ WaitForIdle(); @@ -234,6 +235,7 @@ SetAnalyse(char *Analyse, /* in: analysis type */ /* get actual time */ perf_timer_get_time(&timenow); timediff(&timenow, &timebefore, &diffsec, &diffmillisec); + timediff(&timenow, &timebegin, &sdiffsec, &sdiffmillisec); OldPercent = DecaPercent; /* output only into hwAnalyse window and if time elapsed is larger than @@ -260,7 +262,7 @@ SetAnalyse(char *Analyse, /* in: analysis type */ /* info when previous analysis period has finished */ if (strcmp(OldAn, Analyse)) { if ((ft_nginfo || ft_ngdebug) && (strcmp(OldAn, ""))) - win_x_printf("%s finished after %4.2f seconds.\n", OldAn, seconds()); + win_x_printf("%s finished after %5.3f seconds.\n", OldAn, (double)sdiffsec + (double)sdiffmillisec / 1000.); strncpy(OldAn, Analyse, 127); }