Skip to content

Commit 04715c9

Browse files
committed
SVA: sequence 'and'/'or' vs. property 'and'/'or'
The 1800-2017 SystemVerilog grammar allows "a and b" and "a or b" to be either a sequence, or a property. If both "a" and "b" are sequences, then "a and b" and "a or b" is a sequence as well. This changes the grammar to allow the sequence case.
1 parent 009b13b commit 04715c9

File tree

5 files changed

+31
-8
lines changed

5 files changed

+31
-8
lines changed

regression/verilog/SVA/sequence_and1.desc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
KNOWNBUG
1+
CORE
22
sequence_and1.sv
33

4-
^EXIT=0$
4+
^\[main\.p0\] main\.x == 0 and main\.x == 1: REFUTED$
5+
^\[main\.p1\] strong\(main\.x == 0 and main\.x == 1\): REFUTED$
6+
^\[main\.p2\] main\.x == 0 and \(nexttime main\.x == 1\): PROVED up to bound \d+$
7+
^\[main\.p3\] \(nexttime main\.x == 1\) and main\.x == 0: PROVED up to bound \d+$
8+
^EXIT=10$
59
^SIGNAL=0$
610
--
711
^warning: ignoring
812
--
9-
The grammar for 'SVA sequence and' is missing.

regression/verilog/SVA/sequence_and1.sv

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ module main(input clk);
99
initial p0: assert property (x == 0 and x == 1);
1010

1111
// Given two sequences, 'and' yields a sequence, not a property
12-
initial p1: assert property ((x == 0 and x == 1)[*1]);
12+
initial p1: assert property (strong(x == 0 and x == 1));
13+
14+
// But given a property on either side, 'and' yields a property
15+
initial p2: assert property (x == 0 and nexttime x == 1);
16+
initial p3: assert property (nexttime x == 1 and x == 0);
1317

1418
endmodule

regression/verilog/SVA/sequence_or1.desc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
KNOWNBUG
1+
CORE
22
sequence_or1.sv
33

4+
^\[main\.p0\] main\.x == 0 or main\.x == 1: PROVED up to bound \d+$
5+
^\[main\.p1\] strong\(main\.x == 0 or main\.x == 1\): PROVED up to bound \d+$
6+
^\[main\.p2\] main\.x == 0 or \(nexttime main\.x == 1\): PROVED up to bound \d+$
7+
^\[main\.p3\] \(nexttime main\.x == 1\) or main\.x == 1: PROVED up to bound \d+$
48
^EXIT=0$
59
^SIGNAL=0$
610
--
711
^warning: ignoring
812
--
9-
The grammar for 'SVA sequence or' is missing.

regression/verilog/SVA/sequence_or1.sv

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ module main(input clk);
99
initial p0: assert property (x == 0 or x == 1);
1010

1111
// Given two sequences, 'or' yields a sequence, not a property
12-
initial p1: assert property ((x == 0 or x == 1)[*1]);
12+
initial p1: assert property (strong(x == 0 or x == 1));
13+
14+
// But given a property on either side, 'or' yields a property
15+
initial p2: assert property (x==0 or nexttime x == 1);
16+
initial p3: assert property (nexttime x==1 or x == 1);
1317

1418
endmodule

src/verilog/parser.y

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,10 @@ int yyverilogerror(const char *error)
554554
// whereas the table gives them in decreasing order.
555555
// The precendence of the assertion operators is lower than
556556
// those in Table 11-2.
557+
//
558+
// SEQUENCE_TO_PROPERTY is an artificial token to give
559+
// the right precedence to the conversion of a sequence_expr
560+
// to a property_expr.
557561
%nonassoc "property_expr_abort" // accept_on, reject_on, ...
558562
%nonassoc "property_expr_clocking_event" // @(...) property_expr
559563
%nonassoc "always" "s_always" "eventually" "s_eventually"
@@ -564,6 +568,7 @@ int yyverilogerror(const char *error)
564568
%right "iff"
565569
%left "or"
566570
%left "and"
571+
%nonassoc SEQUENCE_TO_PROPERTY
567572
%nonassoc "not" "nexttime" "s_nexttime"
568573
%left "intersect"
569574
%left "within"
@@ -2419,7 +2424,7 @@ sequence_formal_type:
24192424
// for property_expr into property_expr and property_expr_proper.
24202425

24212426
property_expr:
2422-
sequence_expr
2427+
sequence_expr %prec SEQUENCE_TO_PROPERTY
24232428
| property_expr_proper
24242429
;
24252430

@@ -2582,8 +2587,12 @@ sequence_expr_proper:
25822587
// preserve the operand ordering as in the source code
25832588
stack_expr($$).operands().insert(stack_expr($$).operands().begin(), stack_expr($1));
25842589
}
2590+
| sequence_expr "and" sequence_expr
2591+
{ init($$, ID_sva_and); mto($$, $1); mto($$, $3); }
25852592
| sequence_expr "intersect" sequence_expr
25862593
{ init($$, ID_sva_sequence_intersect); mto($$, $1); mto($$, $3); }
2594+
| sequence_expr "or" sequence_expr
2595+
{ init($$, ID_sva_or); mto($$, $1); mto($$, $3); }
25872596
| "first_match" '(' sequence_expr ')'
25882597
{ init($$, ID_sva_sequence_first_match); mto($$, $3); }
25892598
| "first_match" '(' sequence_expr ',' sequence_match_item_brace ')'

0 commit comments

Comments
 (0)