From be5bfeb172b393ba269e9dec9c46270d63d062ad Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Tue, 11 Feb 2014 18:24:12 -0800 Subject: [PATCH] Elaborate widths of parameters correctly for unsigned values If there is no size in the parameter type declaration or on the value itself, then give the parameter value a minimum width of integer bits. --- net_design.cc | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/net_design.cc b/net_design.cc index 8f89b003a..a523bf4a4 100644 --- a/net_design.cc +++ b/net_design.cc @@ -483,6 +483,20 @@ void NetScope::evaluate_parameter_logic_(Design*des, param_ref_t cur) des->errors += 1; return; } + + // If the parameter has type or range information, then + // make sure the type is set right. Note that if the + // parameter doesn't have an explicit type or range, + // then it will get the signedness from the expression itself. + if (cur->second.type != IVL_VT_NO_TYPE) { + expr->cast_signed(cur->second.signed_flag); + } else if (cur->second.signed_flag) { + expr->cast_signed(true); + } + + if (!range_flag && !expr->has_width()) { + expr = pad_to_width(expr, integer_width, *expr); + } break; default: @@ -492,17 +506,8 @@ void NetScope::evaluate_parameter_logic_(Design*des, param_ref_t cur) des->errors += 1; return; } - (*cur).second.val = expr; - /* If the parameter has type or range information, then make - sure the type is set right. Note that if the parameter - doesn't have an explicit type or range, then it will get - the signedness from the expression itself. */ - if ((*cur).second.type != IVL_VT_NO_TYPE) { - (*cur).second.val->cast_signed((*cur).second.signed_flag); - } else if ((*cur).second.signed_flag) { - (*cur).second.val->cast_signed(true); - } + cur->second.val = expr; // If there are no value ranges to test the value against, // then we are done.