From 1755ee862659f9309712f803cf567d5197ff621a Mon Sep 17 00:00:00 2001 From: rlar Date: Mon, 22 Nov 2010 18:54:46 +0000 Subject: [PATCH] d_source, bug fix --- ChangeLog | 25 +++++++++++++++++++++++ src/xspice/icm/digital/d_source/cfunc.mod | 3 ++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 25f6ca3b9..044f522f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,28 @@ +2010-11-22 Robert Larice + * src/xspice/icm/digital/d_source/cfunc.mod : + d_source, bug fix + + The recently added d_source test-case + did reveal a bug in the implementation of d_source. + The test-case fails in the non-debug version of ngspice. + In src/xspice/icm/digital/d_source/cfunc.mod the following + floating point identity comparison won't match. + >> if ( TIME == test_double ) { /* Breakpoint reached */ + This is, because test_double, though declared as double, + will be calculated in extended precision (80bit) + This phenomenon is well known, see for example + http://gcc.gnu.org/bugzilla/show_bug.cgi?id=323 + This `bug workaround' fixes the problem + by declaring the `test_double' to be a `void' double, + which enforces truncation of the 80bit value, + when it is used in the comparison. + This fix will cause the test-case to pass. + Yet unfortunately DCtran() doesn't seem to process + time-Breakpoints with full 64bit precision + (search for AlmostEqualUlps()) + which makes this whole business a very doubtful thing, + doomed to randomly fail <<<<----- !!!!!!! + 2010-11-21 Robert Larice * src/xspice/icm/digital/d_ram/cfunc.mod , * src/xspice/icm/digital/d_source/cfunc.mod , diff --git a/src/xspice/icm/digital/d_source/cfunc.mod b/src/xspice/icm/digital/d_source/cfunc.mod index 9a6b3c07e..0f899ed34 100644 --- a/src/xspice/icm/digital/d_source/cfunc.mod +++ b/src/xspice/icm/digital/d_source/cfunc.mod @@ -982,7 +982,8 @@ void cm_d_source(ARGS) double *timepoints, /* the storage array for the timepoints...this will have size equal to "depth" */ - *timepoints_old, /* the storage array for the old timepoints */ + *timepoints_old; /* the storage array for the old timepoints */ + volatile double /* enforce 64 bit precision, (equality comparison) */ test_double; /* test variable for doubles */