Real FFT Q31 Functions

RFFTINIT_Q31 (8192, 4096, 1)
RFFTINIT_Q31 (4096, 2048, 2)
RFFTINIT_Q31 (2048, 1024, 4)
RFFTINIT_Q31 (1024, 512, 8)
RFFTINIT_Q31 (512, 256, 16)
RFFTINIT_Q31 (256, 128, 32)
RFFTINIT_Q31 (128, 64, 64)
RFFTINIT_Q31 (64, 32, 128)
RFFTINIT_Q31 (32, 16, 256)
riscv_status riscv_rfft_init_q31(riscv_rfft_instance_q31 *S, uint32_t fftLenReal, uint32_t ifftFlagR, uint32_t bitReverseFlag)
void riscv_rfft_q31(const riscv_rfft_instance_q31 *S, q31_t *pSrc, q31_t *pDst)
RFFTINIT_Q31(LEN, CFFTLEN, TWIDMOD)
group RealFFTQ31

Defines

RFFTINIT_Q31(LEN, CFFTLEN, TWIDMOD)

Functions

RFFTINIT_Q31 (8192, 4096, 1)

Initialization function for the 8192 pt Q31 real FFT.

The parameter ifftFlagR controls whether a forward or inverse transform is computed. Set(=1) ifftFlagR to calculate RIFFT, otherwise RFFT 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.

This function also initializes Twiddle factor table.

Parameters
  • S[inout] points to an instance of the Q31 RFFT/RIFFT structure

  • ifftFlagR[in] flag that selects transform direction

    • value = 0: forward transform

    • value = 1: inverse transform

  • bitReverseFlag[in] flag that enables / disables bit reversal of output

    • value = 0: disables bit reversal of output

    • value = 1: enables bit reversal of output

Returns

execution status

  • RISCV_MATH_SUCCESS : Operation successful

  • RISCV_MATH_ARGUMENT_ERROR : fftLenReal is not a supported length

RFFTINIT_Q31 (4096, 2048, 2)

Initialization function for the 4096 pt Q31 real FFT.

The parameter ifftFlagR controls whether a forward or inverse transform is computed. Set(=1) ifftFlagR to calculate RIFFT, otherwise RFFT 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.

This function also initializes Twiddle factor table.

Parameters
  • S[inout] points to an instance of the Q31 RFFT/RIFFT structure

  • ifftFlagR[in] flag that selects transform direction

    • value = 0: forward transform

    • value = 1: inverse transform

  • bitReverseFlag[in] flag that enables / disables bit reversal of output

    • value = 0: disables bit reversal of output

    • value = 1: enables bit reversal of output

Returns

execution status

  • RISCV_MATH_SUCCESS : Operation successful

  • RISCV_MATH_ARGUMENT_ERROR : fftLenReal is not a supported length

RFFTINIT_Q31 (2048, 1024, 4)

Initialization function for the 2048 pt Q31 real FFT.

The parameter ifftFlagR controls whether a forward or inverse transform is computed. Set(=1) ifftFlagR to calculate RIFFT, otherwise RFFT 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.

This function also initializes Twiddle factor table.

Parameters
  • S[inout] points to an instance of the Q31 RFFT/RIFFT structure

  • ifftFlagR[in] flag that selects transform direction

    • value = 0: forward transform

    • value = 1: inverse transform

  • bitReverseFlag[in] flag that enables / disables bit reversal of output

    • value = 0: disables bit reversal of output

    • value = 1: enables bit reversal of output

Returns

execution status

  • RISCV_MATH_SUCCESS : Operation successful

  • RISCV_MATH_ARGUMENT_ERROR : fftLenReal is not a supported length

RFFTINIT_Q31 (1024, 512, 8)

Initialization function for the 1024 pt Q31 real FFT.

The parameter ifftFlagR controls whether a forward or inverse transform is computed. Set(=1) ifftFlagR to calculate RIFFT, otherwise RFFT 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.

This function also initializes Twiddle factor table.

