Browse Source

vsrc, isrc, whitespace cleanup

pre-master-46
rlar 15 years ago
parent
commit
49211d2153
  1. 5
      ChangeLog
  2. 131
      src/spicelib/devices/isrc/isrcacct.c
  3. 15
      src/spicelib/devices/isrc/isrcacld.c
  4. 12
      src/spicelib/devices/isrc/isrcask.c
  5. 38
      src/spicelib/devices/isrc/isrcdefs.h
  6. 4
      src/spicelib/devices/isrc/isrcdel.c
  7. 144
      src/spicelib/devices/isrc/isrcload.c
  8. 4
      src/spicelib/devices/isrc/isrcmdel.c
  9. 104
      src/spicelib/devices/isrc/isrcpar.c
  10. 10
      src/spicelib/devices/isrc/isrctemp.c
  11. 67
      src/spicelib/devices/vsrc/vsrcacct.c
  12. 5
      src/spicelib/devices/vsrc/vsrcacld.c
  13. 12
      src/spicelib/devices/vsrc/vsrcask.c
  14. 40
      src/spicelib/devices/vsrc/vsrcdefs.h
  15. 4
      src/spicelib/devices/vsrc/vsrcdel.c
  16. 2
      src/spicelib/devices/vsrc/vsrcext.h
  17. 137
      src/spicelib/devices/vsrc/vsrcload.c
  18. 6
      src/spicelib/devices/vsrc/vsrcmdel.c
  19. 87
      src/spicelib/devices/vsrc/vsrcpar.c
  20. 12
      src/spicelib/devices/vsrc/vsrctemp.c

5
ChangeLog

