From e6fa2625a4abe23f7f934885a70334d030c274a4 Mon Sep 17 00:00:00 2001 From: Maciej Kurc Date: Wed, 5 Jun 2019 16:28:45 +0200 Subject: [PATCH 1/2] Added support for parsing attributes on port connections Signed-off-by: Maciej Kurc --- parse.y | 64 ++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 17 deletions(-) diff --git a/parse.y b/parse.y index 76947fd03..c22e299e9 100644 --- a/parse.y +++ b/parse.y @@ -597,6 +597,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 @@ -3922,7 +3923,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; @@ -3932,7 +3933,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; @@ -3947,7 +3948,7 @@ gate_instance $$ = tmp; } - | '(' expression_list_with_nuls ')' + | '(' port_conn_expression_list_with_nuls ')' { lgate*tmp = new lgate; tmp->name = ""; tmp->parms = $2; @@ -5471,34 +5472,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 @@ -5524,6 +5529,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 From b619b43ddd2763a31b3fccc2300707929719172f Mon Sep 17 00:00:00 2001 From: Maciej Kurc Date: Wed, 5 Jun 2019 16:42:52 +0200 Subject: [PATCH 2/2] Added support for parsing attributes on function calls Signed-off-by: Maciej Kurc --- parse.y | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/parse.y b/parse.y index c22e299e9..675487014 100644 --- a/parse.y +++ b/parse.y @@ -3558,11 +3558,12 @@ expr_primary function call. If a system identifier, then a system function call. It can also be a call to a class method (function). */ - | hierarchy_identifier '(' expression_list_with_nuls ')' - { list*expr_list = $3; + | hierarchy_identifier attribute_list_opt '(' expression_list_with_nuls ')' + { list*expr_list = $4; strip_tail_items(expr_list); PECallFunction*tmp = pform_make_call_function(@1, *$1, *expr_list); delete $1; + delete $2; $$ = tmp; } | implicit_class_handle '.' hierarchy_identifier '(' expression_list_with_nuls ')'