From 1a41ac31453d0be9c63e36864105aa3ce5f9850d Mon Sep 17 00:00:00 2001 From: Cary R Date: Wed, 23 Jul 2008 09:36:25 -0700 Subject: [PATCH] Update real to int conversion: -inf is 'b0 not 'b1 like +inf. The new real to int conversion was incorrectly setting the bits for minus infinity to all ones. This is incorrect in a two's complement encoding where the largest negative number would be a leading 1 followed by an infinite number of zeros. --- vvp/vvp_net.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vvp/vvp_net.cc b/vvp/vvp_net.cc index f038777a2..f77850c3e 100644 --- a/vvp/vvp_net.cc +++ b/vvp/vvp_net.cc @@ -373,9 +373,10 @@ vvp_vector4_t::vvp_vector4_t(unsigned size, double val) return; } - /* We return 'b1 for + or - infinity. */ + /* We return 'b1 for + infinity or 'b0 for - infinity. */ if (val && (val == 0.5*val)) { - allocate_words_(size, WORD_1_ABITS, WORD_1_BBITS); + if (val > 0) allocate_words_(size, WORD_1_ABITS, WORD_1_BBITS); + else allocate_words_(size, WORD_0_ABITS, WORD_0_BBITS); return; }