| Contents | Index |
| On this page… |
|---|
Introducing IDE Project Generator |
IDE Project Generator provides the following features for developing projects and generating code:
Automated project building for Green Hills MULTI that lets you create MULTI projects from code generated by Embedded Coder. IDE Project Generator populates projects in the MULTI development environment.
Blocks in the library idelinklib_ghsmulti for controlling the scheduling and timing in generated code.
Highly configurable code generation using model Configuration Parameters and Target Preferences block options.
Ability to use one of two system target files to generate code specific to your processor.
Highly configurable project build process.
Automatic downloading and running of your generated projects on your processor.
To configure your Simulink models to use the IDE Project Generator component, do one or both of the following tasks:
Add a Target Preferences block to your model.
To use the asynchronous scheduler capability in Embedded Coder software, add a hardware interrupt block or idle task block.
The following sections describe the blockset and the blocks in it, the scheduler, and the IDE Project Generator component.
In this tutorial, you build a model and generate a project from the model into Green Hills MULTI.
Note The model shows project generation only. You cannot build and run the model on your processor without additional blocks. |
This is an overview of the process for generating a project from a model:
Use Simulink blocks, DSP System Toolbox blocks, and blocks from other blocksets to create the model application.
Open the Simulink Library Browser and search for "Target Preferences". Copy the Target Preferences block from the search results to your model and configure the settings , as described in Target Preferences.
Set the Configuration Parameters for your model, including the following parameters:
Solver parameters such as simulation start and solver options. Choose the discrete solver when you generate executables. If you are using PIL, select any setting from the Type and Solver lists.
Code Generation settings such as processor configuration and processor compiler selection
To build the model for this tutorial, follow these steps:
Use Simulink blocks, DSP System Toolbox blocks, and blocks from other blocksets to create the model application.
Open the Simulink Library Browser and search for "Target Preferences". Copy the Target Preferences block from the search results to your model and configure the settings , as described in Target Preferences.
Set the Configuration Parameters for your model, including the following parameters:
Solver parameters such as simulation start and solver options. Choose the discrete solver when you generate executables. If you are using PIL, select any setting from the Type and Solver lists.
Code generation settings such as processor configuration and processor compiler selection
Create a new model by selecting File > New > Model from the Simulink menu bar.
Use Simulink blocks and DSP System Toolbox blocks to create the following model.

