Added xspice extension (PHASE parameter and current variable) and AM transient function.
This commit is contained in:
parent
ac9edfbbc5
commit
e7369b7c03
|
|
@ -18,7 +18,8 @@ IFparm ISRCpTable[] = { /* parameters */
|
||||||
IP ( "sin", ISRC_SINE, IF_REALVEC,"Sinusoidal source description"),
|
IP ( "sin", ISRC_SINE, IF_REALVEC,"Sinusoidal source description"),
|
||||||
IP ( "exp", ISRC_EXP, IF_REALVEC,"Exponential source description"),
|
IP ( "exp", ISRC_EXP, IF_REALVEC,"Exponential source description"),
|
||||||
IP ( "pwl", ISRC_PWL, IF_REALVEC,"Piecewise linear description"),
|
IP ( "pwl", ISRC_PWL, IF_REALVEC,"Piecewise linear description"),
|
||||||
IP ( "sffm", ISRC_SFFM, IF_REALVEC,"single freq. FM description"),
|
IP ( "sffm", ISRC_SFFM, IF_REALVEC,"Single freq. FM description"),
|
||||||
|
IP ( "am", ISRC_AM, IF_REALVEC,"Amplitude modulation description"),
|
||||||
OPU ( "neg_node",ISRC_NEG_NODE, IF_INTEGER,"Negative node of source"),
|
OPU ( "neg_node",ISRC_NEG_NODE, IF_INTEGER,"Negative node of source"),
|
||||||
OPU ( "pos_node",ISRC_POS_NODE, IF_INTEGER,"Positive node of source"),
|
OPU ( "pos_node",ISRC_POS_NODE, IF_INTEGER,"Positive node of source"),
|
||||||
OPU ( "acreal", ISRC_AC_REAL, IF_REAL ,"AC real part"),
|
OPU ( "acreal", ISRC_AC_REAL, IF_REAL ,"AC real part"),
|
||||||
|
|
@ -30,6 +31,11 @@ IFparm ISRCpTable[] = { /* parameters */
|
||||||
OP ( "p", ISRC_POWER, IF_REAL, "Power supplied by the source"),
|
OP ( "p", ISRC_POWER, IF_REAL, "Power supplied by the source"),
|
||||||
IP ( "ac", ISRC_AC, IF_REALVEC,"AC magnitude,phase vector"),
|
IP ( "ac", ISRC_AC, IF_REALVEC,"AC magnitude,phase vector"),
|
||||||
IP ( "c", ISRC_DC, IF_REAL, "Current through current source"),
|
IP ( "c", ISRC_DC, IF_REAL, "Current through current source"),
|
||||||
|
/* gtri - begin - add parameter for current source value */
|
||||||
|
#ifdef XSPICE
|
||||||
|
OP ( "current", ISRC_CURRENT, IF_REAL, "Current in DC or Transient mode"),
|
||||||
|
#endif
|
||||||
|
/* gtri - end - add parameter for current source value */
|
||||||
IP ( "distof1", ISRC_D_F1, IF_REALVEC,"f1 input for distortion"),
|
IP ( "distof1", ISRC_D_F1, IF_REALVEC,"f1 input for distortion"),
|
||||||
IP ( "distof2", ISRC_D_F2, IF_REALVEC,"f2 input for distortion")
|
IP ( "distof2", ISRC_D_F2, IF_REALVEC,"f2 input for distortion")
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,14 @@ ISRCaccept(CKTcircuit *ckt, GENmodel *inModel)
|
||||||
#define TIMETOL 1e-7
|
#define TIMETOL 1e-7
|
||||||
|
|
||||||
double TD, TR, TF, PW, PER;
|
double TD, TR, TF, PW, PER;
|
||||||
|
|
||||||
|
/* gtri - begin - wbk - add PHASE parameter */
|
||||||
|
#ifdef XSPICE
|
||||||
|
double PHASE;
|
||||||
|
double phase;
|
||||||
|
double deltat;
|
||||||
|
double basephase;
|
||||||
|
#endif
|
||||||
double time;
|
double time;
|
||||||
double basetime = 0;
|
double basetime = 0;
|
||||||
|
|
||||||
|
|
@ -58,18 +66,37 @@ ISRCaccept(CKTcircuit *ckt, GENmodel *inModel)
|
||||||
PER = here->ISRCfunctionOrder > 6
|
PER = here->ISRCfunctionOrder > 6
|
||||||
&& here->ISRCcoeffs[6] != 0.0
|
&& here->ISRCcoeffs[6] != 0.0
|
||||||
? here->ISRCcoeffs[6] : ckt->CKTfinalTime;
|
? here->ISRCcoeffs[6] : ckt->CKTfinalTime;
|
||||||
|
#ifdef XSPICE
|
||||||
|
PHASE = here->ISRCfunctionOrder > 8
|
||||||
|
? here->ISRCcoeffs[7] : 0.0;
|
||||||
|
|
||||||
|
/* normalize phase to 0 - 2PI */
|
||||||
|
phase = PHASE * M_PI / 180.0;
|
||||||
|
basephase = 2 * M_PI * floor(phase / (2 * M_PI));
|
||||||
|
phase -= basephase;
|
||||||
|
|
||||||
|
/* compute equivalent delta time and add to time */
|
||||||
|
deltat = (phase / (2 * M_PI)) * PER;
|
||||||
|
time += deltat;
|
||||||
|
#endif
|
||||||
|
/* gtri - end - wbk - add PHASE parameter */
|
||||||
|
|
||||||
|
/* offset time by delay */
|
||||||
time = ckt->CKTtime - TD;
|
time = ckt->CKTtime - TD;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(time >= PER) {
|
if(time >= PER) {
|
||||||
/* repeating signal - figure out where we are */
|
/* repeating signal - figure out where we are */
|
||||||
/* in period */
|
/* in period */
|
||||||
basetime = PER * floor(time/PER);
|
basetime = PER * floor(time/PER);
|
||||||
time -= basetime;
|
time -= basetime;
|
||||||
}
|
}
|
||||||
if( time <= 0 || time >= TR + PW + TF) {
|
|
||||||
if(ckt->CKTbreak && SAMETIME(time,0)) {
|
if( time <= 0.0 || time >= TR + PW + TF) {
|
||||||
|
if(ckt->CKTbreak && SAMETIME(time,0.0)) {
|
||||||
/* set next breakpoint */
|
/* set next breakpoint */
|
||||||
error = CKTsetBreak(ckt,basetime + TR +TD);
|
error = CKTsetBreak(ckt,basetime + TR + TD);
|
||||||
if(error) return(error);
|
if(error) return(error);
|
||||||
} else if(ckt->CKTbreak && SAMETIME(TR+PW+TF,time) ) {
|
} else if(ckt->CKTbreak && SAMETIME(TR+PW+TF,time) ) {
|
||||||
/* set next breakpoint */
|
/* set next breakpoint */
|
||||||
|
|
@ -130,6 +157,10 @@ ISRCaccept(CKTcircuit *ckt, GENmodel *inModel)
|
||||||
/* no breakpoints (yet) */
|
/* no breakpoints (yet) */
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case AM:{
|
||||||
|
/* no breakpoints (yet) */
|
||||||
|
}
|
||||||
|
break;
|
||||||
case PWL: {
|
case PWL: {
|
||||||
int i;
|
int i;
|
||||||
if(ckt->CKTtime < *(here->ISRCcoeffs)) {
|
if(ckt->CKTtime < *(here->ISRCcoeffs)) {
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ ISRCask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *
|
||||||
case ISRC_EXP:
|
case ISRC_EXP:
|
||||||
case ISRC_PWL:
|
case ISRC_PWL:
|
||||||
case ISRC_SFFM:
|
case ISRC_SFFM:
|
||||||
|
case ISRC_AM:
|
||||||
case ISRC_FCN_COEFFS:
|
case ISRC_FCN_COEFFS:
|
||||||
temp = value->v.numValue = here->ISRCfunctionOrder;
|
temp = value->v.numValue = here->ISRCfunctionOrder;
|
||||||
value->v.vec.rVec = (double *)
|
value->v.vec.rVec = (double *)
|
||||||
|
|
@ -85,6 +86,13 @@ ISRCask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *
|
||||||
*(ckt->CKTrhsOld + here->ISRCnegNode));
|
*(ckt->CKTrhsOld + here->ISRCnegNode));
|
||||||
}
|
}
|
||||||
return(OK);
|
return(OK);
|
||||||
|
/* gtri - begin - add current value information */
|
||||||
|
#ifdef XSPICE
|
||||||
|
case ISRC_CURRENT:
|
||||||
|
value->rValue = here->ISRCcurrent;
|
||||||
|
return (OK);
|
||||||
|
#endif
|
||||||
|
/* gtri - end - add current value information */
|
||||||
default:
|
default:
|
||||||
return (E_BADPARM);
|
return (E_BADPARM);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,13 @@ typedef struct sISRCinstance {
|
||||||
double ISRCdF1phase; /* distortion f1 phase */
|
double ISRCdF1phase; /* distortion f1 phase */
|
||||||
double ISRCdF2phase; /* distortion f2 phase */
|
double ISRCdF2phase; /* distortion f2 phase */
|
||||||
|
|
||||||
|
/* gtri - begin - add member to hold current source value */
|
||||||
|
#ifdef XSPICE
|
||||||
|
/* needed for outputting results */
|
||||||
|
double ISRCcurrent; /* current value */
|
||||||
|
#endif
|
||||||
|
/* gtri - end - add member to hold current source value */
|
||||||
|
|
||||||
unsigned ISRCdcGiven :1 ; /* flag to indicate dc value given */
|
unsigned ISRCdcGiven :1 ; /* flag to indicate dc value given */
|
||||||
unsigned ISRCacGiven :1 ; /* flag to indicate ac keyword given */
|
unsigned ISRCacGiven :1 ; /* flag to indicate ac keyword given */
|
||||||
unsigned ISRCacMGiven :1 ; /* flag to indicate ac magnitude given */
|
unsigned ISRCacMGiven :1 ; /* flag to indicate ac magnitude given */
|
||||||
|
|
@ -74,6 +81,7 @@ typedef struct sISRCmodel { /* model structure for a resistor */
|
||||||
#define EXP 3
|
#define EXP 3
|
||||||
#define SFFM 4
|
#define SFFM 4
|
||||||
#define PWL 5
|
#define PWL 5
|
||||||
|
#define AM 6
|
||||||
#endif /*PULSE*/
|
#endif /*PULSE*/
|
||||||
|
|
||||||
/* device parameters */
|
/* device parameters */
|
||||||
|
|
@ -98,6 +106,14 @@ typedef struct sISRCmodel { /* model structure for a resistor */
|
||||||
#define ISRC_D_F2 19
|
#define ISRC_D_F2 19
|
||||||
#define ISRC_VOLTS 20
|
#define ISRC_VOLTS 20
|
||||||
|
|
||||||
|
#define ISRC_AM 21
|
||||||
|
/* gtri - begin - add define for current source value */
|
||||||
|
#ifdef XSPICE
|
||||||
|
/* needed for outputting results */
|
||||||
|
#define ISRC_CURRENT 22
|
||||||
|
#endif
|
||||||
|
/* gtri - end - add define for current source value */
|
||||||
|
|
||||||
/* model parameters */
|
/* model parameters */
|
||||||
|
|
||||||
/* device questions */
|
/* device questions */
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,10 @@ Modified: 2000 Alansfixes
|
||||||
#include "sperror.h"
|
#include "sperror.h"
|
||||||
#include "suffix.h"
|
#include "suffix.h"
|
||||||
|
|
||||||
|
#ifdef XSPICE_EXP
|
||||||
|
#include "cmproto.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
int
|
int
|
||||||
ISRCload(GENmodel *inModel, CKTcircuit *ckt)
|
ISRCload(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
/* actually load the current current value into the
|
/* actually load the current current value into the
|
||||||
|
|
@ -33,7 +37,12 @@ ISRCload(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
if( (ckt->CKTmode & (MODEDCOP | MODEDCTRANCURVE)) &&
|
if( (ckt->CKTmode & (MODEDCOP | MODEDCTRANCURVE)) &&
|
||||||
here->ISRCdcGiven ) {
|
here->ISRCdcGiven ) {
|
||||||
/* load using DC value */
|
/* load using DC value */
|
||||||
|
#ifdef XSPICE_EXP
|
||||||
|
/* gtri - begin - wbk - modify to process srcFact, etc. for all sources */
|
||||||
|
value = here->ISRCdcValue;
|
||||||
|
#else
|
||||||
value = here->ISRCdcValue * ckt->CKTsrcFact;
|
value = here->ISRCdcValue * ckt->CKTsrcFact;
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
if(ckt->CKTmode & (MODEDC)) {
|
if(ckt->CKTmode & (MODEDC)) {
|
||||||
time = 0;
|
time = 0;
|
||||||
|
|
@ -42,10 +51,30 @@ ISRCload(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
}
|
}
|
||||||
/* use transient function */
|
/* use transient function */
|
||||||
switch(here->ISRCfunctionType) {
|
switch(here->ISRCfunctionType) {
|
||||||
case PULSE: {
|
|
||||||
|
|
||||||
|
case PULSE: {
|
||||||
double V1, V2, TD, TR, TF, PW, PER;
|
double V1, V2, TD, TR, TF, PW, PER;
|
||||||
double basetime = 0;
|
double basetime = 0;
|
||||||
|
/* gtri - begin - wbk - add PHASE parameter */
|
||||||
|
#ifdef XSPICE
|
||||||
|
double PHASE;
|
||||||
|
double phase;
|
||||||
|
double deltat;
|
||||||
|
double basephase;
|
||||||
|
|
||||||
|
PHASE = here->ISRCfunctionOrder > 7
|
||||||
|
? here->ISRCcoeffs[7] : 0.0;
|
||||||
|
|
||||||
|
/* normalize phase to 0 - 2PI */
|
||||||
|
phase = PHASE * M_PI / 180.0;
|
||||||
|
basephase = 2 * M_PI * floor(phase / (2 * M_PI));
|
||||||
|
phase -= basephase;
|
||||||
|
|
||||||
|
/* compute equivalent delta time and add to time */
|
||||||
|
deltat = (phase / (2 * M_PI)) * PER;
|
||||||
|
time += deltat;
|
||||||
|
#endif
|
||||||
|
/* gtri - end - wbk - add PHASE parameter */
|
||||||
|
|
||||||
V1 = here->ISRCcoeffs[0];
|
V1 = here->ISRCcoeffs[0];
|
||||||
V2 = here->ISRCcoeffs[1];
|
V2 = here->ISRCcoeffs[1];
|
||||||
|
|
@ -85,77 +114,173 @@ ISRCload(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SINE: {
|
case SINE: {
|
||||||
#define VO (*(here->ISRCcoeffs))
|
|
||||||
#define VA (*(here->ISRCcoeffs+1))
|
double VO, VA, FREQ, TD, THETA;
|
||||||
#define FREQ (((here->ISRCfunctionOrder >=3) && (*(here->ISRCcoeffs+2)))? \
|
/* gtri - begin - wbk - add PHASE parameter */
|
||||||
(*(here->ISRCcoeffs+2)):(1/ckt->CKTfinalTime))
|
#ifdef XSPICE
|
||||||
#define TD ((here->ISRCfunctionOrder >=4)?(*(here->ISRCcoeffs+3)):(0.0))
|
double PHASE;
|
||||||
#define THETA ((here->ISRCfunctionOrder >=5)?(*(here->ISRCcoeffs+4)):(0.0))
|
double phase;
|
||||||
|
|
||||||
|
PHASE = here->ISRCfunctionOrder > 5
|
||||||
|
? here->ISRCcoeffs[5] : 0.0;
|
||||||
|
|
||||||
|
/* compute phase in radians */
|
||||||
|
phase = PHASE * M_PI / 180.0;
|
||||||
|
#endif
|
||||||
|
VO = here->ISRCcoeffs[0];
|
||||||
|
VA = here->ISRCcoeffs[1];
|
||||||
|
FREQ = here->ISRCfunctionOrder > 2
|
||||||
|
&& here->ISRCcoeffs[2] != 0.0
|
||||||
|
? here->ISRCcoeffs[2] : (1/ckt->CKTfinalTime);
|
||||||
|
TD = here->ISRCfunctionOrder > 3
|
||||||
|
? here->ISRCcoeffs[3] : 0.0;
|
||||||
|
THETA = here->ISRCfunctionOrder > 4
|
||||||
|
? here->ISRCcoeffs[4] : 0.0;
|
||||||
|
|
||||||
time -= TD;
|
time -= TD;
|
||||||
if (time <= 0) {
|
if (time <= 0) {
|
||||||
value = VO;
|
value = VO;
|
||||||
} else {
|
} else {
|
||||||
|
#ifdef XSPICE
|
||||||
|
value = VO + VA * sin(FREQ*time * 2.0 * M_PI + phase) *
|
||||||
|
exp(-time*THETA);
|
||||||
|
#else
|
||||||
value = VO + VA * sin(FREQ*time * 2.0 * M_PI) *
|
value = VO + VA * sin(FREQ*time * 2.0 * M_PI) *
|
||||||
exp(-time*THETA);
|
exp(-time*THETA);
|
||||||
|
#endif
|
||||||
|
/* gtri - end - wbk - add PHASE parameter */
|
||||||
}
|
}
|
||||||
#undef VO
|
|
||||||
#undef VA
|
|
||||||
#undef FREQ
|
|
||||||
#undef TD
|
|
||||||
#undef THETA
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EXP: {
|
case EXP: {
|
||||||
double td1;
|
double V1, V2, TD1, TD2, TAU1, TAU2;
|
||||||
double td2;
|
|
||||||
#define V1 (*(here->ISRCcoeffs))
|
V1 = here->ISRCcoeffs[0];
|
||||||
#define V2 (*(here->ISRCcoeffs+1))
|
V2 = here->ISRCcoeffs[1];
|
||||||
#define TD1 ((here->ISRCfunctionOrder >=3)?(*(here->ISRCcoeffs+2)):\
|
TD1 = here->ISRCfunctionOrder > 2
|
||||||
ckt->CKTstep)
|
&& here->ISRCcoeffs[2] != 0.0
|
||||||
#define TAU1 (((here->ISRCfunctionOrder >=4) && (*(here->ISRCcoeffs+3)))? \
|
? here->ISRCcoeffs[2] : ckt->CKTstep;
|
||||||
(*(here->ISRCcoeffs+3)):ckt->CKTstep)
|
TAU1 = here->ISRCfunctionOrder > 3
|
||||||
#define TD2 (((here->ISRCfunctionOrder >=5) && (*(here->ISRCcoeffs+4)))? \
|
&& here->ISRCcoeffs[3] != 0.0
|
||||||
(*(here->ISRCcoeffs+4)):TD1+ckt->CKTstep)
|
? here->ISRCcoeffs[3] : ckt->CKTstep;
|
||||||
#define TAU2 (((here->ISRCfunctionOrder >=6) && (*(here->ISRCcoeffs+5)))? \
|
TD2 = here->ISRCfunctionOrder > 4
|
||||||
(*(here->ISRCcoeffs+5)):ckt->CKTstep)
|
&& here->ISRCcoeffs[4] != 0.0
|
||||||
td1 = TD1;
|
? here->ISRCcoeffs[4] : TD1 + ckt->CKTstep;
|
||||||
td2 = TD2;
|
TAU2 = here->ISRCfunctionOrder > 5
|
||||||
if(time <= td1) {
|
&& here->ISRCcoeffs[5]
|
||||||
|
? here->ISRCcoeffs[5] : ckt->CKTstep;
|
||||||
|
|
||||||
|
if(time <= TD1) {
|
||||||
value = V1;
|
value = V1;
|
||||||
} else if (time <= td2) {
|
} else if (time <= TD2) {
|
||||||
value = V1 + (V2-V1)*(1-exp(-(time-td1)/TAU1));
|
value = V1 + (V2-V1)*(1-exp(-(time-TD1)/TAU1));
|
||||||
} else {
|
} else {
|
||||||
value = V1 + (V2-V1)*(1-exp(-(time-td1)/TAU1)) +
|
value = V1 + (V2-V1)*(1-exp(-(time-TD1)/TAU1)) +
|
||||||
(V1-V2)*(1-exp(-(time-td2)/TAU2)) ;
|
(V1-V2)*(1-exp(-(time-TD2)/TAU2)) ;
|
||||||
}
|
}
|
||||||
#undef V1
|
|
||||||
#undef V2
|
|
||||||
#undef TD1
|
|
||||||
#undef TAU1
|
|
||||||
#undef TD2
|
|
||||||
#undef TAU2
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SFFM:{
|
case SFFM:{
|
||||||
#define VO (*(here->ISRCcoeffs))
|
|
||||||
#define VA (*(here->ISRCcoeffs+1))
|
double VO, VA, FC, MDI, FS;
|
||||||
#define FC (((here->ISRCfunctionOrder >=3) && (*(here->ISRCcoeffs+2)))? \
|
/* gtri - begin - wbk - add PHASE parameters */
|
||||||
(*(here->ISRCcoeffs+2)):(1/ckt->CKTfinalTime))
|
#ifdef XSPICE
|
||||||
#define MDI ((here->ISRCfunctionOrder>=4)?(*(here->ISRCcoeffs+3)):0.0)
|
|
||||||
#define FS (((here->ISRCfunctionOrder >=5) && (*(here->ISRCcoeffs+4)))? \
|
double PHASEC, PHASES;
|
||||||
(*(here->ISRCcoeffs+4)):(1/ckt->CKTfinalTime))
|
double phasec;
|
||||||
|
double phases;
|
||||||
|
|
||||||
|
PHASEC = here->ISRCfunctionOrder > 5
|
||||||
|
? here->ISRCcoeffs[5] : 0.0;
|
||||||
|
PHASES = here->ISRCfunctionOrder > 6
|
||||||
|
? here->ISRCcoeffs[6] : 0.0;
|
||||||
|
|
||||||
|
/* compute phases in radians */
|
||||||
|
phasec = PHASEC * M_PI / 180.0;
|
||||||
|
phases = PHASES * M_PI / 180.0;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
VO = here->ISRCcoeffs[0];
|
||||||
|
VA = here->ISRCcoeffs[1];
|
||||||
|
FC = here->ISRCfunctionOrder > 2
|
||||||
|
&& here->ISRCcoeffs[2]
|
||||||
|
? here->ISRCcoeffs[2] : (1/ckt->CKTfinalTime);
|
||||||
|
MDI = here->ISRCfunctionOrder > 3
|
||||||
|
? here->ISRCcoeffs[3] : 0.0;
|
||||||
|
FS = here->ISRCfunctionOrder > 4
|
||||||
|
&& here->ISRCcoeffs[4]
|
||||||
|
? here->ISRCcoeffs[4] : (1/ckt->CKTfinalTime);
|
||||||
|
|
||||||
|
#ifdef XSPICE
|
||||||
|
/* compute waveform value */
|
||||||
|
value = VO + VA *
|
||||||
|
sin((2.0 * M_PI * FC * time + phasec) +
|
||||||
|
MDI * sin(2.0 * M_PI * FS * time + phases));
|
||||||
|
#else /* XSPICE */
|
||||||
value = VO + VA *
|
value = VO + VA *
|
||||||
sin((2.0 * M_PI * FC * time) +
|
sin((2.0 * M_PI * FC * time) +
|
||||||
MDI * sin(2.0 * M_PI * FS * time));
|
MDI * sin(2.0 * M_PI * FS * time));
|
||||||
#undef VO
|
#endif /* XSPICE */
|
||||||
#undef VA
|
/* gtri - end - wbk - add PHASE parameters */
|
||||||
#undef FC
|
|
||||||
#undef MDI
|
|
||||||
#undef FS
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case AM:{
|
||||||
|
|
||||||
|
double VA, FC, MF, VO, TD;
|
||||||
|
/* gtri - begin - wbk - add PHASE parameters */
|
||||||
|
#ifdef XSPICE
|
||||||
|
|
||||||
|
double PHASEC, PHASES;
|
||||||
|
double phasec;
|
||||||
|
double phases;
|
||||||
|
|
||||||
|
PHASEC = here->ISRCfunctionOrder > 5
|
||||||
|
? here->ISRCcoeffs[5] : 0.0;
|
||||||
|
PHASES = here->ISRCfunctionOrder > 6
|
||||||
|
? here->ISRCcoeffs[6] : 0.0;
|
||||||
|
|
||||||
|
/* compute phases in radians */
|
||||||
|
phasec = PHASEC * M_PI / 180.0;
|
||||||
|
phases = PHASES * M_PI / 180.0;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
VA = here->ISRCcoeffs[0];
|
||||||
|
VO = here->ISRCcoeffs[1];
|
||||||
|
MF = here->ISRCfunctionOrder > 2
|
||||||
|
&& here->ISRCcoeffs[2]
|
||||||
|
? here->ISRCcoeffs[2] : (1/ckt->CKTfinalTime);
|
||||||
|
FC = here->ISRCfunctionOrder > 3
|
||||||
|
? here->ISRCcoeffs[3] : 0.0;
|
||||||
|
TD = here->ISRCfunctionOrder > 4
|
||||||
|
&& here->ISRCcoeffs[4]
|
||||||
|
? here->ISRCcoeffs[4] : 0,0;
|
||||||
|
|
||||||
|
time -= TD;
|
||||||
|
if (time <= 0) {
|
||||||
|
value = 0;
|
||||||
|
} else {
|
||||||
|
#ifdef XSPICE
|
||||||
|
/* compute waveform value */
|
||||||
|
value = VA * (VO + sin(2.0 * M_PI * MF * time + phases )) *
|
||||||
|
sin(2 * M_PI * FC * time + phases);
|
||||||
|
|
||||||
|
#else /* XSPICE */
|
||||||
|
value = VA * (VO + sin(2.0 * M_PI * MF * time)) *
|
||||||
|
sin(2 * M_PI * FC * time);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* gtri - end - wbk - add PHASE parameters */
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
|
#ifdef XSPICE_EXP
|
||||||
|
value = here->ISRCdcValue;
|
||||||
|
#else
|
||||||
value = here->ISRCdcValue * ckt->CKTsrcFact;
|
value = here->ISRCdcValue * ckt->CKTsrcFact;
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case PWL: {
|
case PWL: {
|
||||||
int i;
|
int i;
|
||||||
|
|
@ -185,9 +310,28 @@ ISRCload(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loadDone:
|
loadDone:
|
||||||
|
|
||||||
|
/* gtri - begin - wbk - modify for supply ramping option */
|
||||||
|
#ifdef XSPICE_EXP
|
||||||
|
value *= ckt->CKTsrcFact;
|
||||||
|
value *= cm_analog_ramp_factor();
|
||||||
|
|
||||||
|
#else
|
||||||
if (ckt->CKTmode & MODETRANOP) value *= ckt->CKTsrcFact;
|
if (ckt->CKTmode & MODETRANOP) value *= ckt->CKTsrcFact;
|
||||||
|
#endif
|
||||||
|
/* gtri - end - wbk - modify for supply ramping option */
|
||||||
|
|
||||||
*(ckt->CKTrhs + (here->ISRCposNode)) += value;
|
*(ckt->CKTrhs + (here->ISRCposNode)) += value;
|
||||||
*(ckt->CKTrhs + (here->ISRCnegNode)) -= value;
|
*(ckt->CKTrhs + (here->ISRCnegNode)) -= value;
|
||||||
|
|
||||||
|
/* gtri - end - wbk - modify to process srcFact, etc. for all sources */
|
||||||
|
|
||||||
|
#ifdef XSPICE
|
||||||
|
/* gtri - begin - wbk - record value so it can be output if requested */
|
||||||
|
here->ISRCcurrent = value;
|
||||||
|
/* gtri - end - wbk - record value so it can be output if requested */
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(OK);
|
return(OK);
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,14 @@ int i;
|
||||||
here->ISRCfunctionOrder = value->v.numValue;
|
here->ISRCfunctionOrder = value->v.numValue;
|
||||||
here->ISRCcoeffsGiven = TRUE;
|
here->ISRCcoeffsGiven = TRUE;
|
||||||
break;
|
break;
|
||||||
|
case ISRC_AM:
|
||||||
|
if(value->v.numValue <2) return(E_BADPARM);
|
||||||
|
here->ISRCfunctionType = AM;
|
||||||
|
here->ISRCfuncTGiven = TRUE;
|
||||||
|
here->ISRCcoeffs = value->v.vec.rVec;
|
||||||
|
here->ISRCfunctionOrder = value->v.numValue;
|
||||||
|
here->ISRCcoeffsGiven = TRUE;
|
||||||
|
break;
|
||||||
case ISRC_D_F1:
|
case ISRC_D_F1:
|
||||||
here->ISRCdF1given = TRUE;
|
here->ISRCdF1given = TRUE;
|
||||||
here->ISRCdGiven = TRUE;
|
here->ISRCdGiven = TRUE;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue