From f7ba954ef74f320124f40698b7d8942f1ec65c66 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Fri, 18 May 2012 19:43:26 +0100 Subject: [PATCH] Fix for pr3527022. This patch adds support for an explicit range or type in a parameter declaration that is part of a module parameter port list. --- parse.y | 194 ++++++++++++-------------------------------------------- 1 file changed, 41 insertions(+), 153 deletions(-) diff --git a/parse.y b/parse.y index c067278a0..71a17b01a 100644 --- a/parse.y +++ b/parse.y @@ -1833,8 +1833,8 @@ block_item_decl { pform_make_events($2, @1.text, @1.first_line); } - | K_parameter parameter_assign_decl ';' - | K_localparam localparam_assign_decl ';' + | K_parameter param_type parameter_assign_list ';' + | K_localparam param_type localparam_assign_list ';' /* Blocks can have type declarations. */ @@ -1853,15 +1853,15 @@ block_item_decl yyerrok; } - | K_parameter error ';' - { yyerror(@1, "error: syntax error in parameter list."); - yyerrok; - } - | K_localparam error ';' - { yyerror(@1, "error: syntax error localparam list."); - yyerrok; - } - ; + | K_parameter error ';' + { yyerror(@1, "error: syntax error in parameter list."); + yyerrok; + } + | K_localparam error ';' + { yyerror(@1, "error: syntax error localparam list."); + yyerrok; + } + ; block_item_decls : block_item_decl @@ -3932,9 +3932,9 @@ module_parameter_port_list_opt ; module_parameter_port_list - : K_parameter parameter_assign + : K_parameter param_type parameter_assign | module_parameter_port_list ',' parameter_assign - | module_parameter_port_list ',' K_parameter parameter_assign + | module_parameter_port_list ',' K_parameter param_type parameter_assign ; module_item @@ -4474,19 +4474,15 @@ var_type : K_reg { $$ = NetNet::REG; } ; - /* In this rule we have matched the "parameter" keyword. The rule - generates a type (optional) and a list of assignments. */ - -parameter_assign_decl - : parameter_assign_list - | range - { param_active_range = $1; +param_type + : + { param_active_range = 0; param_active_signed = false; param_active_type = IVL_VT_LOGIC; } - parameter_assign_list - { param_active_range = 0; - param_active_signed = false; + | range + { param_active_range = $1; + param_active_signed = false; param_active_type = IVL_VT_LOGIC; } | K_signed @@ -4494,67 +4490,47 @@ parameter_assign_decl 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; param_active_type = IVL_VT_LOGIC; } - parameter_assign_list - { param_active_range = 0; - param_active_signed = false; - param_active_type = IVL_VT_LOGIC; - } | K_integer { param_active_range = make_range_from_width(integer_width); 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_time { param_active_range = make_range_from_width(64); param_active_signed = false; param_active_type = IVL_VT_LOGIC; } - parameter_assign_list - { param_active_range = 0; - param_active_signed = false; - param_active_type = IVL_VT_LOGIC; - } | real_or_realtime { param_active_range = 0; param_active_signed = true; param_active_type = IVL_VT_REAL; } - parameter_assign_list - { param_active_range = 0; - param_active_signed = false; - param_active_type = IVL_VT_LOGIC; - } | atom2_type { param_active_range = make_range_from_width($1); param_active_signed = true; param_active_type = IVL_VT_BOOL; } - parameter_assign_list - { param_active_range = 0; - param_active_signed = false; - param_active_type = IVL_VT_LOGIC; - } ; + /* parameter and localparam assignment lists are broken into + separate BNF so that I can call slightly different parameter + handling code. localparams parse the same as parameters, they + just behave differently when someone tries to override them. */ + parameter_assign_list - : parameter_assign - | parameter_assign_list ',' parameter_assign - ; + : parameter_assign + | parameter_assign_list ',' parameter_assign + ; + +localparam_assign_list + : localparam_assign + | localparam_assign_list ',' localparam_assign + ; parameter_assign : IDENTIFIER '=' expression parameter_value_ranges_opt @@ -4565,6 +4541,15 @@ parameter_assign } ; +localparam_assign + : IDENTIFIER '=' expression + { PExpr*tmp = $3; + pform_set_localparam(@1, lex_strings.make($1), param_active_type, + param_active_signed, param_active_range, tmp); + delete[]$1; + } + ; + parameter_value_ranges_opt : parameter_value_ranges { $$ = $1; } | { $$ = 0; } ; parameter_value_ranges @@ -4596,103 +4581,6 @@ value_range_expression from_exclude : K_from { $$ = false; } | K_exclude { $$ = true; } ; - /* Localparam assignments and assignment lists are broken into - separate BNF so that I can call slightly different parameter - handling code. They parse the same as parameters, they just - behave differently when someone tries to override them. */ - -localparam_assign - : IDENTIFIER '=' expression - { PExpr*tmp = $3; - pform_set_localparam(@1, lex_strings.make($1), - param_active_type, - param_active_signed, - param_active_range, tmp); - delete[]$1; - } - ; - -localparam_assign_decl - : localparam_assign_list - | range - { param_active_range = $1; - param_active_signed = false; - 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 - { 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; - param_active_type = IVL_VT_LOGIC; - } - localparam_assign_list - { param_active_range = 0; - param_active_signed = false; - param_active_type = IVL_VT_LOGIC; - } - | K_integer - { param_active_range = make_range_from_width(integer_width); - 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_time - { param_active_range = make_range_from_width(64); - param_active_signed = false; - param_active_type = IVL_VT_LOGIC; - } - localparam_assign_list - { param_active_range = 0; - param_active_signed = false; - param_active_type = IVL_VT_LOGIC; - } - | real_or_realtime - { param_active_range = 0; - param_active_signed = true; - param_active_type = IVL_VT_REAL; - } - localparam_assign_list - { param_active_range = 0; - param_active_signed = false; - param_active_type = IVL_VT_LOGIC; - } - | atom2_type - { param_active_range = make_range_from_width($1); - param_active_signed = true; - param_active_type = IVL_VT_BOOL; - } - localparam_assign_list - { param_active_range = 0; - param_active_signed = false; - param_active_type = IVL_VT_LOGIC; - } - ; - -localparam_assign_list - : localparam_assign - | localparam_assign_list ',' localparam_assign - ; - - - /* The parameters of a module instance can be overridden by writing a list of expressions in a syntax much like a delay list. (The difference being the list can have any length.) The pform that