Documentation Center

  • Trial Software
  • Product Updates

Simulink Coder Examples

Basic Introductions and Examples

Getting Started with Simulink® Coder™Script
Generating Code Using Simulink® Coder™Script
Roll Axis Autopilot
Uses: Embedded Coder
Script
Generating Code Using Embedded Coder®
Uses: Embedded Coder
Script

Application Examples

Fuel Rate Control System
Uses: Stateflow
Script
Aircraft Position Radar Model
Uses: Embedded Coder
Script
Field-Oriented Control of Permanent Magnet Synchronous Machine
Uses: Embedded Coder, Fixed-Point Designer
Script

Guided Tutorials

Configuring a Model via Command LineScript

Step-by-Step Code Generation Process

Introduction
Uses: Embedded Coder
Script
Understanding the ModelScript
Configuring the Data InterfaceScript
Function Partitioning within the Generated CodeScript
Calling External C Code from the Simulink® Model and Generated CodeScript
Integrating the Generated Code into the External EnvironmentScript
Testing the Generated CodeScript
Evaluating the Generated CodeScript
Installing and Using Cygwin™ and Eclipse™Script

Accelerated Simulations

Using RSim Target for Parameter SurveyScript
Using RSim Target for Batch SimulationsScript
Interactive Parameter Tuning with RSim TargetModel
Using MAT-Files to Feed Data to Inport Blocks for Rapid SimulationsScript

Multirate Support

Single-Rate Modeling (Bare Board, No OS)Model
Multirate Modeling in Single Tasking Mode (Bare Board, no OS)Model
Multirate Modeling in Multitasking Mode (Bare Board, no OS)Model
Asynchronous Event Modeling (VxWorks® OS)Model
Asynchronous Event Modeling via Model Inputs (VxWorks® OS)Model
Trading Determinism and Data Integrity to Improve System PerformanceModel

Optimizations

Inlining Block Parameters and Propagating Constant ValuesModel
Expression Folding in Generated CodeModel
Conditional Input Branch ExecutionModel
Dead Path EliminationModel
For-Loop FusionModel
Timers/Counters for Absolute and Elapsed TimeModel
Efficient Code for Complex SignalsModel
Optimized Vector OperationsModel
Efficient Fixed-Point Operations
Uses: Embedded Coder
Model
Replacing Math Functions and Operators
Uses: Embedded Coder
Script
Optimizing Generated Code Using Specified Minimum and Maximum Values
Uses: Embedded Coder
Script

Fixed-Point

Fixed-Point Code Generation for Simulink®, Stateflow®, and MATLAB®
Uses: Fixed-Point Designer
Model
Fixed-Point Fuel Rate Control System
Uses: Fixed-Point Designer
Script
Fixed-Point Signal Processing
Uses: DSP System Toolbox
Model

Function, File and Data Packaging

Preserving Subsystem Boundaries in Generated CodeModel
Reusing Functions in Generated CodeModel
File Packaging for Atomic Subsystems (Code Only)Model
File Packaging for Models (Code and Data)Model
Memory Sections for Generated Functions and Data
Uses: Embedded Coder
Model

Data Definition and Packaging

Structure Definitions for Simulink® Bus SignalsModel
Specifying Storage Class Within a DiagramModel
Advanced Data Packaging Using Custom Storage Classes
Uses: Embedded Coder
Model
Sharing Data Among Simulink®, Stateflow®, and MATLAB®Model
Controlling the Data Types of Tunable ParametersModel
User-Defined Data Type Objects to Define Numeric Types and Aliases
Uses: Embedded Coder
Model
Import Externally Defined Parameters Into Simulink®
Uses: Embedded Coder
Model
Data Dictionary Driven Modeling Using Simulink® Data Objects
Uses: Embedded Coder
Model
Controlling the Initial Value of Signals and States Using Signal ObjectsModel
Creating a Data Dictionary with the Data Object WizardModel

Variants

Variant Model Blocks Controlled by C Preprocessor Conditionals
Uses: Embedded Coder
Script
Variant Subsystems Controlled by C Preprocessor Conditionals
Uses: Embedded Coder
Script

Code Format and Style

Formatting Generated Files with Templates
Uses: Embedded Coder
Model
Parentheses Control
Uses: Embedded Coder
Model
Identifier Naming Rules
Uses: Embedded Coder
Model
Applying Uniform Naming Conventions for Data Identifiers
Uses: Embedded Coder
Model

Code Verification and Documentation

Documenting Generated Code
Uses: Simulink Report Generator
Model
Tracing Generated Code with Block / Code Highlighting
Uses: Embedded Coder
Model
User-Controlled Comments to Improve Code Readability and Traceability
Uses: Embedded Coder
Model
Linking Code to Requirements
Uses: Embedded Coder
Model
Software and Processor-in-the-Loop (SIL and PIL) Simulation
Uses: Embedded Coder
Script
Collecting Code Coverage Metrics
Uses: Embedded Coder, Simulink Verification and Validation
Script
Using Code Generation Verification
Uses: Embedded Coder
Script
Using the IEC 61508 Modeling Standard Checks
Uses: Embedded Coder, Simulink Verification and Validation
Script

Integrating with C Code

Calling Legacy Functions in Simulink

