From 49066f1601b0a03520daac5a012e72b293c83f51 Mon Sep 17 00:00:00 2001 From: Maciej Kurc Date: Wed, 5 Jun 2019 16:28:45 +0200 Subject: [PATCH] Added support for parsing attributes on port connections Signed-off-by: Maciej Kurc (cherry picked from commit e6fa2625a4abe23f7f934885a70334d030c274a4) --- parse.y | 64 ++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 17 deletions(-) diff --git a/parse.y b/parse.y index aa985085b..b3495a0f0 100644 --- a/parse.y +++ b/parse.y @@ -602,6 +602,7 @@ static void current_function_set_statement(const YYLTYPE&loc, vector %type modport_simple_port port_name parameter_value_byname %type port_name_list parameter_value_byname_list +%type port_conn_expression_list_with_nuls %type attribute %type attribute_list attribute_instance_list attribute_list_opt @@ -3897,7 +3898,7 @@ function_item /* A gate_instance is a module instantiation or a built in part type. In any case, the gate has a set of connections to ports. */ gate_instance - : IDENTIFIER '(' expression_list_with_nuls ')' + : IDENTIFIER '(' port_conn_expression_list_with_nuls ')' { lgate*tmp = new lgate; tmp->name = $1; tmp->parms = $3; @@ -3907,7 +3908,7 @@ gate_instance $$ = tmp; } - | IDENTIFIER dimensions '(' expression_list_with_nuls ')' + | IDENTIFIER dimensions '(' port_conn_expression_list_with_nuls ')' { lgate*tmp = new lgate; list*rng = $2; tmp->name = $1; @@ -3922,7 +3923,7 @@ gate_instance $$ = tmp; } - | '(' expression_list_with_nuls ')' + | '(' port_conn_expression_list_with_nuls ')' { lgate*tmp = new lgate; tmp->name = ""; tmp->parms = $2; @@ -5482,34 +5483,38 @@ port_opt looking for the ports of a module declaration. */ port_name - : '.' IDENTIFIER '(' expression ')' + : attribute_list_opt '.' IDENTIFIER '(' expression ')' { named_pexpr_t*tmp = new named_pexpr_t; - tmp->name = lex_strings.make($2); - tmp->parm = $4; - delete[]$2; + tmp->name = lex_strings.make($3); + tmp->parm = $5; + delete[]$3; + delete $1; $$ = tmp; } - | '.' IDENTIFIER '(' error ')' + | attribute_list_opt '.' IDENTIFIER '(' error ')' { yyerror(@3, "error: invalid port connection expression."); named_pexpr_t*tmp = new named_pexpr_t; - tmp->name = lex_strings.make($2); + tmp->name = lex_strings.make($3); tmp->parm = 0; - delete[]$2; + delete[]$3; + delete $1; $$ = tmp; } - | '.' IDENTIFIER '(' ')' + | attribute_list_opt '.' IDENTIFIER '(' ')' { named_pexpr_t*tmp = new named_pexpr_t; - tmp->name = lex_strings.make($2); + tmp->name = lex_strings.make($3); tmp->parm = 0; - delete[]$2; + delete[]$3; + delete $1; $$ = tmp; } - | '.' IDENTIFIER + | attribute_list_opt '.' IDENTIFIER { named_pexpr_t*tmp = new named_pexpr_t; - tmp->name = lex_strings.make($2); - tmp->parm = new PEIdent(lex_strings.make($2), true); + tmp->name = lex_strings.make($3); + tmp->parm = new PEIdent(lex_strings.make($3), true); FILE_NAME(tmp->parm, @1); - delete[]$2; + delete[]$3; + delete $1; $$ = tmp; } | K_DOTSTAR @@ -5535,6 +5540,31 @@ port_name_list } ; +port_conn_expression_list_with_nuls + : port_conn_expression_list_with_nuls ',' attribute_list_opt expression + { list*tmp = $1; + tmp->push_back($4); + delete $3; + $$ = tmp; + } + | attribute_list_opt expression + { list*tmp = new list; + tmp->push_back($2); + delete $1; + $$ = tmp; + } + | + { list*tmp = new list; + tmp->push_back(0); + $$ = tmp; + } + | port_conn_expression_list_with_nuls ',' + { list*tmp = $1; + tmp->push_back(0); + $$ = tmp; + } + ; + /* A port reference is an internal (to the module) name of the port, possibly with a part of bit select to attach it to specific bits