Radix-4 Complex FFT Functions

| CMSIS-DSP Verison 1.1.0 CMSIS DSP Software Library

- CMSIS
- CORE
- DSP
- RTOS API
- SVD

- Main Page
- Reference

Functions
Radix-4 Complex FFT Functions
Transform Functions

## Functions

void | arm_cfft_radix4_f32 (const arm_cfft_radix4_instance_f32 *S, float32_t *pSrc)
| Processing function for the floating-point Radix-4 CFFT/CIFFT.
arm_status | arm_cfft_radix4_init_f32 (arm_cfft_radix4_instance_f32 *S, uint16_t fftLen, uint8_t ifftFlag, uint8_t bitReverseFlag)
| Initialization function for the floating-point CFFT/CIFFT.
arm_status | arm_cfft_radix4_init_q15 (arm_cfft_radix4_instance_q15 *S, uint16_t fftLen, uint8_t ifftFlag, uint8_t bitReverseFlag)
| Initialization function for the Q15 CFFT/CIFFT.
arm_status | arm_cfft_radix4_init_q31 (arm_cfft_radix4_instance_q31 *S, uint16_t fftLen, uint8_t ifftFlag, uint8_t bitReverseFlag)
| Initialization function for the Q31 CFFT/CIFFT.
void | arm_cfft_radix4_q15 (const arm_cfft_radix4_instance_q15 *S, q15_t *pSrc)
| Processing function for the Q15 CFFT/CIFFT.
void | arm_cfft_radix4_q31 (const arm_cfft_radix4_instance_q31 *S, q31_t *pSrc)
| Processing function for the Q31 CFFT/CIFFT.

## Description

  Complex Fast Fourier Transform(CFFT) and Complex Inverse Fast Fourier Transform(CIFFT) is an efficient algorithm to compute Discrete Fourier Transform(DFT) and Inverse Discrete Fourier Transform(IDFT). Computational complexity of CFFT reduces drastically when compared to DFT.

  This set of functions implements CFFT/CIFFT for Q15, Q31, and floating-point data types. The functions operates on in-place buffer which uses same buffer for input and output. Complex input is stored in input buffer in an interleaved fashion.

  The functions operate on blocks of input and output data and each call to the function processes `2*fftLen` samples through the transform. `pSrc` points to In-place arrays containing `2*fftLen` values.

  The `pSrc` points to the array of in-place buffer of size `2*fftLen` and inputs and outputs are stored in an interleaved fashion as shown below.

       {real[0], imag[0], real[1], imag[1],..}

Lengths supported by the transform:

  Internally, the function utilize a radix-4 decimation in frequency(DIF) algorithm and the size of the FFT supported are of the lengths [16, 64, 256, 1024].

Algorithm:

Complex Fast Fourier Transform:

  Input real and imaginary data:

       x(n) = xa + j * ya
       x(n+N/4 ) = xb + j * yb
       x(n+N/2 ) = xc + j * yc
       x(n+3N 4) = xd + j * yd

  where N is length of FFT

  Output real and imaginary data:

       X(4r) = xa'+ j * ya'
       X(4r+1) = xb'+ j * yb'
       X(4r+2) = xc'+ j * yc'
       X(4r+3) = xd'+ j * yd'

  Twiddle factors for radix-4 FFT:

       Wn = co1 + j * (- si1)
       W2n = co2 + j * (- si2)
       W3n = co3 + j * (- si3)

  Radix-4 Decimation-in Frequency Complex Fast Fourier Transform

  Output from Radix-4 CFFT Results in Digit reversal order. Interchange middle two branches of every butterfly results in Bit reversed output.

  Butterfly CFFT equations:

       xa' = xa + xb + xc + xd
       ya' = ya + yb + yc + yd
       xc' = (xa+yb-xc-yd)* co1 + (ya-xb-yc+xd)* (si1)
       yc' = (ya-xb-yc+xd)* co1 - (xa+yb-xc-yd)* (si1)
       xb' = (xa-xb+xc-xd)* co2 + (ya-yb+yc-yd)* (si2)
       yb' = (ya-yb+yc-yd)* co2 - (xa-xb+xc-xd)* (si2)
       xd' = (xa-yb-xc+yd)* co3 + (ya+xb-yc-xd)* (si3)
       yd' = (ya+xb-yc-xd)* co3 - (xa-yb-xc+yd)* (si3)

