diff --git a/elab_scope.cc b/elab_scope.cc index 295597e46..69afc212a 100644 --- a/elab_scope.cc +++ b/elab_scope.cc @@ -150,19 +150,6 @@ static void elaborate_parm_item_(perm_string name, return; } - if (signed_flag) { - /* If explicitly signed, then say so. */ - val->cast_signed(true); - } else if (cur.msb) { - /* If there is a range, then the signedness comes - from the type and not the expression. */ - val->cast_signed(signed_flag); - } else { - /* otherwise, let the expression describe - itself. */ - signed_flag = val->has_sign(); - } - val = scope->set_parameter(name, val, cur.type, msb, lsb, signed_flag, range_list, cur); delete val; diff --git a/net_design.cc b/net_design.cc index cded937b8..2d56b1bf9 100644 --- a/net_design.cc +++ b/net_design.cc @@ -389,10 +389,10 @@ void NetScope::evaluate_parameter_logic_(Design*des, param_ref_t cur) return; } - /* If the parameter has range information, then make - sure the value is set right. Note that if the - parameter doesn't have an explicit range, then it - will get the signedness from the expression itself. */ + /* 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 (range_flag) { unsigned long wid = (msb >= lsb)? msb - lsb : lsb - msb; wid += 1; @@ -420,6 +420,8 @@ void NetScope::evaluate_parameter_logic_(Design*des, param_ref_t cur) val = new NetEConst(tmp); (*cur).second.expr = expr = val; } + } else if ((*cur).second.signed_flag) { + (*cur).second.expr->cast_signed(true); } // If there are no value ranges to test the value against, diff --git a/parse.y b/parse.y index 076c5788e..003ea90a9 100644 --- a/parse.y +++ b/parse.y @@ -2635,6 +2635,16 @@ parameter_assign_decl param_active_signed = false; param_active_type = IVL_VT_LOGIC; } + | K_signed + { param_active_range = 0; + param_active_signed = true; + param_active_type = IVL_VT_LOGIC; + } + parameter_assign_list + { param_active_range = 0; + param_active_signed = false; + param_active_type = IVL_VT_LOGIC; + } | K_signed range { param_active_range = $2; param_active_signed = true; @@ -2764,6 +2774,16 @@ localparam_assign_decl param_active_signed = false; param_active_type = IVL_VT_LOGIC; } + | K_signed + { param_active_range = 0; + param_active_signed = true; + param_active_type = IVL_VT_LOGIC; + } + localparam_assign_list + { param_active_range = 0; + param_active_signed = false; + param_active_type = IVL_VT_LOGIC; + } | K_signed range { param_active_range = $2; param_active_signed = true;