synERJY: a High-Level Language for Embedded Controllers
by Reinhard Budde, Axel Poigné and Karl-Heinz Sylla
A team at Fraunhofer Institute for Autonomous Intelligent Systems has developed and implemented 'synERJY', a Java-like synchronous object-oriented language and programming system for the efficient design of embedded systems.
The design of embedded systems poses challenges reminiscent of those in the early days of computing: namely, to use as few resources in terms of memory and time as possible. New challenges have also been added, such as the distribution of functionality across a network and dependability of systems. For example, a modern car has a number of microprocessors communicating via field busses, and consumers are not amused if let down by a car due to a software error. Migration of functionality from hardware to software poses another challenge, as does sheer size. A mobile phone today carries software of a million lines of code in C, and substantially more at the high end of the market. Economic considerations are also indisputable: 99% of all processors are said to be used in embedded systems. Most of these are small microprocessors, but even 75% of high-end processors are claimed to reside not in workstations but in embedded systems.
In spite of the scientific challenges and the economic importance of embedded systems, software is often handcrafted as in the early days of computing. Even assembler languages are still used. High-level languages are often considered too costly in terms of memory and time consumption. On the other hand, it is fair to note that coding in assembler or even in C often turns out to be costly, since there is a mismatch between the design and the abstractions supported by the languages. The last fifteen years have seen the evolution of some languages and paradigms to close this gap. For instance, SDL has been adopted in telecommunications for programming asynchronous soft real-time systems, and tools such as STATEMATE have been used for programming synchronous hard real-time systems.
Engineers use tool sets like MATLAB/Simulink for modelling systems and for designing and analysing controllers on a wide scale. The underlying paradigm is that of synchrony. If we consider the difference equation of a filter
we note that:
- computation proceeds in discrete steps
- that the result depends on the actual input x(n) and the system state x(n-1), y(n-1)
- that the result y(n) must present at the same instant n as the input has been read.
The latter implies in practice that, while executing, input and system state should be frozen and that execution should be timely, ie terminate before the next step is supposed to take place. This is exactly the execution model of synchronous programming. In fact, we believe that synchrony is pervasive as a paradigm in the world of embedded control.
With synERJY we promote a high-level reactive Java-like language combining:
- object-oriented modelling for a robust and flexible design
- synchronous execution for a precise modelling of reactive behaviour with a well-defined semantics.
Highlights of synERJY are that it:
- provides a smooth embedding of the reactive behaviour into the object-oriented data model
- offers fine-grained integration of synchronous formalisms such as
- the imperative style of ESTEREL
- the dataflow-based style of LUSTRE
- hierarchical state machines in the style of STATECHARTS
- generates efficient code in space and time even for small microcontrollers.
There is little need to discuss the merits of object-oriented design. There are, however a couple of notable benefits to be gained from the combination of object-oriented design with synchronous programming:
- due to the underlying broadcast mechanism of synchronous programming, reactive objects (ie objects that exhibit reactive behaviour) behave like components, in that they may be 'plugged in' without changing their behaviour, regardless of the environment
- extending the causality analysis of other synchronous languages, time races between method calls can be detected enabling deterministic scheduling at compile time including the scheduling of all data actions
- the component-based approach supports hiding of hardware details such as irrelevant properties of, for example, specific CAN hardware.
Although it is a flexible high-level language, synERJY generates efficient code in contrast to standard expectations for Java-like languages. The language compiles to a subset of ANSI-C, for cross-compiling to the target architecture. Efficiency is gained by optimisation, eg replacing dynamic by static binding and avoiding object allocation whenever feasible. The basis of the optimisation is the closed world assumption that is reasonable for embedded systems. At present, the project is focusing on further optimisation.
The reactive code is compiled to a set of Boolean equations, which have a dense representation due to Boolean optimisation techniques such as using jump tables similar to BDDs. In fact, although the language targets microcontrollers, hardware formats can be generated, for instance for FPGAs, given that the data structures used are elementary. This is an additional benefit in that implementation decisions may be revised using hardware instead of software, without revising the design.
The language features a particular type of 'time' that allows system time to be accessed in a way consistent with the synchronous execution model. As a consequence, simulation using the synERJY tool set exactly coincides with the execution on a target machine including the timing, and is reproducible due to the guaranteed deterministic behaviour, an obvious benefit when testing systems.
SynERJY is a relatively new but by now stable language, the development of which has been supported by the ESPRIT Projects SYRF and CRISYS. At present it is mainly used in-house for robotics applications and externally for teaching purposes.
Links:
http://www.ais.fraunhofer.de/~ap/sE
Please contact:
Reinhard Budde, Fraunhofer-AIS
Tel: +49 2241 142417
E-mail: Reinhard.Budde@ais.fraunhofer.de
|