Fix some valgrind warnings and display a real parameter as a real.

This patch fixes some technically benign problems found by valgrind,
but we may as well give the values a default to make sure things
work correctly. I believe that the default I choose is the
appropriate value for the context.

The other problem is that real valued (local)parameters should be
printed as a real value like a real variable, etc. Trying to
do this as a decimal with the string formatting was causing a
memory problem. I could have fixed the routine to handle this,
but the better solution was to just display things the right way.
This commit is contained in:
Cary R 2009-01-07 19:01:09 -08:00 committed by Stephen Williams
parent a2aff77ca2
commit 7ccc9d4484
2 changed files with 12 additions and 3 deletions

View File

@ -244,7 +244,8 @@ NetAssign_* PEIdent::elaborate_lval_net_word_(Design*des,
ivl_assert(*this, index_head.lsb == 0);
ivl_variable_type_t expr_type_tmp = IVL_VT_NO_TYPE;
bool unsized_flag_tmp;
// This not used, but it needs to have a default value.
bool unsized_flag_tmp = false;
index_head.msb->test_width(des, scope,
reg->vector_width(), reg->vector_width(),
expr_type_tmp,
@ -310,7 +311,8 @@ bool PEIdent::elaborate_lval_net_bit_(Design*des,
NetNet*reg = lv->sig();
ivl_variable_type_t expr_type_tmp = IVL_VT_NO_TYPE;
bool unsized_flag_tmp;
// This not used, but it needs to have a default value.
bool unsized_flag_tmp = false;
index_tail.msb->test_width(des, scope,
lv->lwidth(), lv->lwidth(),
expr_type_tmp,
@ -443,7 +445,8 @@ bool PEIdent::elaborate_lval_net_idx_(Design*des,
calculate_up_do_width_(des, scope, wid);
ivl_variable_type_t expr_type_tmp = IVL_VT_NO_TYPE;
bool unsized_flag_tmp;
// This not used, but it needs to have a default value.
bool unsized_flag_tmp = false;
index_tail.msb->test_width(des, scope,
wid, wid,
expr_type_tmp,

View File

@ -1992,6 +1992,12 @@ static char *get_display(unsigned int *rtnsz, struct strobe_cb_info *info)
fmt = strdup(value.value.str);
width = get_format(&result, fmt, info, &idx);
free(fmt);
} else if (vpi_get(vpiConstType, item) == vpiRealConst) {
value.format = vpiRealVal;
vpi_get_value(item, &value);
sprintf(buf, "%#g", value.value.real);
result = strdup(buf);
width = strlen(result);
} else {
width = get_numeric(&result, info, item);
}