MPLAB® Harmony v2 Math Library Overview

Digital Signal Processing (DSP) Fixed-Point Math Library
LibQ Fixed-Point Math Library

Digital Signal Processing (DSP) Fixed-Point Math Library

The DSP Fixed-Point Library uses fixed-point fractional functions to optimize execution speed. These functions limit the accuracy of the calculations to the bits specified for the function. Due to parallelism in some operations, the 16-bit version of the functions are more efficient than their 32-bit counterparts. In many cases, both 16-bit and 32-bit functions are available to give the user the choice of balance between speed and functional resolution.

A majority of the DSP Fixed-Point Library uses functions with variables in the Q15 or Q31 format. This limits the equivalent numerical range to roughly -1.0 to 0.999999999. It is possible to represent other number ranges but scaling before and after the function call is necessary. All library functions will saturate the output if the value exceeds the maximum or is lower than the minimum allowable value for that resolution. Some pre-scaling may be necessary to prevent unwanted saturation in functions that may otherwise create calculation errors.

The DSP Library supports the following functions:

  • Complex Math Functions: general mathematical operations using a complex structure with the form (a + bi)
  • Vector Math Functions: mathematical operations on an array of numbers or vectors
  • Matrix Math Functions: mathematical operations on a matrix
  • Digital Filter Functions: FIR and IIR filtering functions with various architectures
  • Transform Functions: FFT, Windows, and related transform elements
  • Support Functions: quick support functions for numerical transform

LibQ Fixed-Point Math Library

The LibQ Fixed-Point Math Library simplifies writing fixed point algorithms, supporting Q15, Q31, and other 16-bit and 32-bit data formats. Using the simple C callable functions contained in the library, fast fixed-point mathematical operations can be easily executed. Fixed-point mathematical calculations may replace some functions implemented in the floating-point library (math.h), depending on performance and resolution requirements.

Functions included in the LibQ library include capabilities for trigonometric, power and logarithms, and data conversion. In many cases, the functions are identical other than the precision of their operands and the corresponding value that they return.

These functions are implemented in an efficient assembly and generally tuned to optimize performance over code size. In some cases, the library breaks out functions that enable one to be optimized for accuracy, while another version is optimized for speed. These functions such as _LIBQ_Q2_29_acos_Q31() and _LIBQ_Q2_29_acos_Q31_Fast() are otherwise identical and can be used interchangeably. Each of these functions is typically used in computationally intensive real-time applications where execution time is a critical parameter.

The LibQ Fixed-Point Math Library supports the following functions:

  • Divide
  • Square Root
  • Exponential
  • Log
  • Power
  • Sine
  • Cosine
  • Tangent
  • Arcsin
  • Arccos
  • Arctan
  • Arctan2
  • Random Number
  • Float
  • String
© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.