Merge branch 'pre-master-44' into bt_dev

This commit is contained in:
Brian Taylor 2024-10-10 11:23:33 -07:00
commit 2cf6e80a70
11 changed files with 84 additions and 74 deletions

View File

@ -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

View File

@ -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);
}

View File

@ -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)

View File

@ -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, ' ');

View File

@ -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. */

View File

@ -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);

View File

@ -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;
}

View File

@ -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 <math.h>
/*=== 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;
}
}

View File

@ -236,7 +236,7 @@
<ExceptionHandling>
</ExceptionHandling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<OpenMPSupport>true</OpenMPSupport>
<OpenMPSupport>false</OpenMPSupport>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
@ -257,7 +257,7 @@
<ExceptionHandling>
</ExceptionHandling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<OpenMPSupport>true</OpenMPSupport>
<OpenMPSupport>false</OpenMPSupport>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>

View File

@ -407,7 +407,7 @@ lib /machine:x64 /def:..\..\fftw-3.3-dll64\libfftw3-3.def /out:$(IntDir)libfftw3
<CompileAs>Default</CompileAs>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp14</LanguageStandard>
<AdditionalOptions>/openmp:llvm %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions>%(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<AdditionalDependencies>psapi.lib;KLU_COMPLEX.lib;%(AdditionalDependencies)</AdditionalDependencies>

View File

@ -383,7 +383,7 @@
<CompileAs>Default</CompileAs>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp14</LanguageStandard>
<AdditionalOptions>/openmp:llvm %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions>%(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<AdditionalDependencies>psapi.lib;KLU_COMPLEX.lib;%(AdditionalDependencies)</AdditionalDependencies>
@ -2896,4 +2896,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>