Main Content

Supported CMSIS Functions 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

Note

  • To get the code replacement, in the code generation configuration settings, set CodeReplacementLibrary to ARM 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 typesInput specificationsParameter specificationsReplaced Simulink block
Absolutemw_arm_abs_f32 single
  • Vector and matrix

  • Real inputs

-Abs
mw_arm_abs_q31 fixdt(true,32,31)
  • Vector and matrix

  • Real inputs

mw_arm_abs_q15 fixdt(true,16,15)
  • Vector and matrix

  • Real inputs

mw_arm_abs_q7 fixdt(true,8,7)
  • Vector and matrix

  • Real inputs

Additionmw_arm_add_f32 single
  • Vector and matrix

  • Real and complex inputs

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,*)
  • Vector and matrix

  • Real and complex inputs

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,*)
  • Vector and matrix

  • Real and complex inputs

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,*)
  • Vector and matrix

  • Real and complex inputs

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/Offsetmw_arm_bias_1_f32single
  • Scalar input

  • Real inputs

Bias parameter in the Bias block can be a vector or matrix.Bias
mw_arm_bias_1_q31fixdt(true,32,*)
  • Scalar input

  • Real inputs

  • Supports different input and bias word lengths.

  • Supports different input and bias fractional length

mw_arm_bias_1_q15fixdt(true,16,*)
mw_arm_bias_1_q7fixdt(true,8,*)
mw_arm_bias_2_f32single
  • Vector or matrix

  • Real inputs

Bias parameter in the Bias block must be a scalar.
mw_arm_bias_2_q31fixdt(true,32,*)
  • Vector or matrix

  • Real inputs

  • Supports different input and bias word lengths.

  • Supports different input and bias fractional length

mw_arm_bias_2_q15fixdt(true,16,*)
mw_arm_bias_2_q7fixdt(true,8,*)
Dot productmw_arm_dot_f32single
  • Vector

  • Real inputs

  • Both inputs must have same fraction length

-Dot Product
mw_arm_dot_q15fixdt(true,16,*)
  • Vector

  • Real inputs

  • Both inputs must have same fraction length

Note

  • Set the output word length to 64 for an input word length of 16.

  • Fraction length of output must be sum of input fraction lengths.

mw_arm_dot_q7fixdt(true,8,*)
  • Vector

  • Real inputs

  • Both inputs must have same fraction length

Note

  • Set the output word length to 32 for an input word length of 8.

  • Fraction length of output must be sum of input fraction length.

Exponentialmw_arm_vexp_f32single
  • Vector and matrix

  • Real inputs

Set the Function parameter of Math Function block to exp.

Math Function
Logarithmmw_arm_vlog_f32single
  • Vector and matrix

  • Real inputs

Set the Function parameter of Math Function to log.

Math Function
Multiplicationmw_arm_mult_f32 single
  • Vector and matrix

  • Real inputs

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,*)
  • Vector and matrix

  • Real inputs

Note

  • For multiplication operation, one input can be a vector while the other input can be a matrix.

  • Sum of input fraction length must be grater than 15.

  • Fraction length of output must be 15 less than sum of input fraction length.

mw_arm_mult_q7 fixdt(true,8,*)
  • Vector and matrix

  • Real inputs

Note

  • For multiplication operation, one input can be a vector while the other input can be a matrix.

  • Sum of input fraction length must be grater than 7.

  • Fraction length of output must be 7 less than sum of input fraction length.

Saturate/Limit/Clippingmw_arm_saturate_f32single
  • Vector and matrix

  • Real inputs

Upper and lower limits of the Saturation block must be scalar values

Saturation
mw_arm_saturate_q31fixdt(true,32,*)
  • Vector and matrix

  • Real inputs

  • Upper and lower limits of the Saturation block must be scalar values.

  • The word length of input, upper limit, and lower limit must be 32.

  • The fraction length of input, upper limit, and lower limit can be different.

mw_arm_saturate_q15fixdt(true,16,*)
  • Vector and matrix

  • Real inputs

  • Upper and lower limits of the Saturation block must be scalar values.

  • The word length of input, upper limit, and lower limit must be 16.

  • The fraction length of input, upper limit, and lower limit can be different.

mw_arm_saturate_q7fixdt(true,8,*)
  • Vector and matrix

  • Real inputs

  • Upper and lower limits of the Saturation block must be scalar values.

  • The word length of input, upper limit, and lower limit must be 8.

  • The fraction length of input, upper limit, and lower limit can be different.

