Real-Time Workshop    

Code Formats

The Real-Time Workshop code generator transforms your model to HLL code. Real-Time Workshop supports a variety of code formats designed for different execution environments, or targets.

In the traditional embedded system development process, an engineer develops an algorithm (or equations) to be implemented in an embedded system. These algorithms are manually converted to a computer language such as C. This translation process, usually done by an embedded system engineer, is much like data entry.

Using Simulink to specify the algorithm (or equations), and Real-Time Workshop to generate corresponding code, engineers can bypass this redundant translation step. This enables embedded system engineers to focus on the key issues involved in creating an embedded system: the hardware configuration, device drivers, supervisory logic, and supporting logic for the model equations. Simulink itself is the programming language that expresses the algorithmic portion of the system.

The Simulink code generator provided with Real-Time Workshop is an open "graphical compiler" supporting a variety of code formats. The relationship between code formats and targets is shown below.

Figure D-6: Relationship Between Code Formats and Targets

S-Function/Accelerator Code Format

This code format, used by the S-function Target and Simulink Accelerator, generates code that conforms to Simulink C MEX S-function API.

Real-Time Code Format

The real-time code format is ideally suited for rapid prototyping. This code format (C only) supports increased monitoring and tuning capabilities, enabling easy connection with external mode. Real-time code format supports continuous-time models, discrete-time singlerate or multirate models, and hybrid continuous-time and discrete-time models. Real-time code format supports both inlined and noninlined S-functions. Memory allocation is declared statically at compile time.

Real-Time Malloc Code Format

The real-time malloc code format is similar to the real-time code format. The primary difference is that the real-time malloc code format declares memory dynamically. This supports multiple instances of the same model, with each instance including a unique data set. Multiple models can be combined into one executable without name clashing. Multiple instances of a given model can also be created in one executable.

Embedded Code Format

The embedded code format is designed for embedded targets. The generated code is optimized for speed, memory usage, and simplicity. Generally, this format is used in deeply embedded or deployed applications. There are no dynamic memory allocation calls; all persistent memory is statically allocated.

Real-Time Workshop can generate either C code in the embedded code format. Generating embedded code format requires the Real-Time Workshop Embedded Coder, a separate add-on product for use with Real-Time Workshop.

The embedded code format provides a simplified calling interface and reduced memory usage. This format manages model and timing data in a compact real-time model data structure. This contrasts with the other code formats, which use a significantly larger data structure to manage the generated code.

The embedded code format improves readability of the generated code, reduces code size, and speeds up execution. The embedded code format supports all discrete-time singlerate or multirate models.

Because of its optimized and specialized data structures, the embedded code format supports only inlined S-functions.


  How MathWorks Tools Streamline Development Target Environments