Browse Source

Implemented patches supplied by Andreas Unger <a_unger@gmx.de>. Fixes XSpice bug; variable PER was being used before initialisation.

pre-master-46
sjborley 21 years ago
parent
commit
c2fb0224ed
  1. 32
      src/spicelib/devices/isrc/isrcload.c
  2. 29
      src/spicelib/devices/vsrc/vsrcload.c

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

@ -2,6 +2,7 @@
Copyright 1990 Regents of the University of California. All rights reserved. Copyright 1990 Regents of the University of California. All rights reserved.
Author: 1985 Thomas L. Quarles Author: 1985 Thomas L. Quarles
Modified: 2000 Alansfixes Modified: 2000 Alansfixes
$Id$
**********/ **********/
#include "ngspice.h" #include "ngspice.h"
@ -55,27 +56,12 @@ ISRCload(GENmodel *inModel, CKTcircuit *ckt)
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 #ifdef XSPICE
double PHASE; double PHASE;
double phase; double phase;
double deltat; double deltat;
double basephase; 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 #endif
/* gtri - end - wbk - add PHASE parameter */
V1 = here->ISRCcoeffs[0]; V1 = here->ISRCcoeffs[0];
V2 = here->ISRCcoeffs[1]; V2 = here->ISRCcoeffs[1];
TD = here->ISRCfunctionOrder > 2 TD = here->ISRCfunctionOrder > 2
@ -92,7 +78,21 @@ ISRCload(GENmodel *inModel, CKTcircuit *ckt)
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
/* gtri - begin - wbk - add PHASE parameter */
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;
/* gtri - end - wbk - add PHASE parameter */
#endif
time -= TD; time -= TD;
if(time > PER) { if(time > PER) {

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

@ -2,6 +2,7 @@
Copyright 1990 Regents of the University of California. All rights reserved. Copyright 1990 Regents of the University of California. All rights reserved.
Author: 1985 Thomas L. Quarles Author: 1985 Thomas L. Quarles
Modified: 2000 AlansFixes Modified: 2000 AlansFixes
$Id$
**********/ **********/
#include "ngspice.h" #include "ngspice.h"
@ -69,21 +70,7 @@ VSRCload(GENmodel *inModel, CKTcircuit *ckt)
double phase; double phase;
double deltat; double deltat;
double basephase; double basephase;
PHASE = here->VSRCfunctionOrder > 7
? here->VSRCcoeffs[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 #endif
/* gtri - end - wbk - add PHASE parameter */
V1 = here->VSRCcoeffs[0]; V1 = here->VSRCcoeffs[0];
V2 = here->VSRCcoeffs[1]; V2 = here->VSRCcoeffs[1];
TD = here->VSRCfunctionOrder > 2 TD = here->VSRCfunctionOrder > 2
@ -100,7 +87,21 @@ VSRCload(GENmodel *inModel, CKTcircuit *ckt)
PER = here->VSRCfunctionOrder > 6 PER = here->VSRCfunctionOrder > 6
&& here->VSRCcoeffs[6] != 0.0 && here->VSRCcoeffs[6] != 0.0
? here->VSRCcoeffs[6] : ckt->CKTfinalTime; ? here->VSRCcoeffs[6] : ckt->CKTfinalTime;
#ifdef XSPICE
/* gtri - begin - wbk - add PHASE parameter */
PHASE = here->VSRCfunctionOrder > 7
? here->VSRCcoeffs[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;
/* gtri - end - wbk - add PHASE parameter */
#endif
time -= TD; time -= TD;
if(time > PER) { if(time > PER) {
/* repeating signal - figure out where we are */ /* repeating signal - figure out where we are */

Loading…
Cancel
Save