| 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 |
| On this page… |
|---|
When configuring a model for SIL simulation with the Real-Time Workshop product and when processor word sizes differ between host and target platforms, you can configure the model to use an emulation hardware option. That option guarantees bit-true agreement for integer and fixed-point operations between host system simulation results and target deployment.
In addition to the emulation hardware option, the Real-Time Workshop Embedded Coder product provides an option for configuring a model to use portable word sizes. Using this second option, you can configure a model to generate code that you can compile without changing it for a platform. You can then use the code for SIL simulation on a host system and for deployment on a target system.
Note
|
To configure a model to use portable word sizes, set model configuration parameters.
| Set... | To... |
|---|---|
| Hardware Implementation > Emulation hardware > None | Selected |
| Real-Time Workshop > Interface > Create Simulink (S-Function) block | Selected |
| Real-Time Workshop > Interface > Enable portable word sizes | Selected |

When you generate code for a model with the preceding parameter settings, the code generator conditionalizes data type definitions:
tmwtypes.h supports SIL simulation on the host system
Real-Time Workshop types support deployment on the target system
For example, in the following generated code, the first two lines define types for SIL simulation on a host system. 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 */
For an example of how to configure a model to maintain bit-true agreement between host simulation and target deployment, and generate code that is portable between the host and target systems, see rtwdemo_sil_pil.
When compiling generated code that supports portable word sizes for SIL testing, you need to pass the definition PORTABLE_WORDSIZES to the compiler.
For example:
-DPORTABLE_WORDSIZES
To build the same code for target deployment, compile the code without the PORTABLE_WORDSIZES definition.
When performing SIL testing, using the Enable portable word sizes model configuration parameter, numerical results of the S-function simulation on the MATLAB host might differ from results on the actual target. This difference is due to differences in target characteristics, such as:
C integral promotion in expressions may be different on the target processor
Signed integer division rounding behavior may be different on the target processor
Signed integer arithmetic shift right may behave differently on the target processor
Floating-point precision may be different on the target processor
![]() | About Software-In-the-Loop Simulation Extensions | Generating an S-Function Wrapper for SIL Testing | ![]() |

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 |