Why is the Data Type Conversion code not included in the code generated by Real-Time Workshop Embedded Coder 5.1 (R2008a)?
Mostra commenti meno recenti
I implement the following code in Simulink:
y = x * 128
M16C is a 16-bit microprocessor provided by RENESAS and it has some instructions (mnemonics) for shift operation depending on the data size of operand. For example if x and y are UINT16 the operation is coded as:
y = x << 7U;
If x is a UINT8, then it is possible to insert a Data Type Conversion block and the code generated using RTW-EC is :
y = (uint16_T)x << 7U;
RTW-EC deletes the cast operation represented by Data Type Conversion block if the following conditions are satisfied.
1. The cast data type is signed.
2. The cast data size is equal to "int" size in "hardware implementation" configuration.
In that case the generated code is:
y = x << 7U;
The result of right hand side makes precision loss (overflow). To avoid this overflow, x must be cast to 16-bit.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Deployment, Integration, and Supported Hardware in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!