Supported Simulink Blocks with CMSIS Library for ARM Cortex-M Processors
The Embedded Coder® Support Package for ARM® Cortex®-M Processors provides a code replacement library (CRL) for common microcontroller software interface standard (CMSIS) functions.
CMSIS CRL supports these processors:
Cortex-M0
Cortex-M0+
Cortex-M3
Cortex-M4
Cortex-M7
Cortex-M33
To improve the simulation speed of your models and performance of the generated code, you can set the model configuration parameters under the Code Generation>Optimization category. For more information on how to set the model parameters, see Model Configuration Parameters: Code Generation Optimization.
Note
To get the code replacement, in the code generation configuration settings, set
CodeReplacementLibrary
toARM Cortex-M
.Select the Saturate on integer overflow option in Simulink® blocks for CRL replacements. Refer to Enable Saturate on Integer Overflow on a Block section in Collect Saturation on Integer Overflow Coverage (Simulink Coverage).
All CRLs have been tested with CMSIS version 5.9.
Basic Math Operations
Operation | Wrappers calling CMSIS function | Supported data types | Input specifications | Parameter specifications | Replaced Simulink block |
---|---|---|---|---|---|
Absolute | mw_arm_abs_f32
| single |
| - | Abs |
mw_arm_abs_q31
| fixdt(true,32,31) |
| |||
mw_arm_abs_q15 | fixdt(true,16,15) |
| |||
mw_arm_abs_q7 | fixdt(true,8,7) |
| |||
Addition | mw_arm_add_f32 | single |
Note Using a vector input and a vector bias value in the Bias block will also trigger code replacement. | - | Add |
mw_arm_add_q31
| fixdt(true,32,*) |
Note For real inputs, the CRL generates code replacement when the word length is 32, even if the fraction length of the inputs differ. | |||
mw_arm_add_q15
| fixdt(true,16,*) |
Note For real inputs, the CRL generates code replacement when the word length is 16, even if the fraction length of the inputs differ. | |||
mw_arm_add_q7 | fixdt(true,8,*) |
Note For real inputs, the CRL generates code replacement when the word length is 8, even if the fraction length of the inputs differ. | |||
Bias/Offset | mw_arm_bias_1_f32 | single |
| Bias parameter in the Bias block can be vector and matrix. | Bias |
mw_arm_bias_1_q31 | fixdt(true,32,*) |
| |||
mw_arm_bias_1_q15 | fixdt(true,16,*) | ||||
mw_arm_bias_1_q7 | fixdt(true,8,*) | ||||
mw_arm_bias_2_f32 | single |
| Bias parameter in the Bias block must be a scalar. | ||
mw_arm_bias_2_q31 | fixdt(true,32,*) |
| |||
mw_arm_bias_2_q15 | fixdt(true,16,*) | ||||
mw_arm_bias_2_q7 | fixdt(true,8,*) | ||||
Dot product | mw_arm_dot_f32 | single |
| - | Dot Product |
mw_arm_dot_q15 | fixdt(true,16,*) |
Note
| |||
mw_arm_dot_q7 | fixdt(true,8,*) |
Note
| |||
Exponential | mw_arm_vexp_f32 | single |
| Set the Function parameter of Math Function block to
| Math Function |
Logarithm | mw_arm_vlog_f32 | single |
| Set the Function parameter of Math Function to
| Math Function |
Multiplication | mw_arm_mult_f32
| single |
Note For multiplication operation, one input can be a vector while the other input can be a matrix. | - | Product, Matrix Multiply |
mw_arm_mult_q15 | fixdt(true,16,*) |
Note
| |||
mw_arm_mult_q7 | fixdt(true,8,*) |
Note
| |||
Saturate/Limit/Clipping | mw_arm_saturate_f32 | single |
| Upper and lower limits of the Saturation block must be scalar values | Saturation |
mw_arm_saturate_q31 | fixdt(true,32,*) |
|
| ||
mw_arm_saturate_q15 | fixdt(true,16,*) |
|
| ||
mw_arm_saturate_q7 | fixdt(true,8,*) |
|
| ||
Scale/Gain | mw_arm_scale_1_f32 | single |
|
| Gain |
mw_arm_scale_1_q15 | fixdt(true,16,*) |
|
| ||
mw_arm_scale_1_q7 | fixdt(true,8,*) | ||||
mw_arm_scale_2_f32 | single |
| Set the Multiplication
parameter in the Product, Matrix
Multiply block to
| ||
mw_arm_scale_2_q15 | fixdt(true,16,*) | ||||
mw_arm_scale_2_q7 | fixdt(true,8,*) | ||||
Subtraction | mw_arm_sub_f32 | single |
| - | Sub |
mw_arm_sub_q31
| fixdt(true,32,*) |
Note For real inputs, the CRL generates code replacement when the word length is 32, even if the fraction lengths of the inputs differ. | |||
mw_arm_sub_q15 | fixdt(true,16,*) |
Note For real inputs, the CRL generates code replacement when the word length is 16, even if the fraction lengths of the inputs differ. | |||
mw_arm_sub_q7
| fixdt(true,8,*) |
Note For real inputs, the CRL generates code replacement when the word length is 8, even if the fraction lengths of the inputs differ. | |||
Square root | mw_arm_sqrt_f32
| single |
| - | Sqrt |
Unary minus/Negate | mw_arm_uminus_f32 | single |
| - | Unary Minus |
mw_arm_uminus_q31 | fixdt(true,32,*) | ||||
mw_arm_uminus_q15 | fixdt(true,16,*) | ||||
mw_arm_uminus_q7 | fixdt(true,8,*) |
Shift Operations
Operation | Wrappers calling CMSIS function | Supported data types | Input specifications | Replaced Simulink block |
---|---|---|---|---|
Right shift | mw_arm_shift_q31
| fixdt(true,32,31) |
| Shift Arithmetic |
mw_arm_shift_q15
|
fixdt(true,16,15) |
| ||
mw_arm_shift_q7
| fixdt(true,8,7) |
|
Data Cast Operations
Operation | Wrappers calling CMSIS function | Supported data types | Input specifications | Parameter specifications | Replaced Simulink block |
---|---|---|---|---|---|
Cast float to fixed
point | mw_arm_float_to_q15 | single |
| The Output data type parameter of Data Type Conversion
block must be set to | Data Type Conversion |
mw_arm_float_to_q7 | single |
| The Output data type parameter of Data Type Conversion
block must be set to | ||
Cast q31 to float | mw_arm_q31_to_float | fixdt(true,32,31) |
| The Output data type parameter of Data Type Conversion
block must be set to | |
Cast q31 to q15 | mw_arm_q31_to_q15
| fixdt(true,32,31) |
| The Output data type parameter of Data Type Conversion
block must be set to | |
Cast q31 to q7 | mw_arm_q31_to_q7 | fixdt(true,32,31) |
| The Output data type parameter of Data Type Conversion
block must be set to | |
Cast q15 to float | mw_arm_q15_to_float | fixdt(true,16,15) |
| The Output data type parameter of Data Type Conversion
block must be set to | |
Cast q15 to q31 | mw_arm_q15_to_q31 | fixdt(true,16,15) |
| The Output data type parameter of Data Type Conversion
block must be set to | |
Cast q15 to q7 | mw_arm_q15_to_q7 | fixdt(true,16,15) |
| The Output data type parameter of Data Type Conversion
block must be set to | |
Cast q7 to
float | mw_arm_q7_to_float | fixdt(true,8,7) |
| The Output data type parameter of Data Type Conversion
block must be set to | |
Cast q7 to
q31 | mw_arm_q7_to_q31 | fixdt(true,8,7) |
| The Output data type parameter of Data Type Conversion
block must be set to | |
Cast q7 to
q15 | mw_arm_q7_to_q15 | fixdt(true,8,7) |
| The Output data type parameter of Data Type Conversion
block must be set to |
Trigonometric Operations
Operation | Wrappers calling CMSIS function | Supported data types | Input specifications | Parameter specifications | Replaced Simulink block |
---|---|---|---|---|---|
sine | mw_arm_sin_f32
| single |
|
| Trigonometric Function |
cosine | mw_arm_cos_f32
| single |
Complex Math Operations
Operation | Wrappers calling CMSIS function | Supported data types | Input specifications | Parameter specifications | Replaced Simulink block |
---|---|---|---|---|---|
Complex conjugate | mw_arm_cmplx_conj_f32 | single |
| Set the Function parameter of
Math Function to
| Math Function |
mw_arm_cmplx_conj_q31
| fixdt(true,32,31) | ||||
mw_arm_cmplx_conj_q15
| fixdt(true,16,15) | ||||
Complex-by-complex multiplication | mw_arm_cmplx_mult_cmplx_f32
| single |
| Set the Multiplication parameter of Math Function in the
Product, Matrix
Multiply block to
| Product, Matrix Multiply |
mw_arm_cmplx_mult_cmplx_q31
| fixdt(true,32,31) |
|
| ||
mw_arm_cmplx_mult_cmplx_q15 | fixdt(true,16,15) |
|
| ||
Complex-by-real multiplication | mw_arm_cmplx_mult_real_f32
| single |
| Set the Multiplication parameter in the
Product, Matrix
Multiply block to
| Product, Matrix Multiply |
mw_arm_cmplx_mult_real_q31
| fixdt(true,32,31) |
|
| ||
mw_arm_cmplx_mult_real_q15
| fixdt(true,16,15) |
|
|
Logical Operations
Operation | Wrappers calling CMSIS function | Supported data types | Input specifications | Parameter specifications | Replaced Simulink block |
---|---|---|---|---|---|
Logical AND | mw_arm_and_unit32 |
|
| Set the Operator parameter in
the Bitwise Operator block
to | AND |
mw_arm_and_unit16 |
|
| |||
mw_arm_and_unit8 |
|
| |||
Logical OR | mw_arm_or_unit32 |
|
| Set the Operator parameter in
the Bitwise Operator block
to | OR |
mw_arm_or_unit16 |
|
| |||
mw_arm_or_unit8 |
|
| |||
Logical NOT | mw_arm_not_unit32 |
|
| Set the Operator parameter in
the Bitwise Operator block
to | NOT |
mw_arm_not_unit16 |
|
| |||
mw_arm_not_unit8 |
|
| |||
Logical XOR | mw_arm_xor_unit32 |
|
| Set the Operator parameter in
the Bitwise Operator block
to | XOR |
mw_arm_xor_unit16 |
|
| |||
mw_arm_xor_unit8 |
|
|
Matrix Operations
Operation | Wrappers calling CMSIS function | Supported data types | Input specifications | Parameter specifications | Replaced Simulink block and MATLAB® function |
---|---|---|---|---|---|
Matrix multiplication | mw_arm_mat_mult_f32 |
|
| - | Product, Matrix Multiply |
mw_arm_mat_mult_q15 |
|
Note The output with CRL replacement differs from the Simulink output because the CMSIS APIs use a higher accumulator, whereas Simulink uses an accumulator with a size equal to the input word length | |||
mw_arm_mat_mult_q7 |
|
Note The output with CRL replacement differs from the Simulink output because the CMSIS APIs use a higher accumulator, whereas Simulink uses an accumulator with a size equal to the input word length | |||
Matrix transpose | mw_arm_trans_f32 |
|
| - | Transpose |
mw_arm_trans_q31 |
| ||||
mw_arm_trans_q15 |
| ||||
mw_arm_trans_q7 |
| ||||
mw_arm_mat_cmplx_trans_f32 |
|
| transpose | ||
mw_arm_mat_cmplx_trans_q31 |
| ||||
mw_arm_mat_cmplx_trans_q15 |
|