[FMFP] Modelling

This commit is contained in:
2026-06-07 12:18:14 +02:00
parent 83999cc32c
commit bd50083741
7 changed files with 126 additions and 1 deletions
+53
View File
@@ -0,0 +1,53 @@
// --- Constants -----------------------------------------------
// As C preprocessor macros
#define N 5
// Symbolic constant
mtype = { ack, req };
// --- Typedef -------------------------------------------------
// Structure declarations
typedef vector { int x; int y };
// --- Channels ------------------------------------------------
// Channels are used to exchange messages between processes
chan buf = [2] of { int }; // can store up to 2 integers
chan buf2 = [2] of { mtype, bit, chan }; // Messages are Triples
chan channel = [0] of { int }; // No buffer
chan unassigned_chan; // This channel is unassigned
// --- Variables -----------------------------------------------
// Note that there are no floats and unbounded integers.
// Variables are initialized to 0 (ish) values
// If defined outside a process, they are global, if inside,
// they are scoped to said process
bit bit_val; // 1 bit
bool bool_val; // Equivalent to bit, also 1 bit
byte counter; // 1 byte (0...255)
short short_val; // 2 bytes (-2^15 ... 2^15 - 1)
int val; // 4 bytes
int arr[4]; // 16 bytes, array of four integers
vector v; // using the custom vector type
mtype msg = ack; // Using the symbolic constant
// --- Processes -----------------------------------------------
// Process declarations
proctype myProc(int p) {
// Like the init body, any promela statements go in here
// This includes any variable or channel declarations
printf("My process");
}
active [N] proctype myActiveProc(int p) {
// Body goes here
}
// --- Initial state -------------------------------------------
init {
printf("Hello World");
}