Skip to content

Commit 8cfcf9b

Browse files
covanamrostedt
authored andcommitted
verification/rvgen: Support the 'next' operator
The 'next' operator is a unary operator. It is defined as: "next time, the operand must be true". Support this operator. For RV monitors, "next time" means the next invocation of ltl_validate(). Cc: John Ogness <john.ogness@linutronix.de> Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Link: https://lore.kernel.org/9c32cec04dd18d2e956fddd84b0e0a2503daa75a.1752239482.git.namcao@linutronix.de Signed-off-by: Nam Cao <namcao@linutronix.de> Tested-by: Gabriele Monaco <gmonaco@redhat.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent e93648e commit 8cfcf9b

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

Documentation/trace/rv/linear_temporal_logic.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Operands (opd):
4141
Unary Operators (unop):
4242
always
4343
eventually
44+
next
4445
not
4546

4647
Binary Operators (binop):

tools/verification/rvgen/rvgen/ltl2ba.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
# Unary Operators (unop):
2020
# always
2121
# eventually
22+
# next
2223
# not
2324
#
2425
# Binary Operators (binop):
@@ -35,6 +36,7 @@
3536
'UNTIL',
3637
'ALWAYS',
3738
'EVENTUALLY',
39+
'NEXT',
3840
'VARIABLE',
3941
'LITERAL',
4042
'NOT',
@@ -48,6 +50,7 @@
4850
t_IMPLY = r'imply'
4951
t_UNTIL = r'until'
5052
t_ALWAYS = r'always'
53+
t_NEXT = r'next'
5154
t_EVENTUALLY = r'eventually'
5255
t_VARIABLE = r'[A-Z_0-9]+'
5356
t_LITERAL = r'true|false'
@@ -327,6 +330,26 @@ def negate(self):
327330
# ![]F == <>(!F)
328331
return EventuallyOp(self.child.negate()).normalize()
329332

333+
class NextOp(UnaryOp):
334+
def normalize(self):
335+
return self
336+
337+
def _is_temporal(self):
338+
return True
339+
340+
def negate(self):
341+
# not (next A) == next (not A)
342+
self.child = self.child.negate()
343+
return self
344+
345+
@staticmethod
346+
def expand(n: ASTNode, node: GraphNode, node_set) -> set[GraphNode]:
347+
tmp = GraphNode(node.incoming,
348+
node.new,
349+
node.old | {n},
350+
node.next | {n.op.child})
351+
return tmp.expand(node_set)
352+
330353
class NotOp(UnaryOp):
331354
def __str__(self):
332355
return "!" + str(self.child)
@@ -452,12 +475,15 @@ def p_unop(p):
452475
'''
453476
unop : ALWAYS ltl
454477
| EVENTUALLY ltl
478+
| NEXT ltl
455479
| NOT ltl
456480
'''
457481
if p[1] == "always":
458482
op = AlwaysOp(p[2])
459483
elif p[1] == "eventually":
460484
op = EventuallyOp(p[2])
485+
elif p[1] == "next":
486+
op = NextOp(p[2])
461487
elif p[1] == "not":
462488
op = NotOp(p[2])
463489
else:

0 commit comments

Comments
 (0)