Skip to content

SVA->Buechi: fix translation of ##[*] and ##[+] #1236

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions regression/ebmc-spot/sva-buechi/cycle_delay_plus4.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CORE
../../verilog/SVA/cycle_delay_plus4.sv
--buechi
^\[main\.p0\] main\.x == 0 ##\[\+\] main\.x == 1: PROVED \(1-induction\)$
^\[main\.p1\] main\.x == 0 ##\[\+\] main\.x == 2: PROVED \(1-induction\)$
^\[main\.p2\] main\.x == 1 ##\[\+\] main\.x == 1: REFUTED$
^\[main\.p3\] main\.x == 0 ##\[\+\] main\.x == 6: PROVED \(1-induction\)$
^EXIT=10$
^SIGNAL=0$
--
^warning: ignoring
--
3 changes: 1 addition & 2 deletions regression/ebmc-spot/sva-buechi/cycle_delay_star1.bdd.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
KNOWNBUG
CORE
../../verilog/SVA/cycle_delay_star1.sv
--buechi --bdd
^\[main.p0\] ##\[\*\] main\.x == 2 ##1 main\.x == 3: PROVED$
Expand All @@ -7,4 +7,3 @@ KNOWNBUG
--
^warning: ignoring
--
This gives the wrong answer.
3 changes: 1 addition & 2 deletions regression/ebmc-spot/sva-buechi/cycle_delay_star1.bmc.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
KNOWNBUG
CORE
../../verilog/SVA/cycle_delay_star1.sv
--buechi --bound 10
^\[main.p0\] ##\[\*\] main\.x == 2 ##1 main\.x == 3: PROVED up to bound 10$
Expand All @@ -7,4 +7,3 @@ KNOWNBUG
--
^warning: ignoring
--
This gives the wrong answer.
4 changes: 2 additions & 2 deletions regression/ebmc-spot/sva-buechi/cycle_delay_star2.bdd.desc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
CORE
../../verilog/SVA/cycle_delay_star2.sv
--buechi --bdd
^\[main.p0\] ##\[\*\] main\.x == 4: REFUTED$
^EXIT=10$
^\[main.p0\] ##\[\*\] main\.x == 4: PROVED$
^EXIT=0$
^SIGNAL=0$
--
^warning: ignoring
Expand Down
4 changes: 2 additions & 2 deletions regression/ebmc-spot/sva-buechi/cycle_delay_star2.bmc.desc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
CORE
../../verilog/SVA/cycle_delay_star2.sv
--buechi --bound 10
^\[main.p0\] ##\[\*\] main\.x == 4: REFUTED$
^EXIT=10$
^\[main.p0\] ##\[\*\] main\.x == 4: PROVED up to bound 10$
^EXIT=0$
^SIGNAL=0$
--
^warning: ignoring
Expand Down
5 changes: 2 additions & 3 deletions regression/ebmc-spot/sva-buechi/cycle_delay_star3.bdd.desc
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
KNOWNBUG
CORE
../../verilog/SVA/cycle_delay_star3.sv
--buechi --bdd
^\[main.p0\] ##\[\*\] main\.x == 4: PROVED up to bound 10$
^\[main.p0\] ##\[\*\] main\.x == 4: PROVED$
^EXIT=0$
^SIGNAL=0$
--
^warning: ignoring
--
We get the wrong answer.
3 changes: 1 addition & 2 deletions regression/ebmc-spot/sva-buechi/cycle_delay_star3.bmc.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
KNOWNBUG
CORE
../../verilog/SVA/cycle_delay_star3.sv
--buechi --bound 10
^\[main.p0\] ##\[\*\] main\.x == 4: PROVED up to bound 10$
Expand All @@ -7,4 +7,3 @@ KNOWNBUG
--
^warning: ignoring
--
We get the wrong answer.
13 changes: 13 additions & 0 deletions regression/ebmc-spot/sva-buechi/cycle_delay_star4.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CORE
../../verilog/SVA/cycle_delay_star4.sv
--buechi
^\[main\.p0\] main\.x == 0 ##\[\*\] main\.x == 0: PROVED \(1-induction\)$
^\[main\.p1\] main\.x == 0 ##\[\*\] main\.x == 1: PROVED \(1-induction\)$
^\[main\.p2\] main\.x == 0 ##\[\*\] main\.x == 2: PROVED \(1-induction\)$
^\[main\.p3\] main\.x == 1 ##\[\*\] main\.x == 1: REFUTED$
^\[main\.p4\] main\.x == 0 ##\[\*\] main\.x == 6: PROVED \(1-induction\)$
^EXIT=10$
^SIGNAL=0$
--
^warning: ignoring
--
7 changes: 3 additions & 4 deletions regression/verilog/SVA/cycle_delay_star2.desc
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
KNOWNBUG
CORE
cycle_delay_star2.sv
--bound 10
^\[main.p0\] ##\[\*\] main\.x == 4: REFUTED$
^EXIT=10$
^\[main.p0\] ##\[\*\] main\.x == 4: PROVED up to bound 10$
^EXIT=0$
^SIGNAL=0$
--
^warning: ignoring
--
The BMC engine gives the wrong answer.
3 changes: 2 additions & 1 deletion regression/verilog/SVA/cycle_delay_star2.sv
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ module main(input clk);
always @(posedge clk)
if(x<3) x++;

