Merge commit

This commit is contained in:
Jim Monte 2020-03-08 01:42:03 -05:00
commit 7b6ce1e236
51 changed files with 402 additions and 79 deletions

View File

@ -25,6 +25,8 @@
# Add (optionally) --enable-relpath to avoid absolute paths when searching for code models.
# It might be necessary to uncomment and run ./autogen.sh .
SECONDS=0
if test "$1" = "32"; then
if [ ! -d "release32" ]; then
mkdir release32
@ -38,8 +40,8 @@ else
fi
# If compiling sources from git, you may need to uncomment the following two lines:
#./autogen.sh
#if [ $? -ne 0 ]; then echo "./autogen.sh failed"; exit 1 ; fi
./autogen.sh
if [ $? -ne 0 ]; then echo "./autogen.sh failed"; exit 1 ; fi
# Alternatively, if compiling sources from git, and want to add adms created devices,
# you may need to uncomment the following two lines (and don't forget to add adms option
@ -54,14 +56,14 @@ if test "$1" = "32"; then
echo "configuring for 32 bit"
echo
# You may add --enable-adms to the following command for adding adms generated devices
../configure --with-wingui --enable-xspice --enable-cider --enable-openmp --disable-debug prefix="C:/Spice" CFLAGS="-m32 -O2" LDFLAGS="-m32 -s"
../configure --with-wingui --enable-xspice --enable-cider --enable-openmp --disable-debug prefix="C:/Spice" CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 -m32 -O2" LDFLAGS="-m32 -s"
else
cd release
if [ $? -ne 0 ]; then echo "cd release failed"; exit 1 ; fi
echo "configuring for 64 bit"
echo
# You may add --enable-adms to the following command for adding adms generated devices
../configure --with-wingui --enable-xspice --enable-cider --enable-openmp --disable-debug prefix="C:/Spice64" CFLAGS="-m64 -O2" LDFLAGS="-m64 -s"
../configure --with-wingui --enable-xspice --enable-cider --enable-openmp --disable-debug prefix="C:/Spice64" CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 -m64 -O2" LDFLAGS="-m64 -s"
fi
if [ $? -ne 0 ]; then echo "../configure failed"; exit 1 ; fi
@ -82,5 +84,8 @@ make install 2>&1 | tee make_install.log
exitcode=${PIPESTATUS[0]}
if [ $exitcode -ne 0 ]; then echo "make install failed"; exit 1 ; fi
ELAPSED="Elapsed compile time: $(($SECONDS / 3600))hrs $((($SECONDS / 60) % 60))min $(($SECONDS % 60))sec"
echo
echo $ELAPSED
echo "success"
exit 0

View File

@ -111,6 +111,7 @@ ngspice_SOURCES = \
ngspice_CPPFLAGS = $(AM_CPPFLAGS) -DSIMULATOR
if WINGUI
ngspice_LDFLAGS = -municode $(AM_LDFLAGS)
ngspice_SOURCES += winmain.c hist_info.c
endif

View File

@ -13,8 +13,6 @@
#include "com_commands.h"
#ifdef _WIN32
//#define WIN32_LEAN_AND_MEAN
#undef BOOLEAN
#include <windows.h>
#include <psapi.h>
@ -403,7 +401,6 @@ static void set_static_system_info(void)
/* Get memory information */
static int get_sysmem(struct sys_memory *memall)
{
#if (_WIN32_WINNT >= 0x0500) /* Windows 2000+ */
MEMORYSTATUSEX ms;
ms.dwLength = sizeof(MEMORYSTATUSEX);
if (GlobalMemoryStatusEx(&ms) == FALSE) {
@ -413,17 +410,6 @@ static int get_sysmem(struct sys_memory *memall)
memall->free_m = ms.ullAvailPhys;
memall->swap_t = ms.ullTotalPageFile;
memall->swap_f = ms.ullAvailPageFile;
#else
MEMORYSTATUS ms;
ms.dwLength = sizeof(MEMORYSTATUS);
if (GlobalMemoryStatus(&ms) == FALSE) {
return -1;
}
memall->size_m = ms.dwTotalPhys;
memall->free_m = ms.dwAvailPhys;
memall->swap_t = ms.dwTotalPageFile;
memall->swap_f = ms.dwAvailPageFile;
#endif
return 0;
} /* end of function get_sysmem */

View File

@ -180,6 +180,7 @@ static struct card *pspice_compat(struct card *newcard);
static void pspice_compat_a(struct card *oldcard);
static struct card *ltspice_compat(struct card *oldcard);
static void ltspice_compat_a(struct card *oldcard);
static void inp_rep_ixx(struct card *deck);
#if defined(__MINGW32__) || defined(_MSC_VER)
#ifndef EXT_ASC
@ -705,6 +706,8 @@ struct card *inp_readall(FILE *fp, const char *dir_name,
inp_bsource_compat(working);
inp_dot_if(working);
expr_w_temper = inp_temper_compat(working);
/* i(vxx) to vxx#branch within .control section */
inp_rep_ixx(working);
}
if (expr_w_temper_p)
*expr_w_temper_p = expr_w_temper;
@ -1735,6 +1738,66 @@ static void inp_chk_for_multi_in_vcvs(struct card *c, int *line_number)
}
}
/* replace i(vxx) by vxx#branch */
static void inp_rep_ixx(struct card* deck) {
struct card* c;
int only_control = 0;
for (c = deck; c; c = c->nextcard) {
char* line, * beg;
line = beg = c->line;
/* there is no e source inside .control ... .endc */
if (ciprefix(".control", line)) {
only_control++;
continue;
}
else if (ciprefix(".endc", line)) {
only_control--;
continue;
}
else if (only_control <= 0) {
continue;
}
char* new_str = NULL;
bool strsave = FALSE;
while (line) {
char* s = strstr(line, "i(v");
if (s && (s > line) && (isspace_c(s[-1]) || is_arith_char(s[-1])
|| isquote(s[-1]) || (s[-1] == '=') || (s[-1] == '.'))) {
char* beg_str, *end_str, *t;
line = s;
/* replace i(vxx) by vxx#branch */
if (get_r_paren(&line) == 1) {
fprintf(stderr, "Error: missing ')' in line\n %s\n", c->line);
break;
}
/* token containing name of voltage source to be measured */
t = copy_substring(s + 2, line - 1);
/* change line, convert i(XXX) to XXX#branch */
beg_str = copy_substring(beg, s);
end_str = copy(line);
tfree(new_str);
new_str = tprintf("%s%s%s%s", beg_str, t, "#branch", end_str);
strsave = TRUE;
beg = line = new_str;
tfree(beg_str);
tfree(end_str);
tfree(t);
}
else {
break;
}
}
if (strsave) {
tfree(c->line);
c->line = new_str;
strsave = FALSE;
}
}
}
/* If ngspice is started with option -a, then variable 'autorun'
* will be set and the following function scans the deck.

View File

@ -161,7 +161,7 @@ void ft_gnuplot(double *xlims, double *ylims,
}
/* Set up the file header. */
#if !defined(__MINGW__) && !defined(_MSC_VER) && !defined(__CYGWIN__)
#if !defined(__MINGW32__) && !defined(_MSC_VER) && !defined(__CYGWIN__)
fprintf(file, "set terminal X11 noenhanced\n");
#elif defined(__CYGWIN__)
#ifndef EXT_ASC

