Skip to content

Commit

Permalink
Merge pull request #465 from diffblue/const1
Browse files Browse the repository at this point in the history
Verilog: const variable declarations
  • Loading branch information
tautschnig authored Apr 30, 2024
2 parents a852492 + af4857c commit 88381b0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
8 changes: 8 additions & 0 deletions regression/verilog/const/const1.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
const1.sv

^no properties$
^EXIT=10$
^SIGNAL=0$
--
^warning: ignoring
5 changes: 5 additions & 0 deletions regression/verilog/const/const1.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module main;
const bit my_true2 = 1;
const var my_true3 = 1;
const logic my_true4 = 1;
endmodule
17 changes: 11 additions & 6 deletions src/verilog/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -1110,20 +1110,25 @@ part_select:
// TOK_VAR is optional, but footnote 10 in IEEE 1800-2017 requires it
// when the data_type is omitted. We split the rule in the standard into two.
data_declaration:
TOK_VAR lifetime_opt data_type_or_implicit list_of_variable_decl_assignments ';'
const_opt TOK_VAR lifetime_opt data_type_or_implicit list_of_variable_decl_assignments ';'
{ init($$, ID_decl);
stack_expr($$).set(ID_class, ID_var);
addswap($$, ID_type, $3);
swapop($$, $4); }
| lifetime_opt data_type list_of_variable_decl_assignments ';'
addswap($$, ID_type, $4);
swapop($$, $5); }
| const_opt lifetime_opt data_type list_of_variable_decl_assignments ';'
{ init($$, ID_decl);
stack_expr($$).set(ID_class, ID_reg);
addswap($$, ID_type, $2);
swapop($$, $3); }
addswap($$, ID_type, $3);
swapop($$, $4); }
| type_declaration
| package_import_declaration
;

const_opt:
/* Optional */
| TOK_CONST
;

package_import_declaration_brace:
/* Optional */
{ init($$); }
Expand Down

0 comments on commit 88381b0

Please sign in to comment.