Complex Inverse Fast Fourier Transform:

  CIFFT uses same twiddle factor table as CFFT with modifications in the design equation as shown below.

  Modified Butterfly CIFFT equations:

       xa' = xa + xb + xc + xd
       ya' = ya + yb + yc + yd
       xc' = (xa-yb-xc+yd)* co1 - (ya+xb-yc-xd)* (si1)
       yc' = (ya+xb-yc-xd)* co1 + (xa-yb-xc+yd)* (si1)
       xb' = (xa-xb+xc-xd)* co2 - (ya-yb+yc-yd)* (si2)
       yb' = (ya-yb+yc-yd)* co2 + (xa-xb+xc-xd)* (si2)
       xd' = (xa+yb-xc-yd)* co3 - (ya-xb-yc+xd)* (si3)
       yd' = (ya-xb-yc+xd)* co3 + (xa+yb-xc-yd)* (si3)

Instance Structure
  A separate instance structure must be defined for each Instance but the twiddle factors and bit reversal tables can be reused. There are separate instance structure declarations for each of the 3 supported data types.

Initialization Functions
  There is also an associated initialization function for each data type. The initialization function performs the following operations:
  - Sets the values of the internal structure fields.
  - Initializes twiddle factor table and bit reversal table pointers

  Use of the initialization function is optional. However, if the initialization function is used, then the instance structure cannot be placed into a const data section. To place an instance structure into a const data section, the instance structure must be manually initialized. Manually initialize the instance structure as follows:

      arm_cfft_radix4_instance_f32 S = {fftLen, ifftFlag, bitReverseFlag, pTwiddle, pBitRevTable, twidCoefModifier, bitRevFactor, onebyfftLen};
      arm_cfft_radix4_instance_q31 S = {fftLen, ifftFlag, bitReverseFlag, pTwiddle, pBitRevTable, twidCoefModifier, bitRevFactor};
      arm_cfft_radix4_instance_q15 S = {fftLen, ifftFlag, bitReverseFlag, pTwiddle, pBitRevTable, twidCoefModifier, bitRevFactor};

  where `fftLen` length of CFFT/CIFFT; `ifftFlag` Flag for selection of CFFT or CIFFT(Set ifftFlag to calculate CIFFT otherwise calculates CFFT); `bitReverseFlag` Flag for selection of output order(Set bitReverseFlag to output in normal order otherwise output in bit reversed order); `pTwiddle`points to array of twiddle coefficients; `pBitRevTable` points to the array of bit reversal table. `twidCoefModifier` modifier for twiddle factor table which supports all FFT lengths with same table; `pBitRevTable` modifier for bit reversal table which supports all FFT lengths with same table. `onebyfftLen` value of 1/fftLen to calculate CIFFT;

Fixed-Point Behavior
  Care must be taken when using the fixed-point versions of the CFFT/CIFFT function. Refer to the function specific documentation below for usage guidelines.

## Function Documentation

void arm_cfft_radix4_f32 | ( | const arm_cfft_radix4_instance_f32 * | S,
|  | float32_t * | pSrc
| ) |  |

Processing function for the floating-point CFFT/CIFFT.

Parameters:

  [in] | *S | points to an instance of the floating-point Radix-4 CFFT/CIFFT structure.
  [in,out] | *pSrc | points to the complex data buffer of size `2*fftLen`. Processing occurs in-place.

Returns:
  none.

Examples:
  arm_convolution_example_f32.c, and arm_fft_bin_example_f32.c.

References arm_bitreversal_f32(), arm_radix4_butterfly_f32(), arm_radix4_butterfly_inverse_f32(), arm_cfft_radix4_instance_f32::bitReverseFlag, arm_cfft_radix4_instance_f32::bitRevFactor, arm_cfft_radix4_instance_f32::fftLen, arm_cfft_radix4_instance_f32::ifftFlag, arm_cfft_radix4_instance_f32::onebyfftLen, arm_cfft_radix4_instance_f32::pBitRevTable, arm_cfft_radix4_instance_f32::pTwiddle, and arm_cfft_radix4_instance_f32::twidCoefModifier.

