@@ -35,8 +35,9 @@ void verilog_typecheck_exprt::require_sva_sequence(exprt &expr)
35
35
}
36
36
else
37
37
{
38
- // state formula, can cast to sequence
38
+ // state formula, can convert to sequence
39
39
make_boolean (expr);
40
+ expr = sva_boolean_exprt{std::move (expr), verilog_sva_sequence_typet{}};
40
41
}
41
42
}
42
43
else
@@ -86,10 +87,8 @@ exprt verilog_typecheck_exprt::convert_unary_sva(unary_exprt expr)
86
87
return std::move (expr);
87
88
}
88
89
else if (
89
- expr.id () == ID_sva_cycle_delay_plus || // ##[+]
90
- expr.id () == ID_sva_cycle_delay_star || // ##[*]
91
- expr.id () == ID_sva_sequence_repetition_plus || // x[+]
92
- expr.id () == ID_sva_sequence_repetition_star) // x[*}
90
+ expr.id () == ID_sva_cycle_delay_plus || // ##[+]
91
+ expr.id () == ID_sva_cycle_delay_star) // ##[*]
93
92
{
94
93
// These take a sequence as argument.
95
94
// For some, the grammar allows properties to implement and/or over
@@ -99,6 +98,16 @@ exprt verilog_typecheck_exprt::convert_unary_sva(unary_exprt expr)
99
98
expr.type () = verilog_sva_sequence_typet{};
100
99
return std::move (expr);
101
100
}
101
+ else if (
102
+ expr.id () == ID_sva_sequence_repetition_plus || // x[+]
103
+ expr.id () == ID_sva_sequence_repetition_star) // x[*]
104
+ {
105
+ // These take a Boolean as argument, and yield a sequence.
106
+ convert_expr (expr.op ());
107
+ make_boolean (expr.op ());
108
+ expr.type () = verilog_sva_sequence_typet{};
109
+ return std::move (expr);
110
+ }
102
111
else if (expr.id () == ID_sva_weak || expr.id () == ID_sva_strong)
103
112
{
104
113
convert_sva (expr.op ());
@@ -109,7 +118,11 @@ exprt verilog_typecheck_exprt::convert_unary_sva(unary_exprt expr)
109
118
else
110
119
{
111
120
// not SVA
112
- return convert_expr_rec (std::move (expr));
121
+ DATA_CHECK_WITH_DIAGNOSTICS (
122
+ validation_modet::INVARIANT,
123
+ false ,
124
+ " unexpected unary SVA expression" ,
125
+ expr.pretty ());
113
126
}
114
127
}
115
128
@@ -123,14 +136,12 @@ exprt verilog_typecheck_exprt::convert_binary_sva(binary_exprt expr)
123
136
// These yield sequences when both operands are sequences, and
124
137
// properties otherwise.
125
138
if (
126
- (expr.lhs ().type ().id () == ID_verilog_sva_sequence ||
127
- !has_temporal_operator (expr.lhs ())) &&
128
- (expr.rhs ().type ().id () == ID_verilog_sva_sequence ||
129
- !has_temporal_operator (expr.rhs ())))
139
+ expr.lhs ().type ().id () == ID_verilog_sva_sequence &&
140
+ expr.rhs ().type ().id () == ID_verilog_sva_sequence)
130
141
{
131
- expr.type () = verilog_sva_sequence_typet{};
132
142
require_sva_sequence (expr.lhs ());
133
143
require_sva_sequence (expr.rhs ());
144
+ expr.type () = verilog_sva_sequence_typet{};
134
145
}
135
146
else
136
147
{
@@ -294,8 +305,12 @@ exprt verilog_typecheck_exprt::convert_binary_sva(binary_exprt expr)
294
305
}
295
306
else
296
307
{
297
- // not SVA
298
- return convert_expr_rec (std::move (expr));
308
+ // unexpected SVA expression
309
+ DATA_CHECK_WITH_DIAGNOSTICS (
310
+ validation_modet::INVARIANT,
311
+ false ,
312
+ " unexpected binary SVA expression" ,
313
+ expr.pretty ());
299
314
}
300
315
}
301
316
@@ -409,22 +424,38 @@ exprt verilog_typecheck_exprt::convert_ternary_sva(ternary_exprt expr)
409
424
else
410
425
{
411
426
// not SVA
412
- return convert_expr_rec (std::move (expr));
427
+ DATA_CHECK_WITH_DIAGNOSTICS (
428
+ validation_modet::INVARIANT,
429
+ false ,
430
+ " unexpected ternary SVA expression" ,
431
+ expr.pretty ());
413
432
}
414
433
}
415
434
416
435
exprt verilog_typecheck_exprt::convert_sva_rec (exprt expr)
417
436
{
418
- switch (expr.operands ().size ())
419
- {
420
- case 1 :
421
- return convert_unary_sva (to_unary_expr (expr));
422
- case 2 :
423
- return convert_binary_sva (to_binary_expr (expr));
424
- case 3 :
425
- return convert_ternary_sva (to_ternary_expr (expr));
426
- default :
427
- return convert_expr_rec (expr);
437
+ if (is_SVA_operator (expr))
438
+ {
439
+ switch (expr.operands ().size ())
440
+ {
441
+ case 1 :
442
+ return convert_unary_sva (to_unary_expr (expr));
443
+ case 2 :
444
+ return convert_binary_sva (to_binary_expr (expr));
445
+ case 3 :
446
+ return convert_ternary_sva (to_ternary_expr (expr));
447
+ default :
448
+ DATA_CHECK_WITH_DIAGNOSTICS (
449
+ validation_modet::INVARIANT,
450
+ false ,
451
+ " unexpected SVA expression" ,
452
+ expr.pretty ());
453
+ }
454
+ }
455
+ else
456
+ {
457
+ // not SVA, but an expression that gets sampled.
458
+ return convert_expr_rec (std::move (expr));
428
459
}
429
460
}
430
461
0 commit comments