嵌入式编码器

嵌入式编码器

生成针对嵌入式系统优化的C和C ++代码

开始:

Configuring for Code Generation

为嵌入式编码器配置代码生成设置®,您将MATLAB编码器应用程序用于MATLAB®or Embedded Coder Quick Start for Simulink. You can also configure each setting directly using MATLAB commands and scripts.

From the MATLAB Coder app, you can:

  • Generate code for your MATLAB files and functions
  • Select your processor and code generation output
  • 选择嵌入式编码器优化

从嵌入式编码器快速启动Simulink,您可以:万博1manbetx

  • 为您的Simulink模型和子系统生成代码万博1manbetx
  • Select your processor and code generation output
  • 选择嵌入式编码器以优化RAM或执行速度
使用嵌入式编码器快速启动从Simulink开始JumpStart生产代码。万博1manbetx

使用嵌入式编码器快速启动从Simulink开始JumpStart生产代码。万博1manbetx

Selecting Targets

嵌入式编码器使用配置对象和系统目标文件将MATLAB代码和Simulink模型转换为生产质量源代码和可执行文件。万博1manbetx

For MATLAB, you specify one of the following output targets:

  • mex-file
  • C/C ++静态库
  • C/C++ executable

对于Si万博1manbetxmulink,您指定了即将运行的配置之一,其中包括:

Embedded Real-Time Target— Generates ANSI/ISO C, C++, and encapsulated C++ code with floating-point and fixed-point data for efficient real-time execution on virtually any production processor

AUTOSAR Target— Generates C code and run-time interfaces that support development ofAUTOSAR软件组件(需要Autosar模块)

Shared Library Target- 生成代码的共享库版本以进行主机平台执行,要么作为Windows®动态链接库(.dll)文件或UNIX®shared object (.so) file

此外,数学和第三方还提供MATLAB附加组件,将嵌入式编码器扩展到支持万博1manbetx特定的硬件包括手臂®,英特尔®, NXP™, STMicroelectronics®, 和Texas Instruments™.

Using hardware support packages to quickly deploy generated code on embedded devices.

Using hardware support packages to quickly deploy generated code on embedded devices.

Working with Custom Data

嵌入式编码器enables you to define and control how the model data appears in the generated code to facilitate software integration.

For MATLAB code, Embedded Coder supports all MATLAB Coder data definitions including fixed-point objects and predefined storage classes.

对于Si万博1manbetxmulink模型,嵌入式编码器支持以下数据字典和规范功能:万博1manbetx

嵌入式编码器Dictionary— Lets you view and customize code definitions including function interfaces, storage classes, and memory sections

Simulink data object— Provides predefined storage classes, including constant, volatile, exported global, imported global, define directive, structure, bit field (including bit-packed structure), and get and set access methods

模块包装数据对象先进的d -提供预配置属性ata objects typically used in mass production, such as memory segments to calibrate or tune lookup tables

用户数据类型- 使您可以为复杂数据创建抽象类型,因此您可以精确地控制模型数据在生成的代码中显示如何出现,与任何旧数据接口,并增强或替换Simulink内置类型万博1manbetx

嵌入式编码器gives you access to ASAP2 data exchange files in Simulink, enabling you to export model data with complex data definitions using the ASAP2 standard. You can modify the built-in capabilities to produce other data exchange mechanisms.

Using Embedded Coder Dictionary to define and control how the models and data appear in generated code.

Using Embedded Coder Dictionary to define and control how the models and data appear in generated code.

Optimizing and Packaging Code

Using Embedded Coder, you can control function boundaries, preserve expressions, and apply optimizations on multiple blocks to further reduce code size. Data is exchanged with the generated code via global variables or function arguments. You can trace the generated code to blocks and signals in your model.

用于从MATLAB代码生成代码的嵌入式编码器选项和Simulink模型使您可以:万博1manbetx

  • Generate processor-specific code for math functions and operators
  • 重复使用代码用于导出到遗产或外部环境
  • Eliminate unnecessary initialization, termination, logging, and error-handling code
  • Remove floating-point code from integer-only applications

Additional Embedded Coder optimization and configuration options are available for Simulink models, enabling you to:

  • Generate code variants using macros for preprocessor compilation
  • 控制每个生成文件的格式
  • Determine how global data is defined and referenced
  • Specify the contents and placement of comments
Simulink模型生成SIMD代码。万博1manbetx

Simulink模型生成SIMD代码。万博1manbetx

Commenting, Tracing, and Documenting Code

嵌入式编码器提供了多个功能,可用于检查MATLAB文件和功能的生成代码或Simulink模型和子系统。万博1manbetx使用这些功能,您可以:

  • Generate a code report describing the code modules, function interfaces, and static code metrics
  • Control identifier formats for generated global data, data types, and functions
  • 在生成的代码中包括MATLAB代码作为注释,包括功能帮助文本

借助Sim万博1manbetxulink,嵌入式编码器还提供了插入高级需求的能力,作为带有要求源的链接的代码注释(需要)需求Toolbox™). The code report for Simulink code generation also includes a code interface description, traceability report, and display of generated source files and code. Bidirectional links exist between the model and generated code, making it easy to navigate between every line of code and its corresponding Simulink model element, including subsystems, blocks, MATLAB functions and code, andStateflow®图表和过渡。

Simulink code generation report highlighting bidirectional traceability between algorithm and implementation.

Simulink code generation report highlighting bidirectional traceability between algorithm and implementation.

执行和验证代码

嵌入式编码器enables you to incorporate generated code into your code execution environment.

With MATLAB, the code generated from Embedded Coder executes using the same execution framework as provided by MATLAB Coder.

使用Sim万博1manbetxulink,嵌入式编码器可显着扩展Simulink Coder提供的实时执行框架。默认情况下,可以在有或没有实时操作系统(RTOS)以及单任务,多任务,多项式或异步模式下执行代码。您还可以使用嵌入式编码器验证代码执行结果,以示为“循环”(SIL)和处理器(PIL)测试。万博1manbetxSimulink Test™and万博1manbetxSimulink覆盖范围帮助自动化测试执行,结果比较和覆盖范围分析。还支持代码执行分析分析。万博1manbetx

Generating a Main Program

嵌入式编码器generates an extensible main program based on information you provide for deploying the code in your real-time environment. This capability lets you generate and build a complete customized executable from your model.

执行多条,多任务和多核代码

嵌入式编码器generates single-rate or multirate code using periodic sample times specified in the model. For multirate, multitasking models, it employs a strategy called rate grouping that generates separate functions for the base rate task and for each subrate task in the model. You can also use Simulink Concurrent Execution modeling to produce multithreaded code for multicore processing.

执行SIL和PIL测试

嵌入式编码器自动执行生成的code in Simulink for SIL testing or on the embedded target for PIL testing using Simulink simulation modes or S-function blocks.万博1manbetxSimulink Test™helps automate test execution and comparison of test results to simulation results from the original model. Structural code coverage analysis to measure test completeness can be performed with万博1manbetxSimulink覆盖范围or with integration with third-party tools. Code profiling analysis provides execution time on host or target processors.

对嵌入式编码器生成的代码进行循环的软件(SIL)和处理器(PIL)测试。

对嵌入式编码器生成的代码进行循环的软件(SIL)和处理器(PIL)测试。