MATLAB: Is code not generated for a subsystem which has an Infinite sample time in Real-Time Workshop 7.3 (R2009a)

simulink coder

When I generate code from the attached model NonGeneratedCode.mdl, I get the following warning :
Warning: Real-Time Workshop: The subsystem <S1>/CommonReusable2Lib2 specifies Real-Time Workshop file name options. However, no code is generated for this subsystem. The specified source code file will not be created.
I specified that a reusable function must be generated from my Subsystem NonGeneratedCode/If1st/CommonReusable2Lib2.

Best Answer

Simulink optimizes model execution and code generation, therefore it avoids useless computation when possible. For example, if a subsystem's output is invariant over time, it will be replaced by a constant value.
If such a subsystem is parameterized to be generated as a Reusable function by Real-Time Workshop, optimization will have priority and therefore no code is generated for this subsystem.
The following warning is issued :
Warning: Real-Time Workshop: The subsystem <Sxxx>/XXX specifies Real-Time Workshop file name options. However, no code is generated for this subsystem. The specified source code file will not be created.
Using Sample Time colors is a good way to find out how sample times are propagated in your model. If a subsystem has an infinite sample time, this means that it's not evaluated at a discrete sample time and might be replaced by a constant, if possible. To work around this and ensure code is generated for a subsystem, avoid specifying infinite sample time.