// fails -- 4 is never reached
// 4 is never reached, but this doesn't fail the property
// owing to weak sequence semantics.
initial p0: assert property (##[*] x==4);

endmodule
40 changes: 34 additions & 6 deletions src/temporal-logic/ltl_sva_to_string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,17 +419,45 @@ ltl_sva_to_stringt::rec(const exprt &expr, modet mode)
}
else if(expr.id() == ID_sva_cycle_delay_star) // ##[*] something
{
// ##[*] x ---> 1[*] ; x
// w ##[*] x ---> w : 1[*] ; x
PRECONDITION(mode == SVA_SEQUENCE);
auto new_expr = unary_exprt{
ID_sva_cycle_delay_star, to_sva_cycle_delay_star_expr(expr).rhs()};
return suffix("[*]", new_expr, mode);
auto &cycle_delay_expr = to_sva_cycle_delay_star_expr(expr);
if(cycle_delay_expr.has_lhs())
{
auto new_expr = binary_exprt{
cycle_delay_expr.lhs(),
ID_sva_cycle_delay_star,
cycle_delay_expr.rhs()};
return infix(" : 1[*] ; ", new_expr, mode);
}
else
{
auto new_expr =
unary_exprt{ID_sva_cycle_delay_star, cycle_delay_expr.rhs()};
return prefix("1[*] ; ", new_expr, mode);
}
}
else if(expr.id() == ID_sva_cycle_delay_plus) // ##[+] something
{
// ##[+] x ---> 1[+] ; x
// w ##[+] x ---> w : 1[+] ; x
PRECONDITION(mode == SVA_SEQUENCE);
auto new_expr = unary_exprt{
ID_sva_cycle_delay_star, to_sva_cycle_delay_plus_expr(expr).rhs()};
return suffix("[+]", new_expr, mode);
auto &cycle_delay_expr = to_sva_cycle_delay_plus_expr(expr);
if(cycle_delay_expr.has_lhs())
{
auto new_expr = binary_exprt{
cycle_delay_expr.lhs(),
ID_sva_cycle_delay_plus,
cycle_delay_expr.rhs()};
return infix(" : 1[+] ; ", new_expr, mode);
}
else
{
auto new_expr =
unary_exprt{ID_sva_cycle_delay_plus, cycle_delay_expr.rhs()};
return prefix("1[+] ; ", new_expr, mode);
}
}
else if(expr.id() == ID_if)
{
Expand Down
12 changes: 12 additions & 0 deletions src/verilog/sva_expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,7 @@ static inline sva_cycle_delay_exprt &to_sva_cycle_delay_expr(exprt &expr)
class sva_cycle_delay_plus_exprt : public binary_exprt
{
public:
/// The operands are sequences, the LHS is optional, indicated by nil.
explicit sva_cycle_delay_plus_exprt(exprt __lhs, exprt __rhs)
: binary_exprt(
std::move(__lhs),
Expand All @@ -1212,6 +1213,11 @@ class sva_cycle_delay_plus_exprt : public binary_exprt
{
}

bool has_lhs() const
{
return lhs().is_not_nil();
}

// ##[1:$] op
exprt lower() const;
};
Expand All @@ -1235,6 +1241,7 @@ to_sva_cycle_delay_plus_expr(exprt &expr)
class sva_cycle_delay_star_exprt : public binary_exprt
{
public:
/// The operands are a sequences, the LHS is optional, indicated by nil.
explicit sva_cycle_delay_star_exprt(exprt __lhs, exprt __rhs)
: binary_exprt(
std::move(__lhs),
Expand All @@ -1244,6 +1251,11 @@ class sva_cycle_delay_star_exprt : public binary_exprt
{
}

bool has_lhs() const
{
return lhs().is_not_nil();
}

// ##[0:$] op
exprt lower() const;
};
Expand Down
Loading