Mat Bennion

Case Study:

Automatic Simulink Wrappers

The team were developing Simulink blocks (Simulink is a graphical modelling tool that forms part of MATLAB, a mathematical programming tool).  Each Simulink block consisted of functional code written in C for an embedded target, and a wrapper, also written in C and using the Simulink API to allow the embedded code to be integrated with the Windows Simulink platform.

The problem was that writing the wrappers was time consuming, error prone and the resulting code was difficult to review.  A colleague and I thought that it would be great if we could automate the production of the wrappers.  After investigating various scripting languages, I decided that Perl would be ideal for this task, and quickly taught myself basic Perl skills.  I created a wrapper definition language that contained the least possible information needed to generate a wrapper, to minimise duplication of information and facilitate reviewing.  I developed a set of C, Perl and MATLAB scripts and templates that automatically created a Simulink library containing all our blocks.

This automated system generated about 500,000 lines of code and allowed us to deliver the project fully reviewed and tested, on time and with no reported bugs, even after three years' use.  The customer was very impressed and is looking into using the system themselves.

This experience has taught me to be constantly on the look-out for aspects of the software development process that can be automated, as this often has remarkable benefits.