fix a bug when `alter' a vector parameter (VSRC PWL for example)
This commit is contained in:
parent
f40f6c705a
commit
281d1952c4
|
|
@ -1,3 +1,9 @@
|
||||||
|
2011-02-11 Robert Larice
|
||||||
|
* src/spicelib/devices/cpl/cplmpar.c ,
|
||||||
|
* src/spicelib/devices/isrc/isrcpar.c ,
|
||||||
|
* src/spicelib/devices/vsrc/vsrcpar.c :
|
||||||
|
fix a bug when `alter' a vector parameter (VSRC PWL for example)
|
||||||
|
|
||||||
2011-01-25 Robert Larice
|
2011-01-25 Robert Larice
|
||||||
* Modified src/include/cmproto.h ,
|
* Modified src/include/cmproto.h ,
|
||||||
* Modified src/xspice/icm/dlmain.c ,
|
* Modified src/xspice/icm/dlmain.c ,
|
||||||
|
|
|
||||||
|
|
@ -13,28 +13,39 @@ Author: 1992 Charles Hough
|
||||||
#include "suffix.h"
|
#include "suffix.h"
|
||||||
|
|
||||||
|
|
||||||
|
static void copy_coeffs(double **dst, IFvalue *value)
|
||||||
|
{
|
||||||
|
if(*dst)
|
||||||
|
tfree(*dst);
|
||||||
|
|
||||||
|
*dst = TMALLOC(double, value->v.numValue);
|
||||||
|
|
||||||
|
memcpy(*dst, value->v.vec.rVec, value->v.numValue * sizeof(double));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
CPLmParam(int param, IFvalue *value, GENmodel *inModel)
|
CPLmParam(int param, IFvalue *value, GENmodel *inModel)
|
||||||
{
|
{
|
||||||
register CPLmodel *model = (CPLmodel *)inModel;
|
register CPLmodel *model = (CPLmodel *)inModel;
|
||||||
switch(param) {
|
switch(param) {
|
||||||
case CPL_R:
|
case CPL_R:
|
||||||
model->Rm = value->v.vec.rVec;
|
copy_coeffs(& model->Rm, value);
|
||||||
model->Rm_counter = value->v.numValue;
|
model->Rm_counter = value->v.numValue;
|
||||||
model->Rmgiven = TRUE;
|
model->Rmgiven = TRUE;
|
||||||
break;
|
break;
|
||||||
case CPL_L:
|
case CPL_L:
|
||||||
model->Lm = value->v.vec.rVec;
|
copy_coeffs(& model->Lm, value);
|
||||||
model->Lm_counter = value->v.numValue;
|
model->Lm_counter = value->v.numValue;
|
||||||
model->Lmgiven = TRUE;
|
model->Lmgiven = TRUE;
|
||||||
break;
|
break;
|
||||||
case CPL_G:
|
case CPL_G:
|
||||||
model->Gm = value->v.vec.rVec;
|
copy_coeffs(& model->Gm, value);
|
||||||
model->Gm_counter = value->v.numValue;
|
model->Gm_counter = value->v.numValue;
|
||||||
model->Gmgiven = TRUE;
|
model->Gmgiven = TRUE;
|
||||||
break;
|
break;
|
||||||
case CPL_C:
|
case CPL_C:
|
||||||
model->Cm = value->v.vec.rVec;
|
copy_coeffs(& model->Cm, value);
|
||||||
model->Cm_counter = value->v.numValue;
|
model->Cm_counter = value->v.numValue;
|
||||||
model->Cmgiven = TRUE;
|
model->Cmgiven = TRUE;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,19 @@ Modified: 2000 AlansFixes
|
||||||
#include "1-f-code.h"
|
#include "1-f-code.h"
|
||||||
|
|
||||||
|
|
||||||
|
static void copy_coeffs(ISRCinstance *here, IFvalue *value)
|
||||||
|
{
|
||||||
|
if(here->ISRCcoeffs)
|
||||||
|
tfree(here->ISRCcoeffs);
|
||||||
|
|
||||||
|
here->ISRCcoeffs = TMALLOC(double, value->v.numValue);
|
||||||
|
here->ISRCfunctionOrder = value->v.numValue;
|
||||||
|
here->ISRCcoeffsGiven = TRUE;
|
||||||
|
|
||||||
|
memcpy(here->ISRCcoeffs, value->v.vec.rVec, value->v.numValue * sizeof(double));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ARGSUSED */
|
/* ARGSUSED */
|
||||||
int
|
int
|
||||||
ISRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
|
ISRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
|
||||||
|
|
@ -57,33 +70,25 @@ ISRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
|
||||||
if(value->v.numValue <2) return(E_BADPARM);
|
if(value->v.numValue <2) return(E_BADPARM);
|
||||||
here->ISRCfunctionType = PULSE;
|
here->ISRCfunctionType = PULSE;
|
||||||
here->ISRCfuncTGiven = TRUE;
|
here->ISRCfuncTGiven = TRUE;
|
||||||
here->ISRCcoeffs = value->v.vec.rVec;
|
copy_coeffs(here, value);
|
||||||
here->ISRCfunctionOrder = value->v.numValue;
|
|
||||||
here->ISRCcoeffsGiven = TRUE;
|
|
||||||
break;
|
break;
|
||||||
case ISRC_SINE:
|
case ISRC_SINE:
|
||||||
if(value->v.numValue <2) return(E_BADPARM);
|
if(value->v.numValue <2) return(E_BADPARM);
|
||||||
here->ISRCfunctionType = SINE;
|
here->ISRCfunctionType = SINE;
|
||||||
here->ISRCfuncTGiven = TRUE;
|
here->ISRCfuncTGiven = TRUE;
|
||||||
here->ISRCcoeffs = value->v.vec.rVec;
|
copy_coeffs(here, value);
|
||||||
here->ISRCfunctionOrder = value->v.numValue;
|
|
||||||
here->ISRCcoeffsGiven = TRUE;
|
|
||||||
break;
|
break;
|
||||||
case ISRC_EXP:
|
case ISRC_EXP:
|
||||||
if(value->v.numValue <2) return(E_BADPARM);
|
if(value->v.numValue <2) return(E_BADPARM);
|
||||||
here->ISRCfunctionType = EXP;
|
here->ISRCfunctionType = EXP;
|
||||||
here->ISRCfuncTGiven = TRUE;
|
here->ISRCfuncTGiven = TRUE;
|
||||||
here->ISRCcoeffs = value->v.vec.rVec;
|
copy_coeffs(here, value);
|
||||||
here->ISRCfunctionOrder = value->v.numValue;
|
|
||||||
here->ISRCcoeffsGiven = TRUE;
|
|
||||||
break;
|
break;
|
||||||
case ISRC_PWL:
|
case ISRC_PWL:
|
||||||
if(value->v.numValue <2) return(E_BADPARM);
|
if(value->v.numValue <2) return(E_BADPARM);
|
||||||
here->ISRCfunctionType = PWL;
|
here->ISRCfunctionType = PWL;
|
||||||
here->ISRCfuncTGiven = TRUE;
|
here->ISRCfuncTGiven = TRUE;
|
||||||
here->ISRCcoeffs = value->v.vec.rVec;
|
copy_coeffs(here, value);
|
||||||
here->ISRCfunctionOrder = value->v.numValue;
|
|
||||||
here->ISRCcoeffsGiven = TRUE;
|
|
||||||
|
|
||||||
for (i=0;i<((here->ISRCfunctionOrder/2)-1);i++) {
|
for (i=0;i<((here->ISRCfunctionOrder/2)-1);i++) {
|
||||||
if (*(here->ISRCcoeffs+2*(i+1))<=*(here->ISRCcoeffs+2*i)) {
|
if (*(here->ISRCcoeffs+2*(i+1))<=*(here->ISRCcoeffs+2*i)) {
|
||||||
|
|
@ -98,17 +103,13 @@ ISRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
|
||||||
if(value->v.numValue <2) return(E_BADPARM);
|
if(value->v.numValue <2) return(E_BADPARM);
|
||||||
here->ISRCfunctionType = SFFM;
|
here->ISRCfunctionType = SFFM;
|
||||||
here->ISRCfuncTGiven = TRUE;
|
here->ISRCfuncTGiven = TRUE;
|
||||||
here->ISRCcoeffs = value->v.vec.rVec;
|
copy_coeffs(here, value);
|
||||||
here->ISRCfunctionOrder = value->v.numValue;
|
|
||||||
here->ISRCcoeffsGiven = TRUE;
|
|
||||||
break;
|
break;
|
||||||
case ISRC_AM:
|
case ISRC_AM:
|
||||||
if(value->v.numValue <2) return(E_BADPARM);
|
if(value->v.numValue <2) return(E_BADPARM);
|
||||||
here->ISRCfunctionType = AM;
|
here->ISRCfunctionType = AM;
|
||||||
here->ISRCfuncTGiven = TRUE;
|
here->ISRCfuncTGiven = TRUE;
|
||||||
here->ISRCcoeffs = value->v.vec.rVec;
|
copy_coeffs(here, value);
|
||||||
here->ISRCfunctionOrder = value->v.numValue;
|
|
||||||
here->ISRCcoeffsGiven = TRUE;
|
|
||||||
break;
|
break;
|
||||||
case ISRC_D_F1:
|
case ISRC_D_F1:
|
||||||
here->ISRCdF1given = TRUE;
|
here->ISRCdF1given = TRUE;
|
||||||
|
|
@ -161,9 +162,7 @@ ISRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
|
||||||
|
|
||||||
here->ISRCfunctionType = TRNOISE;
|
here->ISRCfunctionType = TRNOISE;
|
||||||
here->ISRCfuncTGiven = TRUE;
|
here->ISRCfuncTGiven = TRUE;
|
||||||
here->ISRCcoeffs = value->v.vec.rVec;
|
copy_coeffs(here, value);
|
||||||
here->ISRCfunctionOrder = value->v.numValue;
|
|
||||||
here->ISRCcoeffsGiven = TRUE;
|
|
||||||
|
|
||||||
NA = here->ISRCcoeffs[0]; // input is rms value
|
NA = here->ISRCcoeffs[0]; // input is rms value
|
||||||
TS = here->ISRCcoeffs[1]; // time step
|
TS = here->ISRCcoeffs[1]; // time step
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,19 @@ Modified: 2000 AlansFixes
|
||||||
#include "1-f-code.h"
|
#include "1-f-code.h"
|
||||||
|
|
||||||
|
|
||||||
|
static void copy_coeffs(VSRCinstance *here, IFvalue *value)
|
||||||
|
{
|
||||||
|
if(here->VSRCcoeffs)
|
||||||
|
tfree(here->VSRCcoeffs);
|
||||||
|
|
||||||
|
here->VSRCcoeffs = TMALLOC(double, value->v.numValue);
|
||||||
|
here->VSRCfunctionOrder = value->v.numValue;
|
||||||
|
here->VSRCcoeffsGiven = TRUE;
|
||||||
|
|
||||||
|
memcpy(here->VSRCcoeffs, value->v.vec.rVec, value->v.numValue * sizeof(double));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ARGSUSED */
|
/* ARGSUSED */
|
||||||
int
|
int
|
||||||
VSRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
|
VSRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
|
||||||
|
|
@ -56,30 +69,22 @@ VSRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
|
||||||
case VSRC_PULSE:
|
case VSRC_PULSE:
|
||||||
here->VSRCfunctionType = PULSE;
|
here->VSRCfunctionType = PULSE;
|
||||||
here->VSRCfuncTGiven = TRUE;
|
here->VSRCfuncTGiven = TRUE;
|
||||||
here->VSRCcoeffs = value->v.vec.rVec;
|
copy_coeffs(here, value);
|
||||||
here->VSRCfunctionOrder = value->v.numValue;
|
|
||||||
here->VSRCcoeffsGiven = TRUE;
|
|
||||||
break;
|
break;
|
||||||
case VSRC_SINE:
|
case VSRC_SINE:
|
||||||
here->VSRCfunctionType = SINE;
|
here->VSRCfunctionType = SINE;
|
||||||
here->VSRCfuncTGiven = TRUE;
|
here->VSRCfuncTGiven = TRUE;
|
||||||
here->VSRCcoeffs = value->v.vec.rVec;
|
copy_coeffs(here, value);
|
||||||
here->VSRCfunctionOrder = value->v.numValue;
|
|
||||||
here->VSRCcoeffsGiven = TRUE;
|
|
||||||
break;
|
break;
|
||||||
case VSRC_EXP:
|
case VSRC_EXP:
|
||||||
here->VSRCfunctionType = EXP;
|
here->VSRCfunctionType = EXP;
|
||||||
here->VSRCfuncTGiven = TRUE;
|
here->VSRCfuncTGiven = TRUE;
|
||||||
here->VSRCcoeffs = value->v.vec.rVec;
|
copy_coeffs(here, value);
|
||||||
here->VSRCfunctionOrder = value->v.numValue;
|
|
||||||
here->VSRCcoeffsGiven = TRUE;
|
|
||||||
break;
|
break;
|
||||||
case VSRC_PWL:
|
case VSRC_PWL:
|
||||||
here->VSRCfunctionType = PWL;
|
here->VSRCfunctionType = PWL;
|
||||||
here->VSRCfuncTGiven = TRUE;
|
here->VSRCfuncTGiven = TRUE;
|
||||||
here->VSRCcoeffs = value->v.vec.rVec;
|
copy_coeffs(here, value);
|
||||||
here->VSRCfunctionOrder = value->v.numValue;
|
|
||||||
here->VSRCcoeffsGiven = TRUE;
|
|
||||||
|
|
||||||
for(i=0;i<(here->VSRCfunctionOrder/2)-1;i++) {
|
for(i=0;i<(here->VSRCfunctionOrder/2)-1;i++) {
|
||||||
if(*(here->VSRCcoeffs+2*(i+1))<=*(here->VSRCcoeffs+2*i)) {
|
if(*(here->VSRCcoeffs+2*(i+1))<=*(here->VSRCcoeffs+2*i)) {
|
||||||
|
|
@ -118,17 +123,13 @@ VSRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
|
||||||
case VSRC_SFFM:
|
case VSRC_SFFM:
|
||||||
here->VSRCfunctionType = SFFM;
|
here->VSRCfunctionType = SFFM;
|
||||||
here->VSRCfuncTGiven = TRUE;
|
here->VSRCfuncTGiven = TRUE;
|
||||||
here->VSRCcoeffs = value->v.vec.rVec;
|
copy_coeffs(here, value);
|
||||||
here->VSRCfunctionOrder = value->v.numValue;
|
|
||||||
here->VSRCcoeffsGiven = TRUE;
|
|
||||||
break;
|
break;
|
||||||
case VSRC_AM:
|
case VSRC_AM:
|
||||||
if(value->v.numValue <2) return(E_BADPARM);
|
if(value->v.numValue <2) return(E_BADPARM);
|
||||||
here->VSRCfunctionType = AM;
|
here->VSRCfunctionType = AM;
|
||||||
here->VSRCfuncTGiven = TRUE;
|
here->VSRCfuncTGiven = TRUE;
|
||||||
here->VSRCcoeffs = value->v.vec.rVec;
|
copy_coeffs(here, value);
|
||||||
here->VSRCfunctionOrder = value->v.numValue;
|
|
||||||
here->VSRCcoeffsGiven = TRUE;
|
|
||||||
break;
|
break;
|
||||||
case VSRC_D_F1:
|
case VSRC_D_F1:
|
||||||
here->VSRCdF1given = TRUE;
|
here->VSRCdF1given = TRUE;
|
||||||
|
|
@ -180,9 +181,7 @@ VSRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
|
||||||
|
|
||||||
here->VSRCfunctionType = TRNOISE;
|
here->VSRCfunctionType = TRNOISE;
|
||||||
here->VSRCfuncTGiven = TRUE;
|
here->VSRCfuncTGiven = TRUE;
|
||||||
here->VSRCcoeffs = value->v.vec.rVec;
|
copy_coeffs(here, value);
|
||||||
here->VSRCfunctionOrder = value->v.numValue;
|
|
||||||
here->VSRCcoeffsGiven = TRUE;
|
|
||||||
|
|
||||||
NA = here->VSRCcoeffs[0]; // input is rms value
|
NA = here->VSRCcoeffs[0]; // input is rms value
|
||||||
TS = here->VSRCcoeffs[1]; // time step
|
TS = here->VSRCcoeffs[1]; // time step
|
||||||
|
|
@ -215,9 +214,7 @@ VSRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
|
||||||
|
|
||||||
here->VSRCfunctionType = TRRANDOM;
|
here->VSRCfunctionType = TRRANDOM;
|
||||||
here->VSRCfuncTGiven = TRUE;
|
here->VSRCfuncTGiven = TRUE;
|
||||||
here->VSRCcoeffs = value->v.vec.rVec;
|
copy_coeffs(here, value);
|
||||||
here->VSRCfunctionOrder = value->v.numValue;
|
|
||||||
here->VSRCcoeffsGiven = TRUE;
|
|
||||||
|
|
||||||
rndtype = (int)here->VSRCcoeffs[0]; // type of random function
|
rndtype = (int)here->VSRCcoeffs[0]; // type of random function
|
||||||
TS = here->VSRCcoeffs[1]; // time step
|
TS = here->VSRCcoeffs[1]; // time step
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue