Automatic code and test generation

The advantage of having a model based representation of the requirements or the design of a system is that it is very often possible to derive some code from the models automatically, and to derive some tests under given conditions.
Automatic code generation
Code can be generated for:
  • HOOD models; if the Object Description Skeleton is filled with the appropriate pseudo code, then the tools can translate it into flight code
  • UML models, which generate the code skeleton. Some tools assist in editing the code in a graphical way, the code is inserted automatically in the right place. Several tools ensure consistency of the code and the model (round trip engineering)
  • Behavioural models, where code has already been generated for the simulation, but specific code is generated for on-board use.
    • MatLab has code generators for C and Ada. They have been modified to be Ravenscar compatible (Margot project)
    • Telelogic Tau has a SDL-to-C code generator
Autocode requires a good definition of the system/software process, a deep knowledge of the autocoder, and a strong control of the software architecture, as indicated in the ESA guidelines.
Automatic test generation
Automatic test generation is another benefit derived from the existence of a model. The level of the model is important. It must be a model of the requirements. If tests are derived from the very same model from which code is derived, then the tests are testing the code generator. Tests must be derived from a high level model, which will be refined towards the autocode model.

An experiment has been performed with a B model of part of the ATV flight code, using the Leirios technology.
Last update: 20 March 2007

More information

 •  Margot (
 •  Autocode guidelines (pdf) ( on the use of automatic code generation 1.0.PDF)
 •  ATV Autotest generation (pps) ( Test Generator (evaluation).pps)
 •  Industrial use of autocode (pdf) (
 •  Automated software production (pdf) (
 •  Diversity by automation (pdf) (
 •  Automation in statistical testing (pdf) (

Related links

 •  LEIRIOS test generator (