@@ -785,23 +785,29 @@ module_port_input_declaration:
785
785
TOK_INPUT net_port_type port_identifier unpacked_dimension_brace
786
786
{ init($$ , ID_decl);
787
787
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 );
790
792
mto ($$, $3 ); }
791
793
;
792
794
793
795
module_port_output_declaration :
794
796
TOK_OUTPUT net_port_type port_identifier unpacked_dimension_brace
795
797
{ init($$ , ID_decl);
796
798
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 );
799
803
mto ($$, $3 ); }
800
804
| TOK_OUTPUT data_type port_identifier unpacked_dimension_brace
801
805
{ init($$ , ID_decl);
802
806
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 );
805
811
mto ($$, $3 ); }
806
812
;
807
813
@@ -1132,12 +1138,7 @@ genvar_declaration:
1132
1138
;
1133
1139
1134
1140
net_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 ' ;'
1141
1142
{ init($$ , ID_decl);
1142
1143
addswap ($$, ID_class, $1 );
1143
1144
addswap ($$, ID_type, $4 );
@@ -1167,21 +1168,6 @@ vectored_scalared_opt:
1167
1168
| TOK_SCALARED { init($$ , " scalared" ); }
1168
1169
;
1169
1170
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
-
1185
1171
list_of_net_decl_assignments :
1186
1172
net_decl_assignment
1187
1173
{ init($$ ); mto($$ , $1 ); }
@@ -1244,7 +1230,9 @@ data_type:
1244
1230
| TOK_VIRTUAL interface_opt interface_identifier
1245
1231
{ init($$ , " virtual_interface" ); }
1246
1232
| /* 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 ; }
1248
1236
// | class_type
1249
1237
| TOK_EVENT
1250
1238
{ init($$ , ID_event); }
@@ -1659,8 +1647,16 @@ range: part_select;
1659
1647
// System Verilog standard 1800-2017
1660
1648
// A.2.4 Declaration assignments
1661
1649
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 ); }
1664
1660
;
1665
1661
1666
1662
variable_decl_assignment :
@@ -1693,7 +1689,7 @@ packed_dimension_opt:
1693
1689
1694
1690
packed_dimension :
1695
1691
' [' const_expression TOK_COLON const_expression ' ]'
1696
- { init($$ , ID_array );
1692
+ { init($$ , ID_verilog_packed_array );
1697
1693
stack_type ($$).add_subtype().make_nil();
1698
1694
exprt &range=static_cast <exprt &>(stack_type($$ ).add(ID_range));
1699
1695
range.add_to_operands(stack_expr($2 ));
@@ -1703,13 +1699,14 @@ packed_dimension:
1703
1699
1704
1700
unpacked_dimension :
1705
1701
' [' const_expression TOK_COLON const_expression ' ]'
1706
- { init($$ , ID_array );
1702
+ { init($$ , ID_verilog_unpacked_array );
1707
1703
stack_type ($$).add_subtype().make_nil();
1708
1704
exprt &range=static_cast <exprt &>(stack_type($$ ).add(ID_range));
1709
1705
range.add_to_operands(stack_expr($2 ));
1710
1706
range.add_to_operands(stack_expr($4 )); }
1711
1707
| ' [' expression ' ]'
1712
- { init($$ , ID_array);
1708
+ { // starts at index 0
1709
+ init ($$, ID_verilog_unpacked_array);
1713
1710
stack_type ($$).add_subtype().make_nil();
1714
1711
stack_type ($$).set(ID_size, std::move(stack_expr($2 )));
1715
1712
}
0 commit comments