Parameters
  • S[inout] points to an instance of the Q31 RFFT/RIFFT structure

  • ifftFlagR[in] flag that selects transform direction

    • value = 0: forward transform

    • value = 1: inverse transform

  • bitReverseFlag[in] flag that enables / disables bit reversal of output

    • value = 0: disables bit reversal of output

    • value = 1: enables bit reversal of output

Returns

execution status

  • RISCV_MATH_SUCCESS : Operation successful

  • RISCV_MATH_ARGUMENT_ERROR : fftLenReal is not a supported length

RFFTINIT_Q31 (512, 256, 16)

Initialization function for the 512 pt Q31 real FFT.

The parameter ifftFlagR controls whether a forward or inverse transform is computed. Set(=1) ifftFlagR to calculate RIFFT, otherwise RFFT 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.

This function also initializes Twiddle factor table.

Parameters
  • S[inout] points to an instance of the Q31 RFFT/RIFFT structure

  • ifftFlagR[in] flag that selects transform direction

    • value = 0: forward transform

    • value = 1: inverse transform

  • bitReverseFlag[in] flag that enables / disables bit reversal of output

    • value = 0: disables bit reversal of output

    • value = 1: enables bit reversal of output

Returns

execution status

  • RISCV_MATH_SUCCESS : Operation successful

  • RISCV_MATH_ARGUMENT_ERROR : fftLenReal is not a supported length

RFFTINIT_Q31 (256, 128, 32)

Initialization function for the 256 pt Q31 real FFT.

The parameter ifftFlagR controls whether a forward or inverse transform is computed. Set(=1) ifftFlagR to calculate RIFFT, otherwise RFFT 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.

This function also initializes Twiddle factor table.

Parameters
  • S[inout] points to an instance of the Q31 RFFT/RIFFT structure

  • ifftFlagR[in] flag that selects transform direction

    • value = 0: forward transform

    • value = 1: inverse transform

  • bitReverseFlag[in] flag that enables / disables bit reversal of output

    • value = 0: disables bit reversal of output

    • value = 1: enables bit reversal of output

Returns

execution status

  • RISCV_MATH_SUCCESS : Operation successful

  • RISCV_MATH_ARGUMENT_ERROR : fftLenReal is not a supported length

RFFTINIT_Q31 (128, 64, 64)

Initialization function for the 128 pt Q31 real FFT.

The parameter ifftFlagR controls whether a forward or inverse transform is computed. Set(=1) ifftFlagR to calculate RIFFT, otherwise RFFT 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.

This function also initializes Twiddle factor table.

Parameters
  • S[inout] points to an instance of the Q31 RFFT/RIFFT structure

  • ifftFlagR[in] flag that selects transform direction

    • value = 0: forward transform

    • value = 1: inverse transform

  • bitReverseFlag[in] flag that enables / disables bit reversal of output

    • value = 0: disables bit reversal of output

    • value = 1: enables bit reversal of output

Returns

execution status

  • RISCV_MATH_SUCCESS : Operation successful

  • RISCV_MATH_ARGUMENT_ERROR : fftLenReal is not a supported length

RFFTINIT_Q31 (64, 32, 128)

Initialization function for the 64 pt Q31 real FFT.

The parameter ifftFlagR controls whether a forward or inverse transform is computed. Set(=1) ifftFlagR to calculate RIFFT, otherwise RFFT 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.

This function also initializes Twiddle factor table.

Parameters
  • S[inout] points to an instance of the Q31 RFFT/RIFFT structure

  • ifftFlagR[in] flag that selects transform direction

    • value = 0: forward transform

    • value = 1: inverse transform

  • bitReverseFlag[in] flag that enables / disables bit reversal of output

    • value = 0: disables bit reversal of output

    • value = 1: enables bit reversal of output

Returns

execution status

  • RISCV_MATH_SUCCESS : Operation successful

  • RISCV_MATH_ARGUMENT_ERROR : fftLenReal is not a supported length

