Using Traceability in Embedded MATLAB™ Function Blocks

Extent of Traceability in Embedded MATLAB™ Function Blocks

Like other Simulink® blocks, Embedded MATLAB™ Function blocks support bidirectional traceability, but extend navigation to lines of source code. That is, you can navigate between a line of generated code and its corresponding line of source code. In other Simulink blocks, you can navigate between a line of generated code and its corresponding object.

For information about how traceability works in Simulink blocks, see Tracing Generated Code Back to Your Simulink® Model in the Real-Time Workshop® User's Guide.

Traceability Requirements

To enable traceability comments in your code, you must have a license for Real-Time Workshop® Embedded Coder™ software. These comments appear only in code that you generate for an embedded real-time (ert) based target.

Basic Workflow for Using Traceability

The workflow for using traceability is described in Creating and Using a Code Generation Report in the Real-Time Workshop Embedded Coder User's Guide.

Here are the basic steps:

  1. Open the Embedded MATLAB Function block in your Simulink model.

  2. Define your system target file to be an embedded real-time (ert) target.

     How?

  3. Enable traceability options.

     How?

  4. Generate the source code and header files for your model.

  5. Trace a line of code:

    To Trace:Do This:
    Line of source code to line of generated codeRight-click in a line in your source code and select Real-Time Workshop > Navigate to Code from the context menu
    Line of generated code to line of source codeClick a hyperlink in the traceability comment in your generated code

To learn how to complete each step in this workflow, see Tutorial: Using Traceability in an Embedded MATLAB™ Function Block

Tutorial: Using Traceability in an Embedded MATLAB™ Function Block

This example shows how to trace between source code and generated code in an Embedded MATLAB Function block in the eml_fire demo model. Follow these steps:

  1. Type eml_fire at the MATLAB® prompt.

  2. In the Simulink model window, double-click the flame block to open the Embedded MATLAB Editor.

  3. In the Simulink model window, select Simulation > Configuration Parameters.

  4. In the Real-Time Workshop pane, go to the Target selection section and enter ert.tlc for the system target file. Then click Apply.

  5. In the Real-Time Workshop > Report pane, select the Create code generation report option.

    This action automatically selects the Launch report automatically and Code-to-model options.

  6. Select the Model-to-code option in the Navigation section. Then click Apply.

    This action automatically selects all options in the Traceability Report Contents section.

  7. Go to the Real-Time Workshop > Interface pane. In the Software environment section, select the continuous time option. Then click Apply.

  8. In the Real-Time Workshop pane, click Build in the lower right corner.

    This action generates source code and header files for the eml_fire model that contains the flame block. After the code generation process is complete, the code generation report appears automatically.

  9. Click the eml_fire.c hyperlink in the report.

  10. Scroll down through the code to see the traceability comments.

  11. Click the <S2>:1:19 hyperlink in this traceability comment:

    /* '<S2>:1:19' */

    Line 19 of the Embedded MATLAB function appears highlighted in the Embedded MATLAB Editor.

  12. You can also trace a line in an Embedded MATLAB function to a line of generated code. For example, right-click in line 21 of your function and select Real-Time Workshop > Navigate to Code from the context menu.

    The code location for line 21 appears highlighted in eml_fire.c.

  


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