Scale/Gainmw_arm_scale_1_f32single
  • Vector or matrix

  • Real inputs

  • Set the Multiplication parameter in the Gain block to Matrix(K*u).

  • The Gain parameter value of the Gain must be a scalar

Gain
mw_arm_scale_1_q15fixdt(true,16,*)
  • Vector or matrix

  • Real inputs

  • Supports different input, scalar gain value, and word lengths.

  • The fractional length of output must be less than the sum of fractional length of inputs.

  • Set the Multiplication parameter in the Gain block to Matrix(K*u).

  • The Gain parameter value of the Gain block must be a scalar

mw_arm_scale_1_q7fixdt(true,8,*)
mw_arm_scale_2_f32single
  • Vector or matrix

  • Real inputs

  • One input can be a vector or matrix, while the other input to the Product, Matrix Multiply block must be a scalar.

Set the Multiplication parameter in the Product, Matrix Multiply block to Element-wise(.*).

mw_arm_scale_2_q15fixdt(true,16,*)
mw_arm_scale_2_q7fixdt(true,8,*)
Subtraction mw_arm_sub_f32 single
  • Vector and matrix

  • Real and complex inputs

-Sub
mw_arm_sub_q31 fixdt(true,32,*)
  • Vector and matrix

  • Real and complex inputs

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,*)
  • Vector and matrix

  • Real and complex inputs

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,7,*)
  • Vector and matrix

  • Real and complex inputs

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 rootmw_arm_sqrt_f32 single
  • Vector and matrix

  • Real inputs

-Sqrt
Unary minus/Negatemw_arm_uminus_f32single
  • Vector and matrix

  • Real inputs

-Unary Minus
mw_arm_uminus_q31fixdt(true,32,*)
mw_arm_uminus_q15fixdt(true,16,*)
mw_arm_uminus_q7fixdt(true,8,*)

Shift Operations

Operation Wrappers calling CMSIS function Supported data types Input specificationsReplaced Simulink block
Right shiftmw_arm_shift_q31 fixdt(true,32,31)
  • Vector and matrix

  • Real inputs

Shift Arithmetic
mw_arm_shift_q15 fixdt(true,16,15)
  • Vector and matrix

  • Real inputs

mw_arm_shift_q7 fixdt(true,8,7)
  • Vector and matrix

  • Real inputs

Data Cast Operations

Operation Wrappers calling CMSIS function Supported data types Input specificationsParameter specificationsReplaced Simulink block
Cast float to fixed pointmw_arm_float_to_q15single
  • Vector and matrix

  • Real inputs

The Output data type parameter of Data Type Conversion block must be set to fixdt(1,16,15)

Data Type Conversion
mw_arm_float_to_q7single
  • Vector and matrix

  • Real inputs

The Output data type parameter of Data Type Conversion block must be set to fixdt(1,8,7)

Cast q31 to floatmw_arm_q31_to_float fixdt(true,32,31)
  • Vector and matrix

  • Real inputs

The Output data type parameter of Data Type Conversion block must be set to single

Cast q31 to q15mw_arm_q31_to_q15 fixdt(true,32,31)
  • Vector and matrix

  • Real inputs

The Output data type parameter of Data Type Conversion block must be set to fixdt(1,16,15)

Cast q31 to q7mw_arm_q31_to_q7 fixdt(true,32,31)
  • Vector and matrix

  • Real inputs

The Output data type parameter of Data Type Conversion block must be set to fixdt(1,8,7)

Cast q15 to floatmw_arm_q15_to_float fixdt(true,16,15)
  • Vector and matrix

  • Real inputs

The Output data type parameter of Data Type Conversion block must be set to single

Cast q15 to q31mw_arm_q15_to_q31 fixdt(true,16,15)
  • Vector and matrix

  • Real inputs

The Output data type parameter of Data Type Conversion block must be set to fixdt(1,32,31)

Cast q15 to q7mw_arm_q15_to_q7 fixdt(true,16,15)
  • Vector and matrix

  • Real inputs

The Output data type parameter of Data Type Conversion block must be set to fixdt(1,8,7)

Cast q7 to floatmw_arm_q7_to_float fixdt(true,8,7)
  • Vector and matrix

  • Real inputs

The Output data type parameter of Data Type Conversion block must be set to single

Cast q7 to q31mw_arm_q7_to_q31 fixdt(true,8,7)
  • Vector and matrix

  • Real inputs

The Output data type parameter of Data Type Conversion block must be set to fixdt(1,32,31)

Cast q7 to q15mw_arm_q7_to_q15fixdt(true,8,7)
  • Vector and matrix

  • Real inputs

The Output data type parameter of Data Type Conversion block must be set to fixdt(1,16,15)

