Embedded Coder

Generate C and C++ code optimized for embedded systems

Embedded Coder®为批量生产中使用的嵌入式处理器生成可读,紧凑且快速的C和C ++代码。它扩展了MATLAB编码器™和SIMULINK CODER金宝app™,具有先进的优化,以精确控制生成的功能,文件和数据。这些优化提高了代码效率,并促进与传统代码,数据类型和校准参数集成。您可以包含一个第三方开发工具,为嵌入式系统或快速原型制作板上构建用于交钥匙部署的可执行文件。

Embedded Coder offers built-in support for仿奥斯卡,臭臭C.®,以及ASAP2软件标准。它还提供可追溯性报告,代码文档和自动软件验证来支持金宝appDO-178,IEC 61508,和ISO 26262software development. Embedded Coder code is portable, and can be compiled and executed on any processor. In addition, Embedded Coder offers support packages with advanced optimizations and device drivers for具体的硬件.

Learn how companies are generating production code with Embedded Coder forcontrols,signal processing,image processing and computer vision,和machine learningapplications.

Get Started:

Configuring for Code Generation

To configure code generation settings for Embedded Coder®, you use the MATLAB Coder app forMATLAB®or Embedded Coder Quick Start for Simulink. You can also configure each setting directly using MATLAB commands and scripts.

从MATLAB编码器应用程序,您可以:

  • 为MATLAB文件和函数生成代码
  • 选择处理器和代码生成输出
  • Choose Embedded Coder optimizations

From the Embedded Coder Quick Start for Simulink, you can:

  • 为您的Simulink模型和子系统生成代码金宝app
  • 选择处理器和代码生成输出
  • Choose Embedded Coder to optimize for RAM or execution speed

Using Embedded Coder Quick Start for jumpstart production code generation from Simulink.

Selecting Targets

Embedded Coder uses configuration objects and system target files to translate your MATLAB code and Simulink models into production-quality source code and executables.

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

  • MEX-file
  • C/C++ static library
  • C / C ++可执行文件

For Simulink, you specify one of the ready-to-run configurations, which include:

Embedded Real-Time Target- 使用浮点和固定点数据生成ANSI / ISO C,C ++和封装的C ++代码,以便在几乎任何生产处理器上进行高效的实时执行

仿奥斯卡Target— Generates C code and run-time interfaces that support development of仿奥斯卡software components (requires AUTOSAR Blockset)

共享库目标— Generates a shared library version of your code for host platform execution, either as a Windows®dynamic link library (.dll) file or a UNIX®shared object (.so) file

此外,MathWorks和第三方提供了扩展嵌入式编码器以支持的MATLAB附加组件金宝app具体的硬件包括手臂®,英特尔®,NXP™,STMicroelectronics®,和Texas Instruments™.

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

Working with Custom Data

嵌入式编码器使您可以定义和控制模型数据如何出现在生成的代码中以促进软件集成。

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

For Simulink models, Embedded Coder supports the following data dictionary and specification capabilities:

嵌入式编码器词典- 允许您查看和自定义代码定义,包括函数接口,存储类和内存部分

Simulink data object- 提供预定义的存储类,包括常量,易失性,导出的全局,导入的全局,定义指令,结构,比特字段(包括位打包结构),并获取和设置访问方法

Module packaging data object- 为通常用于大规模生产中使用的高级数据对象提供预先配置的属性,例如用于校准或调整查找表的内存段

User data type- 允许您为复杂数据创建抽象类型,因此您可以精确控制模型数据如何出现在生成的代码中,与任何传统数据的接口,以及增强或替换Simulink内置类型金宝app

Embedded Coder 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.

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.

Embedded Coder options for generating code from MATLAB code and Simulink models enable you to:

  • 为数学函数和运算符生成特定于处理器的代码
  • Reuse code for exporting to legacy or external environments
  • 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
  • Control the format of each generated file
  • Determine how global data is defined and referenced
  • Specify the contents and placement of comments

SIMD code generation from Simulink model.

评论,跟踪和记录代码

Embedded Coder offers several capabilities for examining generated code for your MATLAB files and functions or your Simulink models and subsystems. Using these capabilities, you can:

  • Generate a code report describing the code modules, function interfaces, and static code metrics
  • 生成的全局数据,数据类型和函数的控制标识符格式
  • Include MATLAB code as comments in generated code, including function help text

With Simulink, Embedded Coder also provides the ability to insert high-level requirements as code comments with links to the requirement source (requiresSimulink Requirements™)。Simulink代码生成的代码报告还包括金宝app代码接口描述,可追溯性报告和生成的源文件和代码的显示。模型和生成的代码之间存在双向链路,使得在每一行代码和其相应的Simulink模型元素之间易于导航,包括子系统,块,MATLAB函数和代码,以及金宝appStateflow®charts and transitions.

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

Executing and Verifying Code

Embedded Coder 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.

With Simulink, Embedded Coder significantly extends the real-time execution framework provided by Simulink Coder. By default, the code can be executed with or without a real-time operating system (RTOS) and in single-tasking, multitasking, multicore, or asynchronous mode. You can also verify the code execution results using Embedded Coder for software-in-the-loop (SIL) and processor-in-the-loop (PIL) testing.Simulink Test™金宝appSimulink覆盖范围help automate test execution, result comparison, and coverage analysis. Code execution profiling analysis is also supported.

生成主程序

Embedded Coder 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.

执行多速率,多址和多核代码

Embedded Coder 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.

Performing SIL and PIL Testing

嵌入式编码器自动执行生成的code in Simulink for SIL testing or on the embedded target for PIL testing using Simulink simulation modes or S-function blocks.Simulink 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金宝appSimulink覆盖范围or with integration with third-party tools. Code profiling analysis provides execution time on host or target processors.

Performing software-in-the-loop (SIL) and processor-in-the-loop (PIL) testing of code generated by Embedded Coder.

Latest Features

Individual Code Mappings

Configure storage classes for individual data elements in Code Mappings editor

SIMD Code Generation

Generate SIMD intrinsics for fast loop and array execution on Intel SSE, AVX 256/512, and Arm NEON processors

Multithreaded Image Processing Code

Increase execution speed by generating code for Image Processing Toolbox functions with multithreading capabilities

优化的多维阵列

Reduce memory by reusing buffers for multidimensional arrays that preserve dimensions

MISRA compliance

生成C和C ++代码,少数MISRA C:2012和Misra C ++ 2008违规

Optimized FFT for Arm

Generate optimized code for fast Fourier transforms (FFT) using Code Replacement Libraries for Arm Cortex-A and Cortex-M processors

Bitwise operators

Reduce ROM by generating bitwise operators from logical operator blocks

See发行说明for details on any of these features and corresponding functions.

Coder Summit

观看现场工程师和开发人员为软件设计,嵌入式代码生成等产品提供新功能。