Libraries provide a suite of functions you can use in your own code. Helium-enahanced libraries provide implementations of those functions that use Helium instructions.
When you compile for a Helium-enabled target, a library variant using Helium instructions is selected. When you compile for a target that does not support Helium, a library variant using standard Arm instructions is selected. This means that you can easily compile the same source code for both Helium and non-Helium enabled targets.
Examples of Helium-enabled libraries include:
- CMSIS-DSP – A suite of common signal processing functions for use on Cortex-M processor-based devices
- CMSIS-NN – A collection of efficient neural network kernels that are developed to maximize the performance, and minimize the memory footprint, of neural networks on Cortex-M processor cores
In this section of the guide, we examine the CMSIS-DSP library to see how to use libraries to write Helium-enabled code.
Getting the CMSIS-DSP library
The CMSIS-DSP library provides functions that are specifically designed for signal processing. The library provides over sixty common signal processing and mathematical functions for various data types.
CMSIS is the Arm Cortex Microcontroller Software Interface Standard. CMSIS provides a vendor-independent hardware abstraction layer for microcontrollers that are based on Arm Cortex processors. CMSIS defines generic tool interfaces and enables consistent device support. Its software interfaces simplify software reuse, reduce the learning curve for microcontroller developers, and improve time to market for new devices.
CMSIS is integrated into IDEs like Keil MDK and Arm Development Studio, but can also be used with a standalone compiler.
To use CMSIS:
- For Keil MDK, use the MDK Pack Installer to install the ARM::CMSIS pack.
- For Arm Development Studio, use the Pack Manager to install the Generic > ARM.CMSIS pack.
- For a standalone compiler, download CMSIS from git hub and follow the instructions for using CMSIS with Arm Compiler 6.
Writing code using the CMSIS-DSP library
Let's examine the source code of this example to look at some key features:
The preceding code shows the CMSIS-DSP header file that declares the basic math functions used by the example. This code must be included to use the CMSIS-DSP functions.
The following code shows how the variance
example uses CMSIS-DSP library functions to implement an algorithm that
calculates the statistical variance of an input stream. The CMSIS-DSP functions
. . . /* Calculation of mean value of input */ /* x' = 1/blockSize * (x(0)* 1 + x(1) * 1 + ... + x(n-1) * 1) */ /* Fill wire1 buffer with 1.0 value */ arm_fill_f32(1.0, wire1, blockSize); /* Calculate the dot product of wire1 and wire2 */ /* (x(0)* 1 + x(1) * 1 + ...+ x(n-1) * 1) */ arm_dot_prod_f32(testInput_f32, wire1, blockSize, &mean); /* Calculation of 1/blockSize */ oneByBlockSize = 1.0 / (blockSize); /* 1/blockSize * (x(0)* 1 + x(1) * 1 + ... + x(n-1) * 1) */ arm_mult_f32(&mean, &oneByBlockSize, &mean, 1); . . .
The CMSIS-DSP functions used in this example are:
arm_fill_f32()fills a constant value into a floating-point vector.
arm_dot_prod_f32()calculates the dot product of floating-point vectors.
arm_mult_f32()performs floating-point vector multiplication.
All available CMSIS-DSP functions are described in the CMSIS DSP Software Library Reference.
Compiling CMSIS-DSP code for Helium
When compiling for a Helium-enabled target, the compiler will automatically select the CMSIS-DSP variant that uses Helium instructions.
For example, in Arm Development Studio select Generic Armv8.1-M Main (MVE Integer) to target any Helium-enabled Armv8-M platform, as shown in the following screenshot:
When compiling with a standalone compiler, you must ensure that the CMSIS header files are on the include path, and the CMSIS libraries are on the library path.
For example, to target the architecture, use this command:
armclang -target arm-arm-none-eabi -march=armv8.1-m.main+mve.fp+fp.dp -I <cmsis_dir>/DSP/Include/ -L <cmsis_dir>/DSP/Lib/ ...
To target the Cortex-M55, use this command:
armclang -target arm-arm-none-eabi -mcpu=cortex-m55 -I <cmsis_dir>/DSP/Include/ -L <cmsis_dir>/DSP/Lib/ ...