From c2fb0224ed2d7ecdffa7fc99fdf5c737a256d8c0 Mon Sep 17 00:00:00 2001 From: sjborley Date: Sat, 15 Oct 2005 13:53:58 +0000 Subject: [PATCH] Implemented patches supplied by Andreas Unger . Fixes XSpice bug; variable PER was being used before initialisation. --- src/spicelib/devices/isrc/isrcload.c | 32 ++++++++++++++-------------- src/spicelib/devices/vsrc/vsrcload.c | 29 +++++++++++++------------ 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/src/spicelib/devices/isrc/isrcload.c b/src/spicelib/devices/isrc/isrcload.c index 1d3c820b0..ede0d2bf4 100644 --- a/src/spicelib/devices/isrc/isrcload.c +++ b/src/spicelib/devices/isrc/isrcload.c @@ -2,6 +2,7 @@ Copyright 1990 Regents of the University of California. All rights reserved. Author: 1985 Thomas L. Quarles Modified: 2000 Alansfixes +$Id$ **********/ #include "ngspice.h" @@ -55,27 +56,12 @@ ISRCload(GENmodel *inModel, CKTcircuit *ckt) case PULSE: { double V1, V2, TD, TR, TF, PW, PER; 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]; V2 = here->ISRCcoeffs[1]; TD = here->ISRCfunctionOrder > 2 @@ -92,7 +78,21 @@ ISRCload(GENmodel *inModel, CKTcircuit *ckt) PER = here->ISRCfunctionOrder > 6 && here->ISRCcoeffs[6] != 0.0 ? 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; if(time > PER) { diff --git a/src/spicelib/devices/vsrc/vsrcload.c b/src/spicelib/devices/vsrc/vsrcload.c index e173a8f00..02e3e03ed 100644 --- a/src/spicelib/devices/vsrc/vsrcload.c +++ b/src/spicelib/devices/vsrc/vsrcload.c @@ -2,6 +2,7 @@ Copyright 1990 Regents of the University of California. All rights reserved. Author: 1985 Thomas L. Quarles Modified: 2000 AlansFixes +$Id$ **********/ #include "ngspice.h" @@ -69,21 +70,7 @@ VSRCload(GENmodel *inModel, CKTcircuit *ckt) double phase; double deltat; 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 -/* gtri - end - wbk - add PHASE parameter */ - V1 = here->VSRCcoeffs[0]; V2 = here->VSRCcoeffs[1]; TD = here->VSRCfunctionOrder > 2 @@ -100,7 +87,21 @@ VSRCload(GENmodel *inModel, CKTcircuit *ckt) PER = here->VSRCfunctionOrder > 6 && here->VSRCcoeffs[6] != 0.0 ? 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; if(time > PER) { /* repeating signal - figure out where we are */