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));

src/verilog/expr2verilog_class.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ class expr2verilogt
9090

9191
std::string convert_sva_unary(const std::string &name, const unary_exprt &);
9292

93-
std::string
94-
convert_sva(const exprt &lhs, const std::string &name, const exprt &rhs);
93+
std::string convert_sva_binary(const std::string &name, const binary_exprt &);
9594

9695
virtual std::string
9796
convert_replication(const replication_exprt &, unsigned precedence);

src/verilog/parser.y

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2091,10 +2091,14 @@ sequence_expr:
20912091
{ $$=$1; mto($$, $2); }
20922092
| expression cycle_delay_range sequence_expr
20932093
{ init($$, ID_sva_sequence_concatenation); mto($$, $1); mto($2, $3); mto($$, $2); }
2094+
| expression "intersect" sequence_expr
2095+
{ init($$, ID_sva_sequence_intersect); mto($$, $1); mto($$, $3); }
20942096
| "first_match" '(' sequence_expr ')'
20952097
{ init($$, ID_sva_sequence_first_match); mto($$, $3); }
20962098
| expression "throughout" sequence_expr
20972099
{ init($$, ID_sva_sequence_throughout); mto($$, $1); mto($$, $3); }
2100+
| expression "within" sequence_expr
2101+
{ init($$, ID_sva_sequence_within); mto($$, $1); mto($$, $3); }
20982102
;
20992103

21002104
cycle_delay_range:

src/verilog/verilog_typecheck_expr.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1899,6 +1899,11 @@ exprt verilog_typecheck_exprt::convert_unary_expr(unary_exprt expr)
18991899
make_boolean(expr.op());
19001900
expr.type()=bool_typet();
19011901
}
1902+
else if(expr.id() == ID_sva_sequence_first_match)
1903+
{
1904+
throw errort().with_location(expr.source_location())
1905+
<< "no support for 'first_match'";
1906+
}
19021907
else if(expr.id() == ID_verilog_explicit_cast)
19031908
{
19041909
// SystemVerilog has got type'(expr). This is an explicit
@@ -2231,6 +2236,21 @@ exprt verilog_typecheck_exprt::convert_binary_expr(binary_exprt expr)
22312236

22322237
return std::move(expr);
22332238
}
2239+
else if(expr.id() == ID_sva_sequence_intersect)
2240+
{
2241+
throw errort().with_location(expr.source_location())
2242+
<< "no support for 'intersect'";
2243+
}
2244+
else if(expr.id() == ID_sva_sequence_throughout)
2245+
{
2246+
throw errort().with_location(expr.source_location())
2247+
<< "no support for 'throughout'";
2248+
}
2249+
else if(expr.id() == ID_sva_sequence_within)
2250+
{
2251+
throw errort().with_location(expr.source_location())
2252+
<< "no support for 'within'";
2253+
}
22342254
else if(expr.id()==ID_hierarchical_identifier)
22352255
{
22362256
return convert_hierarchical_identifier(

0 commit comments

Comments
 (0)