Creating Modules from MATLAB/Simulink

ALOE signal processing modules code can be automatically generated from MATLAB/Simulink. With this high-level simulation tool you can test the functionality of your module and synthesize C code compatible with ALOE. In addition, a Workshop Target has been created in order to automatically generate the interface to the ALOE SW-API.

The following guide explains with an example how to create signal processing modules from MATLAB/Simulink:


1) MATLAB 2008/2009 and Simulink

2) Linux with ALOE 1.2 or greater


To be able to generate ALOE modules from MATLAB, you need to configure MATLAB and ALOE.


1) Copy ALOE target files to Matlab's path:


ALOE Simulink target list of files:

  • lnx_callback.m
  • lnx_install_dir.m
  • aloe_main.c
  • lnx_unix.tmf
  • make_lnx.m
  • aloe.tlc
  • rtwmakecfg.m

This files are packed in the file:

2) Start Matlab and add the new directory to Matlab's path (File->Set path...)


To compile Matlab models from on the Linux machine, we have to copy Matlab’s libraries and headers to Linux. This is as easy as copying the directory structure from the Matlab directory to the linux machine.

We recomend to create a directory on Linux


Copy there the following directories from the Matlab installation path:


The ALOE target directory under rtw/c/ must also be copied.

The amount of files to copy may be quite big (depending on the number of toolboxes you have installed). Obviously, only the toolboxes that you are going to use should be copied however, we recommend to copy all of them, nobody knows what your will be doing in the future.

Model Generation

Before you generate the code, you have to tell ALOE which signals will be used as inputs and outputs. Any Simulink signal will not be accessible from the C implementation unless we explicitly tell Simulink to enable so. This is done by selecting the signal option “Test point”.

The second trick is to indicate ALOE the direction of the signal (input/output). We will insert the key in_ or out_ before the name of the signal. The name that ALOE will finally use to access this interface (in the Application Definition’s File) will be, for the case of an input interface:

  • in_itfName_re for the real part and
  • in_itfName_im for the imaginary part.

Finally, we have to select the interface we want to use to access this signal which will be global export.

All these options can be selected under the Signal Properties menu (right-click on the signal and select Signal Properties). Then, select Test point option and the name of the signal.

Now select storage class ExportedGlobal? under Real-Time Workshop tab:

1) Generate the code for the model Let’s now configure Simulink’s model to generate an implementation for the ALOE target. On the model window, go to Tools->Real Time Workshop->Options...

Select Target file: aloe.tlc (click on browse button)

Go to Interface menu and select C API interface.

Then go to ALOE Target code generation options and make sure that target files in the Linux machine are correctly specified (step 3):

Finally, we have to select the discretization model. On the same screen, select Solver menu (on the left tree). Under Solver Options, select fixed-step type and Discrete solver. Set also infinite simulation time (set inf at Stop time option). Fill the rest of the parameters according to the following capture if they are different.

Now you can generate the code. Click on Tools->Real Time Workshop->Build Model and the model will be generated (see Matlab’s main output screen for errors).

2) Compile the implementation on Linux

Now, compiling the model under Linux should be easy. Copy the output files (generated by simulink model generator) to any directory on the Linux machine. The files will be generated under a directory with the name modelname_aloe_rtw on your current Matlab’s model path.

On a linux console, go to your model path and type:

make -f

This should compile your model and create the executable at ../modelname

3) Running the model on ALOE

On the last step, we will copy the executables for all the models of our application to the ALOE SWMAN Executable’s repository (usually at %phal-repositories%/swman_execs/linux/) so that it is accessible to the framework.

Then, we will write the Application Definitions File according to how we want to interconnect the modules and paying attention to the interface name convention (step 4) for inputs/outpus and real/imaginary parts.

The following is an example of a source model:

object {
        outputs {
        outputs {

Back to ALOE