Skip to content

Commit 88381b0

Browse files
authored
Merge pull request #465 from diffblue/const1
Verilog: const variable declarations
2 parents a852492 + af4857c commit 88381b0

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

regression/verilog/const/const1.desc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
const1.sv
3+
4+
^no properties$
5+
^EXIT=10$
6+
^SIGNAL=0$
7+
--
8+
^warning: ignoring

regression/verilog/const/const1.sv

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module main;
2+
const bit my_true2 = 1;
3+
const var my_true3 = 1;
4+
const logic my_true4 = 1;
5+
endmodule

src/verilog/parser.y

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,20 +1110,25 @@ part_select:
11101110
// TOK_VAR is optional, but footnote 10 in IEEE 1800-2017 requires it
11111111
// when the data_type is omitted. We split the rule in the standard into two.
11121112
data_declaration:
1113-
TOK_VAR lifetime_opt data_type_or_implicit list_of_variable_decl_assignments ';'
1113+
const_opt TOK_VAR lifetime_opt data_type_or_implicit list_of_variable_decl_assignments ';'
11141114
{ init($$, ID_decl);
11151115
stack_expr($$).set(ID_class, ID_var);
1116-
addswap($$, ID_type, $3);
1117-
swapop($$, $4); }
1118-
| lifetime_opt data_type list_of_variable_decl_assignments ';'
1116+
addswap($$, ID_type, $4);
1117+
swapop($$, $5); }
1118+
| const_opt lifetime_opt data_type list_of_variable_decl_assignments ';'
11191119
{ init($$, ID_decl);
11201120
stack_expr($$).set(ID_class, ID_reg);
1121-
addswap($$, ID_type, $2);
1122-
swapop($$, $3); }
1121+
addswap($$, ID_type, $3);
1122+
swapop($$, $4); }
11231123
| type_declaration
11241124
| package_import_declaration
11251125
;
11261126

1127+
const_opt:
1128+
/* Optional */
1129+
| TOK_CONST
1130+
;
1131+
11271132
package_import_declaration_brace:
11281133
/* Optional */
11291134
{ init($$); }

0 commit comments

Comments
 (0)