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