View File

@ -134,6 +134,8 @@ int gr_init(double *xlims, double *ylims, /* The size of the screen. */
graph->ticdata = NULL;
}
cp_getvar("nolegend", CP_BOOL, &(graph->nolegend), 0);
if (!xlims || !ylims) {
internalerror("gr_init: no range specified");
return FALSE;
@ -184,6 +186,7 @@ int gr_init(double *xlims, double *ylims, /* The size of the screen. */
strcpy(graph->ticchar, pgraph->ticchar);
graph->ticdata = pgraph->ticdata;
graph->ticmarks = pgraph->ticmarks;
graph->nolegend = pgraph->nolegend;
}
/* layout decisions */
@ -434,7 +437,7 @@ static void gr_start_internal(struct dvec *dv, bool copyvec)
}
/* Put the legend entry on the screen. */
if (!cp_getvar("nolegend", CP_BOOL, NULL, 0))
if (!currentgraph->nolegend)
drawlegend(currentgraph, cur.plotno++, dv);
}
@ -610,7 +613,7 @@ void gr_redraw(GRAPH *graph)
cur.plotno = 0;
for (link = graph->plotdata; link; link = link->next) {
/* redraw legend */
if (!cp_getvar("nolegend", CP_BOOL, NULL, 0))
if (!graph->nolegend)
drawlegend(graph, cur.plotno++, link->vector);
/* replot data

View File

@ -243,7 +243,8 @@ com_remcirc(wordlist *wl)
#if defined(XSPICE) && defined(SIMULATOR)
/* remove event queues, if XSPICE and not nutmeg */
EVTunsetup(ft_curckt->ci_ckt);
if (ft_curckt->ci_ckt)
EVTunsetup(ft_curckt->ci_ckt);
#endif
if_cktfree(ft_curckt->ci_ckt, ft_curckt->ci_symtab);

View File

@ -161,7 +161,7 @@ int WIN_Init(void)
TheWndClass.cbClsExtra = 0;
TheWndClass.cbWndExtra = sizeof(GRAPH *);
if (!RegisterClass(&TheWndClass)) {
if (!RegisterClass(&TheWndClass))
return 1;
#else
@ -179,7 +179,8 @@ int WIN_Init(void)
TheWndClassW.hIcon = LoadIconW(hInst, MAKEINTRESOURCEW(2));
TheWndClassW.cbClsExtra = 0;
TheWndClassW.cbWndExtra = sizeof(GRAPH *);
if (!RegisterClassW(&TheWndClassW)) return 1;
if (!RegisterClassW(&TheWndClassW))
return 1;
#endif
IsRegistered = 1;
}

View File

@ -33,6 +33,8 @@ struct graph {
int currentcolor;
int linestyle;
bool nolegend;
struct {
int height, width;
} viewport;

View File

@ -224,7 +224,7 @@ extern double x_atanh(double);
#endif
#ifndef EXT_ASC
#if defined(__MINGW__) || defined(_MSC_VER)
#if defined(__MINGW32__) || defined(_MSC_VER)
#define fopen newfopen
extern FILE *newfopen(const char *fn, const char* md);
#endif

View File

@ -278,7 +278,7 @@ int ds_cat_vprintf(DSTRING *p_ds, const char *sz_fmt, va_list p_arg)
/* Else check for buffer large enough and set length if it is */
if ((size_t) rc < n_byte_free) {
p_ds->length += rc;
p_ds->length += (size_t) rc;
return DS_E_OK;
}
@ -286,7 +286,8 @@ int ds_cat_vprintf(DSTRING *p_ds, const char *sz_fmt, va_list p_arg)
{
/* Double required size to avoid excessive allocations +1 for
* null, which is not included in the count returned by snprintf */
const size_t n_byte_alloc_min = p_ds->length + rc + 1;
const size_t n_byte_alloc_min =
p_ds->length + (size_t) rc + (size_t) 1;
if (ds_reserve_internal(p_ds,
2 * n_byte_alloc_min, n_byte_alloc_min) == DS_E_NO_MEMORY) {
/* vsnprintf may have written bytes to the buffer.
@ -308,7 +309,7 @@ int ds_cat_vprintf(DSTRING *p_ds, const char *sz_fmt, va_list p_arg)
/* Else update length. No need to check buffer size since it was
* sized to fit the string. */
p_ds->length += rc2;
p_ds->length += (size_t) rc2;
return DS_E_OK;
}
} /* end of function ds_cat_vprintf */

View File

@ -220,9 +220,10 @@ int get_int_n(const char *str, size_t n, int *p_value)
if (!isdigit(ch_cur)) { /* Test for exit due to non-numeric char */
break;
}
/* Compute new value and check for overflow. */
const unsigned int value_new = 10 * value + (ch_cur - '0');
const unsigned int value_new =
10 * value + (unsigned int) (ch_cur - '0');
if (value_new < value) {
return -2;
}
@ -236,7 +237,7 @@ int get_int_n(const char *str, size_t n, int *p_value)
/* Test for overflow.
* If negative, can be 1 greater (-2**n vs 2**n -1) */
if (value - f_neg > (unsigned int) INT_MAX) {
if (value - (unsigned int) f_neg > (unsigned int) INT_MAX) {
return -2;
}
@ -769,15 +770,18 @@ get_l_paren(char **s)
(*s)++;
return **s == '\0';
if (**s == '\0')
return -1;
return 0;
}
/*-------------------------------------------------------------------------*
* get_r_paren iterates the pointer forward in a string until it hits
* the position after the next right paren ")". It returns 0 if it found a right
* paren, and 1 if no right paren is found. It is called from 'translate'
* (subckt.c).
* paren, 1 if no right paren is found, and -1 if right paren is te last
* character. It is called from 'translate' (subckt.c).
*-------------------------------------------------------------------------*/
int
@ -791,7 +795,10 @@ get_r_paren(char **s)
(*s)++;
return **s == '\0';
if (**s == '\0')
return -1;
return 0;
}
/*-------------------------------------------------------------------------*
@ -1246,7 +1253,7 @@ static inline const char *next_substr(
for ( ; ; ) {
/* Update hash for next starting point at p_string + 1 */
if ((h_string = (((h_string - (unsigned char) p_string[0] *
msb_factor) << 8) + p_string[n_char_pattern]) %
msb_factor) << 8) + (size_t) p_string[n_char_pattern]) %
KR_MODULUS) > KR_MODULUS) { /* negative value when signed */
h_string += KR_MODULUS;
}