Inputs Passed by Value or AddressScript
Return ArgumentsScript
Fixed Point Signals
Uses: Fixed-Point Designer
Script
Fixed Point Parameters
Uses: Fixed-Point Designer
Script
Lookup TablesScript
Start and Terminate ActionsScript
Structure Arguments Using BusesScript
Inherited Signal DimensionsScript
Persistent MemoryScript
Multi-Dimensional SignalsScript
Complex SignalsScript
Specification of Block Sample TimeScript
Integrating Legacy C Code in Stateflow®Model
Integrating Legacy Code Using Custom Code BlocksModel
Reusable Code Interface
Uses: Embedded Coder
Model
Specifying Function Prototypes for Models
Uses: Embedded Coder
Model
Replacing Math Functions and Operators
Uses: Embedded Coder
Script
Exporting Function-Call Subsystems
Uses: Embedded Coder
Model

Integrating with C++ Code

C++ Classes for ModelsModel
Calling C++ Object Methods Functions in Simulink®
Uses: Embedded Coder
Script
Integrating Arbitrary C++ Code in Simulink®Model
Integrating Legacy C++ Code in Stateflow®Model

Integrating with Custom Environments (IDEs, Targets, and AUTOSAR)

Specifying Target Environment SettingsModel
ANSI® C, ISO® C, GNU® C, and ISO® C++ Math Library SupportModel
Adding a Custom ToolchainScript

Data Exchange Interfaces

Target-Based Data Interface: C-API Data Definition FileModel
Host-Based Data Interface: ASAM-ASAP2 Data Definition FileModel

Host/Target Communication

Creating a Communications Channel for Target Connectivity
Uses: Embedded Coder
Script
Creating a Custom Processor-in-the-Loop (PIL) Configuration
Uses: Embedded Coder
Script
Exporting Generated Files Using PackNGo and BuildInfo APIModel
Customizing a Main Program for Your Target
Uses: Embedded Coder
Model
Custom File Processing Using the Target Language Compiler
Uses: Embedded Coder
Model
Profiling Hooks for Generated Code
Uses: Embedded Coder
Model

Integration with AUTOSAR Runtime Environment

AUTOSAR Code Generation
Uses: Embedded Coder
Script
AUTOSAR Code Generation for Multiple Runnable Entities
Uses: Embedded Coder
Script
Import and Export an AUTOSAR Software Component
Uses: Embedded Coder
Script
Using Data Stores to Access Per-Instance Memory
Uses: Embedded Coder
Script

Desktop IDEs

Eclipse

Automation Interface TutorialScript
Project Generator TutorialModel
Makefile Generator TutorialModel
Getting Started with Application Development
Uses: Embedded Coder
Model
Video Stabilization
Uses: Embedded Coder, DSP System Toolbox, Computer Vision System Toolbox, Fixed-Point Designer
Model

Microsoft Visual Studio

Creating a Microsoft® Visual Studio® SolutionModel

Desktop Targets

Interfacing to Host Simulators Using Shared Libraries
Uses: Embedded Coder
Model

Linux

Video Stabilization
Uses: DSP System Toolbox, Computer Vision System Toolbox, Image Acquisition Toolbox
Model

Windows

Video Stabilization
Uses: DSP System Toolbox, Computer Vision System Toolbox, Image Acquisition Toolbox
Model

Embedded IDEs

Eclipse

Automation Interface TutorialScript
Project Generator TutorialModel
Makefile Generator TutorialModel
Getting Started with Application Development
Uses: Embedded Coder
Model
Optimizing Embedded Code via Code Replacement Library
Uses: Embedded Coder, DSP System Toolbox, Fixed-Point Designer
Model
Verifying the Fixed-Point Fuel Control System
Uses: Embedded Coder, Stateflow
Model
Video Stabilization
Uses: Embedded Coder, DSP System Toolbox, Computer Vision System Toolbox, Fixed-Point Designer
Model

Texas Instruments Code Composer Studio

Automation Interface Tutorial
Uses: Embedded Coder
Script
Project Generator Tutorial
Uses: Embedded Coder
Model
Makefile Generator Tutorial
Uses: Embedded Coder
Model
Real-Time Data Exchange (RTDX™) Tutorial
Uses: Embedded Coder
Script
Multiprocessor Tutorial
Uses: Embedded Coder
Script
Getting Started with Application Development
Uses: Embedded Coder
Model
Real-Time Task Execution Profiling
Uses: Embedded Coder
Model
Optimizing Embedded Code via Code Replacement Library
Uses: Embedded Coder, DSP System Toolbox, Fixed-Point Designer
Model
Debugging a Target Application
Uses: Embedded Coder
Script
Comparing Simulation and Target Implementation with Debug Methods
Uses: Embedded Coder
Model
Comparing Simulation and Target Implementation with RTDX™
Uses: Embedded Coder
Model
Verifying the Fixed-Point Fuel Control System
Uses: Embedded Coder, Stateflow
Model
Video Stabilization
Uses: Embedded Coder, DSP System Toolbox, Computer Vision System Toolbox, Fixed-Point Designer
Model

Embedded Targets

VxWorks/Tornado Real-Time Operating System

Interfacing to the VxWorks®/Tornado® Real-Time Operating System
Uses: Embedded Coder
Model
Multirate Modeling in Multitasking Mode (VxWorks® OS)
Uses: Embedded Coder
Model

Texas Instruments C5000

Reverberation
Uses: Embedded Coder, DSP System Toolbox
Model
Was this topic helpful?