From aa939685738bbe884e1e7728727c1a0b90b369fc Mon Sep 17 00:00:00 2001 From: pnenzi Date: Sat, 19 Dec 2009 18:15:03 +0000 Subject: [PATCH] Fixed bug in time computation for vsrc and isrc with xspice extensions. --- ChangeLog | 5 +++++ src/spicelib/devices/isrc/isrcacct.c | 16 ++++++++++++---- src/spicelib/devices/vsrc/vsrcacct.c | 12 ++++++++++-- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 25241cedc..f91f7e9b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-12-19 Paolo Nenzi + * src/spicelib/devices/isrc/isrcacct.c, src/spicelib/devices/vsrc/vsrcacct.c: + fixed bug reported by Holger. "time" value in accept routine was incorrectly + computed when xspice extensions were compiled in. + 2009-12-19 Holger Vogt * main.c, inpcom.c: source file path added as additional search path for opening .include files (MS Windows only). diff --git a/src/spicelib/devices/isrc/isrcacct.c b/src/spicelib/devices/isrc/isrcacct.c index 3daf1a763..5bd1acf12 100644 --- a/src/spicelib/devices/isrc/isrcacct.c +++ b/src/spicelib/devices/isrc/isrcacct.c @@ -44,7 +44,7 @@ ISRCaccept(CKTcircuit *ckt, GENmodel *inModel) /* gtri - begin - wbk - add PHASE parameter */ #ifdef XSPICE - double PHASE; + double PHASE; double phase; double deltat; double basephase; @@ -69,7 +69,16 @@ ISRCaccept(CKTcircuit *ckt, GENmodel *inModel) #ifdef XSPICE PHASE = here->ISRCfunctionOrder > 8 ? here->ISRCcoeffs[7] : 0.0; - +#endif + /* offset time by delay and limit to zero */ + time = ckt->CKTtime - TD; + +#ifdef XSPICE + if(time < 0.0) + time = 0.0; +#endif + +#ifdef XSPICE /* normalize phase to 0 - 2PI */ phase = PHASE * M_PI / 180.0; basephase = 2 * M_PI * floor(phase / (2 * M_PI)); @@ -81,8 +90,7 @@ ISRCaccept(CKTcircuit *ckt, GENmodel *inModel) #endif /* gtri - end - wbk - add PHASE parameter */ - /* offset time by delay */ - time = ckt->CKTtime - TD; + diff --git a/src/spicelib/devices/vsrc/vsrcacct.c b/src/spicelib/devices/vsrc/vsrcacct.c index a182de113..61c7b7866 100644 --- a/src/spicelib/devices/vsrc/vsrcacct.c +++ b/src/spicelib/devices/vsrc/vsrcacct.c @@ -70,7 +70,15 @@ VSRCaccept(CKTcircuit *ckt, GENmodel *inModel) #ifdef XSPICE PHASE = here->VSRCfunctionOrder > 8 ? here->VSRCcoeffs[7] : 0.0; - +#endif + /* offset time by delay and limit to zero */ + time = ckt->CKTtime - TD; +#ifdef XSPICE + if(time < 0.0) + time = 0.0; +#endif + +#ifdef XSPICE /* normalize phase to 0 - 2PI */ phase = PHASE * M_PI / 180.0; basephase = 2 * M_PI * floor(phase / (2 * M_PI)); @@ -82,7 +90,7 @@ VSRCaccept(CKTcircuit *ckt, GENmodel *inModel) #endif /* gtri - end - wbk - add PHASE parameter */ - time = ckt->CKTtime - TD; + if(time >= PER) { /* repeating signal - figure out where we are */