Referenced by main().

arm_status arm_cfft_radix4_init_f32 | ( | arm_cfft_radix4_instance_f32 * | S,
|  | uint16_t | fftLen,
|  | uint8_t | ifftFlag,
|  | uint8_t | bitReverseFlag
| ) |  |

Parameters:

  [in,out] | *S | points to an instance of the floating-point CFFT/CIFFT structure.
  [in] | fftLen | length of the FFT.
  [in] | ifftFlag | flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform.
  [in] | bitReverseFlag | flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output.

Returns:
  The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if `fftLen` is not a supported value.

Description:

  The parameter `ifftFlag` controls whether a forward or inverse transform is computed. Set(=1) ifftFlag for calculation of CIFFT otherwise CFFT is calculated

  The parameter `bitReverseFlag` controls whether output is in normal order or bit reversed order. Set(=1) bitReverseFlag for output to be in normal order otherwise output is in bit reversed order.

  The parameter `fftLen` Specifies length of CFFT/CIFFT process. Supported FFT Lengths are 16, 64, 256, 1024.

  This Function also initializes Twiddle factor table pointer and Bit reversal table pointer.

Examples:
  arm_convolution_example_f32.c, and arm_fft_bin_example_f32.c.

References ARM_MATH_ARGUMENT_ERROR, ARM_MATH_SUCCESS, armBitRevTable, arm_cfft_radix4_instance_f32::bitReverseFlag, arm_cfft_radix4_instance_f32::bitRevFactor, arm_cfft_radix4_instance_f32::fftLen, ifftFlag, arm_cfft_radix4_instance_f32::ifftFlag, arm_cfft_radix4_instance_f32::onebyfftLen, arm_cfft_radix4_instance_f32::pBitRevTable, arm_cfft_radix4_instance_f32::pTwiddle, status, arm_cfft_radix4_instance_f32::twidCoefModifier, and twiddleCoef.

Referenced by arm_rfft_init_f32(), and main().

arm_status arm_cfft_radix4_init_q15 | ( | arm_cfft_radix4_instance_q15 * | S,
|  | uint16_t | fftLen,
|  | uint8_t | ifftFlag,
|  | uint8_t | bitReverseFlag
| ) |  |

Parameters:

  [in,out] | *S | points to an instance of the Q15 CFFT/CIFFT structure.
  [in] | fftLen | length of the FFT.
  [in] | ifftFlag | flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform.
  [in] | bitReverseFlag | flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output.

Returns:
  The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if `fftLen` is not a supported value.

Description:

  The parameter `ifftFlag` controls whether a forward or inverse transform is computed. Set(=1) ifftFlag for calculation of CIFFT otherwise CFFT is calculated

  The parameter `bitReverseFlag` controls whether output is in normal order or bit reversed order. Set(=1) bitReverseFlag for output to be in normal order otherwise output is in bit reversed order.

  The parameter `fftLen` Specifies length of CFFT/CIFFT process. Supported FFT Lengths are 16, 64, 256, 1024.

  This Function also initializes Twiddle factor table pointer and Bit reversal table pointer.

References ARM_MATH_ARGUMENT_ERROR, ARM_MATH_SUCCESS, armBitRevTable, arm_cfft_radix4_instance_q15::bitReverseFlag, arm_cfft_radix4_instance_q15::bitRevFactor, arm_cfft_radix4_instance_q15::fftLen, ifftFlag, arm_cfft_radix4_instance_q15::ifftFlag, arm_cfft_radix4_instance_q15::pBitRevTable, arm_cfft_radix4_instance_q15::pTwiddle, status, arm_cfft_radix4_instance_q15::twidCoefModifier, and twiddleCoefQ15.

Referenced by arm_rfft_init_q15().

arm_status arm_cfft_radix4_init_q31 | ( | arm_cfft_radix4_instance_q31 * | S,
|  | uint16_t | fftLen,
|  | uint8_t | ifftFlag,
|  | uint8_t | bitReverseFlag
| ) |  |

