| Real-Time Workshop® Embedded Coder™ | ![]() |
| On this page… |
|---|
This section summarizes the code modules and header files that make up a Real-Time Workshop Embedded Coder program, and describes where to find them.
Note that in most cases, the easiest way to locate and examine the generated code files is to use the Real-Time Workshop Embedded Coder code generation report. The code generation report provides a table of hyperlinks that let you view the generated code in the MATLAB® Help browser. See Creating and Using a Code Generation Report for further information.
The Real-Time Workshop Embedded Coder software creates a build directory in your working directory to store generated source code. The build directory also contains object files, a makefile, and other files created during the code generation process. The default name of the build directory is model_ert_rtw.
Real-Time Workshop Embedded Coder File Packaging summarizes the structure of source code generated by the Real-Time Workshop Embedded Coder software.
Note The Real-Time Workshop Embedded Coder file packaging differs slightly (but significantly) from the file packaging employed by the GRT, GRT malloc, and other non-embedded targets. See the Real-Time Workshop documentation for further information. |
Real-Time Workshop Embedded Coder File Packaging
| File | Description |
|---|---|
model.c or .cpp | Contains entry points for code implementing the model algorithm (for example, model_step, model_initialize, and model_terminate). |
model_private.h | Contains local macros and local data that are required by the model and subsystems. This file is included by the generated source files in the model. You do not need to include model_private.h when interfacing hand-written code to a model. |
model.h | Declares model data structures and a public interface to the model entry points and data structures. Also provides an interface to the real-time model data structure (model_M) with accessor macros. model.h is included by subsystem .c or .cpp files in the model. If you are interfacing your hand-written code to generated code for one or more models, you should include model.h for each model to which you want to interface. |
model_data.c or .cpp (conditional) | model_data.c or .cpp is conditionally generated. It contains the declarations for the parameters data structure, the constant block I/O data structure, and any zero representations used for the model's structure data types. If these data structures and zero representations are not used in the model, model_data.c or .cpp is not generated. Note that these structures and zero representations are declared extern in model.h. |
model_types.h | Provides forward declarations for the real-time model data structure and the parameters data structure. These may be needed by function declarations of reusable functions. Also provides type definitions for user-defined types used by the model. |
rtwtypes.h | Defines data types, structures and macros required by Real-Time Workshop Embedded Coder generated code. Most other generated code modules require these definitions. |
ert_main.c or .cpp (optional) | This file is generated only if the Generate an example main program option is on. (This option is on by default.) See Generating the Main Program Module. |
autobuild.h | This file is generated only if the Generate an example main program option is off. (See Generating the Main Program Module.) autobuild.h contains #include directives required by the static version of the ert_main.c main program module. Since the static ert_main.c is not created at code generation time, it includes autobuild.h to access model-specific data structures and entry points. See Static Main Program Module for further information. |
model_capi.c or .cpp | Provides data structures that enable a running program to access model parameters and signals without use of external mode. To learn how to generate and use the model_capi.c or .cpp and .h files, see the Data Exchange APIs chapter in the Real-Time Workshop documentation. |
You can also customize the generated set of files in several ways:
Nonvirtual subsystem code generation: You can instruct the Real-Time Workshop software to generate separate functions, within separate code files, for any nonvirtual subsystems. You can control the names of the functions and of the code files. See Nonvirtual Subsystem Code Generation in the Real-Time Workshop documentation for further information.
Custom storage classes: You can use custom storage classes to partition generated data structures into different files based on file names you specify. See Custom Storage Classes for further information.
Module Packaging Features (MPF) also lets you direct the generated code into a required set of .c or .cpp and .h files, and control the internal organization of the generated files. See the Module Packaging Features document for details.
Code that you write to interface with generated model code usually includes a customized main module (based on a main program provided by the Real-Time Workshop software), and may also include interrupt handlers, device driver blocks and other S-functions, and other supervisory or supporting code.
You should establish a working directory for your own code modules. Your working directory should be on the MATLAB path. Minimally, you must also modify the ERT template makefile and system target file so that the build process can find your source and object files. More extensive modifications to the ERT target files are needed if you want to generate code for a particular microprocessor or development board, and to deploy the code on target hardware with a cross-development system.
See the Developing Embedded Targets document for information on how to customize the ERT target for your production requirements.
![]() | Real-Time Model (rtModel) Data Structure | Generating the Main Program Module | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |