9
9
#include " sequence.h"
10
10
11
11
#include < util/arith_tools.h>
12
- #include < util/ebmc_util.h>
13
12
14
13
#include < temporal-logic/temporal_logic.h>
15
14
#include < verilog/sva_expr.h>
20
19
21
20
sequence_matchest instantiate_sequence (
22
21
exprt expr,
22
+ sva_sequence_semanticst semantics,
23
23
const mp_integer &t,
24
24
const mp_integer &no_timeframes)
25
25
{
@@ -32,17 +32,21 @@ sequence_matchest instantiate_sequence(
32
32
{
33
33
const auto u = t + from;
34
34
35
- // Do we exceed the bound? Make it 'true'
35
+ // Do we exceed the bound? Make it 'false'/'true', depending
36
+ // on semantics.
36
37
if (u >= no_timeframes)
37
38
{
38
39
DATA_INVARIANT (no_timeframes != 0 , " must have timeframe" );
39
- return {{no_timeframes - 1 , true_exprt ()}};
40
+ if (semantics == sva_sequence_semanticst::WEAK)
41
+ return {{no_timeframes - 1 , true_exprt{}}};
42
+ else // STRONG
43
+ return {}; // no match
40
44
}
41
45
else
42
46
return instantiate_sequence (
43
- sva_cycle_delay_expr.op (), u, no_timeframes);
47
+ sva_cycle_delay_expr.op (), semantics, u, no_timeframes);
44
48
}
45
- else
49
+ else // ##[from:to] something
46
50
{
47
51
mp_integer to;
48
52
@@ -51,25 +55,34 @@ sequence_matchest instantiate_sequence(
51
55
DATA_INVARIANT (no_timeframes != 0 , " must have timeframe" );
52
56
to = no_timeframes - 1 ;
53
57
}
54
- else if (to_integer_non_constant ( sva_cycle_delay_expr.to (), to ))
58
+ else if (! sva_cycle_delay_expr.to (). is_constant ( ))
55
59
throw " failed to convert sva_cycle_delay offsets" ;
60
+ else
61
+ to = numeric_cast_v<mp_integer>(
62
+ to_constant_expr (sva_cycle_delay_expr.to ()));
56
63
57
64
auto lower = t + from;
58
65
auto upper = t + to;
59
66
60
- // Do we exceed the bound? Make it 'true'
67
+ // Do we exceed the bound? Make it 'true' if we are doing
68
+ // weak semantics.
61
69
if (upper >= no_timeframes)
62
70
{
63
- DATA_INVARIANT (no_timeframes != 0 , " must have timeframe" );
64
- return {{no_timeframes - 1 , true_exprt ()}};
71
+ if (semantics == sva_sequence_semanticst::WEAK)
72
+ {
73
+ DATA_INVARIANT (no_timeframes != 0 , " must have timeframe" );
74
+ return {{no_timeframes - 1 , true_exprt ()}};
75
+ }
76
+ else
77
+ upper = no_timeframes - 1 ;
65
78
}
66
79
67
80
sequence_matchest matches;
68
81
69
82
for (mp_integer u = lower; u <= upper; ++u)
70
83
{
71
- auto sub_result =
72
- instantiate_sequence ( sva_cycle_delay_expr.op (), u, no_timeframes);
84
+ auto sub_result = instantiate_sequence (
85
+ sva_cycle_delay_expr.op (), semantics , u, no_timeframes);
73
86
for (auto &match : sub_result)
74
87
matches.push_back (match);
75
88
}
@@ -84,21 +97,25 @@ sequence_matchest instantiate_sequence(
84
97
85
98
// This is the product of the match points on the LHS and RHS
86
99
const auto lhs_matches =
87
- instantiate_sequence (implication.lhs (), t, no_timeframes);
100
+ instantiate_sequence (implication.lhs (), semantics, t, no_timeframes);
88
101
89
102
for (auto &lhs_match : lhs_matches)
90
103
{
91
104
auto t_rhs = lhs_match.end_time ;
92
105
93
- // Do we exceed the bound? Make it 'true'
106
+ // Do we exceed the bound? Make it 'false'/'true', depending
107
+ // on semantics.
94
108
if (t_rhs >= no_timeframes)
95
109
{
96
110
DATA_INVARIANT (no_timeframes != 0 , " must have timeframe" );
97
- return {{no_timeframes - 1 , true_exprt ()}};
111
+ if (semantics == sva_sequence_semanticst::WEAK)
112
+ return {{no_timeframes - 1 , true_exprt{}}};
113
+ else // STRONG
114
+ return {}; // no match
98
115
}
99
116
100
- const auto rhs_matches =
101
- instantiate_sequence ( implication.rhs (), t_rhs, no_timeframes);
117
+ const auto rhs_matches = instantiate_sequence (
118
+ implication.rhs (), semantics , t_rhs, no_timeframes);
102
119
103
120
for (auto &rhs_match : rhs_matches)
104
121
{
@@ -119,9 +136,9 @@ sequence_matchest instantiate_sequence(
119
136
auto &intersect = to_sva_sequence_intersect_expr (expr);
120
137
121
138
const auto lhs_matches =
122
- instantiate_sequence (intersect.lhs (), t, no_timeframes);
139
+ instantiate_sequence (intersect.lhs (), semantics, t, no_timeframes);
123
140
const auto rhs_matches =
124
- instantiate_sequence (intersect.rhs (), t, no_timeframes);
141
+ instantiate_sequence (intersect.rhs (), semantics, t, no_timeframes);
125
142
126
143
sequence_matchest result;
127
144
@@ -146,7 +163,7 @@ sequence_matchest instantiate_sequence(
146
163
auto &first_match = to_sva_sequence_first_match_expr (expr);
147
164
148
165
const auto lhs_matches =
149
- instantiate_sequence (first_match.lhs (), t, no_timeframes);
166
+ instantiate_sequence (first_match.lhs (), semantics, t, no_timeframes);
150
167
151
168
// the match of seq with the earliest ending clock tick is a
152
169
// match of first_match (seq)
@@ -183,7 +200,7 @@ sequence_matchest instantiate_sequence(
183
200
auto &throughout = to_sva_sequence_throughout_expr (expr);
184
201
185
202
const auto rhs_matches =
186
- instantiate_sequence (throughout.rhs (), t, no_timeframes);
203
+ instantiate_sequence (throughout.rhs (), semantics, t, no_timeframes);
187
204
188
205
sequence_matchest result;
189
206
@@ -210,16 +227,16 @@ sequence_matchest instantiate_sequence(
210
227
211
228
auto &within_expr = to_sva_sequence_within_expr (expr);
212
229
const auto matches_rhs =
213
- instantiate_sequence (within_expr.rhs (), t, no_timeframes);
230
+ instantiate_sequence (within_expr.rhs (), semantics, t, no_timeframes);
214
231
215
232
sequence_matchest result;
216
233
217
234
for (auto &match_rhs : matches_rhs)
218
235
{
219
236
for (auto start_lhs = t; start_lhs <= match_rhs.end_time ; ++start_lhs)
220
237
{
221
- auto matches_lhs =
222
- instantiate_sequence ( within_expr.lhs (), start_lhs, no_timeframes);
238
+ auto matches_lhs = instantiate_sequence (
239
+ within_expr.lhs (), semantics , start_lhs, no_timeframes);
223
240
224
241
for (auto &match_lhs : matches_lhs)
225
242
{
@@ -245,8 +262,10 @@ sequence_matchest instantiate_sequence(
245
262
// 3. The end time of the composite sequence is
246
263
// the end time of the operand sequence that completes last.
247
264
auto &and_expr = to_sva_and_expr (expr);
248
- auto matches_lhs = instantiate_sequence (and_expr.lhs (), t, no_timeframes);
249
- auto matches_rhs = instantiate_sequence (and_expr.rhs (), t, no_timeframes);
265
+ auto matches_lhs =
266
+ instantiate_sequence (and_expr.lhs (), semantics, t, no_timeframes);
267
+ auto matches_rhs =
268
+ instantiate_sequence (and_expr.rhs (), semantics, t, no_timeframes);
250
269
251
270
sequence_matchest result;
252
271
@@ -268,7 +287,7 @@ sequence_matchest instantiate_sequence(
268
287
sequence_matchest result;
269
288
270
289
for (auto &op : expr.operands ())
271
- for (auto &match : instantiate_sequence (op, t, no_timeframes))
290
+ for (auto &match : instantiate_sequence (op, semantics, t, no_timeframes))
272
291
result.push_back (match);
273
292
274
293
return result;
@@ -277,7 +296,8 @@ sequence_matchest instantiate_sequence(
277
296
{
278
297
// x[*n] is syntactic sugar for x ##1 ... ##1 x, with n repetitions
279
298
auto &repetition = to_sva_sequence_consecutive_repetition_expr (expr);
280
- return instantiate_sequence (repetition.lower (), t, no_timeframes);
299
+ return instantiate_sequence (
300
+ repetition.lower (), semantics, t, no_timeframes);
281
301
}
282
302
else if (
283
303
expr.id () == ID_sva_sequence_repetition_plus ||
0 commit comments