diff --git a/tgt-vvp/eval_expr.c b/tgt-vvp/eval_expr.c index a2c05d263..84449a883 100644 --- a/tgt-vvp/eval_expr.c +++ b/tgt-vvp/eval_expr.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2009 Stephen Williams (steve@icarus.com) + * Copyright (c) 2001-2010 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -1989,6 +1989,7 @@ static struct vector_info draw_realnum_expr(ivl_expr_t exp, unsigned wid) struct vector_info res; double val = ivl_expr_dvalue(exp); long ival = val; + assert(wid <= 8*sizeof(long)); unsigned addr, run, idx; int bit; @@ -2003,11 +2004,11 @@ static struct vector_info draw_realnum_expr(ivl_expr_t exp, unsigned wid) addr = res.base; run = 1; bit = ival & 1; - ival >>= 1LL; + ival >>= 1; for (idx = 1 ; idx < wid ; idx += 1) { int next_bit = ival & 1; - ival >>= 1LL; + ival >>= 1; if (next_bit == bit) { run += 1; diff --git a/tgt-vvp/vvp_process.c b/tgt-vvp/vvp_process.c index 3fb3cd384..c8700f891 100644 --- a/tgt-vvp/vvp_process.c +++ b/tgt-vvp/vvp_process.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2009 Stephen Williams (steve@icarus.com) + * Copyright (c) 2001-2010 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -832,10 +832,39 @@ static int show_stmt_assign_nb(ivl_statement_t net) } - { struct vector_info res = draw_eval_expr(rval, 0); - unsigned wid = res.wid; + { struct vector_info res; + unsigned wid; unsigned lidx; unsigned cur_rbit = 0; + /* Handle the special case that the expression is a real + value. Evaluate the real expression, then convert the + result to a vector. */. + if (ivl_expr_value(rval) == IVL_VT_REAL) { + int word = draw_eval_real(rval); + /* This is the accumulated with of the l-value of the + assignment. */ + wid = ivl_stmt_lwidth(net); + + res.base = allocate_vector(wid); + res.wid = wid; + + if (res.base == 0) { + fprintf(stderr, "%s:%u: vvp.tgt error: " + "Unable to allocate %u thread bits for " + "r-value expression.\n", ivl_expr_file(rval), + ivl_expr_lineno(rval), wid); + vvp_errors += 1; + } + + fprintf(vvp_out, " %%cvt/vr %u, %d, %u;\n", + res.base, word, res.wid); + + clr_word(word); + + } else { + res = draw_eval_expr(rval, 0); + wid = res.wid; + } for (lidx = 0 ; lidx < ivl_stmt_lvals(net) ; lidx += 1) { unsigned bit_limit = wid - cur_rbit;