In this note, we will address the notion of synchronous models and present the model of extended finite state machines, which are a versatile model for synchronous systems.
The term synchrony comes from the Greek words syn meaning "with" and kronos meaning time. As a result, synchronous models are models that are somehow synchronized to a clock. Synchronous models arise from digital computers.
A digital computer performs computation on a processor that has a clock which is a square wave oscillating at a fixed frequency. The computer performs its most fundamental (micro) operations such as reads/writes from register, ALU operations, reads from the bus when an edge (rising or falling edge) of the clock is encountered.
Synchronous systems abstract this concept further. We assume that time \(t\) is a non negative integer starting from \(t = 0\) and proceeding as \(t=1,2,3,\ldots\). Each time instant represents a clock edge, and all system operations happen at this very instant. We assume that the system's operations take no time whatsoever.
The figure below shows an example of a module with an input \(y\) internal state (memory) \(x\) and output \(z\). The module itself runs a C program at each time instant to calculate the new output \(z\) and the new value of the memory store.
Before the start, let us take \(x =1\). Suppose the inputs received are
Time |
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
\(y\) |
1 |
-1 |
-2 |
1 |
-2 |
1 |
2 |
0 |
2 |
At each time instant, the system the system receives a clock signal and processes its input. At \(t=0\), it receives \(y=1\). It calculates the new state \(x= 0\) and outputs \(z=0\). The system executes again at \(t=1, 2\) and so on. Overall, the value of \(x,z\) for the first \(8\) steps are as below.
Time |
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
\(x\) |
0 |
1 |
2 |
1 |
2 |
1 |
0 |
1 |
0 |
\(z\) |
0 |
1 |
2 |
1 |
2 |
1 |
0 |
1 |
0 |
We will first define typed variables and their associated domains. A type such as int, real, bool refers to a set of values associated with the type. For instance, int refers to the set of integers, bool to the set \(\{T, F\}\).
A typed variable \(x:\ \texttt{t}\) declares a variable \(x\) of type \(\texttt{t}\). For such a variable the set \(D(x)\) denotes the set of all possible values that \(x\) can take.
Example: Typed variable
The typed variable \(x: \texttt{int}\) declares a variable \(x\) such that \(D(x):\ \mathbb{Z}\), the set of all integers.
In our presentation, we will associate types to variables that are inputs, outputs and internal state variables for the synchronous systems we define. A typed variable \(x\) has a pre-defined type such as int, real, bool, string and so on. We associate \(x\) with a domain \(D(x)\) that refers to the set of possible values it can take. Likewise, given a set of variables \(X\), we use the shorthand \(D(X)\) to the product of the domains of each individual variables.
A (deterministic) synchronous module is defined by a tuple \((X, I, O, \delta, x_0)\), wherein
Going back to the example (1) above, we have
\[\delta(x,y):\ \begin{cases} (x-1, x-1) & \text{if}\ y > 0\\ (x+1, x+1) & \text{if}\ y \leq 0 \\ \end{cases} \]
An execution of a deterministic synchronous module \((X, I, O, \delta, x_0)\) given a sequence of inputs \[ i(0), i(1), i(2), i(3), \ldots \]
is a sequence of pairs \(( x(j), o(j) )\) for \(j=0,1,\ldots,\) such that
In other words, the systems state before the time \(t = 0\) is \(x_0\). The subsequent states starting from \(x(0), \ldots\) and the subsequent outputs \(o(0), o(1), \ldots\) are all obtained by applying the transition relation on the previous state of the system.
However, the mathematical definition provided above is quite general, and will cover every synchronous model imaginable. However, it is also quite unwieldy. Simply put, it is good for simple example but does not help us model more complex examples. Therefore, we will use the visual model of extended finite state machines to model synchronous systems.
EFSMs are a simple and natural class of models for synchronous systems. An EFSM models a synchronous system using a state machine which has finitely many modes (also known as states) and transitions (edges) between them.
@(ex4) Example of an EFSM
Consider the system shown below.
The system defines a synchronous module.
Let us look in isolation at one of the arrows below.
The arrow goes from \(s_0\) to \(s_1\). The part \([i \geq 0]\) is the guard of the transition and the assignments \(x := 0, z := 0\) represent the updates made by the transition.
Each transition has the following syntax
[guard condition]/{action}
The guard condition can involve a Boolean predicate over the input and internal state variables of the EFSM, and specifies what needs to be true about the input and the internal state for the transition to be enabled. The action specifies assignment to the output and internal state variables when the transition is taken.
An Deterministic EFSM is a tuple \((Q, X, I, O, s_0, x_0, \delta)\) with the following components
Going back to Example @(ex4), we have
\[ \delta(i, q, x): \left\{\begin{array}{cccl|l} q' & x' & z \\ (s_0, & x, & x ) & \text{if}\ q = s_0\ \land\ i < 0 & \texttt{self loop on }\ s_0\\ (s_1, & 0, & 0 ) & \text{if}\ q = s_0\ \land\ i \geq 0 & \texttt{edge from}\ s_0 \rightarrow s_1\\ (s_1, & x+1,& x) & \text{if}\ q = s_1\ \land\ i \geq 0\ \land x \leq 0 & \texttt{self loop on}\ s_1\\ (s_0, & 0, & x ) & \text{if}\ q = s_1\ \land\ (i < 0\ \lor\ x > 0) & \texttt{edge from}\ s_1 \rightarrow s_0\\ \end{array}\right.\]
The guard conditions satisfy the following.
Check that these conditions are actually true for the example of EFSM above. In particular, the guards on the ougoing edges of \(s_1\) are
Verify that \(\varphi_1 \land \varphi_2: \text{false}\) and \(\varphi_1 \lor \varphi_2: \text{true}\).
Thus far, we have defined a deterministic synchronous module and the model of deterministic extended finite state machines. In the subsequent section, we will look into nondeterministic models, introduce event types and talk about compositions of these systems.