View File

@ -260,7 +260,7 @@ ngdirname(const char *name)
/* Replacement for fopen, when using wide chars (utf-16) */
#ifndef EXT_ASC
#if defined(__MINGW__) || defined(_MSC_VER)
#if defined(__MINGW32__) || defined(_MSC_VER)
#undef BOOLEAN
#include <windows.h>
FILE *

View File

@ -9,6 +9,7 @@ Modified: 2005 Paolo Nenzi - Restructured
#include "ngspice/cktdefs.h"
#include "ngspice/devdefs.h"
#include "ngspice/sperror.h"
#include "ngspice/cpextern.h"
#ifdef XSPICE
#include "ngspice/enh.h"
@ -17,6 +18,7 @@ Modified: 2005 Paolo Nenzi - Restructured
static int dynamic_gmin(CKTcircuit *, long int, long int, int);
static int spice3_gmin(CKTcircuit *, long int, long int, int);
static int new_gmin(CKTcircuit*, long int, long int, int);
static int gillespie_src(CKTcircuit *, long int, long int, int);
static int spice3_src(CKTcircuit *, long int, long int, int);
@ -51,10 +53,17 @@ CKTop (CKTcircuit *ckt, long int firstmode, long int continuemode,
/* first, check if we should try gmin stepping */
if (ckt->CKTnumGminSteps >= 1) {
if (ckt->CKTnumGminSteps == 1)
converged = dynamic_gmin(ckt, firstmode, continuemode, iterlim);
else
if (ckt->CKTnumGminSteps == 1) {
if (cp_getvar("dyngmin", CP_BOOL, NULL, 0)) {
converged = dynamic_gmin(ckt, firstmode, continuemode, iterlim);
}
else {
converged = new_gmin(ckt, firstmode, continuemode, iterlim);
}
}
else {
converged = spice3_gmin(ckt, firstmode, continuemode, iterlim);
}
if (converged == 0) /* If gmin-stepping worked... move out */
return converged;
}
@ -304,6 +313,185 @@ spice3_gmin (CKTcircuit *ckt, long int firstmode,
return converged;
}
/* just step the real gmin found in every device model */
static int
new_gmin(CKTcircuit* ckt, long int firstmode,
long int continuemode, int iterlim)
{
double OldGmin, gtarget, factor, startgmin;
int converged;
int NumNodes, iters, i;
double* OldRhsOld, * OldCKTstate0;
CKTnode* n;
ckt->CKTmode = firstmode;
SPfrontEnd->IFerrorf(ERR_INFO, "Starting true gmin stepping");
NumNodes = 0;
for (n = ckt->CKTnodes; n; n = n->next)
NumNodes++;
OldRhsOld = TMALLOC(double, NumNodes + 1);
OldCKTstate0 = TMALLOC(double, ckt->CKTnumStates + 1);
for (n = ckt->CKTnodes; n; n = n->next)
ckt->CKTrhsOld[n->number] = 0;
for (i = 0; i < ckt->CKTnumStates; i++)
ckt->CKTstate0[i] = 0;
startgmin = ckt->CKTgmin;
factor = ckt->CKTgminFactor;
OldGmin = 1e-2;
/*ckt->CKTdiagGmin = */ckt->CKTgmin = OldGmin / factor;
gtarget = MAX(startgmin, ckt->CKTgshunt);
for (;;) {
fprintf(stderr, "Trying gmin = %12.4E ", ckt->CKTgmin);
ckt->CKTnoncon = 1;
iters = ckt->CKTstat->STATnumIter;
converged = NIiter(ckt, ckt->CKTdcTrcvMaxIter);
iters = ckt->CKTstat->STATnumIter - iters;
if (converged == 0) {
ckt->CKTmode = continuemode;
SPfrontEnd->IFerrorf(ERR_INFO, "One successful gmin step");
if (ckt->CKTgmin <= gtarget)
break; /* successfull */
for (i = 0, n = ckt->CKTnodes; n; n = n->next)
OldRhsOld[i++] = ckt->CKTrhsOld[n->number];
memcpy(OldCKTstate0, ckt->CKTstate0,
(size_t)ckt->CKTnumStates * sizeof(double));
if (iters <= (ckt->CKTdcTrcvMaxIter / 4)) {
factor *= sqrt(factor);
if (factor > ckt->CKTgminFactor)
factor = ckt->CKTgminFactor;
}
if (iters > (3 * ckt->CKTdcTrcvMaxIter / 4))
factor = MAX(sqrt(factor), 1.00005);
OldGmin = ckt->CKTgmin;
if (ckt->CKTgmin < factor * gtarget) {
factor = ckt->CKTgmin / gtarget;
/*ckt->CKTdiagGmin = */ckt->CKTgmin = gtarget;
}
else {
/*ckt->CKTdiagGmin = */ckt->CKTgmin /= factor;
}
}
else {
if (factor < 1.00005) {
SPfrontEnd->IFerrorf(ERR_WARNING, "Last gmin step failed");
break; /* failed */
}
SPfrontEnd->IFerrorf(ERR_WARNING, "Further gmin increment");
factor = sqrt(sqrt(factor));
/*ckt->CKTdiagGmin = */ckt->CKTgmin = OldGmin / factor;
for (i = 0, n = ckt->CKTnodes; n; n = n->next)
ckt->CKTrhsOld[n->number] = OldRhsOld[i++];
memcpy(ckt->CKTstate0, OldCKTstate0,
(size_t)ckt->CKTnumStates * sizeof(double));
}
}
/*ckt->CKTdiagGmin = */ckt->CKTgmin = MAX(startgmin, ckt->CKTgshunt);
FREE(OldRhsOld);
FREE(OldCKTstate0);
#ifdef XSPICE
/* gtri - wbk - add convergence problem reporting flags */
ckt->enh->conv_debug.last_NIiter_call = (ckt->CKTnumSrcSteps <= 0);
#endif
converged = NIiter(ckt, iterlim);
if (converged != 0) {
SPfrontEnd->IFerrorf(ERR_WARNING, "True gmin stepping failed");
}
else {
SPfrontEnd->IFerrorf(ERR_INFO, "True gmin stepping completed");
#ifdef XSPICE
/* gtri - wbk - add convergence problem reporting flags */
ckt->enh->conv_debug.last_NIiter_call = MIF_FALSE;
#endif
}
return converged;
}
static int
no_new_gmin(CKTcircuit* ckt, long int firstmode,
long int continuemode, int iterlim)
{
int converged, i;
ckt->CKTmode = firstmode;
SPfrontEnd->IFerrorf(ERR_INFO, "Starting new gmin stepping");
ckt->CKTgmin = 0.01;
// (ckt->CKTgshunt == 0) ? ckt->CKTgmin : ckt->CKTgshunt;
for (i = 0; i < ckt->CKTnumGminSteps; i++)
ckt->CKTgmin *= ckt->CKTgminFactor;
for (i = 0; i <= ckt->CKTnumGminSteps; i++) {
fprintf(stderr, "Trying gmin = %12.4E ", ckt->CKTgmin);
ckt->CKTnoncon = 1;
converged = NIiter(ckt, ckt->CKTdcTrcvMaxIter);
if (converged != 0) {
ckt->CKTgmin = ckt->CKTgshunt;
SPfrontEnd->IFerrorf(ERR_WARNING, "gmin step failed");
break;
}
ckt->CKTgmin /= ckt->CKTgminFactor;
ckt->CKTmode = continuemode;
SPfrontEnd->IFerrorf(ERR_INFO, "One successful gmin step");
}
ckt->CKTgmin = ckt->CKTgshunt;
#ifdef XSPICE
/* gtri - wbk - add convergence problem reporting flags */
ckt->enh->conv_debug.last_NIiter_call = (ckt->CKTnumSrcSteps <= 0);
#endif
converged = NIiter(ckt, iterlim);
if (converged == 0) {
SPfrontEnd->IFerrorf(ERR_INFO, "gmin stepping completed");
#ifdef XSPICE
/* gtri - wbk - add convergence problem reporting flags */
ckt->enh->conv_debug.last_NIiter_call = MIF_FALSE;
#endif
}
else {
SPfrontEnd->IFerrorf(ERR_WARNING, "gmin stepping failed");
}
return converged;
}
/* Gillespie's Source stepping
* Modified 2005 - Paolo Nenzi (extracted from CKTop.c code)
@ -323,6 +511,7 @@ gillespie_src (CKTcircuit *ckt, long int firstmode,
int converged, i, iters;
double ConvFact;
CKTnode *n;
double gminstart = ckt->CKTgmin;
NG_IGNORE(iterlim);
@ -442,7 +631,13 @@ gillespie_src (CKTcircuit *ckt, long int firstmode,
* raise = 0.01;
*/
} else {
}
/* else if (ckt->CKTgmin < 1e-3){
ckt->CKTdiagGmin = ckt->CKTgmin *= 10;
fprintf(stderr,
"gmin raised to %8.4e\n", ckt->CKTgmin);
}*/
else {
if (ckt->CKTsrcFact - ConvFact < 1e-8)
break;
@ -459,7 +654,6 @@ gillespie_src (CKTcircuit *ckt, long int firstmode,
memcpy(ckt->CKTstate0, OldCKTstate0,
(size_t) ckt->CKTnumStates * sizeof(double));
}
if (ckt->CKTsrcFact > 1)
@ -467,6 +661,7 @@ gillespie_src (CKTcircuit *ckt, long int firstmode,
} while ((raise >= 1e-7) && (ConvFact < 1));
ckt->CKTdiagGmin = ckt->CKTgmin = gminstart;
FREE (OldRhsOld);
FREE (OldCKTstate0);
}

