目标语言编译器
自定义生成的代码、内联为 S-Function 模块生成的代码,以及生成其他或不同类型的文件
目标语言编译器 (TLC) 是代码生成器的重要组成部分。使用 TLC 自定义生成的代码。通过自定义,您可以生成特定于平台的代码并融入您自己的算法更改,以改善性能、代码大小或与现有方法的兼容性。
使用目标语言编译器,您可以:
自定义系统目标文件指定的选项集。
内联 S-Function 模块的代码。
生成其他或不同类型的文件。
要了解 TLC 的基础知识,请参阅目标语言编译器基础知识。
有关生成的代码和外部代码之间对接的更简单替代方法,请参阅生成代码接口。
主题
快速入门
- 目标语言编译器基础知识
使用目标语言编译器可生成特定于平台的代码并融入您自己的算法更改,以改善性能、控制代码大小,或保证代码与您想继续使用的现有方法的兼容性。 - Why Use the Target Language Compiler?
Use the Target Language Compiler to customize the set of options specified by your system target file, inline the code for S-Function blocks, or generate additional or different types of files. - The Advantages of Inlining S-Functions
Determine when, how, and why to inline S-functions. - Code Architecture
Learn what information a block object captures. - Target Language Compiler Process
Learn how the Target Language Compiler interprets
files.model
.rtw - 内联 S-Function
应用内联 S-Function 的方法。 - Improve Code Efficiency and Integration of Inlined S-Functions
Learn how to enable the enhanced TLC block interface to effectively integrate S-Function block code into generated code.
目标语言编译器教程
- 关于 TLC 教程的建议
TLC 教程描述了为什么以及如何使用 TLC。 - Read Record Files with TLC
Learn how TLC accesses record files and interprets their contents. - Inline S-Functions with TLC
TLC inlines S-functions, resulting in faster, optimized code. - Explore Variable Names and Loop Rolling
Understand how and when TLC outputs loops and variable names. - Debug Your TLC Code
Invoke TLC debugger commands, set breakpoints, and trace code execution. - TLC Code Coverage to Aid Debugging
Use TLC coverage statistics to help identify bugs in TLC code. - Wrap User Code with TLC
Use TLC to integrate legacy and proprietary code into compiled models.
代码生成架构
- Build Process
Create and use target language files. - Configure TLC
Customize builds by passing configuration data to theset_param
command. - Configure Generated Code with TLC
Use the Target Language Compiler to generate source code in specific ways or to give the code-specific characteristics. - Code Generation Concepts
Understand TLC variables and file and record handling. - TLC 文件
了解系统和模块目标文件的角色和种类。 - Data Handling with TLC
TLC library functions can transform data into data structures.
model.rtw 文件
- model.rtw File and Scopes
The
file is a partial representation of a model generated by the build process for use by the Target Language Compiler.model
.rtw - Data Object Information in model.rtw File
Access information about data objects in the
file.model
.rtw - Data References in the model.rtw File
Simulink® uses data references to optimize data access during code generation. - Exception to Using the Library Functions that Access model.rtw
Access parameter settings for a block in the
records.model
.rtw - Access Memory in Generated Code Using Global Data Map
Generate TLC global data map record inmodel.rtw
file.
指令和内置函数
- Target Language Compiler Directives
Learn the syntax and formats of directives, built-in functions, signal and parameter values, expressions, and comments. - Command-Line Arguments
Specify TLC calling arguments, filenames, and search paths.
S-Function 内联
- Inline S-Functions
Write S-functions to be used for code generation. - Inline C MEX S-Functions
Handle calls made by C MEX S-functions. - TLC Coding Conventions
Observe case conventions and use library functions to make your TLC code more robust. - Block Target File Methods
Use polymorphic block functions combined with the Target Language Compiler library functions to write a block target file. - Loop Rolling
Use the%roll
directive to indicate whether the code generator unrollsfor
loops.
TLC 函数库参考
- 目标语言编译器库函数概述
使用库函数访问模块记录中的许多参数名称/参数值对组。 - Target Language Compiler Function Conventions
Apply proper TLC function syntax and conventions. - Input Signal Functions
These TLC Functions process and report on input signals. - Output Signal Functions
These TLC functions process and report on output signals. - Parameter Functions
These functions process model parameters. - Block State and Work Vector Functions
These functions handle storage and states. - Block Compatibility Functions
These TLC functions are for specifying block compatibility with code generation features. - Block Path and Error Reporting Functions
These functions navigate paths and handle error conditions. - Code Configuration Functions
These functions are for tailoring code elements and comments. - Sample Time Functions
These functions are for handling continuous and discrete time. - Miscellaneous Functions
These functions are not elsewhere classified. - Advanced Functions
These functions are generally required only for special situations.
调试和错误处理
- Using the TLC Debugger
Use the TLC debugger to execute TLC code line-by-line, analyze and/or change variables in a specified block scope, and view the TLC call stack. - TLC Coverage
Determine what TLC statements are executed. - TLC Profiler
Measure the execution time of each TLC function. - TLC Error Handling
Use this alphabetical list of error messages to detect and address error conditions in your TLC code.