Add support for parameter declarations with type but no range.

The standard allows a parameter (or localparam) declaration of the
form "parameter signed my_param = ...". The parser currently rejects
this. A small adjustment is also required in the parameter evaluation
code to correctly apply the type.
This commit is contained in:
Martin Whitaker 2011-12-03 12:11:28 +00:00 committed by Cary R
parent 95e25ad40f
commit 37be84483c
2 changed files with 25 additions and 5 deletions

View File

@ -405,11 +405,11 @@ void NetScope::evaluate_parameter_logic_(Design*des, param_ref_t cur)
} }
(*cur).second.val = expr; (*cur).second.val = expr;
/* If the parameter has range information, then make /* If the parameter has type or range information, then make
sure the type is set right. Note that if the sure the type is set right. Note that if the parameter
parameter doesn't have an explicit range, then it doesn't have an explicit type or range, then it will get
will get the signedness from the expression itself. */ the signedness from the expression itself. */
if (range_flag) { if ((*cur).second.signed_flag || range_flag) {
/* If we have a real value convert it to an integer. */ /* If we have a real value convert it to an integer. */
if(NetECReal*tmp = dynamic_cast<NetECReal*>(expr)) { if(NetECReal*tmp = dynamic_cast<NetECReal*>(expr)) {
verinum nval(tmp->value().as_long64(), (unsigned)lv_width); verinum nval(tmp->value().as_long64(), (unsigned)lv_width);

20
parse.y
View File

@ -3312,6 +3312,16 @@ parameter_assign_decl
param_active_signed = false; param_active_signed = false;
param_active_type = IVL_VT_LOGIC; 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 | K_signed range
{ param_active_range = $2; { param_active_range = $2;
param_active_signed = true; param_active_signed = true;
@ -3427,6 +3437,16 @@ localparam_assign_decl
param_active_signed = false; param_active_signed = false;
param_active_type = IVL_VT_LOGIC; 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 | K_signed range
{ param_active_range = $2; { param_active_range = $2;
param_active_signed = true; param_active_signed = true;