RFFTINIT_Q31 (32, 16, 256)

Initialization function for the 32 pt Q31 real FFT.

The parameter ifftFlagR controls whether a forward or inverse transform is computed. Set(=1) ifftFlagR to calculate RIFFT, otherwise RFFT 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.

This function also initializes Twiddle factor table.

Parameters
  • S[inout] points to an instance of the Q31 RFFT/RIFFT structure

  • ifftFlagR[in] flag that selects transform direction

    • value = 0: forward transform

    • value = 1: inverse transform

  • bitReverseFlag[in] flag that enables / disables bit reversal of output

    • value = 0: disables bit reversal of output

    • value = 1: enables bit reversal of output

Returns

execution status

  • RISCV_MATH_SUCCESS : Operation successful

  • RISCV_MATH_ARGUMENT_ERROR : fftLenReal is not a supported length

riscv_status riscv_rfft_init_q31(riscv_rfft_instance_q31 *S, uint32_t fftLenReal, uint32_t ifftFlagR, uint32_t bitReverseFlag)

Generic initialization function for the Q31 RFFT/RIFFT.

Details

The parameter fftLenReal specifies length of RFFT/RIFFT Process. Supported FFT Lengths are 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192.

The parameter ifftFlagR controls whether a forward or inverse transform is computed. Set(=1) ifftFlagR to calculate RIFFT, otherwise RFFT 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.

This function also initializes Twiddle factor table.

This function should be used only if you don’t know the FFT sizes that you’ll need at build time. The use of this function will prevent the linker from removing the FFT tables that are not needed and the library code size will be bigger than needed.

If you use NMSIS-DSP as a static library, and if you know the FFT sizes that you need at build time, then it is better to use the initialization functions defined for each FFT size.

Parameters
  • S[inout] points to an instance of the Q31 RFFT/RIFFT structure

  • fftLenReal[in] length of the FFT

  • ifftFlagR[in] flag that selects transform direction

    • value = 0: forward transform

    • value = 1: inverse transform

  • bitReverseFlag[in] flag that enables / disables bit reversal of output

    • value = 0: disables bit reversal of output

    • value = 1: enables bit reversal of output

Returns

execution status

  • RISCV_MATH_SUCCESS : Operation successful

  • RISCV_MATH_ARGUMENT_ERROR : fftLenReal is not a supported length

void riscv_rfft_q31(const riscv_rfft_instance_q31 *S, q31_t *pSrc, q31_t *pDst)

Processing function for the Q31 RFFT/RIFFT.

RFFT Size

Input Format

Output Format

Number of bits to upscale

32

1.31

6.26

5

64

1.31

7.25

6

128

1.31

8.24

7

256

1.31

9.23

8

512

1.31

10.22

9

1024

1.31

11.21

10

2048

1.31

12.20

11

4096

1.31

13.19

12

8192

1.31

14.18

13

Input an 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 RFFT sizes. The input and output formats for different RFFT sizes and number of bits to upscale are mentioned in the tables below for RFFT and RIFFT:

Input and Output formats for RFFT Q31

RIFFT Size

Input Format

Output Format

Number of bits to upscale

32

1.31

6.26

0

64

1.31

7.25

0

128

1.31

8.24

0

256

1.31

9.23

0

512

1.31

10.22

0

1024

1.31

11.21

0

2048

1.31

12.20

0

4096

1.31

13.19

0

8192

1.31

14.18

0

Input and Output formats for RIFFT Q31

If the input buffer is of length N (fftLenReal), the output buffer must have length 2N since it is containing the conjugate part. The input buffer is modified by this function.

For the RIFFT, the source buffer must have length N+2 since the Nyquist frequency value is needed but conjugate part is ignored. It is not using the packing trick of the float version.

Parameters
  • S[in] points to an instance of the Q31 RFFT/RIFFT structure

  • pSrc[in] points to input buffer (Source buffer is modified by this function)

  • pDst[out] points to output buffer

Returns

none