Creating a Simulation Object

Only compound blocks can be converted into simulation objects. When a compound block is converted into a simulation object, it retains the step size and the integration method in use at the time it was generated, and not those selected or specified by the diagram in which the simulation object will be embedded. The simulation object does, however, use the simulation start and end times of the diagram that calls it.

To create a simulation object

1.    Open the diagram that contains the blocks you want to convert into a simulation object.

2.    Encapsulate the blocks in a compound block, if you have not already done so.

3.    Select the compound block.

4.    The first time you generate code, choose Tools > Code Gen. For subsequent code generation, press SHIFT+right-click and click Compile to automatically generate code based on the selections in the Code Generation dialog.

The Result File box displays compound-block-name.C, where compound-block-name is the name of selected compound block in the current diagram.

5.    If you are creating more than one simulation object from a single Embed diagram, give each simulation object a unique name.

6.    The Result Dir box indicates where the simulation object will be stored. Click to change the location.

7.    The Target box contains the target platform for code generation. Choose Simulation Object, if it is not already selected.

8.    Activate Use selected compound edge pins for data exchange; then choose from the following parameters:

 

Activate this parameter

To

Add Stack Check Code

Do not activate.

Call from Foreign RTOS/User App

Do not activate.

Check for Performance Issues

Do not activate.

Embed Maps in Code

Inserts map file contents directly into the generated code. When this parameter is activated, the resulting executable will be portable because the map file is no longer needed.

Heap Size

Does not apply.

Include Block Nesting as Comment

Includes comments in the generated code that indicate the compound blocks that correspond to the code.

On-Chip RAM Only

Does not apply.

Optimization Level

Specifies compiler optimization level, from 0 (no optimization) to 4 (highest level). In rare circumstances, Level 4 may yield inconsistent results, necessitating a lower level of optimization.

Periodic Function Name

Specifies the name of the simulation object.

Stack Size

Does not apply.

Target FLASH

Does not apply.

Use selected compound edge pins for data exchange

Activate this parameter.

9.    Click Compile.

10.  Embed opens a text window in which it displays simulation object creation. When the simulation object has been generated, press any key to return to the Code Generation Properties dialog.

11.  Click Done.