View File

@ -70,6 +70,7 @@ BJTparam(int param, IFvalue *value, GENinstance *instPtr, IFvalue *select)
case 2:
here->BJTicVCE = *(value->v.vec.rVec+1);
here->BJTicVCEGiven = TRUE;
/* FALLTHROUGH */
case 1:
here->BJTicVBE = *(value->v.vec.rVec);
here->BJTicVBEGiven = TRUE;

View File

@ -78,9 +78,11 @@ B1param(int param, IFvalue *value, GENinstance *inst,
case 3:
here->B1icVBS = *(value->v.vec.rVec+2);
here->B1icVBSGiven = TRUE;
/* FALLTHROUGH */
case 2:
here->B1icVGS = *(value->v.vec.rVec+1);
here->B1icVGSGiven = TRUE;
/* FALLTHROUGH */
case 1:
here->B1icVDS = *(value->v.vec.rVec);
here->B1icVDSGiven = TRUE;

View File

@ -77,9 +77,11 @@ B2param(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
case 3:
here->B2icVBS = *(value->v.vec.rVec+2);
here->B2icVBSGiven = TRUE;
/* FALLTHROUGH */
case 2:
here->B2icVGS = *(value->v.vec.rVec+1);
here->B2icVGSGiven = TRUE;
/* FALLTHROUGH */
case 1:
here->B2icVDS = *(value->v.vec.rVec);
here->B2icVDSGiven = TRUE;

View File

@ -108,9 +108,11 @@ IFvalue *select)
case 3:
here->BSIM3icVBS = *(value->v.vec.rVec+2);
here->BSIM3icVBSGiven = TRUE;
/* FALLTHROUGH */
case 2:
here->BSIM3icVGS = *(value->v.vec.rVec+1);
here->BSIM3icVGSGiven = TRUE;
/* FALLTHROUGH */
case 1:
here->BSIM3icVDS = *(value->v.vec.rVec);
here->BSIM3icVDSGiven = TRUE;

View File

@ -108,15 +108,19 @@ B3SOIDDparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
case 5:
here->B3SOIDDicVPS = *(value->v.vec.rVec+4);
here->B3SOIDDicVPSGiven = TRUE;
/* FALLTHROUGH */
case 4:
here->B3SOIDDicVES = *(value->v.vec.rVec+3);
here->B3SOIDDicVESGiven = TRUE;
/* FALLTHROUGH */
case 3:
here->B3SOIDDicVBS = *(value->v.vec.rVec+2);
here->B3SOIDDicVBSGiven = TRUE;
/* FALLTHROUGH */
case 2:
here->B3SOIDDicVGS = *(value->v.vec.rVec+1);
here->B3SOIDDicVGSGiven = TRUE;
/* FALLTHROUGH */
case 1:
here->B3SOIDDicVDS = *(value->v.vec.rVec);
here->B3SOIDDicVDSGiven = TRUE;

View File

@ -109,15 +109,19 @@ B3SOIFDparam(int param, IFvalue *value, GENinstance *inst,
case 5:
here->B3SOIFDicVPS = *(value->v.vec.rVec+4);
here->B3SOIFDicVPSGiven = TRUE;
/* FALLTHROUGH */
case 4:
here->B3SOIFDicVES = *(value->v.vec.rVec+3);
here->B3SOIFDicVESGiven = TRUE;
/* FALLTHROUGH */
case 3:
here->B3SOIFDicVBS = *(value->v.vec.rVec+2);
here->B3SOIFDicVBSGiven = TRUE;
/* FALLTHROUGH */
case 2:
here->B3SOIFDicVGS = *(value->v.vec.rVec+1);
here->B3SOIFDicVGSGiven = TRUE;
/* FALLTHROUGH */
case 1:
here->B3SOIFDicVDS = *(value->v.vec.rVec);
here->B3SOIFDicVDSGiven = TRUE;

View File

@ -152,15 +152,19 @@ B3SOIPDparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
case 5:
here->B3SOIPDicVPS = *(value->v.vec.rVec+4);
here->B3SOIPDicVPSGiven = TRUE;
/* FALLTHROUGH */
case 4:
here->B3SOIPDicVES = *(value->v.vec.rVec+3);
here->B3SOIPDicVESGiven = TRUE;
/* FALLTHROUGH */
case 3:
here->B3SOIPDicVBS = *(value->v.vec.rVec+2);
here->B3SOIPDicVBSGiven = TRUE;
/* FALLTHROUGH */
case 2:
here->B3SOIPDicVGS = *(value->v.vec.rVec+1);
here->B3SOIPDicVGSGiven = TRUE;
/* FALLTHROUGH */
case 1:
here->B3SOIPDicVDS = *(value->v.vec.rVec);
here->B3SOIPDicVDSGiven = TRUE;

View File

@ -84,9 +84,11 @@ BSIM3v0param(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
case 3:
here->BSIM3v0icVBS = *(value->v.vec.rVec+2);
here->BSIM3v0icVBSGiven = TRUE;
/* FALLTHROUGH */
case 2:
here->BSIM3v0icVGS = *(value->v.vec.rVec+1);
here->BSIM3v0icVGSGiven = TRUE;
/* FALLTHROUGH */
case 1:
here->BSIM3v0icVDS = *(value->v.vec.rVec);
here->BSIM3v0icVDSGiven = TRUE;

View File

@ -90,9 +90,11 @@ BSIM3v1param(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
case 3:
here->BSIM3v1icVBS = *(value->v.vec.rVec+2);
here->BSIM3v1icVBSGiven = TRUE;
/* FALLTHROUGH */
case 2:
here->BSIM3v1icVGS = *(value->v.vec.rVec+1);
here->BSIM3v1icVGSGiven = TRUE;
/* FALLTHROUGH */
case 1:
here->BSIM3v1icVDS = *(value->v.vec.rVec);
here->BSIM3v1icVDSGiven = TRUE;

View File

@ -101,9 +101,11 @@ BSIM3v32param (int param, IFvalue *value, GENinstance *inst, IFvalue *select)
case 3:
here->BSIM3v32icVBS = *(value->v.vec.rVec+2);
here->BSIM3v32icVBSGiven = TRUE;
/* FALLTHROUGH */
case 2:
here->BSIM3v32icVGS = *(value->v.vec.rVec+1);
here->BSIM3v32icVGSGiven = TRUE;
/* FALLTHROUGH */
case 1:
here->BSIM3v32icVDS = *(value->v.vec.rVec);
here->BSIM3v32icVDSGiven = TRUE;

View File

@ -234,9 +234,11 @@ IFvalue *select)
{ case 3:
here->BSIM4icVBS = *(value->v.vec.rVec+2);
here->BSIM4icVBSGiven = TRUE;
/* FALLTHROUGH */
case 2:
here->BSIM4icVGS = *(value->v.vec.rVec+1);
here->BSIM4icVGSGiven = TRUE;
/* FALLTHROUGH */
case 1:
here->BSIM4icVDS = *(value->v.vec.rVec);
here->BSIM4icVDSGiven = TRUE;

View File

@ -184,9 +184,11 @@ IFvalue *select)
{ case 3:
here->BSIM4v5icVBS = *(value->v.vec.rVec+2);
here->BSIM4v5icVBSGiven = TRUE;
/* FALLTHROUGH */
case 2:
here->BSIM4v5icVGS = *(value->v.vec.rVec+1);
here->BSIM4v5icVGSGiven = TRUE;
/* FALLTHROUGH */
case 1:
here->BSIM4v5icVDS = *(value->v.vec.rVec);
here->BSIM4v5icVDSGiven = TRUE;

View File

@ -186,9 +186,11 @@ IFvalue *select)
{ case 3:
here->BSIM4v6icVBS = *(value->v.vec.rVec+2);
here->BSIM4v6icVBSGiven = TRUE;
/* FALLTHROUGH */
case 2:
here->BSIM4v6icVGS = *(value->v.vec.rVec+1);
here->BSIM4v6icVGSGiven = TRUE;
/* FALLTHROUGH */
case 1:
here->BSIM4v6icVDS = *(value->v.vec.rVec);
here->BSIM4v6icVDSGiven = TRUE;

View File

@ -190,9 +190,11 @@ IFvalue *select)
{ case 3:
here->BSIM4v7icVBS = *(value->v.vec.rVec+2);
here->BSIM4v7icVBSGiven = TRUE;
/* FALLTHROUGH */
case 2:
here->BSIM4v7icVGS = *(value->v.vec.rVec+1);
here->BSIM4v7icVGSGiven = TRUE;
/* FALLTHROUGH */
case 1:
here->BSIM4v7icVDS = *(value->v.vec.rVec);
here->BSIM4v7icVDSGiven = TRUE;

View File

@ -47,6 +47,7 @@ HFETAparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
case 2:
here->HFETAicVGS = *(value->v.vec.rVec+1);
here->HFETAicVGSGiven = TRUE;
/* FALLTHROUGH */
case 1:
here->HFETAicVDS = *(value->v.vec.rVec);
here->HFETAicVDSGiven = TRUE;

View File

@ -38,6 +38,7 @@ int HFET2param(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
case 2:
here->HFET2icVGS = *(value->v.vec.rVec+1);
here->HFET2icVGSGiven = TRUE;
/* FALLTHROUGH */
case 1:
here->HFET2icVDS = *(value->v.vec.rVec);
here->HFET2icVDSGiven = TRUE;

View File

@ -137,9 +137,11 @@ int HSM2param(
case 3:
here->HSM2_icVBS = *(value->v.vec.rVec + 2);
here->HSM2_icVBS_Given = TRUE;
/* FALLTHROUGH */
case 2:
here->HSM2_icVGS = *(value->v.vec.rVec + 1);
here->HSM2_icVGS_Given = TRUE;
/* FALLTHROUGH */
case 1:
here->HSM2_icVDS = *(value->v.vec.rVec);
here->HSM2_icVDS_Given = TRUE;

View File

@ -102,9 +102,11 @@ int HSMHVparam(
case 3:
here->HSMHV_icVBS = *(value->v.vec.rVec + 2);
here->HSMHV_icVBS_Given = TRUE;
/* FALLTHROUGH */
case 2:
here->HSMHV_icVGS = *(value->v.vec.rVec + 1);
here->HSMHV_icVGS_Given = TRUE;
/* FALLTHROUGH */
case 1:
here->HSMHV_icVDS = *(value->v.vec.rVec);
here->HSMHV_icVDS_Given = TRUE;

View File

@ -144,9 +144,11 @@ int HSMHV2param(
case 3:
here->HSMHV2_icVBS = *(value->v.vec.rVec + 2);
here->HSMHV2_icVBS_Given = TRUE;
/* FALLTHROUGH */
case 2:
here->HSMHV2_icVGS = *(value->v.vec.rVec + 1);
here->HSMHV2_icVGS_Given = TRUE;
/* FALLTHROUGH */
case 1:
here->HSMHV2_icVDS = *(value->v.vec.rVec);
here->HSMHV2_icVDS_Given = TRUE;

View File

@ -67,9 +67,11 @@ ISRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
case 2:
here->ISRCacPhase = *(value->v.vec.rVec+1);
here->ISRCacPGiven = TRUE;
/* FALLTHROUGH */
case 1:
here->ISRCacMag = *(value->v.vec.rVec);
here->ISRCacMGiven = TRUE;
/* FALLTHROUGH */
case 0:
here->ISRCacGiven = TRUE;
break;

View File

@ -54,6 +54,7 @@ JFETparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
case 2:
here->JFETicVGS = *(value->v.vec.rVec+1);
here->JFETicVGSGiven = TRUE;
/* FALLTHROUGH */
case 1:
here->JFETicVDS = *(value->v.vec.rVec);
here->JFETicVDSGiven = TRUE;

View File

@ -58,6 +58,7 @@ JFET2param(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
case 2:
here->JFET2icVGS = *(value->v.vec.rVec+1);
here->JFET2icVGSGiven = TRUE;
/* FALLTHROUGH */
case 1:
here->JFET2icVDS = *(value->v.vec.rVec);
here->JFET2icVDSGiven = TRUE;

View File

@ -39,10 +39,13 @@ LTRAparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
switch (value->v.numValue) {
case 4:
here->LTRAinitCur2 = *(value->v.vec.rVec + 3);
/* FALLTHROUGH */
case 3:
here->LTRAinitVolt2 = *(value->v.vec.rVec + 2);
/* FALLTHROUGH */
case 2:
here->LTRAinitCur1 = *(value->v.vec.rVec + 1);
/* FALLTHROUGH */
case 1:
here->LTRAinitVolt1 = *(value->v.vec.rVec);
break;

View File

@ -45,6 +45,7 @@ MESparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
case 2:
here->MESicVGS = *(value->v.vec.rVec+1);
here->MESicVGSGiven = TRUE;
/* FALLTHROUGH */
case 1:
here->MESicVDS = *(value->v.vec.rVec);
here->MESicVDSGiven = TRUE;

View File

@ -49,6 +49,7 @@ MESAparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
case 2:
here->MESAicVGS = *(value->v.vec.rVec+1);
here->MESAicVGSGiven = TRUE;
/* FALLTHROUGH */
case 1:
here->MESAicVDS = *(value->v.vec.rVec);
here->MESAicVDSGiven = TRUE;

View File

@ -93,9 +93,11 @@ MOS1param(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
case 3:
here->MOS1icVBS = *(value->v.vec.rVec+2);
here->MOS1icVBSGiven = TRUE;
/* FALLTHROUGH */
case 2:
here->MOS1icVGS = *(value->v.vec.rVec+1);
here->MOS1icVGSGiven = TRUE;
/* FALLTHROUGH */
case 1:
here->MOS1icVDS = *(value->v.vec.rVec);
here->MOS1icVDSGiven = TRUE;

View File

@ -94,9 +94,11 @@ MOS2param(int param, IFvalue *value, GENinstance *inst,
case 3:
here->MOS2icVBS = *(value->v.vec.rVec+2);
here->MOS2icVBSGiven = TRUE;
/* FALLTHROUGH */
case 2:
here->MOS2icVGS = *(value->v.vec.rVec+1);
here->MOS2icVGSGiven = TRUE;
/* FALLTHROUGH */
case 1:
here->MOS2icVDS = *(value->v.vec.rVec);
here->MOS2icVDSGiven = TRUE;

View File

@ -94,9 +94,11 @@ MOS3param(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
case 3:
here->MOS3icVBS = *(value->v.vec.rVec+2);
here->MOS3icVBSGiven = TRUE;
/* FALLTHROUGH */
case 2:
here->MOS3icVGS = *(value->v.vec.rVec+1);
here->MOS3icVGSGiven = TRUE;
/* FALLTHROUGH */
case 1:
here->MOS3icVDS = *(value->v.vec.rVec);
here->MOS3icVDSGiven = TRUE;

View File

@ -86,9 +86,11 @@ MOS6param(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
case 3:
here->MOS6icVBS = *(value->v.vec.rVec+2);
here->MOS6icVBSGiven = TRUE;
/* FALLTHROUGH */
case 2:
here->MOS6icVGS = *(value->v.vec.rVec+1);
here->MOS6icVGSGiven = TRUE;
/* FALLTHROUGH */
case 1:
here->MOS6icVDS = *(value->v.vec.rVec);
here->MOS6icVDSGiven = TRUE;

View File

@ -89,9 +89,11 @@ MOS9param(int param, IFvalue *value, GENinstance *inst,
case 3:
here->MOS9icVBS = *(value->v.vec.rVec+2);
here->MOS9icVBSGiven = TRUE;
/* FALLTHROUGH */
case 2:
here->MOS9icVGS = *(value->v.vec.rVec+1);
here->MOS9icVGSGiven = TRUE;
/* FALLTHROUGH */
case 1:
here->MOS9icVDS = *(value->v.vec.rVec);
here->MOS9icVDSGiven = TRUE;

View File

@ -137,12 +137,15 @@ SOI3param(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
case 4:
here->SOI3icVBS = *(value->v.vec.rVec+3);
here->SOI3icVBSGiven = TRUE;
/* FALLTHROUGH */
case 3:
here->SOI3icVGBS = *(value->v.vec.rVec+2);
here->SOI3icVGBSGiven = TRUE;
/* FALLTHROUGH */
case 2:
here->SOI3icVGFS = *(value->v.vec.rVec+1);
here->SOI3icVGFSGiven = TRUE;
/* FALLTHROUGH */
case 1:
here->SOI3icVDS = *(value->v.vec.rVec);
here->SOI3icVDSGiven = TRUE;

View File

@ -65,10 +65,13 @@ TRAparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
switch(value->v.numValue){
case 4:
here->TRAinitCur2 = *(value->v.vec.rVec+3);
/* FALLTHROUGH */
case 3:
here->TRAinitVolt2 = *(value->v.vec.rVec+2);
/* FALLTHROUGH */
case 2:
here->TRAinitCur1 = *(value->v.vec.rVec+1);
/* FALLTHROUGH */
case 1:
here->TRAinitVolt1 = *(value->v.vec.rVec);
break;

View File

@ -59,6 +59,7 @@ VBICparam(int param, IFvalue *value, GENinstance *instPtr, IFvalue *select)
case 2:
here->VBICicVCE = *(value->v.vec.rVec+1);
here->VBICicVCEGiven = TRUE;
/* FALLTHROUGH */
case 1:
here->VBICicVBE = *(value->v.vec.rVec);
here->VBICicVBEGiven = TRUE;

View File

@ -70,6 +70,7 @@ VDMOSparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
case 2:
here->VDMOSicVGS = *(value->v.vec.rVec+1);
here->VDMOSicVGSGiven = TRUE;
/* FALLTHROUGH */
case 1:
here->VDMOSicVDS = *(value->v.vec.rVec);
here->VDMOSicVDSGiven = TRUE;

View File

@ -62,9 +62,11 @@ VSRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
case 2:
here->VSRCacPhase = *(value->v.vec.rVec+1);
here->VSRCacPGiven = TRUE;
/* FALLTHROUGH */
case 1:
here->VSRCacMag = *(value->v.vec.rVec);
here->VSRCacMGiven = TRUE;
/* FALLTHROUGH */
case 0:
here->VSRCacGiven = TRUE;
break;

View File

@ -68,7 +68,12 @@ INPdevParse(char **line, CKTcircuit *ckt, int dev, GENinstance *fast,
IFparm *p = find_instance_parameter(parameter, device);
if (!p) {
errbuf = tprintf(" unknown parameter (%s) \n", parameter);
if (cieq(parameter, "$")) {
errbuf = copy(" unknown parameter ($). Check the compatibility flag!\n");
}
else {
errbuf = tprintf(" unknown parameter (%s) \n", parameter);
}
rtn = errbuf;
goto quit;
}
@ -112,7 +117,12 @@ INPdevParse(char **line, CKTcircuit *ckt, int dev, GENinstance *fast,
IFparm *p = find_instance_parameter(parm, device);
if (!p) {
errbuf = tprintf(" unknown parameter (%s) \n", parm);
if (eq(parm, "$")) {
errbuf = copy(" unknown parameter ($). Check the compatibility flag!\n");
}
else {
errbuf = tprintf(" unknown parameter (%s) \n", parm);
}
rtn = errbuf;
goto quit;
}

View File

@ -12,6 +12,10 @@
#ifdef HAS_WINGUI
#ifndef _WIN32
#define _WIN32
#endif
#define STRICT // strict type checking
#define WIN32_LEAN_AND_MEAN
#include <windows.h> // standard Windows calls
@ -27,7 +31,10 @@
#include <ctype.h>
#include <sys/types.h>
#include <sys/timeb.h>
#ifdef __MINGW32__
#include <tchar.h>
#include <stdio.h>
#endif
#include "hist_info.h" /* history management */
#include "ngspice/bool.h" /* bool defined as unsigned char */
@ -107,6 +114,7 @@ static LPCWSTR hwElementClassNameW = L"ElementClass";
static LPCWSTR hwSourceWindowNameW = L"SourceDisplay";
static LPCWSTR hwAnalyseWindowNameW = L"AnalyseDisplay";
#endif
static size_t TBufEnd = 0; /* Pointer to \0 */
static char TBuffer[TBufSize + 1]; /* Text buffer */
static SBufLine SBuffer; /* Input buffer */
@ -265,8 +273,8 @@ SetAnalyse(char *Analyse, /* in: analysis type */
#else
wchar_t sw[256];
wchar_t tw[256];
swprintf(sw, 256, L"%S", s);
swprintf(tw, 256, L"%S", t);
MultiByteToWideChar(CP_UTF8, 0, s, -1, sw, 256);
MultiByteToWideChar(CP_UTF8, 0, t, -1, tw, 256);
/* Analysis window */
SetWindowTextW(hwAnalyse, sw);
/* ngspice task bar */
@ -624,7 +632,7 @@ StringWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
/* for utf-8 the number of characters is not the number of bytes returned */
GetWindowTextW(hwnd, WBuffer, sizeof SBuffer - (sizeof CRLF - 1));
WideCharToMultiByte(CP_UTF8, 0, WBuffer,
-1, SBuffer, sizeof SBuffer - 1, NULL, NULL);
-1, SBuffer, sizeof SBuffer - 1, NULL, FALSE);
/* retrive here the number of bytes returned */
const int n_char_returned = (int)strlen(SBuffer);
tfree(WBuffer);
@ -961,9 +969,6 @@ MakeArgcArgv(char *cmdline, int *argc, char ***argv)
#ifdef EXT_ASC
int WINAPI
WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpszCmdLine, _In_ int nCmdShow)
#elif __MINGW32__ /* MINGW bug not knowing wWinMain */
int WINAPI
WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR nolpszCmdLine, _In_ int nCmdShow)
#else
int WINAPI
wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR wlpszCmdLine, _In_ int nCmdShow)
@ -988,35 +993,8 @@ wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR
#ifndef EXT_ASC
/* convert wchar to utf-8 */
/* MINGW not knowing wWinMain
https://github.com/coderforlife/mingw-unicode-main/blob/master/mingw-unicode-gui.c
*/
#ifdef __MINGW32__
NG_IGNORE(nolpszCmdLine);
char lpszCmdLine[1024];
wchar_t *lpCmdLine = GetCommandLineW();
if (__argc == 1) { // avoids GetCommandLineW bug that does not always quote the program name if no arguments
do { ++lpCmdLine; } while (*lpCmdLine);
}
else {
BOOL quoted = lpCmdLine[0] == L'"';
++lpCmdLine; // skips the " or the first letter (all paths are at least 1 letter)
while (*lpCmdLine) {
if (quoted && lpCmdLine[0] == L'"') { quoted = FALSE; } // found end quote
else if (!quoted && lpCmdLine[0] == L' ') {
// found an unquoted space, now skip all spaces
do { ++lpCmdLine; } while (lpCmdLine[0] == L' ');
break;
}
++lpCmdLine;
}
}
WideCharToMultiByte(CP_UTF8, 0, lpCmdLine, -1, lpszCmdLine, 1023, NULL, NULL);
#else
char lpszCmdLine[1024];
WideCharToMultiByte(CP_UTF8, 0, wlpszCmdLine, -1, lpszCmdLine, 1023, NULL, NULL);
#endif
WideCharToMultiByte(CP_UTF8, 0, wlpszCmdLine, -1, lpszCmdLine, 1023, NULL, FALSE);
#endif
/* fill global variables */
hInst = hInstance;