Supported MATLAB Functions with CMSIS Library for ARM Cortex-M Processors
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
CodeReplacementLibrarytoARM Cortex-M.If you encounter situations where the ARM Cortex-M CMSIS CRL does not provide code replacements due to the input vector length being below the threshold, you can enable CMSIS function generation for all input lengths. To do this, set the environment variable
DISABLE_ARMCORTEXM_CMSIS_CRL_THRESHOLDSto true using the following command:setenv('DISABLE_ARMCORTEXM_CMSIS_CRL_THRESHOLDS','true')To generate optimized code, thresholds are introduced . Forcing CMSIS function generation for all input lengths using this command can degrade performance.
Basic Math Operations
Basic Math Operations
| Operation | Wrappers calling CMSIS function | Supported data types | Input/Output specifications | Replaced MATLAB® code |
|---|---|---|---|---|
| Absolute | mw_arm_abs_f32
| single |
|
abs(a) |
| Addition | mw_arm_add_f32 | single |
|
a+b |
mw_arm_add_q31
| fixdt(true,32,31) |
|
fimath_q31 = fimath('SumMode','SpecifyPrecision',...
'OverflowAction','Saturate',...
'RoundingMethod','Floor',...
'SumWordLength',32,'SumFractionLength',31);
add(fimath_q31,a,b); | |
mw_arm_add_q15
| fixdt(true,16,15) |
|
fimath_q15 = fimath('SumMode','SpecifyPrecision',...
'OverflowAction','Saturate',...
'RoundingMethod','Floor',...
'SumWordLength',16,'SumFractionLength',15);
add(fimath_q15,a,b); | |
mw_arm_add_q7 | fixdt(true,8,7) |
|
fimath_q7 = fimath('SumMode','SpecifyPrecision',...
'OverflowAction','Saturate',...
'RoundingMethod','Floor',...
'SumWordLength',8,'SumFractionLength',7);
add(fimath_q7,a,b); | |
| Bias/Offset | mw_arm_bias_1_f32 | single |
|
a+b |
mw_arm_bias_1_q31 | fixdt(true,32,*) |
|
FimathObj = fimath('SumMode','SpecifyPrecision',...
'SumWordLength',32,'SumFractionLength',31,...
'OverflowAction','Saturate',...
'RoundingMethod','Floor');
add(FimathObj,a,b); | |
mw_arm_bias_1_q15 | fixdt(true,16,*) |
FimathObj = fimath('SumMode','SpecifyPrecision',...
'SumWordLength',16,'SumFractionLength',15,...
'OverflowAction','Saturate',...
'RoundingMethod','Floor');
add(FimathObj,a,b); | ||
mw_arm_bias_1_q7 | fixdt(true,8,*) |
FimathObj = fimath('SumMode','SpecifyPrecision',...
'SumWordLength',8,'SumFractionLength',7,...
'OverflowAction','Saturate',...
'RoundingMethod','Floor');
add(FimathObj,a,b); | ||
mw_arm_bias_2_f32 | single |
|
a+b | |
mw_arm_bias_2_q31 | fixdt(true,32,*) |
|
FimathObj = fimath('SumMode','SpecifyPrecision',...
'SumWordLength',32,'SumFractionLength',31,...
'OverflowAction','Saturate',...
'RoundingMethod','Floor');
add(FimathObj,a,b); | |
mw_arm_bias_2_q15 | fixdt(true,16,*) |
FimathObj = fimath('SumMode','SpecifyPrecision',...
'SumWordLength',16,'SumFractionLength',15,...
'OverflowAction','Saturate',...
'RoundingMethod','Floor');
add(FimathObj,a,b); | ||
mw_arm_bias_2_q7 | fixdt(true,8,*) |
FimathObj = fimath('SumMode','SpecifyPrecision',...
'SumWordLength',8,'SumFractionLength',7,...
'OverflowAction','Saturate',...
'RoundingMethod','Floor');
add(FimathObj,a,b); | ||
| Exponential | mw_arm_vexp_f32 | single |
|
exp(a) |
| Logarithm | mw_arm_vlog_f32 | single |
|
log(a) |
| Multiplication | mw_arm_mult_f32
| single |
|
a.*b |
mw_arm_mult_q15 | fixdt(true,16,*) |
|
FimathObj = fimath('ProductMode','SpecifyPrecision',...
'OverflowAction','Saturate',...
'RoundingMethod','Floor',...
'ProductWordLength',16,'ProductFractionLength',15);
mpy(FimathObj,a,b); | |
mw_arm_mult_q7 | fixdt(true,8,*) |
|
FimathObj = fimath('ProductMode','SpecifyPrecision',...
'OverflowAction','Saturate',...
'RoundingMethod','Floor',...
'ProductWordLength',8,'ProductFractionLength',7);
mpy(FimathObj,a,b); | |
| Scale/Gain | mw_arm_scale_1_f32 | single |
|
a.*b |
mw_arm_scale_1_q15 | fixdt(true,16,*) |
|
FimathObj = fimath('ProductMode','SpecifyPrecision',...
'ProductWordLength',16,...
'ProductFractionLength',15,...
'OverflowAction','Saturate',...
'RoundingMethod','Floor');
mpy(FimathObj,a,b); | |
mw_arm_scale_1_q7 | fixdt(true,8,*) |
FimathObj = fimath('ProductMode','SpecifyPrecision',...
'ProductWordLength',8,...
'ProductFractionLength',7,...
'OverflowAction','Saturate',...
'RoundingMethod','Floor');
mpy(FimathObj,a,b); | ||
mw_arm_scale_2_f32 | single |
|
a.*b | |
mw_arm_scale_2_q15 | fixdt(true,16,*) |
FimathObj = fimath('ProductMode','SpecifyPrecision',...
'ProductWordLength',16,...
'ProductFractionLength',15,...
'OverflowAction','Saturate',...
'RoundingMethod','Floor');
mpy(FimathObj,a,b); | ||
mw_arm_scale_2_q7 | fixdt(true,8,*) |
FimathObj = fimath('ProductMode','SpecifyPrecision',...
'ProductWordLength',8,...
'ProductFractionLength',7,...
'OverflowAction','Saturate',...
'RoundingMethod','Floor');
mpy(FimathObj,a,b); | ||
| Subtraction | mw_arm_sub_f32 | single |
|
a-b |
mw_arm_sub_q31
| fixdt(true,32,31) |
|
FimathObj = fimath('SumMode','SpecifyPrecision',...
'OverflowAction','Saturate',...
'RoundingMethod','Floor',...
'SumWordLength',32,'SumFractionLength',31);
sub(FimathObj,a,b); | |
mw_arm_sub_q15 | fixdt(true,16,15) |
|
FimathObj = fimath('SumMode','SpecifyPrecision',...
'OverflowAction','Saturate',...
'RoundingMethod','Floor',...
'SumWordLength',16,'SumFractionLength',15);
sub(FimathObj,a,b); | |
mw_arm_sub_q7
| fixdt(true,8,7) |
|
FimathObj = fimath('SumMode','SpecifyPrecision',...
'OverflowAction','Saturate',...
'RoundingMethod','Floor',...
'SumWordLength',8,'SumFractionLength',7);
sub(FimathObj,a,b); | |
| Square root | mw_arm_sqrt_f32
| single |
|
sqrt(a) |
| Unary minus/Negate | mw_arm_uminus_f32 | single |
|
uminus(a) |
mw_arm_uminus_q31 | fixdt(true,32,*) | |||
mw_arm_uminus_q15 | fixdt(true,16,*) | |||
mw_arm_uminus_q7 | fixdt(true,8,*) |
Shift Operations
Shift Operations
| Operation | Wrappers calling CMSIS function | Supported data types | Input/Output specifications | Replaced MATLAB code |
|---|---|---|---|---|
| Left shift | mw_arm_shift_q31
| fixdt(true,32,*) |
|
cast(a,'like',b) |
mw_arm_shift_q15
|
fixdt(true,16,*) | |||
mw_arm_shift_q7
| fixdt(true,8,*) |
Data Cast Operations
Data Cast Operations
| Operation | Wrappers calling CMSIS function | Supported data types | Input/Output specifications | Replaced MATLAB code |
|---|---|---|---|---|
Cast float to fixed
point | mw_arm_float_to_q15 | single |
|
cast(a,'like',b) |
mw_arm_float_to_q7 | single |
| ||
Cast q31 to float | mw_arm_q31_to_float | fixdt(true,32,31) |
| |
Cast q31 to q15 | mw_arm_q31_to_q15
| fixdt(true,32,31) |
| |
Cast q31 to q7 | mw_arm_q31_to_q7 | fixdt(true,32,31) |
| |
Cast q15 to float | mw_arm_q15_to_float | fixdt(true,16,15) |
| |
Cast q15 to q31 | mw_arm_q15_to_q31 | fixdt(true,16,15) |
| |
Cast q15 to q7 | mw_arm_q15_to_q7 | fixdt(true,16,15) |
| |
Cast q7 to
float | mw_arm_q7_to_float | fixdt(true,8,7) |
| |
Cast q7 to
q31 | mw_arm_q7_to_q31 | fixdt(true,8,7) |
| |
Cast q7 to
q15 | mw_arm_q7_to_q15 | fixdt(true,8,7) |
|
Complex Math Operations
Complex Math Operations
| Operation | Wrappers calling CMSIS function | Supported data types | Input/Output specifications | Replaced MATLAB code |
|---|---|---|---|---|
| Complex conjugate | mw_arm_cmplx_conj_f32
| single |
|
conj(a) |
| Complex-by-complex multiplication | mw_arm_cmplx_mult_cmplx_f32
| single |
|
a.*b |
| Complex-by-real multiplication | mw_arm_cmplx_mult_real_f32
| single |
|
a.*b |
Logical Operations
Logical Operations
| Operation | Wrappers calling CMSIS function | Supported data types | Input/Output specifications | Replaced MATLAB code |
|---|---|---|---|---|
| Logical AND | mw_arm_and_uint32 |
|
|
bitand(a,b) |
mw_arm_and_uint16 |
|
| ||
mw_arm_and_uint8 |
|
| ||
| Logical OR | mw_arm_or_uint32 |
|
|
bitor(a,b) |
mw_arm_or_uint16 |
|
| ||
mw_arm_or_uint8 |
|
| ||
| Logical NOT | mw_arm_not_uint32 |
|
|
bitcmp(a) |
mw_arm_not_uint16 |
|
| ||
mw_arm_not_uint8 |
|
| ||
| Logical XOR | mw_arm_xor_uint32 |
|
|
bitxor(a,b) |
mw_arm_xor_uint16 |
|
| ||
mw_arm_xor_uint8 |
|
|
Matrix Operations
Matrix Operations
| Operation | Wrappers calling CMSIS function | Supported data types | Input/Output specifications | Replaced MATLAB code |
|---|---|---|---|---|
| Matrix multiplication | mw_arm_mat_mult_f32 |
|
|
a*b |
| Complex matrix multiplication | mw_arm_mat_cmplx_mult_f32 |
|
|
a*b |
| Matrix transpose | mw_arm_trans_f32 |
|
|
|
mw_arm_trans_q31 |
| |||
mw_arm_trans_q15 |
| |||
mw_arm_trans_q7 |
| |||
mw_arm_mat_cmplx_trans_f32 |
|
|
| |
mw_arm_mat_cmplx_trans_q31 |
| |||
mw_arm_mat_cmplx_trans_q15 |
|
Fourier Transform Operations
Fourier Transform Operations
| MATLAB Function | Supported Function Signatures | Input specifications | Property specifications | Equivalent CMSIS Functions |
|---|---|---|---|---|
fft | Y = fft(X) Y = fft(X, n) Y = fft(X, n, dim) |
| Transform Length
Dimension to operate along
|
Wrapper functions, each with an
|
ifft | X = ifft(Y) X = ifft(Y, n) X = ifft(Y, n, dim) X = ifft(__, symflag) |
| Transform Length
Dimension to operate along
Symmetric type
|
Wrapper functions, each with an
|
fft2 | Y = fft2(X) Y = fft2(X, m, n) |
| Number of transform rows
Number of
transform rows
|
Wrapper functions, each with an
|
ifft2 | X = ifft2(Y) X = ifft2(Y, m, n) X = ifft2(__, symflag) |
| Number of transform rows
Number of
transform rows
Symmetric type
|
Wrapper functions, each with an
|
fftn | Y = fftn(X) Y = fftn(X, sz) |
| Length of transform dimension
|
Wrapper functions, each with an
|
ifftn | X = ifftn(Y) X = ifftn(Y, sz) X = ifftn(__, symflag) |
| Length of transform dimension
|
Wrapper functions, each with an
|