diff --git a/examples/numparam/vector_param.cir b/examples/numparam/vector_param.cir new file mode 100644 index 000000000..ce79093a9 --- /dev/null +++ b/examples/numparam/vector_param.cir @@ -0,0 +1,33 @@ +.TITLE SUBCKT VECTOR PARAM TEST +* Example of passing a vector parameter to a sub-circuit. +* Modified from https://sourceforge.net/p/ngspice/feature-requests/55/ + +* An AND gate impmented as a LUT in a subcircuit. + +.param default_vec="[1e-12 2e-12]" + *--vector parameter-- +.subckt testcir in0 in1 outlut testpar = {default_vec} + +A_genlut [in0 in1] [outlut] genlut +.model genlut d_genlut ( ++ input_delay = {testpar} ++ table_values = "0001") + +.ends testcir + +V_Vss vss 0 DC 3.3 +V_pulse sine 0 DC 0 SIN(0 1 1000) + +.param actual_vec="[1.3e-3 2e-3]" + *--vector parameter-- +X_subckt no1 dss node3 testcir testpar={actual_vec} + +A_ADC [sine vss] [no1 dss] ADC +.model ADC adc_bridge(in_low=0.7 in_high=0.71) + +.control + tran 20u 4m + plot sine node3 +.endc + +.end diff --git a/src/frontend/evaluate.c b/src/frontend/evaluate.c index ee9bec045..42fc4540b 100644 --- a/src/frontend/evaluate.c +++ b/src/frontend/evaluate.c @@ -721,7 +721,7 @@ op_ind(struct pnode *arg1, struct pnode *arg2) v->v_numdims = 1; v->v_dims[0] = v->v_length; if (v->v_length <= 1) { - fprintf(cp_err, "Error: nostrchring on a scalar (%s)\n", + fprintf(cp_err, "Error: indexing a scalar (%s)\n", v->v_name); return (NULL); } diff --git a/src/frontend/numparam/numparam.h b/src/frontend/numparam/numparam.h index 890bf8299..148311149 100644 --- a/src/frontend/numparam/numparam.h +++ b/src/frontend/numparam/numparam.h @@ -20,6 +20,11 @@ extern const struct nupa_type S_nupa_string; extern const struct nupa_type S_nupa_subckt; extern const struct nupa_type S_nupa_unknown; +/* Length of "numparam____ ..." string to be inserted and replaced. */ + +#define ACT_CHARACTS 25 +#define MARKER "numparm__________" + #define NUPA_REAL (&S_nupa_real) #define NUPA_STRING (&S_nupa_string) #define NUPA_SUBCKT (&S_nupa_subckt) diff --git a/src/frontend/numparam/spicenum.c b/src/frontend/numparam/spicenum.c index fc1454759..bd7690e08 100644 --- a/src/frontend/numparam/spicenum.c +++ b/src/frontend/numparam/spicenum.c @@ -121,8 +121,9 @@ stripbraces(DSTRINGPTR dstr_p) cadd(&tstr, ' '); { - char buf[25+1]; - sprintf(buf, "numparm__________%08lx", ++placeholder); + char buf[ACT_CHARACTS + 1]; + + sprintf(buf, MARKER "%08lx", ++placeholder); sadd(&tstr, buf); } cadd(&tstr, ' '); diff --git a/src/frontend/numparam/xpressn.c b/src/frontend/numparam/xpressn.c index a3c049d73..c1bb96208 100644 --- a/src/frontend/numparam/xpressn.c +++ b/src/frontend/numparam/xpressn.c @@ -23,8 +23,6 @@ extern long dynsubst; /* see inpcom.c */ -#define ACT_CHARACTS 25 /* actual string length to be inserted and replaced */ - #define S_init 0 #define S_atom 1 #define S_binop 2 @@ -1165,7 +1163,7 @@ static char *string_expr(dico_t *dico, DSTRINGPTR qstr_p, /* stupid, produce a string representation of a given double * to be spliced back into the circuit deck - * we want *exactly* 25 chars, we have + * we want *exactly* 25 (ACT_CHARACTS) chars, we have * sign, leading digit, '.', 'e', sign, upto 3 digits exponent * ==> 8 chars, thus we have 17 left for precision * don't print a leading '+', something choked @@ -1214,10 +1212,10 @@ insertnumber(dico_t *dico, char **lp, DSTRINGPTR ustr_p) long id = 0; int n; - char *p = strstr(s, "numparm__________"); + char *p = strstr(s, MARKER); if (p && - (1 == sscanf(p, "numparm__________%8lx%n", &id, &n)) && + (1 == sscanf(p, MARKER "%8lx%n", &id, &n)) && (n == ACT_CHARACTS) && (id > 0) && (id < dynsubst + 1)) { /* Found a target for substitution. */ diff --git a/src/frontend/plotting/agraf.c b/src/frontend/plotting/agraf.c index de750a973..464cb0ac1 100644 --- a/src/frontend/plotting/agraf.c +++ b/src/frontend/plotting/agraf.c @@ -86,12 +86,6 @@ ft_agraf(double *xlims, double *ylims, struct dvec *xscale, struct plot *plot, s yrange[0] = ylims[0]; yrange[1] = ylims[1]; - if (maxx < 2) { - fprintf(cp_err, - "Error: asciiplot can't handle scale with length < 2\n"); - return; - } - if (maxx <= 0) { fprintf(cp_err, "Note: no points to plot\n"); return; @@ -294,12 +288,18 @@ ft_agraf(double *xlims, double *ylims, struct dvec *xscale, struct plot *plot, s for (i = 0; i < maxx; i++) { if (nointerp) x = isreal(xscale) ? xscale->v_realdata[i] : - realpart(xscale->v_compdata[i]); + realpart(xscale->v_compdata[i]); else if (xlog && xrange[0] > 0.0 && xrange[1] > 0.0) - x = xrange[0] * pow(10.0, mylog10(xrange[1]/xrange[0]) - * i / (maxx - 1)); + if (maxx == 1) + x = (xrange[0] + xrange[1]) / 2.; + else + x = xrange[0] * pow(10.0, mylog10(xrange[1] / xrange[0]) + * i / (maxx - 1)); else - x = xrange[0] + (xrange[1] - xrange[0]) * i / (maxx - 1); + if (maxx == 1) + x = (xrange[0] + xrange[1]) / 2.; + else + x = xrange[0] + (xrange[1] - xrange[0]) * i / (maxx - 1); if (x < 0.0) out_printf("%.3e ", x); diff --git a/src/spicelib/devices/vsrc/vsrcload.c b/src/spicelib/devices/vsrc/vsrcload.c index 54183aaa5..c74c9a756 100644 --- a/src/spicelib/devices/vsrc/vsrcload.c +++ b/src/spicelib/devices/vsrc/vsrcload.c @@ -320,9 +320,8 @@ VSRCload(GENmodel *inModel, CKTcircuit *ckt) double end_time, itime; time -= here->VSRCrdelay; - if (time < here->VSRCcoeffs[0]) { + if (time <= here->VSRCcoeffs[0]) { value = here->VSRCcoeffs[1]; - value = value; break; } diff --git a/src/xspice/icm/xtradev/potentiometer/cfunc.mod b/src/xspice/icm/xtradev/potentiometer/cfunc.mod index 8b9448c2d..c7d0a8c36 100644 --- a/src/xspice/icm/xtradev/potentiometer/cfunc.mod +++ b/src/xspice/icm/xtradev/potentiometer/cfunc.mod @@ -8,9 +8,8 @@ Public Domain Georgia Tech Research Corporation Atlanta, Georgia 30332 PROJECT A-8503-405 - -AUTHORS +AUTHORS 19 June 1992 Jeffrey P. Murray @@ -19,7 +18,7 @@ MODIFICATIONS 19 June 1992 Jeffrey P. Murray 22 October 2022 Holger Vogt - + 05 October 2024 Holger Vogt SUMMARY @@ -27,17 +26,16 @@ SUMMARY code model. -INTERFACES +INTERFACES - FILE ROUTINE CALLED + FILE ROUTINE CALLED - CMmacros.h cm_message_send(); + CMmacros.h cm_message_send(); REFERENCED FILES Inputs from and outputs to ARGS structure. - NON-STANDARD FEATURES @@ -49,36 +47,24 @@ NON-STANDARD FEATURES #include - - /*=== CONSTANTS ========================*/ - - /*=== MACROS ===========================*/ - - /*=== LOCAL VARIABLES & TYPEDEFS =======*/ - - /*=== FUNCTION PROTOTYPE DEFINITIONS ===*/ - - - - /*============================================================================== FUNCTION cm_potentiometer() -AUTHORS +AUTHORS 19 June 1992 Jeffrey P. Murray @@ -90,11 +76,11 @@ SUMMARY This function implements the potentiometer code model. -INTERFACES +INTERFACES - FILE ROUTINE CALLED + FILE ROUTINE CALLED - CMmacros.h cm_message_send(); + CMmacros.h cm_message_send(); RETURNED VALUE @@ -123,11 +109,7 @@ void cm_potentiometer (ARGS) double vr1; /* voltage at r1 */ double vwiper; /* voltage at wiper */ - - Mif_Complex_t ac_gain; - - /* Retrieve frequently used parameters... */ @@ -148,29 +130,25 @@ void cm_potentiometer (ARGS) vr1 = INPUT(r1); - if ( PARAM(log) == FALSE ) { + if ( PARAM(log) == FALSE ) { /* Linear Variation in resistance w.r.t. position */ r_lower = position * resistance; r_upper = resistance - r_lower; } - else { + else { /* Logarithmic Variation in resistance w.r.t. position */ - r_lower = resistance / + r_lower = resistance / pow(10.0,(position * PARAM(log_multiplier))); r_upper = resistance - r_lower; } - - - - /* Output DC & Transient Values */ - if(ANALYSIS != MIF_AC) { + if(ANALYSIS != MIF_AC) { OUTPUT(r0) = (vr0 - vwiper) / r_lower; OUTPUT(r1) = (vr1 - vwiper) / r_upper; OUTPUT(wiper) = ((vwiper - vr0)/r_lower) + ((vwiper - vr1)/r_upper); @@ -188,43 +166,39 @@ void cm_potentiometer (ARGS) PARTIAL(wiper,wiper) = (1.0/r_lower) + (1.0/r_upper); } - else { + else { /* Output AC Gain Values */ - ac_gain.imag= 0.0; + ac_gain.imag= 0.0; - ac_gain.real = -1.0 / r_lower; + ac_gain.real = 1.0 / r_lower; AC_GAIN(r0,r0) = ac_gain; - ac_gain.real = 0.0; + ac_gain.real = 0.0; AC_GAIN(r0,r1) = ac_gain; - ac_gain.real = 1.0 / r_lower; + ac_gain.real = -1.0 / r_lower; AC_GAIN(r0,wiper) = ac_gain; ac_gain.real = 0.0; AC_GAIN(r1,r0) = ac_gain; - ac_gain.real = -1.0 / r_upper; + ac_gain.real = 1.0 / r_upper; AC_GAIN(r1,r1) = ac_gain; - ac_gain.real = 1.0 / r_upper; + ac_gain.real = -1.0 / r_upper; AC_GAIN(r1,wiper) = ac_gain; - ac_gain.real = 1.0 / r_lower; + ac_gain.real = -1.0 / r_lower; AC_GAIN(wiper,r0) = ac_gain; - ac_gain.real = 1.0 / r_upper; + ac_gain.real = -1.0 / r_upper; AC_GAIN(wiper,r1) = ac_gain; - ac_gain.real = -(1.0/r_lower) - (1.0/r_upper); + ac_gain.real = (1.0/r_lower) + (1.0/r_upper); AC_GAIN(wiper,wiper) = ac_gain; } } - - - - diff --git a/visualc/KLU/KLU_COMPLEX.vcxproj b/visualc/KLU/KLU_COMPLEX.vcxproj index e4222f58e..e1af1f11b 100644 --- a/visualc/KLU/KLU_COMPLEX.vcxproj +++ b/visualc/KLU/KLU_COMPLEX.vcxproj @@ -236,7 +236,7 @@ MultiThreaded - true + false Level3 @@ -257,7 +257,7 @@ MultiThreaded - true + false Level3 diff --git a/visualc/sharedspice.vcxproj b/visualc/sharedspice.vcxproj index bce301c2a..c18f68813 100644 --- a/visualc/sharedspice.vcxproj +++ b/visualc/sharedspice.vcxproj @@ -407,7 +407,7 @@ lib /machine:x64 /def:..\..\fftw-3.3-dll64\libfftw3-3.def /out:$(IntDir)libfftw3 Default true stdcpp14 - /openmp:llvm %(AdditionalOptions) + %(AdditionalOptions) psapi.lib;KLU_COMPLEX.lib;%(AdditionalDependencies) diff --git a/visualc/vngspice.vcxproj b/visualc/vngspice.vcxproj index 476250aa7..5281546d0 100644 --- a/visualc/vngspice.vcxproj +++ b/visualc/vngspice.vcxproj @@ -383,7 +383,7 @@ Default true stdcpp14 - /openmp:llvm %(AdditionalOptions) + %(AdditionalOptions) psapi.lib;KLU_COMPLEX.lib;%(AdditionalDependencies) @@ -2896,4 +2896,4 @@ - + \ No newline at end of file