| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Real-Time Workshop Embedded Coder |
| Contents | Index |
| Learn more about Real-Time Workshop Embedded Coder |
This table summarizes what's new in Version 4.6 (R2007a):
| New Features and Changes | Version Compatibility Considerations | Fixed Bugs and Known Problems | Related Documentation at Web Site |
|---|---|---|---|
| Yes Details below | No | Bug
Reports Includes fixes | No |
New features and changes introduced in this version are
New ModelStepFunctionPrototypeControlCompliant Target Configuration Parameter
Enhanced Software-in-the-loop (SIL) Testing with New Portable Word Sizes Option
New Code Style Options for Controlling Expression Optimizations in Generated Code
In previous releases, there were only limited ways to control the function prototype of an ERT-based model's generated model_step function. The default model_step function prototype resembles the following:
void model_step(void);
If you generate reusable, reentrant code for an ERT-based model, the model's root-level inputs and outputs, block states, parameters, and external outputs are passed in to model_step using a function prototype that resembles the following:
void model_step(inport_args, outport_args, BlockIO_arg, DWork_arg, RT_model_arg);
This release adds more flexible user control over the model_step function prototype that is generated for ERT-based Simulink models. From the Interface pane of the Configuration Parameters dialog box, you can click a new Configure Functions button that launches a Model Step Functions dialog box. Based on the Function specification value you select for your model_step function (supported values include Default model-step function and Model specific C prototype), you can preview and modify the function prototype. Here is a sample dialog box:

Once you validate and apply your changes, you can generate code based on your function prototype modifications.
Alternatively, you can use function prototype control functions to programmatically control model_step function prototypes. For more information, see Configuring Model Function Prototypes Programmatically in the Real-Time Workshop Embedded Coder documentation.
You can also control step function prototypes for nonvirtual subsystems, if you generate subsystem code using right-click build. To launch the Model Step Functions for subsystem dialog box, use the function RTW.configSubsystemBuild:
RTW.configSubsystemBuild('model/subsystem')
RTW.configSubsystemBuild(gcb)Right-click building the subsystem will generate the step function according to the customizations you make.
For more information about controlling model_step function prototypes, see the sections Configuring the Target Hardware Environment and Controlling Generation of Function Prototypes in the Real-Time Workshop Embedded Coder documentation. For limitations that apply, see Model Function Prototype Control Limitations in the Real-Time Workshop Embedded Coder documentation.
For more detailed information about the default calling interface for the model_step function, see the model_step reference page.
In conjunction with the function prototype control feature described in the previous section, this release introduces the ModelStepFunctionPrototypeControlCompliant target configuration parameter. This parameter is set in the SelectCallback function for a target to indicate whether the target supports the ability to control the function prototypes of step functions that are generated for a Simulink model. The default is off for custom and non-ERT targets and on for ERT (ert.tlc) targets.
When this parameter is set to off and you attempt to use function prototype control to modify a step function signature, Real-Time Workshop Embedded Coder ignores the modified function prototype control configuration.
To make a target compliant,
Use the SelectCallback function to set ModelStepFunctionPrototypeControlCompliant to on. This enables the feature infrastructure and user interface.
If your target uses a custom static main module, and if a nondefault function prototype control configuration is associated with a model, update the main module to call the function prototype controlled model step function. You can do this in either of the following ways:
Manually adapt your main module to declare appropriate model data and call the function prototype controlled model step function.
Generate your main module using Generate an example main program on the Templates pane of the Configuration Parameters dialog box. This mechanism has been updated to declare model data and call the function prototype controlled model step function appropriately.
This release adds a new ERT target, ert_shrlib.tlc, for generating a host-based shared library from your Simulink model. Selecting this target allows you to generate a shared library version of your model code that is appropriate for your host platform, either a Windows® dynamic link library (.dll) file or a UNIX® shared object (.so) file. This feature can be used to package your source code securely for easy distribution and shared use. The generated .dll or .so file is shareable among different applications and upgradeable without having to recompile the applications that use it.
To configure your model code for shared use by applications, you select the ert_shrlib.tlc target on the Real-Time Workshop pane of the Configuration Parameters dialog box.

