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