@ -1,3 +1,8 @@
2011-02-27 Robert Larice
* src/spicelib/devices/isrc/* ,
* src/spicelib/devices/vsrc/* :
vsrc, isrc, whitespace cleanup
2011-02-27 Robert Larice
* src/spicelib/devices/isrc/* ,
* src/spicelib/devices/vsrc/* :

131
src/spicelib/devices/isrc/isrcacct.c

@ -24,7 +24,7 @@ int
ISRCaccept(CKTcircuit *ckt, GENmodel *inModel)
/* set up the breakpoint table. */
{
ISRCmodel *model = (ISRCmodel*)inModel;
ISRCmodel *model = (ISRCmodel *) inModel;
ISRCinstance *here;
int error;
@ -34,48 +34,49 @@ ISRCaccept(CKTcircuit *ckt, GENmodel *inModel)
/* loop through all the instances of the model */
for (here = model->ISRCinstances; here != NULL ;
here=here->ISRCnextInstance) {
if(!(ckt->CKTmode & (MODETRAN | MODETRANOP))) {
/* not transient, so shouldn't be here */
return(OK);
} else {
/* use the transient functions */
switch(here->ISRCfunctionType) {
default: { /* no function specified:DC no breakpoints */
break;
}
case PULSE: {
double TD, TR, TF, PW, PER;
/* gtri - begin - wbk - add PHASE parameter */
#ifdef XSPICE
double PHASE;
#ifdef XSPICE
double PHASE;
double phase;
double deltat;
double basephase;
#endif
#endif
double time;
double basetime = 0;
TD = here->ISRCfunctionOrder > 2
? here->ISRCcoeffs[2] : 0.0;
? here->ISRCcoeffs[2] : 0.0;
TR = here->ISRCfunctionOrder > 3
&& here->ISRCcoeffs[3] != 0.0
? here->ISRCcoeffs[3] : ckt->CKTstep;
&& here->ISRCcoeffs[3] != 0.0
? here->ISRCcoeffs[3] : ckt->CKTstep;
TF = here->ISRCfunctionOrder > 4
&& here->ISRCcoeffs[4] != 0.0
? here->ISRCcoeffs[4] : ckt->CKTstep;
&& here->ISRCcoeffs[4] != 0.0
? here->ISRCcoeffs[4] : ckt->CKTstep;
PW = here->ISRCfunctionOrder > 5
&& here->ISRCcoeffs[5] != 0.0
? here->ISRCcoeffs[5] : ckt->CKTfinalTime;
&& here->ISRCcoeffs[5] != 0.0
? here->ISRCcoeffs[5] : ckt->CKTfinalTime;
PER = here->ISRCfunctionOrder > 6
&& here->ISRCcoeffs[6] != 0.0
? here->ISRCcoeffs[6] : ckt->CKTfinalTime;
&& here->ISRCcoeffs[6] != 0.0
? here->ISRCcoeffs[6] : ckt->CKTfinalTime;
#ifdef XSPICE
PHASE = here->ISRCfunctionOrder > 8
? here->ISRCcoeffs[7] : 0.0;
PHASE = here->ISRCfunctionOrder > 8
? here->ISRCcoeffs[7] : 0.0;
#endif
/* offset time by delay and limit to zero */
time = ckt->CKTtime - TD;
@ -85,18 +86,18 @@ ISRCaccept(CKTcircuit *ckt, GENmodel *inModel)
time = 0.0;
#endif
#ifdef XSPICE
/* normalize phase to 0 - 2PI */
#ifdef XSPICE
/* 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
time += deltat;
#endif
/* gtri - end - wbk - add PHASE parameter */
if(time >= PER) {
/* repeating signal - figure out where we are */
/* in period */
@ -147,21 +148,25 @@ ISRCaccept(CKTcircuit *ckt, GENmodel *inModel)
break;
case SINE: {
/* no breakpoints (yet) */
/* no breakpoints (yet) */
}
break;
case EXP: {
/* no breakpoints (yet) */
/* no breakpoints (yet) */
}
break;
case SFFM:{
/* no breakpoints (yet) */
/* no breakpoints (yet) */
}
break;
case AM:{
/* no breakpoints (yet) */
/* no breakpoints (yet) */
}
break;
case PWL: {
int i;
if(ckt->CKTtime < *(here->ISRCcoeffs)) {
@ -178,17 +183,17 @@ ISRCaccept(CKTcircuit *ckt, GENmodel *inModel)
if(error) return(error);
}
goto bkptset;
}
}
}
break;
}
/**** tansient noise routines:
INoi2 2 0 DC 0 TRNOISE(10n 0.5n 0 0n) : generate gaussian distributed noise
rms value, time step, 0 0
INoi1 1 0 DC 0 TRNOISE(0n 0.5n 1 10n) : generate 1/f noise
0, time step, exponent < 2, rms value
*/
/**** tansient noise routines:
INoi2 2 0 DC 0 TRNOISE(10n 0.5n 0 0n) : generate gaussian distributed noise
rms value, time step, 0 0
INoi1 1 0 DC 0 TRNOISE(0n 0.5n 1 10n) : generate 1/f noise
0, time step, exponent < 2, rms value
*/
case TRNOISE: {
struct trnoise_state *state = here -> ISRCtrnoise_state;
@ -221,45 +226,40 @@ INoi1 1 0 DC 0 TRNOISE(0n 0.5n 1 10n) : generate 1/f noise
}
}
if (RTSAM > 0) {
double RTScapTime = state->RTScapTime;
double RTSemTime = state->RTSemTime;
double RTSCAPT = state->RTSCAPT;
double RTSEMT = state->RTSEMT;
if (RTSAM > 0) {
double RTScapTime = state->RTScapTime;
double RTSemTime = state->RTSemTime;
double RTSCAPT = state->RTSCAPT;
double RTSEMT = state->RTSEMT;
if (ckt->CKTtime == 0) {
if (ckt->CKTbreak) {
error = CKTsetBreak(ckt, RTScapTime);
if(error)
return(error);
if (ckt->CKTtime == 0) {
if (ckt->CKTbreak) {
error = CKTsetBreak(ckt, RTScapTime);
if(error)
return(error);
}
}
}
if(AlmostEqualUlps(RTScapTime, ckt->CKTtime, 3)) {
if (ckt->CKTbreak) {
error = CKTsetBreak(ckt, RTSemTime);
if(error)
return(error);
}
}
if(AlmostEqualUlps(RTSemTime, ckt->CKTtime, 3)) {
/* new values */
RTScapTime = here -> ISRCtrnoise_state ->RTScapTime = ckt->CKTtime + exprand(RTSCAPT);
here -> ISRCtrnoise_state ->RTSemTime = RTScapTime + exprand(RTSEMT);
if (ckt->CKTbreak) {
error = CKTsetBreak(ckt, RTScapTime);
if(error)
return(error);
if(AlmostEqualUlps(RTScapTime, ckt->CKTtime, 3)) {
if (ckt->CKTbreak) {
error = CKTsetBreak(ckt, RTSemTime);
if(error)
return(error);
}
}
if(AlmostEqualUlps(RTSemTime, ckt->CKTtime, 3)) {
/* new values */
RTScapTime = here -> ISRCtrnoise_state ->RTScapTime = ckt->CKTtime + exprand(RTSCAPT);
here -> ISRCtrnoise_state ->RTSemTime = RTScapTime + exprand(RTSEMT);
if (ckt->CKTbreak) {
error = CKTsetBreak(ckt, RTScapTime);
if(error)
return(error);
}
}
}
}
}
break;
@ -268,5 +268,6 @@ INoi1 1 0 DC 0 TRNOISE(0n 0.5n 1 10n) : generate 1/f noise
bkptset: ;
} // for
} // for
return(OK);
}

15
src/spicelib/devices/isrc/isrcacld.c

@ -9,10 +9,11 @@ Author: 1985 Thomas L. Quarles
#include "sperror.h"
#include "suffix.h"
int
ISRCacLoad(GENmodel *inModel, CKTcircuit *ckt)
{
ISRCmodel *model = (ISRCmodel*)inModel;
ISRCmodel *model = (ISRCmodel *) inModel;
ISRCinstance *here;
for( ; model != NULL; model = model->ISRCnextModel ) {
@ -20,18 +21,18 @@ ISRCacLoad(GENmodel *inModel, CKTcircuit *ckt)
/* loop through all the instances of the model */
for (here = model->ISRCinstances; here != NULL ;
here=here->ISRCnextInstance) {
if (here->ISRCowner != ARCHme) continue;
if (here->ISRCowner != ARCHme) continue;
*(ckt->CKTrhs + (here->ISRCposNode)) +=
*(ckt->CKTrhs + (here->ISRCposNode)) +=
here->ISRCacReal;
*(ckt->CKTrhs + (here->ISRCnegNode)) -=
*(ckt->CKTrhs + (here->ISRCnegNode)) -=
here->ISRCacReal;
*(ckt->CKTirhs + (here->ISRCposNode)) +=
*(ckt->CKTirhs + (here->ISRCposNode)) +=
here->ISRCacImag;
*(ckt->CKTirhs + (here->ISRCnegNode)) -=
*(ckt->CKTirhs + (here->ISRCnegNode)) -=
here->ISRCacImag;
}
}
return(OK);
return(OK);
}

12
src/spicelib/devices/isrc/isrcask.c

@ -45,12 +45,12 @@ ISRCask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *
case ISRC_EXP:
case ISRC_PWL:
case ISRC_SFFM:
case ISRC_AM:
case ISRC_AM:
case ISRC_TRNOISE:
case ISRC_FCN_COEFFS:
temp = value->v.numValue = here->ISRCfunctionOrder;
v = value->v.vec.rVec = TMALLOC(double, here->ISRCfunctionOrder);
w = here->ISRCcoeffs;
w = here->ISRCcoeffs;
while (temp--)
*v++ = *w++;
return (OK);
@ -73,8 +73,8 @@ ISRCask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *
value->rValue = here->ISRCfunctionOrder;
return (OK);
case ISRC_VOLTS:
value->rValue = (*(ckt->CKTrhsOld + here->ISRCposNode) -
*(ckt->CKTrhsOld + here->ISRCnegNode));
value->rValue = (*(ckt->CKTrhsOld + here->ISRCposNode) -
*(ckt->CKTrhsOld + here->ISRCnegNode));
return(OK);
case ISRC_POWER:
if (ckt->CKTcurrentAnalysis & DOING_AC) {
@ -83,7 +83,7 @@ ISRCask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *
strcpy(errMsg,msg);
return(E_ASKPOWER);
} else {
value->rValue = -here->ISRCdcValue *
value->rValue = -here->ISRCdcValue *
(*(ckt->CKTrhsOld + here->ISRCposNode) -
*(ckt->CKTrhsOld + here->ISRCnegNode));
}
@ -93,7 +93,7 @@ ISRCask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *
case ISRC_CURRENT:
value->rValue = here->ISRCcurrent;
return (OK);
#endif
#endif
/* gtri - end - add current value information */
default:
return (E_BADPARM);

38
src/spicelib/devices/isrc/isrcdefs.h

@ -20,11 +20,11 @@ Author: 1985 Thomas L. Quarles
typedef struct sISRCinstance {
struct sISRCmodel *ISRCmodPtr; /* backpointer to model */
struct sISRCinstance *ISRCnextInstance; /* pointer to next instance of
*current model*/
struct sISRCinstance *ISRCnextInstance; /* pointer to next instance of
*current model */
IFuid ISRCname; /* pointer to character string naming this instance */
int ISRCowner; /* number of owner process */
int ISRCstate; /* not used */
int ISRCstate; /* not used */
int ISRCposNode; /* number of positive node of source */
int ISRCnegNode; /* number of negative node of source */
@ -34,8 +34,10 @@ typedef struct sISRCinstance {
double *ISRCcoeffs; /* pointer to array of coefficients */
double ISRCdcValue; /* DC and TRANSIENT value of source */
double ISRCacPhase; /* AC phase angle */
double ISRCacMag; /* AC magnitude */
double ISRCacReal; /* AC real component */
double ISRCacImag; /* AC imaginary component */
@ -46,22 +48,22 @@ typedef struct sISRCinstance {
struct trnoise_state *ISRCtrnoise_state; /* transient noise */
/* gtri - begin - add member to hold current source value */
/* 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 ISRCacGiven :1 ; /* flag to indicate ac keyword given */
unsigned ISRCacMGiven :1 ; /* flag to indicate ac magnitude given */
unsigned ISRCacPGiven :1 ; /* flag to indicate ac phase given */
unsigned ISRCfuncTGiven :1 ; /* flag to indicate function type given */
unsigned ISRCcoeffsGiven :1 ; /* flag to indicate function coeffs given */
unsigned ISRCdGiven :1 ; /* flag to indicate source is a distortion input */
unsigned ISRCdF1given :1; /* flag to indicate source is an f1 distortion input */
unsigned ISRCdF2given :1; /* flag to indicate source is an f2 distortion input */
/* gtri - end - add member to hold current source value */
unsigned ISRCdcGiven :1 ; /* flag to indicate dc value given */
unsigned ISRCacGiven :1 ; /* flag to indicate ac keyword given */
unsigned ISRCacMGiven :1 ; /* flag to indicate ac magnitude given */
unsigned ISRCacPGiven :1 ; /* flag to indicate ac phase given */
unsigned ISRCfuncTGiven :1 ; /* flag to indicate function type given */
unsigned ISRCcoeffsGiven :1 ; /* flag to indicate function coeffs given */
unsigned ISRCdGiven :1 ; /* flag to indicate source is a distortion input */
unsigned ISRCdF1given :1 ; /* flag to indicate source is an f1 distortion input */
unsigned ISRCdF2given :1 ; /* flag to indicate source is an f2 distortion input */
} ISRCinstance ;
@ -69,10 +71,10 @@ typedef struct sISRCinstance {
typedef struct sISRCmodel {
int ISRCmodType; /* type index of this device type */
struct sISRCmodel *ISRCnextModel; /* pointer to next possible model
struct sISRCmodel *ISRCnextModel; /* pointer to next possible model
*in linked list */
ISRCinstance * ISRCinstances; /* pointer to list of instances
* that have this model */
ISRCinstance * ISRCinstances; /* pointer to list of instances
* that have this model */
IFuid ISRCmodName; /* pointer to character string naming this model */
} ISRCmodel;

4
src/spicelib/devices/isrc/isrcdel.c

@ -14,8 +14,8 @@ Author: 1985 Thomas L. Quarles
int
ISRCdelete(GENmodel *inModel, IFuid name, GENinstance **inst)
{
ISRCmodel *model = (ISRCmodel*)inModel;
ISRCinstance **fast = (ISRCinstance**)inst;
ISRCmodel *model = (ISRCmodel *) inModel;
ISRCinstance **fast = (ISRCinstance **) inst;
ISRCinstance **prev = NULL;
ISRCinstance *here;

144
src/spicelib/devices/isrc/isrcload.c

@ -25,7 +25,7 @@ ISRCload(GENmodel *inModel, CKTcircuit *ckt)
* sparse matrix previously provided
*/
{
ISRCmodel *model = (ISRCmodel*)inModel;
ISRCmodel *model = (ISRCmodel *) inModel;
ISRCinstance *here;
double value;
double time;
@ -37,7 +37,7 @@ ISRCload(GENmodel *inModel, CKTcircuit *ckt)
for (here = model->ISRCinstances; here != NULL ;
here=here->ISRCnextInstance) {
if (here->ISRCowner != ARCHme) continue;
if( (ckt->CKTmode & (MODEDCOP | MODEDCTRANCURVE)) &&
here->ISRCdcGiven ) {
/* load using DC value */
@ -63,8 +63,9 @@ ISRCload(GENmodel *inModel, CKTcircuit *ckt)
value = here->ISRCdcValue * ckt->CKTsrcFact;
#endif
break;
case PULSE: {
double V1, V2, TD, TR, TF, PW, PER;
double V1, V2, TD, TR, TF, PW, PER;
double basetime = 0;
#ifdef XSPICE
double PHASE;
@ -89,31 +90,31 @@ ISRCload(GENmodel *inModel, CKTcircuit *ckt)
&& here->ISRCcoeffs[6] != 0.0
? here->ISRCcoeffs[6] : ckt->CKTfinalTime;
#ifdef XSPICE
/* gtri - begin - wbk - add PHASE parameter */
/* gtri - begin - wbk - add PHASE parameter */
PHASE = here->ISRCfunctionOrder > 7
? here->ISRCcoeffs[7] : 0.0;
/* normalize phase to 0 - 2PI */
/* 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;
/* gtri - end - wbk - add PHASE parameter */
/* gtri - end - wbk - add PHASE parameter */
#endif
time -= TD;
if(time > PER) {
/* repeating signal - figure out where we are */
/* in period */
basetime = PER * floor(time/PER);
time -= basetime;
}
if( time <= 0 || time >= TR + PW + TF) {
if (time <= 0 || time >= TR + PW + TF) {
value = V1;
} else if ( time >= TR && time <= TR + PW) {
} else if (time >= TR && time <= TR + PW) {
value = V2;
} else if (time > 0 && time < TR) {
value = V1 + (V2 - V1) * (time) / TR;
@ -124,7 +125,7 @@ ISRCload(GENmodel *inModel, CKTcircuit *ckt)
break;
case SINE: {
double VO, VA, FREQ, TD, THETA;
/* gtri - begin - wbk - add PHASE parameter */
#ifdef XSPICE
@ -133,13 +134,13 @@ ISRCload(GENmodel *inModel, CKTcircuit *ckt)
PHASE = here->ISRCfunctionOrder > 5
? here->ISRCcoeffs[5] : 0.0;
/* compute phase in radians */
/* compute phase in radians */
phase = PHASE * M_PI / 180.0;
#endif
VO = here->ISRCcoeffs[0];
VA = here->ISRCcoeffs[1];
FREQ = here->ISRCfunctionOrder > 2
FREQ = here->ISRCfunctionOrder > 2
&& here->ISRCcoeffs[2] != 0.0
? here->ISRCcoeffs[2] : (1/ckt->CKTfinalTime);
TD = here->ISRCfunctionOrder > 3
@ -152,123 +153,120 @@ ISRCload(GENmodel *inModel, CKTcircuit *ckt)
#ifdef XSPICE
value = VO + VA * sin(phase);
} else {
value = VO + VA * sin(FREQ*time * 2.0 * M_PI + phase) *
exp(-time*THETA);
value = VO + VA * sin(FREQ*time * 2.0 * M_PI + phase) *
exp(-time*THETA);
#else
value = VO;
} else {
value = VO + VA * sin(FREQ*time * 2.0 * M_PI) *
exp(-time*THETA);
value = VO + VA * sin(FREQ * time * 2.0 * M_PI) *
exp(-time*THETA);
#endif
/* gtri - end - wbk - add PHASE parameter */
/* gtri - end - wbk - add PHASE parameter */
}
}
break;
case EXP: {
double V1, V2, TD1, TD2, TAU1, TAU2;
V1 = here->ISRCcoeffs[0];
V2 = here->ISRCcoeffs[1];
TD1 = here->ISRCfunctionOrder > 2
TD1 = here->ISRCfunctionOrder > 2
&& here->ISRCcoeffs[2] != 0.0
? here->ISRCcoeffs[2] : ckt->CKTstep;
TAU1 = here->ISRCfunctionOrder > 3
TAU1 = here->ISRCfunctionOrder > 3
&& here->ISRCcoeffs[3] != 0.0
? here->ISRCcoeffs[3] : ckt->CKTstep;
TD2 = here->ISRCfunctionOrder > 4
TD2 = here->ISRCfunctionOrder > 4
&& here->ISRCcoeffs[4] != 0.0
? here->ISRCcoeffs[4] : TD1 + ckt->CKTstep;
TAU2 = here->ISRCfunctionOrder > 5
TAU2 = here->ISRCfunctionOrder > 5
&& here->ISRCcoeffs[5]
? here->ISRCcoeffs[5] : ckt->CKTstep;
if(time <= TD1) {
value = V1;
} else if (time <= TD2) {
value = V1 + (V2-V1)*(1-exp(-(time-TD1)/TAU1));
} else {
value = V1 + (V2-V1)*(1-exp(-(time-TD1)/TAU1)) +
(V1-V2)*(1-exp(-(time-TD2)/TAU2)) ;
(V1-V2)*(1-exp(-(time-TD2)/TAU2)) ;
}
}
break;
case SFFM:{
case SFFM: {
double VO, VA, FC, MDI, FS;
/* gtri - begin - wbk - add PHASE parameters */
#ifdef XSPICE
double PHASEC, PHASES;
double phasec;
double phases;
PHASEC = here->ISRCfunctionOrder > 5
? here->ISRCcoeffs[5] : 0.0;
? here->ISRCcoeffs[5] : 0.0;
PHASES = here->ISRCfunctionOrder > 6
? here->ISRCcoeffs[6] : 0.0;
? here->ISRCcoeffs[6] : 0.0;
/* compute phases in radians */
phasec = PHASEC * M_PI / 180.0;
phases = PHASES * M_PI / 180.0;
phases = PHASES * M_PI / 180.0;
#endif
#endif
VO = here->ISRCcoeffs[0];
VA = here->ISRCcoeffs[1];
FC = here->ISRCfunctionOrder > 2
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
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));
/* compute waveform value */
value = VO + VA *
sin((2.0 * M_PI * FC * time + phasec) +
MDI * sin(2.0 * M_PI * FS * time + phases));
#else
value = VO + VA *
sin((2.0 * M_PI * FC * time) +
MDI * sin(2.0 * M_PI * FS * time));
value = VO + VA *
sin((2.0 * M_PI * FC * time) +
MDI * sin(2.0 * M_PI * FS * time));
#endif
/* gtri - end - wbk - add PHASE parameters */
}
break;
case AM:{
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;
? here->ISRCcoeffs[5] : 0.0;
PHASES = here->ISRCfunctionOrder > 6
? here->ISRCcoeffs[6] : 0.0;
? here->ISRCcoeffs[6] : 0.0;
/* compute phases in radians */
phasec = PHASEC * M_PI / 180.0;
phases = PHASES * M_PI / 180.0;
phases = PHASES * M_PI / 180.0;
#endif
#endif
VA = here->ISRCcoeffs[0];
VO = here->ISRCcoeffs[1];
MF = here->ISRCfunctionOrder > 2
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
TD = here->ISRCfunctionOrder > 4
&& here->ISRCcoeffs[4]
? here->ISRCcoeffs[4] : 0.0;
@ -277,23 +275,23 @@ ISRCload(GENmodel *inModel, CKTcircuit *ckt)
value = 0;
} else {
#ifdef XSPICE
/* compute waveform value */
value = VA * (VO + sin(2.0 * M_PI * MF * time + phases )) *
sin(2.0 * M_PI * FC * time + phases);
/* compute waveform value */
value = VA * (VO + sin(2.0 * M_PI * MF * time + phases )) *
sin(2.0 * M_PI * FC * time + phases);
#else
value = VA * (VO + sin(2.0 * M_PI * MF * time)) *
sin(2.0 * M_PI * FC * time);
#endif
value = VA * (VO + sin(2.0 * M_PI * MF * time)) *
sin(2.0 * M_PI * FC * time);
#endif
}
/* gtri - end - wbk - add PHASE parameters */
}
break;
case PWL: {
int i;
if(time< *(here->ISRCcoeffs)) {
if(time < *(here->ISRCcoeffs)) {
value = *(here->ISRCcoeffs + 1) ;
break;
}
@ -306,9 +304,9 @@ ISRCload(GENmodel *inModel, CKTcircuit *ckt)
(*(here->ISRCcoeffs+2*(i+1)) >time)) {
value = *(here->ISRCcoeffs+2*i+1) +
(((time-*(here->ISRCcoeffs+2*i))/
(*(here->ISRCcoeffs+2*(i+1)) -
(*(here->ISRCcoeffs+2*(i+1)) -
*(here->ISRCcoeffs+2*i))) *
(*(here->ISRCcoeffs+2*i+3) -
(*(here->ISRCcoeffs+2*i+3) -
*(here->ISRCcoeffs+2*i+1)));
goto loadDone;
}
@ -317,7 +315,7 @@ ISRCload(GENmodel *inModel, CKTcircuit *ckt)
break;
}
/**** tansient noise routines:
/**** tansient noise routines:
INoi2 2 0 DC 0 TRNOISE(10n 0.5n 0 0n) : generate gaussian distributed noise
rms value, time step, 0 0
INoi1 1 0 DC 0 TRNOISE(0n 0.5n 1 10n) : generate 1/f noise
@ -354,17 +352,16 @@ INoi1 1 0 DC 0 TRNOISE(0n 0.5n 1 10n) : generate 1/f noise
if(here -> ISRCdcGiven)
value += here->ISRCdcValue;
}
break;
break;
} // switch
} // switch
} // else (line 48)
loadDone:
/* gtri - begin - wbk - modify for supply ramping option */
#ifdef XSPICE_EXP
value *= ckt->CKTsrcFact;
value *= ckt->CKTsrcFact;
value *= cm_analog_ramp_factor();
#else
if (ckt->CKTmode & MODETRANOP)
value *= ckt->CKTsrcFact;
@ -383,5 +380,6 @@ loadDone:
#endif
} // for loop instances
} // for loop models
return(OK);
}

4
src/spicelib/devices/isrc/isrcmdel.c

@ -14,14 +14,14 @@ Author: 1985 Thomas L. Quarles
int
ISRCmDelete(GENmodel **inModel, IFuid modname, GENmodel *fast)
{
ISRCmodel **model = (ISRCmodel**)inModel;
ISRCmodel **model = (ISRCmodel **) inModel;
ISRCmodel *modfast = (ISRCmodel *) fast;
ISRCinstance *here;
ISRCinstance *prev = NULL;
ISRCmodel **oldmod;
oldmod = model;
for( ; *model ; model = &((*model)->ISRCnextModel)) {
if( (*model)->ISRCmodName == modname ||
if( (*model)->ISRCmodName == modname ||
(modfast && *model == modfast) ) goto delgot;
oldmod = model;
}

104
src/spicelib/devices/isrc/isrcpar.c

@ -31,26 +31,30 @@ static void copy_coeffs(ISRCinstance *here, IFvalue *value)
int
ISRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
{
int i;
ISRCinstance *here = (ISRCinstance*)inst;
int i;
ISRCinstance *here = (ISRCinstance *) inst;
NG_IGNORE(select);
switch(param) {
case ISRC_DC:
here->ISRCdcValue = value->rValue;
here->ISRCdcGiven = TRUE;
break;
case ISRC_AC_MAG:
here->ISRCacMag = value->rValue;
here->ISRCacMGiven = TRUE;
here->ISRCacGiven = TRUE;
break;
case ISRC_AC_PHASE:
here->ISRCacPhase = value->rValue;
here->ISRCacPGiven = TRUE;
here->ISRCacGiven = TRUE;
break;
case ISRC_AC:
switch(value->v.numValue) {
case 2:
@ -66,6 +70,7 @@ ISRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
return(E_BADPARM);
}
break;
case ISRC_PULSE:
if(value->v.numValue < 2)
return(E_BADPARM);
@ -73,6 +78,7 @@ ISRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
here->ISRCfuncTGiven = TRUE;
copy_coeffs(here, value);
break;
case ISRC_SINE:
if(value->v.numValue < 2)
return(E_BADPARM);
@ -80,6 +86,7 @@ ISRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
here->ISRCfuncTGiven = TRUE;
copy_coeffs(here, value);
break;
case ISRC_EXP:
if(value->v.numValue < 2)
return(E_BADPARM);
@ -87,13 +94,14 @@ ISRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
here->ISRCfuncTGiven = TRUE;
copy_coeffs(here, value);
break;
case ISRC_PWL:
if(value->v.numValue < 2)
return(E_BADPARM);
here->ISRCfunctionType = PWL;
here->ISRCfuncTGiven = TRUE;
copy_coeffs(here, value);
for (i=0; i<(here->ISRCfunctionOrder/2)-1; i++) {
if (*(here->ISRCcoeffs+2*(i+1))<=*(here->ISRCcoeffs+2*i)) {
fprintf(stderr, "Warning : current source %s",
@ -101,8 +109,9 @@ ISRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
fprintf(stderr, " has non-increasing PWL time points.\n");
}
}
break;
case ISRC_SFFM:
if(value->v.numValue < 2)
return(E_BADPARM);
@ -117,47 +126,49 @@ ISRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
here->ISRCfunctionType = AM;
here->ISRCfuncTGiven = TRUE;
copy_coeffs(here, value);
break;
case ISRC_D_F1:
here->ISRCdF1given = TRUE;
here->ISRCdGiven = TRUE;
switch(value->v.numValue) {
case 2:
here->ISRCdF1phase = *(value->v.vec.rVec+1);
here->ISRCdF1mag = *(value->v.vec.rVec);
break;
case 1:
here->ISRCdF1mag = *(value->v.vec.rVec);
here->ISRCdF1phase = 0.0;
break;
case 0:
here->ISRCdF1mag = 1.0;
here->ISRCdF1phase = 0.0;
break;
default:
return(E_BADPARM);
}
break;
case ISRC_D_F2:
here->ISRCdF2given = TRUE;
here->ISRCdGiven = TRUE;
switch(value->v.numValue) {
case 2:
here->ISRCdF2phase = *(value->v.vec.rVec+1);
here->ISRCdF2mag = *(value->v.vec.rVec);
break;
case 1:
here->ISRCdF2mag = *(value->v.vec.rVec);
here->ISRCdF2phase = 0.0;
break;
case 0:
here->ISRCdF2mag = 1.0;
here->ISRCdF2phase = 0.0;
break;
default:
return(E_BADPARM);
}
break;
break;
case ISRC_D_F1:
here->ISRCdF1given = TRUE;
here->ISRCdGiven = TRUE;
switch(value->v.numValue) {
case 2:
here->ISRCdF1phase = *(value->v.vec.rVec+1);
here->ISRCdF1mag = *(value->v.vec.rVec);
break;
case 1:
here->ISRCdF1mag = *(value->v.vec.rVec);
here->ISRCdF1phase = 0.0;
break;
case 0:
here->ISRCdF1mag = 1.0;
here->ISRCdF1phase = 0.0;
break;
default:
return(E_BADPARM);
}
break;
case ISRC_D_F2:
here->ISRCdF2given = TRUE;
here->ISRCdGiven = TRUE;
switch(value->v.numValue) {
case 2:
here->ISRCdF2phase = *(value->v.vec.rVec+1);
here->ISRCdF2mag = *(value->v.vec.rVec);
break;
case 1:
here->ISRCdF2mag = *(value->v.vec.rVec);
here->ISRCdF2phase = 0.0;
break;
case 0:
here->ISRCdF2mag = 1.0;
here->ISRCdF2phase = 0.0;
break;
default:
return(E_BADPARM);
}
break;
case ISRC_TRNOISE: {
double NA, TS;
@ -193,10 +204,11 @@ ISRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
trnoise_state_init(NA, TS, NALPHA, NAMP, RTSAM, RTSCAPT, RTSEMT);
}
break;
break;
default:
return(E_BADPARM);
}
return(OK);
}

10
src/spicelib/devices/isrc/isrctemp.c

@ -16,7 +16,7 @@ ISRCtemp(GENmodel *inModel, CKTcircuit *ckt)
/* Pre-process voltage source parameters
*/
{
ISRCmodel *model = (ISRCmodel*)inModel;
ISRCmodel *model = (ISRCmodel *) inModel;
ISRCinstance *here;
double radians;
@ -28,13 +28,13 @@ ISRCtemp(GENmodel *inModel, CKTcircuit *ckt)
/* loop through all the instances of the model */
for (here = model->ISRCinstances; here != NULL ;
here=here->ISRCnextInstance) {
if (here->ISRCowner != ARCHme) continue;
if (here->ISRCowner != ARCHme) continue;
if(here->ISRCacGiven && !here->ISRCacMGiven) {
here->ISRCacMag=1;
here->ISRCacMag = 1;
}
if(here->ISRCacGiven && !here->ISRCacPGiven) {
here->ISRCacPhase=0;
here->ISRCacPhase = 0;
}
if(!here->ISRCdcGiven) {
/* no DC value - either have a transient value, or none */
@ -53,6 +53,6 @@ ISRCtemp(GENmodel *inModel, CKTcircuit *ckt)
here->ISRCacImag = here->ISRCacMag * sin(radians);
}
}
return(OK);
return(OK);
}

67
src/spicelib/devices/vsrc/vsrcacct.c

@ -19,12 +19,12 @@ extern double exprand(double);
#define SAMETIME(a,b) (fabs((a)-(b))<= TIMETOL * PW)
#define TIMETOL 1e-7
int
VSRCaccept(CKTcircuit *ckt, GENmodel *inModel)
/* set up the breakpoint table. */
{
VSRCmodel *model = (VSRCmodel *)inModel;
VSRCmodel *model = (VSRCmodel *) inModel;
VSRCinstance *here;
int error;
@ -34,32 +34,33 @@ VSRCaccept(CKTcircuit *ckt, GENmodel *inModel)
/* loop through all the instances of the model */
for (here = model->VSRCinstances; here != NULL ;
here=here->VSRCnextInstance) {
if(!(ckt->CKTmode & (MODETRAN | MODETRANOP))) {
/* not transient, so shouldn't be here */
return(OK);
} else {
/* use the transient functions */
switch(here->VSRCfunctionType) {
default: { /* no function specified:DC no breakpoints */
break;
}
case PULSE: {
double TD, TR, TF, PW, PER;
double tshift;
double time = 0.;
double basetime = 0;
/* gtri - begin - wbk - add PHASE parameter */
#ifdef XSPICE
/* gtri - begin - wbk - add PHASE parameter */
#ifdef XSPICE
double PHASE;
double phase;
double deltat;
#endif
#endif
TD = here->VSRCfunctionOrder > 2
? here->VSRCcoeffs[2] : 0.0;
? here->VSRCcoeffs[2] : 0.0;
TR = here->VSRCfunctionOrder > 3
&& here->VSRCcoeffs[3] != 0.0
? here->VSRCcoeffs[3] : ckt->CKTstep;
@ -72,27 +73,27 @@ VSRCaccept(CKTcircuit *ckt, GENmodel *inModel)
PER = here->VSRCfunctionOrder > 6
&& here->VSRCcoeffs[6] != 0.0
? here->VSRCcoeffs[6] : ckt->CKTfinalTime;
#ifdef XSPICE
PHASE = here->VSRCfunctionOrder > 7
#ifdef XSPICE
PHASE = here->VSRCfunctionOrder > 7
? here->VSRCcoeffs[7] : 0.0;
#endif
#endif
/* offset time by delay */
time = ckt->CKTtime - TD;
tshift = TD;
#ifdef XSPICE
/* normalize phase to 0 - 360° */
#ifdef XSPICE
/* normalize phase to 0 - 360° */
/* normalize phase to cycles */
phase = PHASE / 360.0;
phase = fmod(phase, 1.0);
deltat = phase * PER;
while (deltat > 0)
while (deltat > 0)
deltat -= PER;
time += deltat;
tshift = TD - deltat;
#endif
/* gtri - end - wbk - add PHASE parameter */
tshift = TD - deltat;
#endif
/* gtri - end - wbk - add PHASE parameter */
if(time >= PER) {
/* repeating signal - figure out where we are */
/* in period */
@ -105,45 +106,36 @@ VSRCaccept(CKTcircuit *ckt, GENmodel *inModel)
error = CKTsetBreak(ckt,basetime + TR + tshift);
if(error) return(error);
} else if(ckt->CKTbreak && SAMETIME(TR+PW+TF,time) ) {
error = CKTsetBreak(ckt,basetime + PER + tshift);
if(error) return(error);
} else if (ckt->CKTbreak && (time == -tshift) ) {
error = CKTsetBreak(ckt,basetime + tshift);
if(error) return(error);
} else if (ckt->CKTbreak && SAMETIME(PER,time) ) {
error = CKTsetBreak(ckt,basetime + tshift + TR + PER);
if(error) return(error);
}
} else if ( time >= TR && time <= TR + PW) {
if(ckt->CKTbreak && SAMETIME(time,TR) ) {
error = CKTsetBreak(ckt,basetime + tshift + TR + PW);
if(error) return(error);
} else if(ckt->CKTbreak && SAMETIME(TR+PW,time) ) {
error = CKTsetBreak(ckt,basetime + tshift + TR + PW + TF);
if(error) return(error);
}
} else if (time > 0 && time < TR) {
if(ckt->CKTbreak && SAMETIME(time,0) ) {
error = CKTsetBreak(ckt,basetime + tshift + TR);
if(error) return(error);
} else if(ckt->CKTbreak && SAMETIME(time,TR)) {
error = CKTsetBreak(ckt,basetime + tshift + TR + PW);
if(error) return(error);
}
} else { /* time > TR + PW && < TR + PW + TF */
if(ckt->CKTbreak && SAMETIME(time,TR+PW) ) {
error = CKTsetBreak(ckt,basetime + tshift+TR + PW +TF);
if(error) return(error);
} else if(ckt->CKTbreak && SAMETIME(time,TR+PW+TF) ) {
error = CKTsetBreak(ckt,basetime + tshift + PER);
if(error) return(error);
}
@ -155,18 +147,22 @@ VSRCaccept(CKTcircuit *ckt, GENmodel *inModel)
/* no breakpoints (yet) */
}
break;
case EXP: {
/* no breakpoints (yet) */
}
break;
case SFFM:{
/* no breakpoints (yet) */
}
break;
case AM:{
/* no breakpoints (yet) */
}
break;
case PWL: {
int i;
if(ckt->CKTtime < *(here->VSRCcoeffs)) {
@ -180,18 +176,19 @@ VSRCaccept(CKTcircuit *ckt, GENmodel *inModel)
error = CKTsetBreak(ckt, *(here->VSRCcoeffs+2*i+2));
if(error) return(error);
goto bkptset;
}
}
}
break;
}
/**** tansient noise routines:
/**** tansient noise routines:
VNoi2 2 0 DC 0 TRNOISE(10n 0.5n 0 0n) : generate gaussian distributed noise
rms value, time step, 0 0
VNoi1 1 0 DC 0 TRNOISE(0n 0.5n 1 10n) : generate 1/f noise
0, time step, exponent < 2, rms value
*/
case TRNOISE: {
struct trnoise_state *state = here -> VSRCtrnoise_state;
double TS = state -> TS;
double RTSAM = state ->RTSAM;
@ -206,6 +203,7 @@ VSRCaccept(CKTcircuit *ckt, GENmodel *inModel)
}
if(ckt->CKTbreak) {
int n = (int) floor(ckt->CKTtime / TS + 0.5);
volatile double nearest = n * TS;
@ -242,9 +240,9 @@ VSRCaccept(CKTcircuit *ckt, GENmodel *inModel)
return(error);
}
}
if(AlmostEqualUlps(RTSemTime, ckt->CKTtime, 3)) {
/* new values */
/* new values */
RTScapTime = here -> VSRCtrnoise_state ->RTScapTime = ckt->CKTtime + exprand(RTSCAPT);
here -> VSRCtrnoise_state ->RTSemTime = RTScapTime + exprand(RTSEMT);
@ -257,6 +255,7 @@ VSRCaccept(CKTcircuit *ckt, GENmodel *inModel)
}
}
break;
case TRRANDOM: {
struct trrandom_state *state = here -> VSRCtrrandom_state;
double TS = state -> TS;
@ -285,10 +284,12 @@ VSRCaccept(CKTcircuit *ckt, GENmodel *inModel)
}
}
break;
} //switch
} // switch
} // if ... else
bkptset: ;
} // for
} // for
return(OK);
}

5
src/spicelib/devices/vsrc/vsrcacld.c

@ -13,7 +13,7 @@ Author: 1985 Thomas L. Quarles
int
VSRCacLoad(GENmodel *inModel, CKTcircuit *ckt)
{
VSRCmodel *model = (VSRCmodel *)inModel;
VSRCmodel *model = (VSRCmodel *) inModel;
VSRCinstance *here;
for( ; model != NULL; model = model->VSRCnextModel ) {
@ -21,7 +21,7 @@ VSRCacLoad(GENmodel *inModel, CKTcircuit *ckt)
/* loop through all the instances of the model */
for (here = model->VSRCinstances; here != NULL ;
here=here->VSRCnextInstance) {
if (here->VSRCowner != ARCHme) continue;
if (here->VSRCowner != ARCHme) continue;
*(here->VSRCposIbrptr) += 1.0 ;
*(here->VSRCnegIbrptr) -= 1.0 ;
@ -31,5 +31,6 @@ VSRCacLoad(GENmodel *inModel, CKTcircuit *ckt)
*(ckt->CKTirhs + (here->VSRCbranch)) += here->VSRCacImag;
}
}
return(OK);
}

12
src/spicelib/devices/vsrc/vsrcask.c

@ -24,7 +24,7 @@ int
VSRCask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *select)
{
VSRCinstance *here = (VSRCinstance*)inst;
static char *msg = "Current and power not available in ac analysis";
static char *msg = "Current and power not available in ac analysis";
int temp;
double *v, *w;
@ -45,13 +45,13 @@ VSRCask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *
case VSRC_EXP:
case VSRC_PWL:
case VSRC_SFFM:
case VSRC_AM:
case VSRC_TRNOISE:
case VSRC_TRRANDOM:
case VSRC_AM:
case VSRC_TRNOISE:
case VSRC_TRRANDOM:
case VSRC_FCN_COEFFS:
temp = value->v.numValue = here->VSRCfunctionOrder;
v = value->v.vec.rVec = TMALLOC(double, here->VSRCfunctionOrder);
w = here->VSRCcoeffs;
w = here->VSRCcoeffs;
while (temp--)
*v++ = *w++;
return (OK);
@ -103,7 +103,7 @@ VSRCask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *
return(E_ASKPOWER);
} else {
value->rValue = (*(ckt->CKTrhsOld+here->VSRCposNode)
- *(ckt->CKTrhsOld + here->VSRCnegNode)) *
- *(ckt->CKTrhsOld + here->VSRCnegNode)) *
-*(ckt->CKTrhsOld + here->VSRCbranch);
}
return(OK);

40
src/spicelib/devices/vsrc/vsrcdefs.h

@ -13,20 +13,20 @@ Author: 1985 Thomas L. Quarles
struct trnoise_state;
/*
* structures to describe independent voltage sources
*/
/*
* structures to describe independent voltage sources
*/
/* information needed for each instance */
typedef struct sVSRCinstance {
struct sVSRCmodel *VSRCmodPtr; /* backpointer to model */
struct sVSRCinstance *VSRCnextInstance; /* pointer to next instance of
struct sVSRCinstance *VSRCnextInstance; /* pointer to next instance of
*current model */
IFuid VSRCname; /* pointer to character string naming this instance */
int VSRCowner; /* number of owner process */
int VSRCstate; /* not used */
int VSRCstate; /* not used */
int VSRCposNode; /* number of positive node of source */
int VSRCnegNode; /* number of negative node of source */
@ -50,32 +50,32 @@ typedef struct sVSRCinstance {
double VSRCdF2mag; /* distortion f2 magnitude */
double VSRCdF1phase; /* distortion f1 phase */
double VSRCdF2phase; /* distortion f2 phase */
struct trnoise_state *VSRCtrnoise_state; /* transient noise */
struct trrandom_state *VSRCtrrandom_state; /* transient random source */
double VSRCr; /* pwl repeat */
double VSRCrdelay; /* pwl delay period */
double *VSRCposIbrptr; /* pointer to sparse matrix element at
double *VSRCposIbrptr; /* pointer to sparse matrix element at
* (positive node, branch equation) */
double *VSRCnegIbrptr; /* pointer to sparse matrix element at
double *VSRCnegIbrptr; /* pointer to sparse matrix element at
* (negative node, branch equation) */
double *VSRCibrPosptr; /* pointer to sparse matrix element at
double *VSRCibrPosptr; /* pointer to sparse matrix element at
* (branch equation, positive node) */
double *VSRCibrNegptr; /* pointer to sparse matrix element at
double *VSRCibrNegptr; /* pointer to sparse matrix element at
* (branch equation, negative node) */
double *VSRCibrIbrptr; /* pointer to sparse matrix element at
double *VSRCibrIbrptr; /* pointer to sparse matrix element at
* (branch equation, branch equation) */
unsigned VSRCdcGiven :1 ; /* flag to indicate dc value given */
unsigned VSRCacGiven :1 ; /* flag to indicate ac keyword given */
unsigned VSRCacMGiven :1 ; /* flag to indicate ac magnitude given */
unsigned VSRCacPGiven :1 ; /* flag to indicate ac phase given */
unsigned VSRCfuncTGiven :1 ; /* flag to indicate function type given */
unsigned VSRCcoeffsGiven :1 ; /* flag to indicate function coeffs given */
unsigned VSRCdcGiven :1 ; /* flag to indicate dc value given */
unsigned VSRCacGiven :1 ; /* flag to indicate ac keyword given */
unsigned VSRCacMGiven :1 ; /* flag to indicate ac magnitude given */
unsigned VSRCacPGiven :1 ; /* flag to indicate ac phase given */
unsigned VSRCfuncTGiven :1 ; /* flag to indicate function type given */
unsigned VSRCcoeffsGiven :1 ; /* flag to indicate function coeffs given */
unsigned VSRCdGiven :1 ; /* flag to indicate source is a distortion input */
unsigned VSRCdF1given :1 ; /* flag to indicate source is an f1 distortion input */
unsigned VSRCdF2given :1 ; /* flag to indicate source is an f2 distortion input */
unsigned VSRCrGiven :1; /* flag to indicate repeating pwl */
unsigned VSRCrGiven :1 ; /* flag to indicate repeating pwl */
} VSRCinstance ;
@ -83,9 +83,9 @@ typedef struct sVSRCinstance {
typedef struct sVSRCmodel {
int VSRCmodType; /* type index of this device type */
struct sVSRCmodel *VSRCnextModel; /* pointer to next possible model
struct sVSRCmodel *VSRCnextModel; /* pointer to next possible model
*in linked list */
VSRCinstance * VSRCinstances; /* pointer to list of instances
VSRCinstance * VSRCinstances; /* pointer to list of instances
* that have this model */
IFuid VSRCmodName; /* pointer to character string naming this model */
} VSRCmodel;

4
src/spicelib/devices/vsrc/vsrcdel.c

@ -14,8 +14,8 @@ Author: 1985 Thomas L. Quarles
int
VSRCdelete(GENmodel *inModel, IFuid name, GENinstance **inst)
{
VSRCmodel *model = (VSRCmodel *)inModel;
VSRCinstance **fast = (VSRCinstance**)inst;
VSRCmodel *model = (VSRCmodel *) inModel;
VSRCinstance **fast = (VSRCinstance **) inst;
VSRCinstance **prev = NULL;
VSRCinstance *here;

2
src/spicelib/devices/vsrc/vsrcext.h

@ -3,7 +3,7 @@ Copyright 1990 Regents of the University of California. All rights reserved.
Author: 1985 Thomas L. Quarles
**********/
extern int VSRCaccept(CKTcircuit*,GENmodel *);
extern int VSRCaccept(CKTcircuit*,GENmodel*);
extern int VSRCacLoad(GENmodel*,CKTcircuit*);
extern int VSRCask(CKTcircuit*,GENinstance*,int,IFvalue*,IFvalue*);
extern int VSRCdelete(GENmodel*,IFuid,GENinstance**);

137
src/spicelib/devices/vsrc/vsrcload.c

@ -25,7 +25,7 @@ VSRCload(GENmodel *inModel, CKTcircuit *ckt)
* sparse matrix previously provided
*/
{
VSRCmodel *model = (VSRCmodel *)inModel;
VSRCmodel *model = (VSRCmodel *) inModel;
VSRCinstance *here;
double time;
double value = 0.0;
@ -37,7 +37,7 @@ VSRCload(GENmodel *inModel, CKTcircuit *ckt)
for (here = model->VSRCinstances; here != NULL ;
here=here->VSRCnextInstance) {
if (here->VSRCowner != ARCHme) continue;
*(here->VSRCposIbrptr) += 1.0 ;
*(here->VSRCnegIbrptr) -= 1.0 ;
*(here->VSRCibrPosptr) += 1.0 ;
@ -59,10 +59,11 @@ VSRCload(GENmodel *inModel, CKTcircuit *ckt)
}
/* use the transient functions */
switch(here->VSRCfunctionType) {
default:
value = here->VSRCdcValue;
break;
case PULSE: {
double V1, V2, TD, TR, TF, PW, PER;
double basetime = 0;
@ -88,11 +89,11 @@ VSRCload(GENmodel *inModel, CKTcircuit *ckt)
&& here->VSRCcoeffs[6] != 0.0
? here->VSRCcoeffs[6] : ckt->CKTfinalTime;
/* shift time by delay time TD */
/* shift time by delay time TD */
time -= TD;
#ifdef XSPICE
/* gtri - begin - wbk - add PHASE parameter */
/* gtri - begin - wbk - add PHASE parameter */
PHASE = here->VSRCfunctionOrder > 7
? here->VSRCcoeffs[7] : 0.0;
@ -100,12 +101,12 @@ VSRCload(GENmodel *inModel, CKTcircuit *ckt)
phase = PHASE / 360.0;
phase = fmod(phase, 1.0);
deltat = phase * PER;
while (deltat > 0)
while (deltat > 0)
deltat -= PER;
/* shift time by pase (neg. for pos. phase value) */
time += deltat;
/* gtri - end - wbk - add PHASE parameter */
#endif
/* gtri - end - wbk - add PHASE parameter */
#endif
if(time > PER) {
/* repeating signal - figure out where we are */
/* in period */
@ -121,75 +122,73 @@ VSRCload(GENmodel *inModel, CKTcircuit *ckt)
} else { /* time > TR + PW && < TR + PW + TF */
value = V2 + (V1 - V2) * (time - (TR + PW)) / TF;
}
}
break;
case SINE: {
double VO, VA, FREQ, TD, THETA;
/* gtri - begin - wbk - add PHASE parameter */
/* gtri - begin - wbk - add PHASE parameter */
#ifdef XSPICE
double PHASE;
double phase;
PHASE = here->VSRCfunctionOrder > 5
? here->VSRCcoeffs[5] : 0.0;
/* compute phase in radians */
/* compute phase in radians */
phase = PHASE * M_PI / 180.0;
#endif
VO = here->VSRCcoeffs[0];
VA = here->VSRCcoeffs[1];
FREQ = here->VSRCfunctionOrder > 2
FREQ = here->VSRCfunctionOrder > 2
&& here->VSRCcoeffs[2] != 0.0
? here->VSRCcoeffs[2] : (1/ckt->CKTfinalTime);
TD = here->VSRCfunctionOrder > 3
? here->VSRCcoeffs[3] : 0.0;
THETA = here->VSRCfunctionOrder > 4
? here->VSRCcoeffs[4] : 0.0;
time -= TD;
if (time <= 0) {
#ifdef XSPICE
value = VO + VA * sin(phase);
} else {
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 + phase) *
exp(-time*THETA);
#else
value = VO;
} else {
value = VO + VA * sin(FREQ * time * 2.0 * M_PI) *
exp(-time*THETA);
} else {
value = VO + VA * sin(FREQ * time * 2.0 * M_PI) *
exp(-time*THETA);
#endif
/* gtri - end - wbk - add PHASE parameter */
/* gtri - end - wbk - add PHASE parameter */
}
}
break;
case EXP: {
double V1, V2, TD1, TD2, TAU1, TAU2;
V1 = here->VSRCcoeffs[0];
V2 = here->VSRCcoeffs[1];
TD1 = here->VSRCfunctionOrder > 2
TD1 = here->VSRCfunctionOrder > 2
&& here->VSRCcoeffs[2] != 0.0
? here->VSRCcoeffs[2] : ckt->CKTstep;
TAU1 = here->VSRCfunctionOrder > 3
TAU1 = here->VSRCfunctionOrder > 3
&& here->VSRCcoeffs[3] != 0.0
? here->VSRCcoeffs[3] : ckt->CKTstep;
TD2 = here->VSRCfunctionOrder > 4
TD2 = here->VSRCfunctionOrder > 4
&& here->VSRCcoeffs[4] != 0.0
? here->VSRCcoeffs[4] : TD1 + ckt->CKTstep;
TAU2 = here->VSRCfunctionOrder > 5
TAU2 = here->VSRCfunctionOrder > 5
&& here->VSRCcoeffs[5]
? here->VSRCcoeffs[5] : ckt->CKTstep;
if(time <= TD1) {
value = V1;
} else if (time <= TD2) {
value = V1 + (V2-V1)*(1-exp(-(time-TD1)/TAU1));
value = V1 + (V2-V1)*(1-exp(-(time-TD1)/TAU1));
} else {
value = V1 + (V2-V1)*(1-exp(-(time-TD1)/TAU1)) +
(V1-V2)*(1-exp(-(time-TD2)/TAU2)) ;
@ -197,75 +196,78 @@ VSRCload(GENmodel *inModel, CKTcircuit *ckt)
}
break;
case SFFM:{
case SFFM: {
double VO, VA, FC, MDI, FS;
/* gtri - begin - wbk - add PHASE parameters */
#ifdef XSPICE
double PHASEC, PHASES;
double phasec;
double phases;
PHASEC = here->VSRCfunctionOrder > 5
? here->VSRCcoeffs[5] : 0.0;
? here->VSRCcoeffs[5] : 0.0;
PHASES = here->VSRCfunctionOrder > 6
? here->VSRCcoeffs[6] : 0.0;
? here->VSRCcoeffs[6] : 0.0;
/* compute phases in radians */
phasec = PHASEC * M_PI / 180.0;
phases = PHASES * M_PI / 180.0;
#endif
phases = PHASES * M_PI / 180.0;
#endif
VO = here->VSRCcoeffs[0];
VA = here->VSRCcoeffs[1];
FC = here->VSRCfunctionOrder > 2
FC = here->VSRCfunctionOrder > 2
&& here->VSRCcoeffs[2]
? here->VSRCcoeffs[2] : (1/ckt->CKTfinalTime);
MDI = here->VSRCfunctionOrder > 3
? here->VSRCcoeffs[3] : 0.0;
FS = here->VSRCfunctionOrder > 4
FS = here->VSRCfunctionOrder > 4
&& here->VSRCcoeffs[4]
? here->VSRCcoeffs[4] : (1/ckt->CKTfinalTime);
#ifdef XSPICE
/* compute waveform value */
value = VO + VA *
value = VO + VA *
sin((2.0 * M_PI * FC * time + phasec) +
MDI * sin(2.0 * M_PI * FS * time + phases));
#else
value = VO + VA *
sin((2.0 * M_PI * FC * time) +
MDI * sin(2.0 * M_PI * FS * time));
value = VO + VA *
sin((2.0 * M_PI * FC * time) +
MDI * sin(2.0 * M_PI * FS * time));
#endif
/* gtri - end - wbk - add PHASE parameters */
/* gtri - end - wbk - add PHASE parameters */
}
break;
case AM:{
case AM: {
double VA, FC, MF, VO, TD;
/* gtri - begin - wbk - add PHASE parameters */
/* gtri - begin - wbk - add PHASE parameters */
#ifdef XSPICE
double PHASEC, PHASES;
double phasec;
double phases;
PHASEC = here->VSRCfunctionOrder > 5
? here->VSRCcoeffs[5] : 0.0;
? here->VSRCcoeffs[5] : 0.0;
PHASES = here->VSRCfunctionOrder > 6
? here->VSRCcoeffs[6] : 0.0;
? here->VSRCcoeffs[6] : 0.0;
/* compute phases in radians */
phasec = PHASEC * M_PI / 180.0;
phases = PHASES * M_PI / 180.0;
phases = PHASES * M_PI / 180.0;
#endif
#endif
VA = here->VSRCcoeffs[0];
VO = here->VSRCcoeffs[1];
MF = here->VSRCfunctionOrder > 2
MF = here->VSRCfunctionOrder > 2
&& here->VSRCcoeffs[2]
? here->VSRCcoeffs[2] : (1/ckt->CKTfinalTime);
FC = here->VSRCfunctionOrder > 3
? here->VSRCcoeffs[3] : 0.0;
TD = here->VSRCfunctionOrder > 4
TD = here->VSRCfunctionOrder > 4
&& here->VSRCcoeffs[4]
? here->VSRCcoeffs[4] : 0.0;
@ -277,16 +279,17 @@ VSRCload(GENmodel *inModel, CKTcircuit *ckt)
/* compute waveform value */
value = VA * (VO + sin(2.0 * M_PI * MF * time + phases )) *
sin(2.0 * M_PI * FC * time + phases);
#else
value = VA * (VO + sin(2.0 * M_PI * MF * time)) *
sin(2.0 * M_PI * FC * time);
#endif
#endif
}
/* gtri - end - wbk - add PHASE parameters */
/* gtri - end - wbk - add PHASE parameters */
}
break;
case PWL: {
int i = 0, num_repeat = 0, ii = 0;
double foo, repeat_time = 0, end_time, breakpt_time, itime;
@ -306,7 +309,7 @@ VSRCload(GENmodel *inModel, CKTcircuit *ckt)
foo = *(here->VSRCcoeffs+2*i+1);
value = foo;
goto loadDone;
} else if ( (*(here->VSRCcoeffs+2*i)+repeat_time < time)
} else if ( (*(here->VSRCcoeffs+2*i)+repeat_time < time)
&& (*(here->VSRCcoeffs+2*(i+1))+repeat_time > time) ) {
foo = *(here->VSRCcoeffs+2*i+1) + (((time-(*(here->VSRCcoeffs+2*i)+repeat_time))/
(*(here->VSRCcoeffs+2*(i+1)) - *(here->VSRCcoeffs+2*i))) *
@ -319,7 +322,7 @@ VSRCload(GENmodel *inModel, CKTcircuit *ckt)
value = foo;
if ( !here->VSRCrGiven ) goto loadDone;
end_time = *(here->VSRCcoeffs + here->VSRCfunctionOrder-2);
breakpt_time = *(here->VSRCcoeffs + here->VSRCrBreakpt);
repeat_time = end_time + (end_time - breakpt_time)*num_repeat++ - breakpt_time;
@ -328,7 +331,7 @@ VSRCload(GENmodel *inModel, CKTcircuit *ckt)
break;
}
/**** tansient noise routines:
/**** tansient noise routines:
VNoi2 2 0 DC 0 TRNOISE(10n 0.5n 0 0n) : generate gaussian distributed noise
rms value, time step, 0 0
VNoi1 1 0 DC 0 TRNOISE(0n 0.5n 1 10n) : generate 1/f noise
@ -368,12 +371,12 @@ VNoi3 3 0 DC 0 TRNOISE(0 0 0 0 15m 22u 50u) : generate RTS noise
if(here -> VSRCdcGiven)
value += here->VSRCdcValue;
}
break;
break;
case TRRANDOM: {
struct trrandom_state *state = here -> VSRCtrrandom_state;
value = state -> value;
/* DC value */
/* DC value */
if(here -> VSRCdcGiven)
value += here->VSRCdcValue;
}
@ -382,6 +385,7 @@ VNoi3 3 0 DC 0 TRNOISE(0 0 0 0 15m 22u 50u) : generate RTS noise
} // switch
} // else (line 48)
loadDone:
/* gtri - begin - wbk - modify for supply ramping option */
#ifdef XSPICE_EXP
value *= ckt->CKTsrcFact;
@ -397,5 +401,6 @@ loadDone:
} // for loop instances
} // for loop models
return(OK);
}

6
src/spicelib/devices/vsrc/vsrcmdel.c

@ -14,14 +14,14 @@ Author: 1985 Thomas L. Quarles
int
VSRCmDelete(GENmodel **inModel, IFuid modname, GENmodel *fast)
{
VSRCmodel **model = (VSRCmodel **)inModel;
VSRCmodel *modfast = (VSRCmodel *)fast;
VSRCmodel **model = (VSRCmodel **) inModel;
VSRCmodel *modfast = (VSRCmodel *) fast;
VSRCinstance *here;
VSRCinstance *prev = NULL;
VSRCmodel **oldmod;
oldmod = model;
for( ; *model ; model = &((*model)->VSRCnextModel)) {
if( (*model)->VSRCmodName == modname ||
if( (*model)->VSRCmodName == modname ||
(modfast && *model == modfast) ) goto delgot;
oldmod = model;
}

87
src/spicelib/devices/vsrc/vsrcpar.c

@ -32,25 +32,29 @@ int
VSRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
{
int i;
VSRCinstance *here = (VSRCinstance *)inst;
VSRCinstance *here = (VSRCinstance *) inst;
NG_IGNORE(select);
switch(param) {
case VSRC_DC:
here->VSRCdcValue = value->rValue;
here->VSRCdcGiven = TRUE;
break;
case VSRC_AC_MAG:
here->VSRCacMag = value->rValue;
here->VSRCacMGiven = TRUE;
here->VSRCacGiven = TRUE;
break;
case VSRC_AC_PHASE:
here->VSRCacPhase = value->rValue;
here->VSRCacPGiven = TRUE;
here->VSRCacGiven = TRUE;
break;
case VSRC_AC:
switch(value->v.numValue) {
case 2:
@ -66,6 +70,7 @@ VSRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
return(E_BADPARM);
}
break;
case VSRC_PULSE:
if(value->v.numValue < 2)
return(E_BADPARM);
@ -73,6 +78,7 @@ VSRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
here->VSRCfuncTGiven = TRUE;
copy_coeffs(here, value);
break;
case VSRC_SINE:
if(value->v.numValue < 2)
return(E_BADPARM);
@ -80,6 +86,7 @@ VSRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
here->VSRCfuncTGiven = TRUE;
copy_coeffs(here, value);
break;
case VSRC_EXP:
if(value->v.numValue < 2)
return(E_BADPARM);
@ -87,35 +94,38 @@ VSRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
here->VSRCfuncTGiven = TRUE;
copy_coeffs(here, value);
break;
case VSRC_PWL:
if(value->v.numValue < 2)
return(E_BADPARM);
here->VSRCfunctionType = PWL;
here->VSRCfuncTGiven = TRUE;
copy_coeffs(here, value);
for(i=0;i<(here->VSRCfunctionOrder/2)-1;i++) {
if(*(here->VSRCcoeffs+2*(i+1))<=*(here->VSRCcoeffs+2*i)) {
for (i=0; i<(here->VSRCfunctionOrder/2)-1; i++) {
if (*(here->VSRCcoeffs+2*(i+1))<=*(here->VSRCcoeffs+2*i)) {
fprintf(stderr, "Warning : voltage source %s",
here->VSRCname);
fprintf(stderr, " has non-increasing PWL time points.\n");
}
}
break;
case VSRC_TD:
here->VSRCrdelay = value->rValue;
break;
case VSRC_R: {
double end_time;
here->VSRCr = value->rValue;
here->VSRCrGiven = TRUE;
for ( i = 0; i < here->VSRCfunctionOrder; i += 2 ) {
here->VSRCrBreakpt = i;
if ( here->VSRCr == *(here->VSRCcoeffs+i) ) break;
}
end_time = *(here->VSRCcoeffs + here->VSRCfunctionOrder-2);
if ( here->VSRCr > end_time ) {
fprintf(stderr, "ERROR: repeat start time value %g for pwl voltage source must be smaller than final time point given!\n", here->VSRCr );
@ -129,6 +139,7 @@ VSRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
break;
}
case VSRC_SFFM:
if(value->v.numValue < 2)
return(E_BADPARM);
@ -136,13 +147,15 @@ VSRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
here->VSRCfuncTGiven = TRUE;
copy_coeffs(here, value);
break;
case VSRC_AM:
if(value->v.numValue < 2)
return(E_BADPARM);
here->VSRCfunctionType = AM;
here->VSRCfuncTGiven = TRUE;
copy_coeffs(here, value);
break;
break;
case VSRC_D_F1:
here->VSRCdF1given = TRUE;
here->VSRCdGiven = TRUE;
@ -163,6 +176,7 @@ VSRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
return(E_BADPARM);
}
break;
case VSRC_D_F2:
here->VSRCdF2given = TRUE;
here->VSRCdGiven = TRUE;
@ -183,39 +197,40 @@ VSRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
return(E_BADPARM);
}
break;
case VSRC_TRNOISE: {
double NA, TS;
double NALPHA = 0.0;
double NAMP = 0.0;
double RTSAM = 0.0;
double RTSCAPT = 0.0;
double RTSEMT = 0.0;
here->VSRCfunctionType = TRNOISE;
here->VSRCfuncTGiven = TRUE;
copy_coeffs(here, value);
case VSRC_TRNOISE: {
double NA, TS;
double NALPHA = 0.0;
double NAMP = 0.0;
double RTSAM = 0.0;
double RTSCAPT = 0.0;
double RTSEMT = 0.0;
NA = here->VSRCcoeffs[0]; // input is rms value
TS = here->VSRCcoeffs[1]; // time step
here->VSRCfunctionType = TRNOISE;
here->VSRCfuncTGiven = TRUE;
copy_coeffs(here, value);
if (here->VSRCfunctionOrder > 2)
NALPHA = here->VSRCcoeffs[2]; // 1/f exponent
NA = here->VSRCcoeffs[0]; // input is rms value
TS = here->VSRCcoeffs[1]; // time step
if (here->VSRCfunctionOrder > 3 && NALPHA != 0.0)
NAMP = here->VSRCcoeffs[3]; // 1/f amplitude
if (here->VSRCfunctionOrder > 2)
NALPHA = here->VSRCcoeffs[2]; // 1/f exponent
if (here->VSRCfunctionOrder > 4)
RTSAM = here->VSRCcoeffs[4]; // RTS amplitude
if (here->VSRCfunctionOrder > 3 && NALPHA != 0.0)
NAMP = here->VSRCcoeffs[3]; // 1/f amplitude
if (here->VSRCfunctionOrder > 5 && RTSAM != 0.0)
RTSCAPT = here->VSRCcoeffs[5]; // RTS trap capture time
if (here->VSRCfunctionOrder > 4)
RTSAM = here->VSRCcoeffs[4]; // RTS amplitude
if (here->VSRCfunctionOrder > 6 && RTSAM != 0.0)
RTSEMT = here->VSRCcoeffs[6]; // RTS trap emission time
if (here->VSRCfunctionOrder > 5 && RTSAM != 0.0)
RTSCAPT = here->VSRCcoeffs[5]; // RTS trap capture time
here->VSRCtrnoise_state =
trnoise_state_init(NA, TS, NALPHA, NAMP, RTSAM, RTSCAPT, RTSEMT);
}
if (here->VSRCfunctionOrder > 6 && RTSAM != 0.0)
RTSEMT = here->VSRCcoeffs[6]; // RTS trap emission time
here->VSRCtrnoise_state =
trnoise_state_init(NA, TS, NALPHA, NAMP, RTSAM, RTSCAPT, RTSEMT);
}
break;
case VSRC_TRRANDOM: {
@ -232,7 +247,7 @@ VSRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
TS = here->VSRCcoeffs[1]; // time step
if (here->VSRCfunctionOrder > 2)
TD = here->VSRCcoeffs[2]; // delay
if (here->VSRCfunctionOrder > 3)
PARAM1 = here->VSRCcoeffs[3]; // first parameter
@ -242,9 +257,11 @@ VSRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
here->VSRCtrrandom_state =
trrandom_state_init(rndtype, TS, TD, PARAM1, PARAM2);
}
break;
break;
default:
return(E_BADPARM);
}
return(OK);
}

12
src/spicelib/devices/vsrc/vsrctemp.c

@ -10,13 +10,13 @@ Author: 1985 Thomas L. Quarles
#include "sperror.h"
#include "suffix.h"
/* ARGSUSED */
/*ARGSUSED*/
int
VSRCtemp(GENmodel *inModel, CKTcircuit *ckt)
/* Pre-process voltage source parameters
/* Pre-process voltage source parameters
*/
{
VSRCmodel *model = (VSRCmodel *)inModel;
VSRCmodel *model = (VSRCmodel *) inModel;
VSRCinstance *here;
double radians;
@ -28,8 +28,8 @@ VSRCtemp(GENmodel *inModel, CKTcircuit *ckt)
/* loop through all the instances of the model */
for (here = model->VSRCinstances; here != NULL ;
here=here->VSRCnextInstance) {
if (here->VSRCowner != ARCHme) continue;
if (here->VSRCowner != ARCHme) continue;
if(here->VSRCacGiven && !here->VSRCacMGiven) {
here->VSRCacMag = 1;
}
@ -51,8 +51,8 @@ VSRCtemp(GENmodel *inModel, CKTcircuit *ckt)
radians = here->VSRCacPhase * M_PI / 180.0;
here->VSRCacReal = here->VSRCacMag * cos(radians);
here->VSRCacImag = here->VSRCacMag * sin(radians);
}
}
return(OK);
}
Loading…
Cancel
Save