Properly pad results of function calls.

The elaborator improperly allowed user function call nodes to take on
the expression width requested of them. The result was that generated
code had junk pad bits in certain cases.
This commit is contained in:
Stephen Williams 2008-05-09 15:25:42 -07:00
parent a1495bb007
commit a33619a0f5
3 changed files with 8 additions and 5 deletions

View File

@ -1711,7 +1711,7 @@ NetProc* PAssign::elaborate(Design*des, NetScope*scope) const
netlist. The compound statement is exactly equivalent. */ netlist. The compound statement is exactly equivalent. */
if (delay || event_) { if (delay || event_) {
unsigned wid = lv->lwidth(); unsigned wid = count_lval_width(lv);
rv->set_width(wid); rv->set_width(wid);
rv = pad_to_width(rv, wid); rv = pad_to_width(rv, wid);

View File

@ -413,8 +413,10 @@ bool NetETernary::set_width(unsigned w, bool last_chance)
*/ */
bool NetEUFunc::set_width(unsigned wid, bool) bool NetEUFunc::set_width(unsigned wid, bool)
{ {
expr_width(wid); if (result_sig_->expr_width() == wid)
return true; return true;
else
return false;
} }
bool NetEUnary::set_width(unsigned w, bool) bool NetEUnary::set_width(unsigned w, bool)

View File

@ -82,8 +82,9 @@ static void show_function_call(ivl_expr_t net, unsigned ind)
const char*vt = vt_type_string(net); const char*vt = vt_type_string(net);
unsigned idx; unsigned idx;
fprintf(out, "%*s<%s %s function %s with %u arguments>\n", ind, "", fprintf(out, "%*s<%s %s function %s with %u arguments (width=%u)>\n",
vt, sign, ivl_scope_name(def), ivl_expr_parms(net)); ind, "", vt, sign, ivl_scope_name(def), ivl_expr_parms(net),
ivl_expr_width(net));
for (idx = 0 ; idx < ivl_expr_parms(net) ; idx += 1) for (idx = 0 ; idx < ivl_expr_parms(net) ; idx += 1)
show_expression(ivl_expr_parm(net,idx), ind+4); show_expression(ivl_expr_parm(net,idx), ind+4);