MATLAB: Does Real-Time Workshop 6.3 (R14SP3) generate non optimal code for automatically inserted Rate Transition blocks

realsimulink codertime

I have a model in which I have selected "Automatically handle data transfers between tasks" in the Configurations Parameters dialog. The generated code for the model includes several IF statements that correspond to automatically inserted Rate Transition blocks. Each of the IF statements tests the same condition. The code could be optimized by combining the several IF statements into a single IF statement. The following section of code illustrates the issue:
/* RateTransition: '<S14>/TmpRTBAtBusCtrlInport1' incorporates:
* Inport: '<Root>/AnyAxisEnabledInput'
*/
if(KinetixMbc_M->Timing.RateInteraction.TID0_1) {
KinetixMbc_B.TmpRTBAtBusCtrlInport1 = CtrlFlags.AnyAxisEnabledInput;
}
/* Gain: '<S14>/FLT1Convert' incorporates:
* Inport: '<Root>/FLT1_HW'
*/
rtb_FLT1 = KCL->FLT1_HW;
/* RateTransition: '<S14>/TmpRTBAtBusCtrlInport7' */
if(KinetixMbc_M->Timing.RateInteraction.TID0_1) {
KinetixMbc_B.TmpRTBAtBusCtrlInport7 = rtb_FLT1;
}
/* Gain: '<S14>/VbusConvert' incorporates:
* DataTypeConversion: '<S14>/VbusCast'
* Inport: '<Root>/Vbus_HW'
*/
Ireg.Vbus = (real_T)KCL->Vbus_HW * Pwr.VbusBitsToVolts;
/* RateTransition: '<S14>/TmpRTBAtBusCtrlInport8' */
if(KinetixMbc_M->Timing.RateInteraction.TID0_1) {
KinetixMbc_B.TmpRTBAtBusCtrlInport8 = Ireg.Vbus;
}
/* RateTransition: '<S14>/Rate Transition' incorporates:
* Inport: '<Root>/ExcptResetInput'
*/
if(KinetixMbc_M->Timing.RateInteraction.TID0_1) {
KinetixMbc_B.Reset_a = CtrlFlags.ExcptResetInput;
}

Best Answer

Real-Time Workshop 6.3 (R14SP3) generates an IF statement whenever it sees a Rate Transition block in the model. It does not optimize the code by combining all IF statements that check for the same condition.
There are no workarounds.