Real-Time Workshop | ![]() ![]() |
Making an Executable
Real-Time Workshop generates code into a set of source files that vary little among different targets. Not all possible files will be generated for every model. Some files are only created when the model includes subsystems or particular types of data.
The file packaging of the Real-Time Workshop Embedded Coder differs slightly (but significantly) from the file packaging described below. See the "Data Structures and Code Modules" section in the Real-Time Workshop Embedded Coder documentation for further information.
Generated Source Files
The following table summarizes the structure of source code generated by the Real-Time Workshop. All code modules described are written to the build directory within your current working directory. Figure 2-9 summarizes the dependencies among these files.
File |
Description |
model .c |
Contains entry points for all code implementing the model algorithm (MdlStart , MdlOutputs , MdlUpdate , MdlInitializeSizes , MdlInitializeSampleTimes ). Also contains model registration code. |
model _private.h |
Contains local defines and local data that are required by the model and subsystems. This file is included by the genberated source files in the model. You do not need to include model _private.h when interfacing hand-written code to a model. |
model .h |
Defines 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 _rtM ) via accessor macros. model .h is included by subsystem .c 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 (conditional) |
model _data.c is conditionally generated. It contains the declarations for the parameters data structure and the constant block I/O data structure. If these data structures are not used in the model, model _data.c is not generated. Note that these structures 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. model _types.h is included by all the generated header files in the model. |
rtmodel.h |
Contains #include directives required by static main program modules such as grt_main.c and grt_malloc_main.c . Since these modules are not created at code generation time, they include rt_model.h to access model-specific data structures and entry points. If you create your own main program module, take care to include rtmodel.h . |
model_pt.c (optional) |
Provides data structures that enable a running program to access model parameters without use of external mode. To learn how to generate and use the model_pt.c file, see C API for Parameter Tuning. |
model_bio.c (optional) |
Provides data structures that enable your code to access block outputs. To learn how to generate and use the model_bio.c file, see Signal Monitoring via Block Outputs. |
If you have interfaced hand-written code to code generated by previous releases of the Real-Time Workshop, you may need to remove dependencies on header files that are no longer generated. Use #include
model
.h
directives, and remove #include
directives referencing any of the following:
model_
common.h
(replaced by model
_types.h
and model
_private.h
)
model_
export.h
(replaced by model
.h
)
model_
prm.h
(replaced by model
_data.c
)
model_
reg.h
(subsumed by model
_.c
)
Real-Time Workshop generated source file dependencies are depicted in Figure 2-9. Arrows emitting from a file indicate the files it includes. As the illustration notes, other dependencies exist, for example on Simulink header files files tmw_types.h
, simstruc_types.h
, and optionally on rtlibsrc.h
, plus C library files. The diagram only maps inclusion relations between files that are generated in the build directory.
The diagram shows that parent system header files (model
.h
) include all child subsystem header files (subsystem
.h
). In more layered models, subsystems similarly include their children's header files, on down the model hierarchy. As a consequence, subsystems are able to recursively "see" into all their descendents' subsystems, as well as to see into the root system (because every subsystem
.c
includes model
.h
and model
_private.h
).
Figure 2-9: Real-Time Workshop Generated File Dependencies
![]() | Available Targets | Compilation and Linking | ![]() |