Skip to content

Commit 7dc3d30

Browse files
committed
Verilog: module port declarations with default value
This fixes the grammar to allow ANSI module port declarations that have a default value. This adds support for module ports (ANSI and non-ANSI) that have a default value to the type checker.
1 parent 0e0fa44 commit 7dc3d30

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/verilog/parser.y

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -899,14 +899,15 @@ ansi_port_declaration_brace:
899899

900900
// append to last one -- required to make
901901
// the grammar LR1
902-
| ansi_port_declaration_brace ',' port_identifier
902+
| ansi_port_declaration_brace ',' port_identifier ansi_port_initializer_opt
903903
{ $$=$1;
904904
exprt decl(ID_decl);
905905
decl.add_to_operands(std::move(stack_expr($3)));
906906
// grab the type and class from previous!
907907
const irept &prev=stack_expr($$).get_sub().back();
908908
decl.set(ID_type, prev.find(ID_type));
909909
decl.set(ID_class, prev.find(ID_class));
910+
decl.set(ID_value, stack_expr($4));
910911
stack_expr($$).move_to_sub(decl);
911912
}
912913
;
@@ -935,6 +936,7 @@ ansi_port_declaration:
935936
// and the unpacked_array_type goes onto the declarator.
936937
stack_expr($$).type() = std::move(stack_expr($1).type());
937938
addswap($2, ID_type, $3);
939+
stack_expr($2).set(ID_value, stack_expr($4));
938940
mto($$, $2); /* declarator */ }
939941
| variable_port_header port_identifier unpacked_dimension_brace ansi_port_initializer_opt
940942
{ init($$, ID_decl);
@@ -946,6 +948,7 @@ ansi_port_declaration:
946948
// and the unpacked_array_type goes onto the declarator.
947949
stack_expr($$).type() = std::move(stack_expr($1).type());
948950
addswap($2, ID_type, $3);
951+
stack_expr($2).set(ID_value, stack_expr($4));
949952
mto($$, $2); /* declarator */ }
950953
;
951954

0 commit comments

Comments
 (0)