Code Analysis and Tracing
After you generate code, make sure that the code meets your requirements by analyzing the code metrics, interfaces, replacements, and code generation assumptions. The code generation report provides information about these aspects of the generated code. You can assess the code and modify your model to generate code that meets your requirements.
Verify the generated code by navigating between a line of code and its corresponding model elements by using code tracing. You can trace from hyperlinks in the code to model elements and from model elements to code lines. You can also include links from the generated code to the model element requirements.
|Trace a block to generated code in code generation report|
- Check Code Generation Assumptions
Use standalone workflow to check code generator assumptions.
- Analyze Code Replacements in Generated Code
The Code Replacements Report section in the code generation report documents the code replacement library (CRL) functions that were used for code replacements during code generation.
- Generate Static Code Metrics Report for Simulink Model
When generating code, generate a report that includes static code metrics, such as, the number of lines of code, size of global variables, and the number of reads and writes.
- Static Code Metrics
The code generator performs static analysis of the generated C or C++ code and provides these metrics in the static code metrics report in the code generation report.
- Analyze Generated Data Code Interface
Use the code interface report to see documentation of the generated code data interfaces, including model entry-point functions and interface data.
- Analyze Generated Service Code Interface
Use the code interface report to see documentation of the generated code service interface, including execution functions and services.
- Log Program Execution Results
Log data to a MAT-file during execution of generated code.
- Verify Generated Code by Using Code Tracing
Code tracing enables navigation between generated code and its corresponding elements in a model.
- Trace Simulink Model Elements in Generated Code
Trace Simulink® model elements by using code-to-model and model-to-code traceability in the code generation report.
- Trace Stateflow Elements in Generated Code
Trace different Stateflow® elements to corresponding lines in generated code.
- Reload Existing Traceability Information
Example of how to reload existing traceability information for a model.
- Customize Traceability Reports
Obtain complete mapping between model elements and generated code.
- Use Traceability in MATLAB Function Blocks
Trace between source code and generated code in a MATLAB Function block.