From 5c2c5453ac4b9a4554991274f88e2d737a15406d Mon Sep 17 00:00:00 2001 From: steve Date: Wed, 11 Oct 2006 00:19:04 +0000 Subject: [PATCH] Fix code generation for signed numbers in real expressions. --- tgt-vvp/eval_real.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tgt-vvp/eval_real.c b/tgt-vvp/eval_real.c index 6e9ef4e3e..c5be1b35f 100644 --- a/tgt-vvp/eval_real.c +++ b/tgt-vvp/eval_real.c @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: eval_real.c,v 1.11 2004/10/04 01:10:57 steve Exp $" +#ident "$Id: eval_real.c,v 1.11.2.1 2006/10/11 00:19:04 steve Exp $" #endif /* @@ -108,13 +108,23 @@ static int draw_number_real(ivl_expr_t exp) const char*bits = ivl_expr_bits(exp); unsigned wid = ivl_expr_width(exp); unsigned long mant = 0; + int vexp = 0x1000; for (idx = 0 ; idx < wid ; idx += 1) { if (bits[idx] == '1') mant |= 1 << idx; } - fprintf(vvp_out, " %%loadi/wr %d, %lu, 4096;\n", res, mant); + /* If this is actually a negative number, then get the + positive equivilent, and set the sign bit in the exponent + field. */ + if (ivl_expr_signed(exp) && (bits[wid-1] == '1')) { + mant = (0-mant) & ((1UL<