Real-Time Workshop User's Guide    

Getting Started

This section illustrates, through a simple example, how to transform a Simulink model into a stand-alone executable program. This program runs independently of Simulink, allowing accelerated execution on the development host or a different target computer.

Generating Ada code from a Simulink model is very similar to generating C code. Begin by typing

at the MATLAB prompt. This block diagram appears.

Figure 16-1: Counter Demonstration with Subsystems Open

Setting Options for Ada Code Generation

You must specify the correct options before you generate Ada code from this model. These are the steps:

  1. Select Parameters under the Simulation menu. This opens the Simulation Parameters dialog box.
  2. On the Solver page, set the Solver options to Fixed-step discrete (no continuous states)
  3. Select the Real-Time Workshop page. In the Category menu, select Target configuration.
  4. Click the Browse button. This opens the System Target File Browser.
  5. Select Ada Simulation Target for GNAT and click OK. This automatically sets the correct System target file, Template makefile, and Make command fields for Ada code generation.

    Figure 16-2 shows the System Target File Browser with the correct selection for Ada code generation.

Figure 16-2: The System Target File Browser

Alternatively, you can specify the settings on the Real-Time Workshop page manually by following these steps:

  1. Select Options under the Real-Time Workshop submenu of the Tools menu. This opens the Real-Time Workshop page of the Simulation Parameters dialog box.
  2. In the Category menu, select Target configuration.
  3. Specify rt_ada_sim.tlc as the System target file.
  4. Specify gnat_sim.tmf as the Template makefile.
  5. Specify make_rtw -ada as the Make command.

Figure 16-3 shows the Real-Time Workshop page with the correct settings.

Figure 16-3: Target Configuration Settings in the Real-Time Workshop Page

In addition, you can use the make command to pass compiler switches to the code compilation phase. For example, if you want to compile with debugging symbols, add a -g after the -ada switch in the Make command field (there must be a space between each switch). This switch is applied on a model basis; for more permanent changes, see Configuring the Template Makefile.

Generating Ada Code

To generate Ada code and build an Ada executable, open the Real-Time Workshop page. In the Category menu, select Target configuration. Click the Build button.

Alternatively, select Build Model under the Real-Time Workshop submenu of the Tools menu.

Generated Files

The Real-Time Workshop Ada Coder creates output files in two directories during the build process:

This table lists the Ada files generated by the Real-Time Workshop Ada Coder from the counter demonstration (countersdemo).

Table 16-1: Ada Files Generated by the Real-Time Workshop
Ada Coder  
Filename
Description
countersdemo.adb
Package body with the implementation details of the model.
countersdemo.ads
Package specification that defines the callable procedures of the model and any external inputs and outputs to the model.
countersdemo_types.ads
Package specification of data types used by the model. The Real-Time Ada Coder derives the data types from the block name and signal width.
register.ads
Package specification that defines model rate information and renames program entry points in countersdemo.ads.
register2.ads
Package specification that contains the subset of register.ads required for elimination of circular compilation dependencies.
rt_engine-rto_data.ads
Package specification that contains the timing information for executing the model encapsulated in the real-time object.


 Restrictions Models with S-Functions