Previous Up Next

3  The CRP Language

CRP (Communicating Regular Processes) is an extension of C to handle processes, port and channels.

3.1  Program Structure

An application is a collection of function and process definitions. Several definitions can be collected in a module (usually a file); an application can be composed of an arbitrary number of modules. Like in C, process and function definitions are toplevel objects and cannot be embedded in each others.

3.2  Syntax

The basis of the syntax of CRP is ANSI C1. There are, however, a few new keywords: process, inport, outport, channel. All these are reserved and are considered as additional “storage class specifiers” in the C grammar.

3.3  Semantics

3.3.1  Basic Types

The basic types are void, int and float in various sizes (long, long long, short, char, double). The addition of another basic type, fix, is contemplated for embedded system design.

3.3.2  Arrays and other Data Structures

There is an array constructor, [], with the same properties as the C array constructor. However, the rules for dimensions are much more permissive than in C. In fact, in many cases, the compiler deduces the size of the array from the way it is used.

The array constructor may not be applied to ports, channels and processes.

There is a structure constructor, with the same syntax and properties as in C. However ports, channel and processes cannot be members of a structure.

In the present version of the language, pointers are ignored.

3.3.3  Functions

User-defined functions are inlined. Hence, recursion is forbidden.

One may use blackbox functions, which are handled by the system as if they were pure (no modifications of the actual parameters or of global variables). In embedded system design, such functions may be useful for representing the use of IPs. For instance, instead of writing:

  x = y + z;

on may want to write

  x = adder_7bits(y, z);

if one knows that 7 bits are enough for this particular addition.

3.3.4  Processes

A process is a sequential program which can communicate with other processes through channels (see ??). All variables are local to one and only one process and are not visible from other processes.

Besides operative statements, a process can include process start statements, which have the same syntax as a function call. Process Start Statements (PSS) are not part of the control flow of the surrounding process. In effect all the PSS in an application are collected and executed immediately at application start time. One can define a process start graph, which must be a DAG.

The operating code of a process must be regular, or have static control, in the following sense:

Some of these restrictions are quite natural when one is designing compute-intensive embedded systems with real time constraints. It is difficult, for instance, to predict the execution time of a while loop or of the traversal of a truly dynamic data structure. Other restrictions can be lifted by preprocessing (goto removal, inductive variable detection, subscript-like pointer detection, function inlining).

3.3.5  Channels

A channel is the only medium of communication between processes. A channel can be viewed as a write-once/read-many array of indefinite dimension. Each cell has a (virtual) full/empty bit. At application start time, all such bits are set to “empty”.

There is no way of emptying a cell.

The reader is cautionned that this is just a specification of the behaviour of a channel. The actual implementation may be quite different. In fact, syntol object code is synchronous.

A channel may have any number of readers, and there are no constraints on the reading patterns. Reading is not destructive: a value remains in a channel at least as long as some process may have some use for it.

3.3.6  Ports

A port is an interface between a process and a channel. It allows, inter alia, that a process be instanciated several times, each instance being connected to different channels.

When connecting ports, one must verify (statically) that the two ports have the same (data) type and dimension, The connections between channel and ports are satisfied when a process is created. Channels play the role of actual parameters to the port formal parameters.

The usual rule of visibility applies to ports and channels. Let P be a process in which a channel c is declared. The only processes which can access c are P itself and processes which are started by P and which have a port connected to c.


Previous Up Next