Skip to content

Commit 4fcfde4

Browse files
committed
SVA followed-by operators
This adds the SVA operators #=# and #-#.
1 parent 1d075d4 commit 4fcfde4

File tree

8 files changed

+46
-7
lines changed

8 files changed

+46
-7
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
sequence_followed_by1.sv
3+
--bound 20 --numbered-trace
4+
^\[main\.property\.1\] main\.x == 0 #=# \(main\.x == 1 #=# main\.x == 2\): FAILURE: property not supported by BMC engine$
5+
^\[main\.property\.2\] main\.x == 0 #-# \(\(##1 main\.x == 1\) #-# \(##1 main\.x == 2\)\): FAILURE: property not supported by BMC engine$
6+
^EXIT=10$
7+
^SIGNAL=0$
8+
--
9+
^warning: ignoring
10+
--
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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 #=# x == 1 #=# x == 2);
9+
10+
initial p0: assert property (x == 0 #-# ##1 x == 1 #-# ##1 x == 2);
11+
12+
endmodule

src/hw_cbmc_irep_ids.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ IREP_ID_ONE(sva_until)
3636
IREP_ID_ONE(sva_s_until)
3737
IREP_ID_ONE(sva_until_with)
3838
IREP_ID_ONE(sva_s_until_with)
39+
IREP_ID_ONE(sva_overlapped_followed_by)
40+
IREP_ID_ONE(sva_nonoverlapped_followed_by)
3941
IREP_ID_ONE(sva_overlapped_implication)
4042
IREP_ID_ONE(sva_non_overlapped_implication)
4143
IREP_ID_ONE(module_instance)

src/temporal-logic/temporal_logic.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ bool is_temporal_operator(const exprt &expr)
2020
expr.id() == ID_sva_until || expr.id() == ID_sva_s_until ||
2121
expr.id() == ID_sva_until_with || expr.id() == ID_sva_s_until_with ||
2222
expr.id() == ID_sva_eventually || expr.id() == ID_sva_s_eventually ||
23-
expr.id() == ID_sva_cycle_delay;
23+
expr.id() == ID_sva_cycle_delay ||
24+
expr.id() == ID_sva_overlapped_followed_by ||
25+
expr.id() == ID_sva_nonoverlapped_followed_by;
2426
}
2527

2628
bool has_temporal_operator(const exprt &expr)

src/verilog/expr2verilog.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,12 @@ std::string expr2verilogt::convert(
11411141
else if(src.id() == ID_sva_cycle_delay_plus)
11421142
return convert_sva_unary("##[+]", to_unary_expr(src));
11431143

1144+
else if(src.id() == ID_sva_overlapped_followed_by)
1145+
return precedence = 0, convert_sva_binary("#-#", to_binary_expr(src));
1146+
1147+
else if(src.id() == ID_sva_nonoverlapped_followed_by)
1148+
return precedence = 0, convert_sva_binary("#=#", to_binary_expr(src));
1149+
11441150
else if(src.id()==ID_sva_cycle_delay)
11451151
return convert_sva_cycle_delay(to_ternary_expr(src), precedence = 0);
11461152
// not sure about precedence

src/verilog/parser.y

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,8 @@ int yyverilogerror(const char *error)
372372
%token TOK_LESSLESSLESSEQUAL "<<<="
373373
%token TOK_GREATERGREATERGREATEREQUAL ">>>="
374374
%token TOK_HASHHASH "##"
375+
%token TOK_HASHMINUSHASH "#-#"
376+
%token TOK_HASHEQUALHASH "#=#"
375377
%token TOK_COLONCOLON "::"
376378

377379
/* System Verilog Keywords */
@@ -2059,6 +2061,8 @@ property_expr_proper:
20592061
| property_expr "and" property_expr { init($$, ID_and); mto($$, $1); mto($$, $3); }
20602062
| property_expr "|->" property_expr { init($$, ID_sva_overlapped_implication); mto($$, $1); mto($$, $3); }
20612063
| property_expr "|=>" property_expr { init($$, ID_sva_non_overlapped_implication); mto($$, $1); mto($$, $3); }
2064+
| sequence_expr "#-#" property_expr { init($$, ID_sva_overlapped_followed_by); mto($$, $1); mto($$, $3); }
2065+
| sequence_expr "#=#" property_expr { init($$, ID_sva_nonoverlapped_followed_by); mto($$, $1); mto($$, $3); }
20622066
| "nexttime" property_expr
20632067
{ init($$, "sva_nexttime"); stack_expr($$).add_to_operands(nil_exprt()); mto($$, $2); }
20642068
| "nexttime" '[' constant_expression ']' property_expr %prec "nexttime"

src/verilog/scanner.l

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ void verilog_scanner_init()
258258
"<<<=" { SYSTEM_VERILOG_OPERATOR(TOK_LESSLESSLESSEQUAL, "<<<="); }
259259
">>>=" { SYSTEM_VERILOG_OPERATOR(TOK_GREATERGREATERGREATEREQUAL, ">>>="); }
260260
"##" { SYSTEM_VERILOG_OPERATOR(TOK_HASHHASH, "##"); }
261+
"#-#" { SYSTEM_VERILOG_OPERATOR(TOK_HASHMINUSHASH, "#-#"); }
262+
"#=#" { SYSTEM_VERILOG_OPERATOR(TOK_HASHEQUALHASH, "#=#"); }
261263
"<->" { SYSTEM_VERILOG_OPERATOR(TOK_LESSMINUSGREATER, "<->"); }
262264
"->" { SYSTEM_VERILOG_OPERATOR(TOK_MINUSGREATER, "->"); }
263265
"'" { SYSTEM_VERILOG_OPERATOR('\'', "'"); }

src/verilog/verilog_typecheck_expr.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2260,12 +2260,13 @@ exprt verilog_typecheck_exprt::convert_binary_expr(binary_exprt expr)
22602260

22612261
return std::move(expr);
22622262
}
2263-
else if(expr.id()==ID_sva_overlapped_implication ||
2264-
expr.id()==ID_sva_non_overlapped_implication ||
2265-
expr.id()==ID_sva_until ||
2266-
expr.id()==ID_sva_s_until ||
2267-
expr.id()==ID_sva_until_with ||
2268-
expr.id()==ID_sva_s_until_with)
2263+
else if(
2264+
expr.id() == ID_sva_overlapped_implication ||
2265+
expr.id() == ID_sva_non_overlapped_implication ||
2266+
expr.id() == ID_sva_overlapped_followed_by ||
2267+
expr.id() == ID_sva_nonoverlapped_followed_by ||
2268+
expr.id() == ID_sva_until || expr.id() == ID_sva_s_until ||
2269+
expr.id() == ID_sva_until_with || expr.id() == ID_sva_s_until_with)
22692270
{
22702271
convert_expr(expr.op0());
22712272
make_boolean(expr.op0());

0 commit comments

Comments
 (0)