The shared library generated from your model can be dynamically loaded from another application. For example, if you open the demo rtwdemo_counter, select the ert_shrlib.tlc target, and generate code, application code similar to the following could be used to dynamically load the generated library file:
#if (defined(_WIN32)||defined(_WIN64)) /* WINDOWS */
#include <windows.h>
#define GETSYMBOLADDR GetProcAddress
#define LOADLIB LoadLibrary
#define CLOSELIB FreeLibrary
#else /* UNIX */
#include <dlfcn.h>
#define GETSYMBOLADDR dlsym
#define LOADLIB dlopen
#define CLOSELIB dlclose
#endif
int main()
{
void* handleLib;
...
#if defined(_WIN64)
handleLib = LOADLIB("./rtwdemo_counter_win64.dll");
#else
#if defined(_WIN32)
handleLib = LOADLIB("./rtwdemo_counter_win32.dll");
#else /* UNIX */
handleLib = LOADLIB("./rtwdemo_counter.so", RTLD_LAZY);
#endif
#endif
...
return(CLOSELIB(handleLib));
}For more information about using the ert_shrlib.tlc target, see Creating and Using Host-Based Shared Libraries in the Real-Time Workshop Embedded Coder documentation. For limitations that apply, see Host-Based Shared Library Limitations in the Real-Time Workshop Embedded Coder documentation.
This release adds a new model configuration option, Enable portable word sizes, that supports code generation for host-target configurations in which the processor word sizes differ between host and target platforms (for example, a 32-bit host and a 16-bit target). Selecting the Enable portable word sizes option allows you to generate code with conditional processing macros that allow the same generated source code files to be used both for software-in-the-loop (SIL) testing on the host platform and for production deployment on the target platform.
To use this feature, select both Create Simulink (S-Function) block and Enable portable word sizes on the Interface pane of the Configuration Parameters dialog box. Also, make sure that Emulation hardware is set to None on the Hardware Implementation pane.

When you generate code from your model, data type definitions are conditionalized such that tmwtypes.h is included to support SIL testing on the host platform and Real-Time Workshop types are used to support deployment on the target platform. For example, in the generated code below, the first two lines define types for host-based SIL testing and the bold lines define types for target deployment:
#ifdef PORTABLE_WORDSIZES /* PORTABLE_WORDSIZES defined */ # include "tmwtypes.h" #else /* PORTABLE_WORDSIZES not defined */ #define __TMWTYPES__ #include <limits.h> ... typedef signed char int8_T; typedef unsigned char uint8_T; typedef int int16_T; typedef unsigned int uint16_T; typedef long int32_T; typedef unsigned long uint32_T; typedef float real32_T; typedef double real64_T; ... #endif /* PORTABLE_WORDSIZES */
To build the generated code for SIL testing on the host platform, the definition PORTABLE_WORDSIZES should be passed to the compiler, for example by using the compiler option -DPORTABLE_WORDSIZES. To build the same code for target deployment, the code should be compiled without the PORTABLE_WORDSIZES definition.
For more information about using portable word sizes for host-based SIL testing, see Configuring the Target Hardware Environment and Setting Up a Model to Generate Code for Host Simulations and Target Deployment in the Real-Time Workshop Embedded Coder documentation. For limitations that apply, see Portable Word Sizes Limitation in the Real-Time Workshop Embedded Coder documentation.
Two new options on the Code Style pane of the Configuration Parameters dialog box allow you to control specific optimizations in generated code:
| Option | Description |
|---|---|
| Preserve operand order in expression | By default, Real-Time Workshop might reorder commutable operands to make an expression left-recursive. Selecting this option preserves the expression order you specify in the model. |
| Preserve condition expression in if statement | By default, Real-Time Workshop negates the condition expression in an if statement if the first statement branch is empty. Selecting this option preserves the condition expression you specify in the model. |
For more information, see Code Style Pane in the Real-Time Workshop Embedded Coder documentation.
This release provides several enhancements to MISRA C compliance, including
Numerous improvements to source files in the matlabroot/rtw/c/libsrc directory
Elimination of goto statements in Stateflow generated code (for more information, see the Stateflow and Stateflow Coder Release Notes)
Simplified generated code for reusable enabled subsystems (for more information, see the Real-Time Workshop Release Notes)
The following demos have been added:
| Demo... | Shows How You Can... |
|---|---|
| rtwdemo_fcnprotoctrl | Control the generated function prototype for the model entry point function model_step |
| rtwdemo_shrlib | Use the ERT shared library target to generate a host-based shared library (.dll or .so) from a model and then load the shared library from another application |
The following demo has been enhanced:
rtwdemo_sil
![]() | Version 4.6.1 (R2007a+) Real-Time Workshop Embedded Coder Software | Version 4.5 (R2006b) Real-Time Workshop Embedded Coder Software | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |