Skip to content

Commit 4bdc90a

Browse files
committed
introduce sva_implies and sva_iff
This introduces separate expressions for SVA iff and SVA implies.
1 parent 61c93bf commit 4bdc90a

File tree

12 files changed

+118
-4
lines changed

12 files changed

+118
-4
lines changed

regression/verilog/SVA/eventually1.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CORE
22
eventually1.sv
33
--bound 20
4-
^\[main\.property\.p0\] always \(main\.counter == 1 |-> eventually \[1:2\] main\.counter == 3\): PROVED up to bound 20$
4+
^\[main\.p0\] always main\.counter == 1 implies \(eventually \[1:2\] main\.counter == 3\): PROVED up to bound 20$
55
^EXIT=0$
66
^SIGNAL=0$
77
--

regression/verilog/SVA/sva_iff1.desc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
sva_iff1.sv
3+
--bound 0
4+
^\[main\.p0\] always 1 iff 1: PROVED up to bound 0$
5+
^\[main\.p1\] always 1 iff 0: REFUTED$
6+
^\[main\.p2\] always 1 iff 32'b0000000000000000000000000000000x: PROVED up to bound 0$
7+
^EXIT=10$
8+
^SIGNAL=0$
9+
--
10+
^warning: ignoring
11+
--

regression/verilog/SVA/sva_iff1.sv

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module main;
2+
3+
// should pass
4+
p0: assert property (10 iff 20);
5+
6+
// should fail
7+
p1: assert property (10 iff 0);
8+
9+
// should fail
10+
p2: assert property (10 iff 'bx);
11+
12+
endmodule
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
sva_implies1.sv
3+
--bound 0
4+
^\[main\.p0\] always 1 implies 1: PROVED up to bound 0$
5+
^\[main\.p1\] always 1 implies 0: REFUTED$
6+
^\[main\.p2\] always 1 implies 32'b0000000000000000000000000000000x: PROVED up to bound 0$
7+
^EXIT=10$
8+
^SIGNAL=0$
9+
--
10+
^warning: ignoring
11+
--
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module main;
2+
3+
// should pass
4+
p0: assert property (10 implies 20);
5+
6+
// should fail
7+
p1: assert property (10 implies 0);
8+
9+
// should fail
10+
p2: assert property (10 implies 'bx);
11+
12+
endmodule

src/hw_cbmc_irep_ids.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ IREP_ID_ONE(sva_nonoverlapped_followed_by)
5555
IREP_ID_ONE(sva_overlapped_implication)
5656
IREP_ID_ONE(sva_non_overlapped_implication)
5757
IREP_ID_ONE(sva_and)
58+
IREP_ID_ONE(sva_iff)
59+
IREP_ID_ONE(sva_implies)
5860
IREP_ID_ONE(sva_not)
5961
IREP_ID_ONE(sva_or)
6062
IREP_ID_ONE(module_instance)

src/temporal-logic/normalize_property.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,16 @@ exprt normalize_property(exprt expr)
143143
else if(expr.id() == ID_sva_non_overlapped_implication)
144144
expr = normalize_pre_sva_non_overlapped_implication(
145145
to_sva_non_overlapped_implication_expr(expr));
146+
else if(expr.id() == ID_sva_iff)
147+
{
148+
expr =
149+
equal_exprt{to_sva_iff_expr(expr).lhs(), to_sva_iff_expr(expr).rhs()};
150+
}
151+
else if(expr.id() == ID_sva_implies)
152+
{
153+
expr = implies_exprt{
154+
to_sva_implies_expr(expr).lhs(), to_sva_implies_expr(expr).rhs()};
155+
}
146156
else if(expr.id() == ID_sva_and)
147157
expr = normalize_pre_sva_and(to_sva_and_expr(expr));
148158
else if(expr.id() == ID_sva_not)

src/temporal-logic/normalize_property.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Author: Daniel Kroening, [email protected]
1616
/// ¬(a ∨ b) --> ¬a ∧ ¬b
1717
/// ¬(a ∧ b) --> ¬a ∨ ¬b
1818
/// (a -> b) --> ¬a ∨ b
19+
/// a sva_iff b --> a <-> b
20+
/// a sva_implies b --> a -> b
1921
/// sva_not a --> ¬a
2022
/// a sva_and b --> a ∧ b if a and b are not SVA sequences
2123
/// a sva_or b --> a ∨ b if a and b are not SVA sequences

src/verilog/expr2verilog.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,12 @@ expr2verilogt::convert(const exprt &src, verilog_precedencet &precedence)
12731273
else if(src.id() == ID_sva_and)
12741274
return convert_sva_binary("and", to_sva_and_expr(src));
12751275

1276+
else if(src.id() == ID_sva_iff)
1277+
return convert_sva_binary("iff", to_sva_iff_expr(src));
1278+
1279+
else if(src.id() == ID_sva_implies)
1280+
return convert_sva_binary("implies", to_sva_implies_expr(src));
1281+
12761282
else if(src.id()==ID_power)
12771283
return convert_binary(
12781284
to_multi_ary_expr(src), "**", precedence = verilog_precedencet::POWER);

src/verilog/parser.y

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2200,9 +2200,9 @@ property_expr_proper:
22002200
| property_expr "s_until_with" property_expr
22012201
{ init($$, "sva_s_until_with"); mto($$, $1); mto($$, $3); }
22022202
| property_expr "implies" property_expr
2203-
{ init($$, ID_implies); mto($$, $1); mto($$, $3); }
2203+
{ init($$, ID_sva_implies); mto($$, $1); mto($$, $3); }
22042204
| property_expr "iff" property_expr
2205-
{ init($$, ID_iff); mto($$, $1); mto($$, $3); }
2205+
{ init($$, ID_sva_iff); mto($$, $1); mto($$, $3); }
22062206
| "accept_on" '(' expression_or_dist ')' property_expr %prec "property_expr_abort"
22072207
{ init($$, ID_sva_accept_on); mto($$, $3); mto($$, $5); }
22082208
| "reject_on" '(' expression_or_dist ')' property_expr %prec "property_expr_abort"

0 commit comments

Comments
 (0)