Trigonometric Operations

Operation Wrappers calling CMSIS function Supported data typesInput specificationsParameter specificationsReplaced Simulink block
sine mw_arm_sin_f32 single
  • Vector and matrix

  • Real inputs

  • The Approximation method parameter of Trigonometric Function block must be set to Lookup

  • Look-up table errors cause a numerical mismatch on the order of 5e-03.

Trigonometric Function
cosine mw_arm_cos_f32 single

Complex Math Operations

Operation Wrappers calling CMSIS function Supported data typesInput specificationsParameter specificationsReplaced Simulink block
Complex conjugatemw_arm_cmplx_conj_f32 single
  • Vector and matrix

  • Complex inputs

Set the Function parameter of Math Function to conj.

Math Function
mw_arm_cmplx_conj_q31 fixdt(true,32,31)
mw_arm_cmplx_conj_q15 fixdt(true,16,15)
Complex-by-complex multiplicationmw_arm_cmplx_mult_cmplx_f32 single
  • Vector and matrix

  • Both inputs must be complex

Set the Multiplication parameter of Math Function in the Product, Matrix Multiply block to Elementwise(.*).

Product, Matrix Multiply
mw_arm_cmplx_mult_cmplx_q31 fixdt(true,32,31)
  • Vector and matrix

  • Both inputs must be complex

mw_arm_cmplx_mult_cmplx_q15 fixdt(true,16,15)
  • Vector and matrix

  • Both inputs must be complex

Complex-by-real multiplicationmw_arm_cmplx_mult_real_f32 single
  • Vector and matrix

  • Real and complex inputs

  • One input should be complex, and the other input should be real.

Set the Multiplication parameter in the Product, Matrix Multiply block to Elementwise(.*).

Product, Matrix Multiply
mw_arm_cmplx_mult_real_q31 fixdt(true,32,31)
  • Vector and matrix

  • Real and complex inputs

  • One input should be complex, and the other input should be real.

mw_arm_cmplx_mult_real_q15 fixdt(true,16,15)
  • Vector and matrix

  • Real and complex inputs

  • One input should be complex, and the other input should be real.

Logical Operations

Operation Wrappers calling CMSIS functionSupported data typesInput specificationsReplaced Simulink block
Logical ANDmw_arm_and_unit32
  • unit32

  • fixdt(false,32,*)

  • Vector and matrix

  • Both inputs must be unit32 or fixdt(false,32,*).

  • Both inputs must have same fraction length.

AND
mw_arm_and_unit16
  • unit16

  • fixdt(false,16,*)

  • Vector and matrix

  • Both inputs must be unit16 or fixdt(false,16,*).

  • Both inputs must have same fraction length.

mw_arm_and_unit8
  • unit8

  • fixdt(false,8,*)

  • Vector and matrix

  • Both inputs must be unit8 or fixdt(false,8,*).

  • Both inputs must have same fraction length.

Logical ORmw_arm_or_unit32
  • unit32

  • fixdt(false,32,*)

  • Vector and matrix

  • Both inputs must be unit32 or fixdt(false,32,*).

  • Both inputs must have same fraction length.

OR
mw_arm_or_unit16
  • unit16

  • fixdt(false,16,*)

  • Vector and matrix

  • Both inputs must be unit16 or fixdt(false,16,*).

  • Both inputs must have same fraction length.

mw_arm_or_unit8
  • unit8

  • fixdt(false,8,*)

  • Vector and matrix

  • Both inputs must be unit8 or fixdt(false,8,*).

  • Both inputs must have same fraction length.

Logical NOTmw_arm_not_unit32
  • unit32

  • fixdt(false,32,*)

  • Vector and matrix

NOT
mw_arm_not_unit16
  • unit16

  • fixdt(false,16,*)

  • Vector and matrix

mw_arm_not_unit8
  • unit8

  • fixdt(false,8,*)

  • Vector and matrix

Logical XORmw_arm_xor_unit32
  • unit32

  • fixdt(false,32,*)

  • Vector and matrix

  • Both inputs must be unit32 or fixdt(false,32,*).

  • Both inputs must have same fraction length.

XOR
mw_arm_xor_unit16
  • unit16

  • fixdt(false,16,*)

  • Vector and matrix

  • Both inputs must be unit16 or fixdt(false,16,*).

  • Both inputs must have same fraction length.

mw_arm_xor_unit8
  • unit8

  • fixdt(false,8,*)

  • Vector and matrix

  • Both inputs must be unit8 or fixdt(false,8,*).

  • Both inputs must have same fraction length.