m4 magic
This commit is contained in:
parent
6f31f57b32
commit
942de9a1ae
3 changed files with 22 additions and 7 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
|||
Examples
|
||||
**/pan.*
|
||||
**/pan
|
||||
*.tmp
|
||||
*.tmp
|
||||
/ReversalModel/reversal.pml
|
|
@ -1,6 +1,9 @@
|
|||
#define N 2
|
||||
#define LENGTH 3
|
||||
#define R 2
|
||||
define(N, `2')
|
||||
define(LENGTH, `3')
|
||||
define(R, `2')
|
||||
|
||||
define(`for',`ifelse($#,0,``$0'',`ifelse(eval($2<=$3),1,
|
||||
`pushdef(`$1',$2)$4`'popdef(`$1')$0(`$1',incr($2),$3,`$4')')')')
|
||||
|
||||
int to_reverse[LENGTH]; // array to reverse
|
||||
int reversed_seq[LENGTH]; // for SequentialReverser: where the reverse is stored
|
||||
|
@ -15,8 +18,8 @@ bool seq_eq_to_parallel = true;
|
|||
|
||||
// ThreadedReverser implementation
|
||||
proctype ThreadedReverser(int from; int to; int n) {
|
||||
printf("proc[%d]: started\n", _pid);
|
||||
|
||||
printf("proc[%d]: started from=%d to=%d\n", n, from, to);
|
||||
|
||||
int k;
|
||||
for (k: from .. to) {
|
||||
printf("reversed_par[%d] = to_reverse[%d]\n", LENGTH - k - 1, k);
|
||||
|
@ -63,7 +66,7 @@ init {
|
|||
int from = n * s;
|
||||
int to;
|
||||
if
|
||||
:: (n == N - 1) -> to = LENGTH - 1;
|
||||
:: (n == N) -> to = LENGTH - 1;
|
||||
:: else -> to = n * s + s - 1;
|
||||
fi
|
||||
run ThreadedReverser(from, to, n); // run as "thread n"
|
||||
|
@ -97,5 +100,11 @@ ltl seq_eq_parallel {
|
|||
}
|
||||
|
||||
ltl termination {
|
||||
// <> (done[0] == true for(`x', 1, N, ` && done[x] == true'))
|
||||
<> (done[0] == true && done[N] == true)
|
||||
}
|
||||
|
||||
ltl correctness_seq {
|
||||
done[0] == true -> (true for(`k', 0, LENGTH-1, ` &&
|
||||
reversed_seq[eval(LENGTH - k - 1)] == to_reverse[k]'))
|
||||
}
|
|
@ -1,5 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
|
||||
|
||||
if [ $# -ne 1 ]; then
|
||||
echo "LTL property name required" > /dev/stderr
|
||||
exit 1
|
||||
|
@ -9,6 +13,7 @@ fi
|
|||
|
||||
set -e
|
||||
|
||||
m4 -I"$SCRIPT_DIR" reversal.pml.m4 > reversal.pml
|
||||
spin -a reversal.pml
|
||||
gcc-13 -Wno-format-overflow -DPRINTF -o pan pan.c
|
||||
./pan -a -N "$1"
|
||||
|
|
Reference in a new issue