Model Reference and Embedded IDE Link CC

Model reference lets your model include other models as modular components. This technique provides useful features because it:

Your Real-Time Workshop documentation provides much more information about model reference.

How Model Reference Works

Model reference behaves differently in simulation and in code generation. For this discussion, you need to know the following terms:

The following sections describe briefly how model reference works. More details are available in your Real-Time Workshop documentation in the online Help system.

Model Reference in Simulation

When you simulate the top model, Real-Time Workshop software detects that your model contains referenced models. Simulink software 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 (a MEX file, .mex) 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 and on the Rebuild options settings. You can access these setting through the Model Reference pane of the Configuration Parameters dialog box.

Model Reference in Code Generation

Real-Time Workshop software requires executables to generate code from models. If you have not simulated your model at least once, Real-Time Workshop software 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, Real-Time Workshop software calls make_rtw on the top model, linking to all the library files it created for the associated referenced models.

Using Model Reference with Embedded IDE Link CC

With few limitations or restrictions, Embedded IDE Link CC 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 TI's processors is that you must set the Build action (go to Configuration Parameters > Embedded IDE Link CC) for all models referred to in the simulation to Archive_library.

To set the build action

  1. Open your model.

  2. Select Simulation > Configuration Parameters from the model menus.

    The Configuration Parameters dialog box opens.

  3. From the Select tree, choose Embedded IDE Link CC.

  4. In the right pane, under Runtime, select set 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.

As a result of selecting the Archive_library setting, other options are disabled:

Target Preferences Blocks in Reference Models

Each referenced model and the top model must include a Target Preferences block for the correct processor. You must configure all the Target Preferences blocks for the same processor.

To obtain information about which compiler to use and which archiver to use to build the referenced models, the referenced models require Target Preferences blocks. Without them, the compile and archive processes does not work.

By design, model reference does not allow information to pass from the top model to the referenced models. Referenced models must contain all the necessary information, which the Target Preferences block in the model provides.

Other Block Limitations

Model reference with Embedded IDE Link CC does not allow you to use certain blocks or S-functions in reference models:

Configuring processors to Use Model Reference

processors that you plan to use in Model Referencing must meet some general requirements.

To use an existing processor, or a new processor, with Model Reference, you set the ModelReferenceCompliant flag for the processor. For information on how to set this option, refer to ModelReferenceCompliant in the online Help system.

If you start with a model that was created prior to version 2.4 (R14SP3), to make your model compatible with the model reference processor, use the following command to set the ModelReferenceCompliant flag to On:

set_param(bdroot,'ModelReferenceCompliant','on')

Models that you develop with versions 2.4 and later of Embedded IDE Link CC automatically include the model reference capability. You do not need to set the flag.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS
 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS