The objectives of this step are the following:

  • Use an existing DSL dedicated to programming reactive systems as data-flow
  • integrate the DSL in the compilation toolchain

This step requires an up and running setup of Lustre on your computer. Lustre is a language that was designed for safety-critical systems (avionics, nuclear plants), in Grenoble, in the late 80s. Its industrial version Scade is still used by Airbus.


The blinking led example (again!)

In Lustre, things are simple, we encode the sequence of values of boolean or numerical variables into nodes. The compilation chain does the rest!

node cpt(reset:bool) returns  (led_on: bool) ;
let
led_on = false -> not(pre(led_on));
tel

Compilation Infrastructure

The Lustre compiler takes as input a Lustre program and produces two files: node.c (the code for the reactive nodes) and main.c, the entry point. To produce an ELF (Executable and Linkable Format) file ready to be uploaded on the board we will rely on avr_gcc, a version of GCC that targets AVR micro-controllers.

We feed  avr_gcc with the files produced by the Lustre compiler, as well as Arduino-related files (header and implementation). Finally, a file named glue_arduino is necessary to bind the abstract node representation to physical pins.


Expected work

  • download the sample material, and read the different files
  • Modify the lustre code to implement the reset mechanism when the button is pressed. Identify the artifacts that also need to be modified.
  • Implement the 7-segments counter behaviour using this environment.

Stepback Questions

  • Who is the intended user for such a language?

  • What is the cost of reusing this existing DSL for the developer in terms of code?

  • What is the cost of adding a new task to our domain?

  • Was is the cost of adding a new hardware target?

  • The Lustre language comes with its own ecosystem (test, formal verification), what are the generic properties we can imagine to prove from our domain?
  •  
  • Next: Designing an external DSL