These source files contain the implementation, models, and proof of correctness of a formally verified Lustre compiler
This file contains instructions for (i) using the compiler from (ii) a local opam installation.
The examples/ subdirectory contains another readme file presenting several
example programs that can be used to test the compiler.
The pre operator used in many Lustre programs is not yet treated.
An uninitialized delay pre e must be replaced by an initialized one 0 fby e.
Compiler error messages are still very brutal. In particular the parser only reports syntax errors with a line number and character offset. We will implement more helpful messages when we have finalized one or two remaining details of the final language.
To run the compiler:
./velus -h
In particular, typing
./velus examples/count.lus
will compile the Lustre program in examples/count.lus into an assembler program examples/count.s.
The compiler also accepts the options
-
-dnolastOutput the Lustre code after compilation of last declarations into .nolast.lus -
-dnoautoOutput the Lustre code after compilation of state machines into .noauto.lus -
-dnoswitchOutput the Lustre code after compilation of switch blocks into .noswitch.lus -
-dnolocalOutput the Lustre code after inlining of local scopes into .nolocal.lus -
-dnlustreOutput the normalized NLustre code into .n.lus -
-dstcOutput the Stc intermediate code into .stc -
-dschOutput the scheduled code into .sch.stc -
-dobcOutput the Obc intermediate code into .obc -
-dclightOutput the generated Clight code into .light.c -
-
nofusionDisable the if/then/else fusion optimization. -
-
syncGenerate an optionalmain_syncentry point and a .sync.c containing a simulation that prints the outputs at each cycle and requests inputs. In contrast tomain_proved, this entry point is not formally verified but it is useful for testing the dynamic behaviour of compiled programs. Seeexamples/Makefilefor examples.
Vélus has been implemented in Coq.8.20.1. It includes a modified version of CompCert and depends on menhir.
To build a self-contained installation for compiling and running Vélus, we recommend installing an ad-hoc opam directory:
$ git clone https://github.com/INRIA/velus
$ cd velus
$ git submodule --init --recursive
$ opam switch create velus --packages=ocaml.4.14.2,coq.8.20.1
$ eval $(opam env --switch=velus --set-switch)
$ opam install -j ocamlbuild menhir ocamlgraphTo check the proofs and build Vélus:
$ ./configure [options] <target>
$ make -j # Uses all the available coresThe <target> must be one of the supported target platforms
of CompCert.
The configuration script has the same options as CompCert's with the following specfic to Vélus:
-
-velus-onlyOnly compile Vélus (and not CompCert). This option may be useful with-compcertdir. -
-compcertdirOverrides the default path to the directory containing your local version of CompCert. -
-flocqdirSet the path to the directory containingFlocqif you're not using the one packaged in CompCert. -
-menhirlibdirSet the path to the directory containingMenhirLibif you're not using the one packaged in CompCert.
If you are using the nix package manager, you can
directly compile Vélus using the flake with the command nix build. This does
not require a local version of CompCert to build.