How to determine the sequence of generated code?

1 view (last 30 days)
I have develop my own TLC file to generate C code.
In my own TLC, there are:
%function Outputs(block, system) Output
%if (CompiledModel.ConfigSet.SystemTargetFile == "GW_RCP.tlc")
%assign ECUOutputNum = enuRelay6Ctrl
%<ECUOutput>= %<LibBlockInputSignal(0,"","",0)> ;
%endif
%endfunction
In the generated code, the codes are:
/* S-Function (rcp_ecu_output): '<Root>/ECU_Output' */
enuRelay6Ctrl = Output ;
/* S-Function (rcp_ecu_input): '<Root>/ECU_Input' */
Input1 = fPumpOut5Vol ;
/* S-Function (rcp_ecu_input): '<Root>/ECU_Input1' */
Input3 = fValvePwmOut1Vol ;
/* Sum: '<Root>/Add2' incorporates:
* DotProduct: '<Root>/Dot Product'
* Sum: '<Root>/Add'
* Sum: '<Root>/Add1'
*/
Output = ((Input1 + Input2) + Input3) + Input3 * Input2;
The "Output" is assigned before its caculationg, which make the "Output" update delayed one step.
How could I change the sequence of code generation to make the code as below:
Output = ((Input1 + Input2) + Input3) + Input3 * Input2;
enuRelay6Ctrl = Output ;
Thank you very much.

Answers (1)

Dinesh Yadav
Dinesh Yadav on 30 Oct 2019

Categories

Find more on Code Generation in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!