Fix code generation for signed numbers in real expressions.

This commit is contained in:
steve 2006-10-11 00:19:04 +00:00
parent 0c6bb476ea
commit 5c2c5453ac
1 changed files with 15 additions and 2 deletions

View File

@ -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<<wid) - 1UL);
vexp |= 0x4000;
}
fprintf(vvp_out, " %%loadi/wr %d, %lu, %d; load(num)= %c%lu\n",
res, mant, vexp, (vexp&0x4000)? '-' : '+', mant);
return res;
}
@ -298,6 +308,9 @@ int draw_eval_real(ivl_expr_t exp)
/*
* $Log: eval_real.c,v $
* Revision 1.11.2.1 2006/10/11 00:19:04 steve
* Fix code generation for signed numbers in real expressions.
*
* Revision 1.11 2004/10/04 01:10:57 steve
* Clean up spurious trailing white space.
*