Skip to content

Commit e6f1060

Browse files
authored
Merge pull request #511 from diffblue/sva_sequence_operators
SystemVerilog: error for unsupported sequence operators
2 parents 829854e + 53023b9 commit e6f1060

13 files changed

+135
-33
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
sequence_first_match1.sv
3+
4+
^file .* line \d+: no support for 'first_match'$
5+
^EXIT=2$
6+
^SIGNAL=0$
7+
--
8+
^warning: ignoring
9+
--
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module main(input clk);
2+
3+
reg [31:0] x = 0;
4+
5+
always @(posedge clk)
6+
x<=x+1;
7+
8+
initial p0: assert property (first_match(x == 0));
9+
10+
endmodule
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
sequence_intersect1.sv
3+
4+
^file .* line \d+: no support for 'intersect'$
5+
^EXIT=2$
6+
^SIGNAL=0$
7+
--
8+
^warning: ignoring
9+
--
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module main(input clk);
2+
3+
reg [31:0] x = 0;
4+
5+
always @(posedge clk)
6+
x<=x+1;
7+
8+
initial p0: assert property (x == 0 intersect x == 1);
9+
10+
endmodule
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
sequence_throughout1.sv
3+
4+
^file .* line \d+: no support for 'throughout'$
5+
^EXIT=2$
6+
^SIGNAL=0$
7+
--
8+
^warning: ignoring
9+
--
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module main(input clk);
2+
3+
reg [31:0] x = 0;
4+
5+
always @(posedge clk)
6+
x<=x+1;
7+
8+
initial p0: assert property (x == 0 throughout x == 1);
9+
10+
endmodule
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
sequence_within1.sv
3+
4+
^file .* line \d+: no support for 'within'$
5+
^EXIT=2$
6+
^SIGNAL=0$
7+
--
8+
^warning: ignoring
9+
--
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module main(input clk);
2+
3+
reg [31:0] x = 0;
4+
5+
always @(posedge clk)
6+
x<=x+1;
7+
8+
initial p0: assert property (x == 0 within x == 1);
9+
10+
endmodule

src/hw_cbmc_irep_ids.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ IREP_ID_ONE(E)
1616
IREP_ID_ONE(G)
1717
IREP_ID_ONE(X)
1818
IREP_ID_ONE(sva_cycle_delay)
19-
IREP_ID_ONE(sva_sequence_throughout)
2019
IREP_ID_ONE(sva_sequence_concatenation)
2120
IREP_ID_ONE(sva_sequence_first_match)
21+
IREP_ID_ONE(sva_sequence_intersect)
22+
IREP_ID_ONE(sva_sequence_throughout)
23+
IREP_ID_ONE(sva_sequence_within)
2224
IREP_ID_ONE(sva_always)
2325
IREP_ID_ONE(sva_ranged_always)
2426
IREP_ID_ONE(sva_s_always)

src/verilog/expr2verilog.cpp

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -440,18 +440,17 @@ Function: expr2verilogt::convert_sva
440440
441441
\*******************************************************************/
442442

443-
std::string expr2verilogt::convert_sva(
444-
const exprt &lhs,
443+
std::string expr2verilogt::convert_sva_binary(
445444
const std::string &name,
446-
const exprt &rhs)
445+
const binary_exprt &expr)
447446
{
448447
unsigned p0;
449-
auto s0 = convert(lhs, p0);
448+
auto s0 = convert(expr.lhs(), p0);
450449
if(p0 == 0)
451450
s0 = "(" + s0 + ")";
452451

453452
unsigned p1;
454-
auto s1 = convert(rhs, p1);
453+
auto s1 = convert(expr.rhs(), p1);
455454
if(p1 == 0)
456455
s1 = "(" + s1 + ")";
457456

@@ -1091,16 +1090,10 @@ std::string expr2verilogt::convert(
10911090
return convert_function("$onehot0", src);
10921091

10931092
else if(src.id()==ID_sva_overlapped_implication)
1094-
{
1095-
auto &binary = to_binary_expr(src);
1096-
return precedence = 0, convert_sva(binary.lhs(), "|->", binary.rhs());
1097-
}
1093+
return precedence = 0, convert_sva_binary("|->", to_binary_expr(src));
10981094

10991095
else if(src.id()==ID_sva_non_overlapped_implication)
1100-
{
1101-
auto &binary = to_binary_expr(src);
1102-
return precedence = 0, convert_sva(binary.lhs(), "|=>", binary.rhs());
1103-
}
1096+
return precedence = 0, convert_sva_binary("|=>", to_binary_expr(src));
11041097

11051098
else if(src.id()==ID_sva_cycle_delay)
11061099
return convert_sva_cycle_delay(to_ternary_expr(src), precedence = 0);
@@ -1110,7 +1103,24 @@ std::string expr2verilogt::convert(
11101103
return convert_sva_sequence_concatenation(
11111104
to_binary_expr(src), precedence = 0);
11121105
// not sure about precedence
1113-
1106+
1107+
else if(src.id() == ID_sva_sequence_first_match)
1108+
return convert_function("first_match", src);
1109+
1110+
else if(src.id() == ID_sva_sequence_intersect)
1111+
return precedence = 0, convert_sva_binary("intersect", to_binary_expr(src));
1112+
// not sure about precedence
1113+
1114+
else if(src.id() == ID_sva_sequence_within)
1115+
return convert_sva_sequence_concatenation(
1116+
to_binary_expr(src), precedence = 0);
1117+
// not sure about precedence
1118+
1119+
else if(src.id() == ID_sva_sequence_throughout)
1120+
return convert_sva_sequence_concatenation(
1121+
to_binary_expr(src), precedence = 0);
1122+
// not sure about precedence
1123+
11141124
else if(src.id()==ID_sva_always)
11151125
return precedence = 0, convert_sva_unary("always", to_sva_always_expr(src));
11161126

@@ -1151,28 +1161,19 @@ std::string expr2verilogt::convert(
11511161
convert_sva_unary("s_eventually", to_sva_s_eventually_expr(src));
11521162

11531163
else if(src.id()==ID_sva_until)
1154-
return precedence = 0, convert_sva(
1155-
to_sva_until_expr(src).lhs(),
1156-
"until",
1157-
to_sva_until_expr(src).rhs());
1164+
return precedence = 0, convert_sva_binary("until", to_sva_until_expr(src));
11581165

11591166
else if(src.id()==ID_sva_s_until)
1160-
return precedence = 0, convert_sva(
1161-
to_sva_s_until_expr(src).lhs(),
1162-
"s_until",
1163-
to_sva_s_until_expr(src).rhs());
1167+
return precedence = 0,
1168+
convert_sva_binary("s_until", to_sva_s_until_expr(src));
11641169

11651170
else if(src.id()==ID_sva_until_with)
1166-
return precedence = 0, convert_sva(
1167-
to_sva_until_with_expr(src).lhs(),
1168-
"until_with",
1169-
to_sva_until_with_expr(src).rhs());
1171+
return precedence = 0,
1172+
convert_sva_binary("until_with", to_sva_until_with_expr(src));
11701173

11711174
else if(src.id()==ID_sva_s_until_with)
1172-
return precedence = 0, convert_sva(
1173-
to_sva_s_until_with_expr(src).lhs(),
1174-
"s_until_with",
1175-
to_sva_s_until_with_expr(src).rhs());
1175+
return precedence = 0,
1176+
convert_sva_binary("s_until_with", to_sva_s_until_with_expr(src));
11761177

11771178
else if(src.id()==ID_function_call)
11781179
return convert_function_call(to_function_call_expr(src));

0 commit comments

Comments
 (0)