Examples of Generated Code with Memory Sections
Sample ERT-Based Model with Subsystem
The next figure shows an ERT-based Simulink model that
defines one subsystem, and the contents of that subsystem.

Assume that the subsystem is atomic, the Real-Time
Workshop system code is Reusable function,
memory sections have been created and assigned as shown in the next
two tables, and all data memory sections specify Pragma
surrounds to be Each variable.
Model-Level Memory Section Assignments and Definitions
| Section Assignment | Section Name | Field Name | Field Value |
| Input/Output | MemSect1 | Prepragma | #pragma IO_begin |
| Postpragma | #pragma IO-end |
| Internal data | MemSect2 | Prepragma | #pragma InData-begin(%<identifier>) |
| Postpragma | #pragma InData-end |
| Parameters | MemSect3 | Prepragma | #pragma Parameters-begin |
| Postpragma | #pragma Parameters-end |
Initialize/ Terminate | MemSect4 | Prepragma | #pragma InitTerminate-begin |
| Postpragma | #pragma InitTerminate-end |
| Execution functions | MemSect5 | Prepragma | #pragma ExecFunc-begin(%<identifier>) |
| Postpragma | #pragma ExecFunc-begin(%<identifier>) |
Subsystem-Level Memory Section Assignments and Definitions
| Section Assignment | Section Name | Field Name | Field Value |
| Execution functions | MemSect6 | Prepragma | #pragma DATA_SEC(%<identifier>, "FAST_RAM") |
| Postpragma | |
Given the preceding specifications and definitions, the code
generator would create the following code, with minor variations depending
on the current version of the Target Language Compiler.
Back to Top
 | Applying Memory Sections | | Model-Level Data Structures |  |
Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
Get this Simulink Kit