2.2. Cellular Automata

Cellular automata are likewise an application area well suited to SIMD systems. Every cell can be assigned a processor and carries out the same processing instructions. One of the most prominent cellular automata is Conway's `Game of Life', which is a two-dimensional structure changing in time. The cellular automaton shown here is simpler and only one-dimensional; however, it generates a two-dimensional image during execution (one line on every iteration). The processing instructions are conceptually simple: Every cell has only two possible states and computes its successor state from an exclusive-or of the states of its left and right neighbor. The middle cell is initialized with TRUE (printed as `X'), while all of the other cells are initialized with FALSE (printed as empty spaces).

MODULE cellular_automaton; 
CONST n = 79;           (* number of elements        *) 
      m = (n+1) DIV 2;  (* number of loops := middle *) 
CONFIGURATION list [1..n];
CONNECTION left:  list[i] <-> list[i-1] :right; 
 
VAR i  : INTEGER; 
    val: list OF BOOLEAN; 
    c  : list OF ARRAY BOOLEAN OF CHAR; 
            (* = ARRAY[FALSE..TRUE] OF CHAR *) 
BEGIN 
  val     := ID(list) = m; (* Init *) 
  c[FALSE]:= " "; 
  c[TRUE] := "X"; 
  FOR i := 1 TO m DO 
    Write(c[val]); WriteLn;< 
    val := MOVE.left(val) <> MOVE.right(val); 
  END; 
END cellular_automaton. 
The CONFIGURATION and CONNECTION declarations define a doubly linked list of PEs. For screen output of the current state of all PEs, every boolean state is converted to a symbol of type CHAR. The complete character vector is then written to the screen sequentially by a vector valued Write operation. The initialization of the main program assigns the value TRUE only to the middle PE with number (n+1 DIV 2); all other PEs receive the value FALSE. Finally, there is a scalar loop which prints the current state and calculates the next cell state in each pass, using data exchange with the left and right neighbors.

Figure 13 shows the states of this cellular automaton, in which time progresses from top to bottom.

Figure 13 Output of cellular automaton


[ Previous Page | Table of Contents | Next Page ]