Parameters:

  [in,out] | *S | points to an instance of the Q31 CFFT/CIFFT structure.
  [in] | fftLen | length of the FFT.
  [in] | ifftFlag | flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform.
  [in] | bitReverseFlag | flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output.

Returns:
  The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if `fftLen` is not a supported value.

Description:

  The parameter `ifftFlag` controls whether a forward or inverse transform is computed. Set(=1) ifftFlag for calculation of CIFFT otherwise CFFT is calculated

  The parameter `bitReverseFlag` controls whether output is in normal order or bit reversed order. Set(=1) bitReverseFlag for output to be in normal order otherwise output is in bit reversed order.

  The parameter `fftLen` Specifies length of CFFT/CIFFT process. Supported FFT Lengths are 16, 64, 256, 1024.

  This Function also initializes Twiddle factor table pointer and Bit reversal table pointer.

References ARM_MATH_ARGUMENT_ERROR, ARM_MATH_SUCCESS, armBitRevTable, arm_cfft_radix4_instance_q31::bitReverseFlag, arm_cfft_radix4_instance_q31::bitRevFactor, arm_cfft_radix4_instance_q31::fftLen, ifftFlag, arm_cfft_radix4_instance_q31::ifftFlag, arm_cfft_radix4_instance_q31::pBitRevTable, arm_cfft_radix4_instance_q31::pTwiddle, status, arm_cfft_radix4_instance_q31::twidCoefModifier, and twiddleCoefQ31.

Referenced by arm_rfft_init_q31().

void arm_cfft_radix4_q15 | ( | const arm_cfft_radix4_instance_q15 * | S,
|  | q15_t * | pSrc
| ) |  |

Parameters:

  [in] | *S | points to an instance of the Q15 CFFT/CIFFT structure.
  [in,out] | *pSrc | points to the complex data buffer. Processing occurs in-place.

Returns:
  none.

Input and output formats:

  Internally input is downscaled by 2 for every stage to avoid saturations inside CFFT/CIFFT process. Hence the output format is different for different FFT sizes. The input and output formats for different FFT sizes and number of bits to upscale are mentioned in the tables below for CFFT and CIFFT:

  Input and Output Formats for Q15 CFFT
  Input and Output Formats for Q15 CIFFT

References arm_bitreversal_q15(), arm_radix4_butterfly_inverse_q15(), arm_radix4_butterfly_q15(), arm_cfft_radix4_instance_q15::bitReverseFlag, arm_cfft_radix4_instance_q15::bitRevFactor, arm_cfft_radix4_instance_q15::fftLen, arm_cfft_radix4_instance_q15::ifftFlag, arm_cfft_radix4_instance_q15::pBitRevTable, arm_cfft_radix4_instance_q15::pTwiddle, and arm_cfft_radix4_instance_q15::twidCoefModifier.

void arm_cfft_radix4_q31 | ( | const arm_cfft_radix4_instance_q31 * | S,
|  | q31_t * | pSrc
| ) |  |

Parameters:

  [in] | *S | points to an instance of the Q31 CFFT/CIFFT structure.
  [in,out] | *pSrc | points to the complex data buffer of size `2*fftLen`. Processing occurs in-place.

Returns:
  none.

Input and output formats:

  Internally input is downscaled by 2 for every stage to avoid saturations inside CFFT/CIFFT process. Hence the output format is different for different FFT sizes. The input and output formats for different FFT sizes and number of bits to upscale are mentioned in the tables below for CFFT and CIFFT:

  Input and Output Formats for Q31 CFFT
  Input and Output Formats for Q31 CIFFT

References arm_bitreversal_q31(), arm_radix4_butterfly_inverse_q31(), arm_radix4_butterfly_q31(), arm_cfft_radix4_instance_q31::bitReverseFlag, arm_cfft_radix4_instance_q31::bitRevFactor, arm_cfft_radix4_instance_q31::fftLen, arm_cfft_radix4_instance_q31::ifftFlag, arm_cfft_radix4_instance_q31::pBitRevTable, arm_cfft_radix4_instance_q31::pTwiddle, and arm_cfft_radix4_instance_q31::twidCoefModifier.