代码生成
生成符合标准的优化 C、C++、CUDA、Verilog 或 VHDL 代码
借助 MathWorks® 产品的代码生成功能,您可以从 MATLAB® 代码或 Simulink® 模型中生成代码。与手动编写成千上万行代码相比,这样做可以提高工作效率和代码质量。您可以为信号处理、工业控制、嵌入式视觉和深度学习等应用生成代码。生成 C、C++、CUDA®、Verilog®、VHDL® 和 PLC 代码,或为 AUTOSAR 或 DDS 等中间件架构和标准生成代码。要使您的代码获得认证,请根据 ISO26262 和 DO-178C 等标准验证代码。
适用产品: 代码生成
主题
C/C++ 代码生成
- 使用 Embedded Coder 生成代码 (Embedded Coder)
MathWorks 代码生成技术为算法生成 C 或 C++ 代码和可执行程序。您可以通过使用 MATLAB 以编程方式编写算法,或在 Simulink 环境中以图形方式编写算法。您可以为 MATLAB 函数和 Simulink 模块生成对实时和嵌入式应用程序很有用的代码。为浮点算法生成的源代码和可执行程序与 MATLAB 代码执行和 Simulink 仿真的功能行为的匹配度非常高。使用 Fixed-Point Designer 产品,您可以生成与模型仿真结果按位匹配的定点代码。代码生成之所以能实现如此广泛的支持和高度的准确性,是因为它紧密集成了 MATLAB 和 Simulink 的执行引擎和仿真引擎。Simulink 中内置的加速仿真模式就使用了代码生成技术。 - Deploy Algorithm Model for Real-Time Rapid Prototyping (Simulink Coder)
Deploy algorithm model for testing in real time. - 使用 MATLAB Coder 生成 C 代码 (MATLAB Coder)
使用 MATLAB Coder™ 从示例 MATLAB 函数生成 C 代码。
HDL 代码生成
- Generate Code and Synthesize on FPGA Using HDL Workflow Advisor (HDL Coder)
The HDL Workflow Advisor guides you through the stages of generating HDL code for a Simulink subsystem and the FPGA design process, such as: - Basic HDL Code Generation and FPGA Synthesis from MATLAB (HDL Coder)
This example shows how to create a HDL Coder™ project, generate code for your MATLAB® design, and synthesize the HDL code. - Verify HDL Design Using SystemVerilog DPI Test Bench (HDL Coder)
This example shows how to use SystemVerilog DPI test bench for verification of HDL code where a large data set is required.
GPU 代码生成
- Generate Code by Using the GPU Coder App (GPU Coder)
Generate CUDA code from MATLAB code by using the GPU Coder™ app. - Code Generation from Simulink Models with GPU Coder (GPU Coder)
Generate CUDA code from Simulink models by using GPU Coder. - Code Generation for Deep Learning Networks (GPU Coder)
Get started with CUDA code generation for image classification networks such asResNet
.
PLC 代码生成
- Generating Ladder Diagram Code from Simulink (Simulink PLC Coder)
Generate Ladder Diagram code (L5X) from Simulink. - Generate Structured Text Code for a Simple Simulink Subsystem (Simulink PLC Coder)
This example shows how to select the target IDE for a Simulink® model, generate IEC 61131-10 code, and view generated files. - Model, Simulate, and Generate Code for Ladder Logic-Based Elevator Controller (Simulink PLC Coder)
Rapidly prototype the ladder logic-based controller for a single car elevator by using Simulink® PLC Coder™ to model and simulate the ladder logic.
中间件架构的代码生成
- Generate AUTOSAR C Code and XML Descriptions (AUTOSAR Blockset)
Generate AUTOSAR-compliant C code and export AUTOSAR XML (ARXML) descriptions from AUTOSAR component model. - Generate AUTOSAR Adaptive C++ Code and XML Descriptions (AUTOSAR Blockset)
Generate AUTOSAR-compliant C++ code and export AUTOSAR XML (ARXML) descriptions from AUTOSAR adaptive component model. - DDS Blockset Shapes Demo (DDS Blockset)
DDS Blockset implementation of Shapes Demo.
认证和标准
- Highway Lane Following: A Model-Based Design Example for ISO 26262:2018 (IEC Certification Kit)
Demonstrates the use of Simulink to apply a Model-Based Design workflow to an ISO 26262 ASIL D project. - Helicopter Flight Control: A Model-Based Design Example for DO-178C and DO-331 (DO Qualification Kit)
Demonstrates the use of the DO-178C project template in a helicopter flight control project.