Look for the Delay block in the Discrete library of Simulink and the Gain block in the Commonly Used Blocks library. This model implements an audio signal reverberation scheme. Part of the input audio signal passes directly to the output. A delayed version passes through a feedback loop before reaching the output. The result is an echo, or reverberation, added to the audio output.
To configure your model to work with the processors your IDE supports, add a Target Preferences block to your model, as described in Target Preferences.
You have completed the model. Next, configure the model Configuration Parameters to generate a project in Green Hills MULTI from your model.
The following sections describe how to configure the build and run parameters for your model. Generating a project, or building and running a model on the processor, starts with configuring model options in the Configuration Parameters dialog box in Simulink.
Setting Solver Options. After you have designed and implemented your digital signal processing model in Simulink, complete the following steps to set the Configuration Parameters for the model:
Open the Configuration Parameters dialog box and set the options on the Solver category for your model and for Embedded Coder software.
Set Start time to 0.0 and Stop time to inf (model runs without stopping). If you set a stop time, your generated code does not honor the setting. Set this parameter to inf for completeness.
Under Solver options, set Type to fixed-step and set Solver to discrete (no continuous states). For PIL, set Type and Solver to any setting.
For Fixed step size (fundamental sample time), enter Auto, and set Tasking mode for periodic sample times to SingleTasking.
Note Generated code does not honor Simulink stop time from the simulation. Stop time is interpreted as inf. To implement a stop in generated code, you must put a Stop Simulation block in your model. |
Ignore the Data Import/Export, Diagnostics, and Optimization panes in the Configuration Parameters dialog box. The default settings are valid for your new model.
Setting Code Generation Options. To configure Simulink Coder software to use the processor files, compile your model, and run your model executable file, set the options in the Code Generation category of the model Configuration Parameters. Follow these steps to set the Simulink Coder software options to generate code tailored for your processor:
In the Configuration Parameters dialog box, select the Code Generation pane.
Click the Browse button next to System target file and set the system target file to idelink_grt.tlc or idelink_ert.tlc (if you use Embedded Coder software).
Clicking Browse opens the System Target File Browser to allow you to change the system target file.
On the System Target File Browser, select the idelink_grt.tlc or idelink_ert.tlc system target file, and click OK to close the browser.
Setting IDE Link Options. After you set the Configuration Parameters for code generation, set the options that apply to your Embedded Coder software run-time and build processes.
In the Configuration Parameters dialog box, expand the node for the Code Generation pane and select the IDE Link pane.
Set the following Run-Time options:
Build action: Create_project.
Interrupt overrun notification method: Print_message.
(optional) Under Link Automation, verify that Export MULTI link handle to base workspace is selected and provide a name for the handle in MULTI link handle name.
If you are using an actual board, identify a Board Support Package (BSP) in the Compiler options string (under Vendor Tool Chain). For example, enter "-bsp=at91rm9200". If you do not provide this type of information, the software can generate errors that do not identify the absence of linker directives as the cause.
Verify that the Device type is valid for your processor—Analog Devices, NEC, or Freescale.
You have configured the Code Generation pane settings to generate a project for your processor. A few of the panes under the node for the Code Generation pane, such as Comments and Symbols do not require configuration.
For your new model, the default values for the options in these panes are valid. For other models you develop, setting the options in these panes provides more information during the build process. Some of the options configure the model to run TLC debugging when you generate code. Refer to your Simulink and Simulink Coder documentation for more information about setting the Configuration Parameters.
After you set the Configuration Parameters and configure Simulink Coder to create the files you need, you direct Simulink Coder to create your project:
To verify that you configured your Embedded Coder software, issue the following command at the prompt to open the IDE Link Configuration dialog box.
ghsmulticonfig
Verify the settings in the Embedded Coder dialog box.
After you verify the settings, click OK to close the dialog box.
Enter cd at the prompt to verify that your working folder is the right one to store your project results.
Click Incremental Build (
) on the model toolbar
to generate your project into Green Hills MULTI IDE.
When you press
with Create_project selected
for Build action, the build process
starts the Green Hills MULTI application and populates a new project.
Model reference lets your model include other models as modular components. This technique is useful because it provides the following capabilities:
Simplifies working with large models by letting you build large models from smaller ones, or even large ones.
Lets you generate code once for all the modules in the entire model and then only regenerate code for modules that change.
Lets you develop the modules independently.
Lets you reuse modules and models by reference, rather than including the model or module multiple times in your model. Also, multiple models can refer to the same model or module.
Your Simulink Coder documentation provides much more information about model reference.
Model reference behaves differently in simulation and in code generation. This discussion uses the following terms:
The top-model is the root model block or model. It refers to other blocks or models. In the model hierarchy, this model is the topmost model.
Referenced models are blocks or models that other models reference, such as models the top-model refers to. All models or blocks below the top-model in the hierarchy are reference models.
The following sections describe briefly how model reference works. More details are available in your Simulink Coder documentation in the online Help system.
Model Reference in Simulation. When you simulate the top-model, Simulink Coder detects that your model contains referenced models. Simulink generates code for the referenced models and uses the generated code to build shared library files for updating the model diagram and simulation. It also creates an executable (.mex file) for each reference model that is used to simulate the top-model.
When you rebuild reference models for simulations or when you run or update a simulation, Simulink software rebuilds the model reference files. Whether reference files or models are rebuilt depends on:
Whether and how you change the models.
The Rebuild parameter on the Model Reference pane in the Configuration Parameters dialog.
Model Reference in Code Generation. Simulink Coder requires executables to generate code from models. If you have not simulated your model at least once, Simulink Coder creates a .mex file for simulation.
Next, for each referenced model, the code generation process calls make_rtw and builds each referenced model. This build process creates a library file for each of the referenced models in your model.
After building all the referenced models, Simulink Coder calls make_rtw on the top-model. The call to make_rtw links to the library files Simulink Coder created for the associated referenced models.
With few limitations or restrictions, Embedded Coder software provides full support for generating code from models that use model reference.
Build Action Setting. The most important requirement for using model reference with the Green Hills MULTI software supported processors is you must set the Build action (select Configuration Parameters > IDE Link) for all models referred to in the simulation to Archive_library.
To set the build action, perform the following steps:
Select Simulation > Configuration Parameters from the model menus.
The Configuration Parameters dialog box opens.
In the Configuration Parameters dialog box, expand the node for the Code Generation pane and select the IDE Link pane.
In the right pane, under Run-Time, select Archive_library from the Build action list.
If your top-model uses a reference model that does not have the build action set to Archive_library, the build process automatically changes the build action to Archive_library and issues a warning about the change.
Selecting Archive_library disables the Interrupt overrun notification method, Export MULTI link handle to the base workspace, and System stack size options for the referenced models.
Target Preferences Blocks in Reference Models. Each referenced model and the top-model must include a Target Preferences block for the right processor. Configure all the Target Preferences blocks for the same processor.
The referenced models need Target Preferences blocks to provide information about which compiler and which archiver to use. Without these blocks, the compile and archive processes do not work.
Other Block Limitations. Model reference with Embedded Coder software code generation options does not allow you to use noninlined S-functions in reference models. Verify that the blocks in your model do not use noninlined S-functions.
When you create models to use in Model Referencing, keep in mind the following considerations:
Your model must use a system target file derived from the ERT or GRT target files.
When you generate code from a model that references other models, configure the top-level model and the referenced models for the same system target file.
Simulink Coder builds and Embedded Coder software projects do not support External mode in model reference. If you select the External mode option, it is ignored during code generation.
Your TMF must support use of the shared utilities folder, as described in Supporting Shared Utility Directories in the Build Process in the Simulink Coder documentation.
To use an existing processor, or a new processor, with Model Reference, set the ModelReferenceCompliant flag for the processor. For information about setting this option, refer to ModelReferenceCompliant in the online Help system.
If you start with a model that was created before MATLAB release R14SP3, use the following command to make your model compatible with model reference :
% Set the Model Reference Compliant flag to on. set_param(bdroot,'ModelReferenceCompliant','on')
Code that you generate from Simulink models by using Embedded Coder software includes the model reference capability. You do not need to set the flag.
![]() | IDE Automation Interface | Breakpoints and PIL | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |