NB-assign needs to convert reals at the l-value width.
This patch mimics what was done for normal assignments to get the width correct for nonblocking assignments when converting a real r-value to a l-value vector.
This commit is contained in:
parent
15a657c83b
commit
d5c10af4f4
|
|
@ -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
|
* This source code is free software; you can redistribute it
|
||||||
* and/or modify it in source code form under the terms of the GNU
|
* 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;
|
struct vector_info res;
|
||||||
double val = ivl_expr_dvalue(exp);
|
double val = ivl_expr_dvalue(exp);
|
||||||
long ival = val;
|
long ival = val;
|
||||||
|
assert(wid <= 8*sizeof(long));
|
||||||
|
|
||||||
unsigned addr, run, idx;
|
unsigned addr, run, idx;
|
||||||
int bit;
|
int bit;
|
||||||
|
|
@ -2003,11 +2004,11 @@ static struct vector_info draw_realnum_expr(ivl_expr_t exp, unsigned wid)
|
||||||
addr = res.base;
|
addr = res.base;
|
||||||
run = 1;
|
run = 1;
|
||||||
bit = ival & 1;
|
bit = ival & 1;
|
||||||
ival >>= 1LL;
|
ival >>= 1;
|
||||||
|
|
||||||
for (idx = 1 ; idx < wid ; idx += 1) {
|
for (idx = 1 ; idx < wid ; idx += 1) {
|
||||||
int next_bit = ival & 1;
|
int next_bit = ival & 1;
|
||||||
ival >>= 1LL;
|
ival >>= 1;
|
||||||
|
|
||||||
if (next_bit == bit) {
|
if (next_bit == bit) {
|
||||||
run += 1;
|
run += 1;
|
||||||
|
|
|
||||||
|
|
@ -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
|
* This source code is free software; you can redistribute it
|
||||||
* and/or modify it in source code form under the terms of the GNU
|
* 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);
|
{ struct vector_info res;
|
||||||
unsigned wid = res.wid;
|
unsigned wid;
|
||||||
unsigned lidx;
|
unsigned lidx;
|
||||||
unsigned cur_rbit = 0;
|
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) {
|
for (lidx = 0 ; lidx < ivl_stmt_lvals(net) ; lidx += 1) {
|
||||||
unsigned bit_limit = wid - cur_rbit;
|
unsigned bit_limit = wid - cur_rbit;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue