Skip to content

Commit fde0f9b

Browse files
authored
Merge pull request #144 from diffblue/verilog-property-expr
Verilog: allow parentheses in property expressions
2 parents 65e3eab + 6bd0658 commit fde0f9b

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

regression/verilog/system_verilog_assertion/system_verilog_assertion4.sv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ module main(input clk);
2020
p10: assert property (x==0 |-> ##1 x==1 and ##2 x==2);
2121
p11: assert property (x==0 |-> ##1 x==1 and not ##2 x==3);
2222
p12: assert property (x==0 |-> ##1 x==1 && y==2);
23+
p13: assert property ((x==0 |-> y==0) |=> y != 0);
2324

2425
endmodule

src/verilog/parser.y

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1571,8 +1571,18 @@ property_declaration:
15711571
TOK_PROPERTY property_identifier TOK_ENDPROPERTY
15721572
;
15731573

1574+
// The 1800-2017 grammar has an ambiguity where
1575+
// '(' expression ')' can either be an expression or a property_expr,
1576+
// which yields a reduce/reduce conflict. Hence, we split the rules
1577+
// for property_expr into property_expr and property_expr_proper.
1578+
15741579
property_expr:
1575-
sequence_expr
1580+
sequence_expr
1581+
| property_expr_proper
1582+
;
1583+
1584+
property_expr_proper:
1585+
'(' property_expr_proper ')' { $$ = $2; }
15761586
| "not" property_expr { init($$, ID_not); mto($$, $2); }
15771587
| property_expr "or" property_expr { init($$, ID_or); mto($$, $1); mto($$, $3); }
15781588
| property_expr "and" property_expr { init($$, ID_and); mto($$, $1); mto($$, $3); }

0 commit comments

Comments
 (0)