@@ -785,23 +785,29 @@ module_port_input_declaration:
785785 TOK_INPUT net_port_type port_identifier unpacked_dimension_brace
786786 { init($$ , ID_decl);
787787 stack_expr ($$).set(ID_class, ID_input);
788- add_as_subtype (stack_type($4 ), stack_type($2 ));
789- addswap ($$, ID_type, $4 );
788+ // The net_port_type goes onto the declaration,
789+ // and the unpacked_array_type goes onto the declarator.
790+ addswap ($$, ID_type, $2 );
791+ addswap ($3 , ID_type, $4 );
790792 mto ($$, $3 ); }
791793 ;
792794
793795module_port_output_declaration :
794796 TOK_OUTPUT net_port_type port_identifier unpacked_dimension_brace
795797 { init($$ , ID_decl);
796798 stack_expr ($$).set(ID_class, ID_output);
797- add_as_subtype (stack_type($4 ), stack_type($2 ));
798- addswap ($$, ID_type, $4 );
799+ // The data_type goes onto the declaration,
800+ // and the unpacked_array_type goes onto the declarator.
801+ addswap ($$, ID_type, $2 );
802+ addswap ($3 , ID_type, $4 );
799803 mto ($$, $3 ); }
800804 | TOK_OUTPUT data_type port_identifier unpacked_dimension_brace
801805 { init($$ , ID_decl);
802806 stack_expr ($$).set(ID_class, ID_output_register);
803- add_as_subtype (stack_type($4 ), stack_type($2 ));
804- addswap ($$, ID_type, $4 );
807+ // The data_type goes onto the declaration,
808+ // and the unpacked_array_type goes onto the declarator.
809+ addswap ($$, ID_type, $2 );
810+ addswap ($3 , ID_type, $4 );
805811 mto ($$, $3 ); }
806812 ;
807813
@@ -1132,12 +1138,7 @@ genvar_declaration:
11321138 ;
11331139
11341140net_declaration :
1135- net_type drive_strength_opt vectored_scalared_opt data_type_or_implicit delay3_opt list_of_net_names ' ;'
1136- { init($$ , ID_decl);
1137- addswap ($$, ID_class, $1 );
1138- addswap ($$, ID_type, $4 );
1139- swapop ($$, $6 ); }
1140- | net_type drive_strength_opt vectored_scalared_opt data_type_or_implicit delay3_opt list_of_net_decl_assignments ' ;'
1141+ net_type drive_strength_opt vectored_scalared_opt data_type_or_implicit delay3_opt list_of_net_decl_assignments ' ;'
11411142 { init($$ , ID_decl);
11421143 addswap ($$, ID_class, $1 );
11431144 addswap ($$, ID_type, $4 );
@@ -1167,21 +1168,6 @@ vectored_scalared_opt:
11671168 | TOK_SCALARED { init($$ , " scalared" ); }
11681169 ;
11691170
1170- list_of_net_names :
1171- net_name
1172- { init($$ ); mto($$ , $1 ); }
1173- | list_of_net_names ' ,' net_name
1174- { $$ =$1 ; mto($$ , $3 ); }
1175- ;
1176-
1177- net_name : net_identifier packed_dimension_brace
1178- {
1179- $$ =$1 ;
1180- stack_expr ($$).id(ID_declarator);
1181- addswap ($$, ID_type, $2 );
1182- }
1183- ;
1184-
11851171list_of_net_decl_assignments :
11861172 net_decl_assignment
11871173 { init($$ ); mto($$ , $1 ); }
@@ -1244,7 +1230,9 @@ data_type:
12441230 | TOK_VIRTUAL interface_opt interface_identifier
12451231 { init($$ , " virtual_interface" ); }
12461232 | /* scope_opt*/ type_identifier packed_dimension_brace
1247- { $$ = $1 ; stack_expr($$ ).id(ID_typedef_type); }
1233+ { stack_expr($1 ).id(ID_typedef_type);
1234+ add_as_subtype (stack_type($2 ), stack_type($1 ));
1235+ $$ = $2 ; }
12481236// | class_type
12491237 | TOK_EVENT
12501238 { init($$ , ID_event); }
@@ -1659,8 +1647,16 @@ range: part_select;
16591647// System Verilog standard 1800-2017
16601648// A.2.4 Declaration assignments
16611649
1662- net_decl_assignment : net_identifier ' =' expression
1663- { $$ = $1 ; stack_expr($$ ).id(ID_declarator); addswap($$ , ID_value, $3 ); }
1650+ net_decl_assignment :
1651+ net_identifier unpacked_dimension_brace
1652+ { $$ = $1 ;
1653+ stack_expr ($$).id(ID_declarator);
1654+ addswap ($$, ID_type, $2 ); }
1655+ | net_identifier unpacked_dimension_brace ' =' expression
1656+ { $$ = $1 ;
1657+ stack_expr ($$).id(ID_declarator);
1658+ addswap ($$, ID_type, $2 );
1659+ addswap ($$, ID_value, $4 ); }
16641660 ;
16651661
16661662variable_decl_assignment :
@@ -1693,7 +1689,7 @@ packed_dimension_opt:
16931689
16941690packed_dimension :
16951691 ' [' const_expression TOK_COLON const_expression ' ]'
1696- { init($$ , ID_array );
1692+ { init($$ , ID_verilog_packed_array );
16971693 stack_type ($$).add_subtype().make_nil();
16981694 exprt &range=static_cast <exprt &>(stack_type($$ ).add(ID_range));
16991695 range.add_to_operands(stack_expr($2 ));
@@ -1703,13 +1699,14 @@ packed_dimension:
17031699
17041700unpacked_dimension :
17051701 ' [' const_expression TOK_COLON const_expression ' ]'
1706- { init($$ , ID_array );
1702+ { init($$ , ID_verilog_unpacked_array );
17071703 stack_type ($$).add_subtype().make_nil();
17081704 exprt &range=static_cast <exprt &>(stack_type($$ ).add(ID_range));
17091705 range.add_to_operands(stack_expr($2 ));
17101706 range.add_to_operands(stack_expr($4 )); }
17111707 | ' [' expression ' ]'
1712- { init($$ , ID_array);
1708+ { // starts at index 0
1709+ init ($$, ID_verilog_unpacked_array);
17131710 stack_type ($$).add_subtype().make_nil();
17141711 stack_type ($$).set(ID_size, std::move(stack_expr($2 )));
17151712 }
0 commit comments