From 54aae2c1c2b04974b7175b93d9f4b6f093e87e05 Mon Sep 17 00:00:00 2001 From: Cary R Date: Fri, 19 Oct 2007 11:21:19 -0700 Subject: [PATCH] Fix number to real mask generation The << operator may not be defined when the RHS is greater than or equal to the LHS width. To work around the problem the mask is incrementally generated. --- tgt-vvp/eval_real.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tgt-vvp/eval_real.c b/tgt-vvp/eval_real.c index 832c398c2..fccabfb90 100644 --- a/tgt-vvp/eval_real.c +++ b/tgt-vvp/eval_real.c @@ -111,10 +111,11 @@ static int draw_number_real(ivl_expr_t exp) int res = allocate_word(); const char*bits = ivl_expr_bits(exp); unsigned wid = ivl_expr_width(exp); - unsigned long mant = 0; + unsigned long mant = 0, mask = -1UL; int vexp = 0x1000; for (idx = 0 ; idx < wid ; idx += 1) { + mask <<= 1; if (bits[idx] == '1') mant |= 1 << idx; } @@ -129,7 +130,7 @@ static int draw_number_real(ivl_expr_t exp) mant variable. This would lead to spurious '1' bits in the high bits of mant that are masked by ~((-1UL)<