[Add] First commit
This commit is contained in:
229
NSPE/Firmware/CMSIS/DSP_Lib_v1.6.0/source/arm_bitreversal.c
Normal file
229
NSPE/Firmware/CMSIS/DSP_Lib_v1.6.0/source/arm_bitreversal.c
Normal file
@ -0,0 +1,229 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
* Project: CMSIS DSP Library
|
||||
* Title: arm_bitreversal.c
|
||||
* Description: Bitreversal functions
|
||||
*
|
||||
* $Date: 18. March 2019
|
||||
* $Revision: V1.6.0
|
||||
*
|
||||
* Target Processor: Cortex-M cores
|
||||
* -------------------------------------------------------------------- */
|
||||
/*
|
||||
* Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "arm_math.h"
|
||||
#include "arm_common_tables.h"
|
||||
|
||||
/**
|
||||
@brief In-place floating-point bit reversal function.
|
||||
@param[in,out] pSrc points to in-place floating-point data buffer
|
||||
@param[in] fftSize length of FFT
|
||||
@param[in] bitRevFactor bit reversal modifier that supports different size FFTs with the same bit reversal table
|
||||
@param[in] pBitRevTab points to bit reversal table
|
||||
@return none
|
||||
*/
|
||||
|
||||
void arm_bitreversal_f32(
|
||||
float32_t * pSrc,
|
||||
uint16_t fftSize,
|
||||
uint16_t bitRevFactor,
|
||||
const uint16_t * pBitRevTab)
|
||||
{
|
||||
uint16_t fftLenBy2, fftLenBy2p1;
|
||||
uint16_t i, j;
|
||||
float32_t in;
|
||||
|
||||
/* Initializations */
|
||||
j = 0U;
|
||||
fftLenBy2 = fftSize >> 1U;
|
||||
fftLenBy2p1 = (fftSize >> 1U) + 1U;
|
||||
|
||||
/* Bit Reversal Implementation */
|
||||
for (i = 0U; i <= (fftLenBy2 - 2U); i += 2U)
|
||||
{
|
||||
if (i < j)
|
||||
{
|
||||
/* pSrc[i] <-> pSrc[j]; */
|
||||
in = pSrc[2U * i];
|
||||
pSrc[2U * i] = pSrc[2U * j];
|
||||
pSrc[2U * j] = in;
|
||||
|
||||
/* pSrc[i+1U] <-> pSrc[j+1U] */
|
||||
in = pSrc[(2U * i) + 1U];
|
||||
pSrc[(2U * i) + 1U] = pSrc[(2U * j) + 1U];
|
||||
pSrc[(2U * j) + 1U] = in;
|
||||
|
||||
/* pSrc[i+fftLenBy2p1] <-> pSrc[j+fftLenBy2p1] */
|
||||
in = pSrc[2U * (i + fftLenBy2p1)];
|
||||
pSrc[2U * (i + fftLenBy2p1)] = pSrc[2U * (j + fftLenBy2p1)];
|
||||
pSrc[2U * (j + fftLenBy2p1)] = in;
|
||||
|
||||
/* pSrc[i+fftLenBy2p1+1U] <-> pSrc[j+fftLenBy2p1+1U] */
|
||||
in = pSrc[(2U * (i + fftLenBy2p1)) + 1U];
|
||||
pSrc[(2U * (i + fftLenBy2p1)) + 1U] =
|
||||
pSrc[(2U * (j + fftLenBy2p1)) + 1U];
|
||||
pSrc[(2U * (j + fftLenBy2p1)) + 1U] = in;
|
||||
|
||||
}
|
||||
|
||||
/* pSrc[i+1U] <-> pSrc[j+1U] */
|
||||
in = pSrc[2U * (i + 1U)];
|
||||
pSrc[2U * (i + 1U)] = pSrc[2U * (j + fftLenBy2)];
|
||||
pSrc[2U * (j + fftLenBy2)] = in;
|
||||
|
||||
/* pSrc[i+2U] <-> pSrc[j+2U] */
|
||||
in = pSrc[(2U * (i + 1U)) + 1U];
|
||||
pSrc[(2U * (i + 1U)) + 1U] = pSrc[(2U * (j + fftLenBy2)) + 1U];
|
||||
pSrc[(2U * (j + fftLenBy2)) + 1U] = in;
|
||||
|
||||
/* Reading the index for the bit reversal */
|
||||
j = *pBitRevTab;
|
||||
|
||||
/* Updating the bit reversal index depending on the fft length */
|
||||
pBitRevTab += bitRevFactor;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@brief In-place Q31 bit reversal function.
|
||||
@param[in,out] pSrc points to in-place Q31 data buffer.
|
||||
@param[in] fftLen length of FFT.
|
||||
@param[in] bitRevFactor bit reversal modifier that supports different size FFTs with the same bit reversal table
|
||||
@param[in] pBitRevTab points to bit reversal table
|
||||
@return none
|
||||
*/
|
||||
|
||||
void arm_bitreversal_q31(
|
||||
q31_t * pSrc,
|
||||
uint32_t fftLen,
|
||||
uint16_t bitRevFactor,
|
||||
const uint16_t * pBitRevTab)
|
||||
{
|
||||
uint32_t fftLenBy2, fftLenBy2p1, i, j;
|
||||
q31_t in;
|
||||
|
||||
/* Initializations */
|
||||
j = 0U;
|
||||
fftLenBy2 = fftLen / 2U;
|
||||
fftLenBy2p1 = (fftLen / 2U) + 1U;
|
||||
|
||||
/* Bit Reversal Implementation */
|
||||
for (i = 0U; i <= (fftLenBy2 - 2U); i += 2U)
|
||||
{
|
||||
if (i < j)
|
||||
{
|
||||
/* pSrc[i] <-> pSrc[j]; */
|
||||
in = pSrc[2U * i];
|
||||
pSrc[2U * i] = pSrc[2U * j];
|
||||
pSrc[2U * j] = in;
|
||||
|
||||
/* pSrc[i+1U] <-> pSrc[j+1U] */
|
||||
in = pSrc[(2U * i) + 1U];
|
||||
pSrc[(2U * i) + 1U] = pSrc[(2U * j) + 1U];
|
||||
pSrc[(2U * j) + 1U] = in;
|
||||
|
||||
/* pSrc[i+fftLenBy2p1] <-> pSrc[j+fftLenBy2p1] */
|
||||
in = pSrc[2U * (i + fftLenBy2p1)];
|
||||
pSrc[2U * (i + fftLenBy2p1)] = pSrc[2U * (j + fftLenBy2p1)];
|
||||
pSrc[2U * (j + fftLenBy2p1)] = in;
|
||||
|
||||
/* pSrc[i+fftLenBy2p1+1U] <-> pSrc[j+fftLenBy2p1+1U] */
|
||||
in = pSrc[(2U * (i + fftLenBy2p1)) + 1U];
|
||||
pSrc[(2U * (i + fftLenBy2p1)) + 1U] =
|
||||
pSrc[(2U * (j + fftLenBy2p1)) + 1U];
|
||||
pSrc[(2U * (j + fftLenBy2p1)) + 1U] = in;
|
||||
|
||||
}
|
||||
|
||||
/* pSrc[i+1U] <-> pSrc[j+1U] */
|
||||
in = pSrc[2U * (i + 1U)];
|
||||
pSrc[2U * (i + 1U)] = pSrc[2U * (j + fftLenBy2)];
|
||||
pSrc[2U * (j + fftLenBy2)] = in;
|
||||
|
||||
/* pSrc[i+2U] <-> pSrc[j+2U] */
|
||||
in = pSrc[(2U * (i + 1U)) + 1U];
|
||||
pSrc[(2U * (i + 1U)) + 1U] = pSrc[(2U * (j + fftLenBy2)) + 1U];
|
||||
pSrc[(2U * (j + fftLenBy2)) + 1U] = in;
|
||||
|
||||
/* Reading the index for the bit reversal */
|
||||
j = *pBitRevTab;
|
||||
|
||||
/* Updating the bit reversal index depending on the fft length */
|
||||
pBitRevTab += bitRevFactor;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@brief In-place Q15 bit reversal function.
|
||||
@param[in,out] pSrc16 points to in-place Q15 data buffer
|
||||
@param[in] fftLen length of FFT
|
||||
@param[in] bitRevFactor bit reversal modifier that supports different size FFTs with the same bit reversal table
|
||||
@param[in] pBitRevTab points to bit reversal table
|
||||
@return none
|
||||
*/
|
||||
|
||||
void arm_bitreversal_q15(
|
||||
q15_t * pSrc16,
|
||||
uint32_t fftLen,
|
||||
uint16_t bitRevFactor,
|
||||
const uint16_t * pBitRevTab)
|
||||
{
|
||||
q31_t *pSrc = (q31_t *) pSrc16;
|
||||
q31_t in;
|
||||
uint32_t fftLenBy2, fftLenBy2p1;
|
||||
uint32_t i, j;
|
||||
|
||||
/* Initializations */
|
||||
j = 0U;
|
||||
fftLenBy2 = fftLen / 2U;
|
||||
fftLenBy2p1 = (fftLen / 2U) + 1U;
|
||||
|
||||
/* Bit Reversal Implementation */
|
||||
for (i = 0U; i <= (fftLenBy2 - 2U); i += 2U)
|
||||
{
|
||||
if (i < j)
|
||||
{
|
||||
/* pSrc[i] <-> pSrc[j]; */
|
||||
/* pSrc[i+1U] <-> pSrc[j+1U] */
|
||||
in = pSrc[i];
|
||||
pSrc[i] = pSrc[j];
|
||||
pSrc[j] = in;
|
||||
|
||||
/* pSrc[i + fftLenBy2p1] <-> pSrc[j + fftLenBy2p1]; */
|
||||
/* pSrc[i + fftLenBy2p1+1U] <-> pSrc[j + fftLenBy2p1+1U] */
|
||||
in = pSrc[i + fftLenBy2p1];
|
||||
pSrc[i + fftLenBy2p1] = pSrc[j + fftLenBy2p1];
|
||||
pSrc[j + fftLenBy2p1] = in;
|
||||
}
|
||||
|
||||
/* pSrc[i+1U] <-> pSrc[j+fftLenBy2]; */
|
||||
/* pSrc[i+2] <-> pSrc[j+fftLenBy2+1U] */
|
||||
in = pSrc[i + 1U];
|
||||
pSrc[i + 1U] = pSrc[j + fftLenBy2];
|
||||
pSrc[j + fftLenBy2] = in;
|
||||
|
||||
/* Reading the index for the bit reversal */
|
||||
j = *pBitRevTab;
|
||||
|
||||
/* Updating the bit reversal index depending on the fft length */
|
||||
pBitRevTab += bitRevFactor;
|
||||
}
|
||||
}
|
||||
220
NSPE/Firmware/CMSIS/DSP_Lib_v1.6.0/source/arm_bitreversal2.S
Normal file
220
NSPE/Firmware/CMSIS/DSP_Lib_v1.6.0/source/arm_bitreversal2.S
Normal file
@ -0,0 +1,220 @@
|
||||
;/* ----------------------------------------------------------------------
|
||||
; * Project: CMSIS DSP Library
|
||||
; * Title: arm_bitreversal2.S
|
||||
; * Description: arm_bitreversal_32 function done in assembly for maximum speed.
|
||||
; * Called after doing an fft to reorder the output.
|
||||
; * The function is loop unrolled by 2. arm_bitreversal_16 as well.
|
||||
; *
|
||||
; * $Date: 18. March 2019
|
||||
; * $Revision: V1.5.2
|
||||
; *
|
||||
; * Target Processor: Cortex-M cores
|
||||
; * -------------------------------------------------------------------- */
|
||||
;/*
|
||||
; * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
|
||||
; *
|
||||
; * SPDX-License-Identifier: Apache-2.0
|
||||
; *
|
||||
; * Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
; * not use this file except in compliance with the License.
|
||||
; * You may obtain a copy of the License at
|
||||
; *
|
||||
; * www.apache.org/licenses/LICENSE-2.0
|
||||
; *
|
||||
; * Unless required by applicable law or agreed to in writing, software
|
||||
; * distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
; * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
; * See the License for the specific language governing permissions and
|
||||
; * limitations under the License.
|
||||
; */
|
||||
|
||||
#if defined ( __CC_ARM ) /* Keil */
|
||||
#define CODESECT AREA ||.text||, CODE, READONLY, ALIGN=2
|
||||
#define LABEL
|
||||
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||
#define CODESECT AREA ||.text||, CODE, READONLY, ALIGN=2
|
||||
#define LABEL
|
||||
#elif defined ( __IASMARM__ ) /* IAR */
|
||||
#define CODESECT SECTION `.text`:CODE
|
||||
#define PROC
|
||||
#define LABEL
|
||||
#define ENDP
|
||||
#define EXPORT PUBLIC
|
||||
#elif defined ( __CSMC__ ) /* Cosmic */
|
||||
#define CODESECT switch .text
|
||||
#define THUMB
|
||||
#define EXPORT xdef
|
||||
#define PROC :
|
||||
#define LABEL :
|
||||
#define ENDP
|
||||
#define arm_bitreversal_32 _arm_bitreversal_32
|
||||
#elif defined ( __TI_ARM__ ) /* TI ARM */
|
||||
#define THUMB .thumb
|
||||
#define CODESECT .text
|
||||
#define EXPORT .global
|
||||
#define PROC : .asmfunc
|
||||
#define LABEL :
|
||||
#define ENDP .endasmfunc
|
||||
#define END
|
||||
#elif defined ( __GNUC__ ) /* GCC */
|
||||
#define THUMB .thumb
|
||||
#define CODESECT .section .text
|
||||
#define EXPORT .global
|
||||
#define PROC :
|
||||
#define LABEL :
|
||||
#define ENDP
|
||||
#define END
|
||||
|
||||
.syntax unified
|
||||
#endif
|
||||
|
||||
CODESECT
|
||||
THUMB
|
||||
|
||||
;/**
|
||||
; @brief In-place bit reversal function.
|
||||
; @param[in,out] pSrc points to the in-place buffer of unknown 32-bit data type
|
||||
; @param[in] bitRevLen bit reversal table length
|
||||
; @param[in] pBitRevTab points to bit reversal table
|
||||
; @return none
|
||||
; */
|
||||
EXPORT arm_bitreversal_32
|
||||
EXPORT arm_bitreversal_16
|
||||
|
||||
#if defined ( __CC_ARM ) /* Keil */
|
||||
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||
#elif defined ( __IASMARM__ ) /* IAR */
|
||||
#elif defined ( __CSMC__ ) /* Cosmic */
|
||||
#elif defined ( __TI_ARM__ ) /* TI ARM */
|
||||
#elif defined ( __GNUC__ ) /* GCC */
|
||||
.type arm_bitreversal_16, %function
|
||||
.type arm_bitreversal_32, %function
|
||||
#endif
|
||||
|
||||
#if defined (ARM_MATH_CM0_FAMILY)
|
||||
|
||||
arm_bitreversal_32 PROC
|
||||
ADDS r3,r1,#1
|
||||
PUSH {r4-r6}
|
||||
ADDS r1,r2,#0
|
||||
LSRS r3,r3,#1
|
||||
arm_bitreversal_32_0 LABEL
|
||||
LDRH r2,[r1,#2]
|
||||
LDRH r6,[r1,#0]
|
||||
ADD r2,r0,r2
|
||||
ADD r6,r0,r6
|
||||
LDR r5,[r2,#0]
|
||||
LDR r4,[r6,#0]
|
||||
STR r5,[r6,#0]
|
||||
STR r4,[r2,#0]
|
||||
LDR r5,[r2,#4]
|
||||
LDR r4,[r6,#4]
|
||||
STR r5,[r6,#4]
|
||||
STR r4,[r2,#4]
|
||||
ADDS r1,r1,#4
|
||||
SUBS r3,r3,#1
|
||||
BNE arm_bitreversal_32_0
|
||||
POP {r4-r6}
|
||||
BX lr
|
||||
ENDP
|
||||
|
||||
arm_bitreversal_16 PROC
|
||||
ADDS r3,r1,#1
|
||||
PUSH {r4-r6}
|
||||
ADDS r1,r2,#0
|
||||
LSRS r3,r3,#1
|
||||
arm_bitreversal_16_0 LABEL
|
||||
LDRH r2,[r1,#2]
|
||||
LDRH r6,[r1,#0]
|
||||
LSRS r2,r2,#1
|
||||
LSRS r6,r6,#1
|
||||
ADD r2,r0,r2
|
||||
ADD r6,r0,r6
|
||||
LDR r5,[r2,#0]
|
||||
LDR r4,[r6,#0]
|
||||
STR r5,[r6,#0]
|
||||
STR r4,[r2,#0]
|
||||
ADDS r1,r1,#4
|
||||
SUBS r3,r3,#1
|
||||
BNE arm_bitreversal_16_0
|
||||
POP {r4-r6}
|
||||
BX lr
|
||||
ENDP
|
||||
|
||||
#else
|
||||
|
||||
arm_bitreversal_32 PROC
|
||||
ADDS r3,r1,#1
|
||||
CMP r3,#1
|
||||
IT LS
|
||||
BXLS lr
|
||||
PUSH {r4-r9}
|
||||
ADDS r1,r2,#2
|
||||
LSRS r3,r3,#2
|
||||
arm_bitreversal_32_0 LABEL ;/* loop unrolled by 2 */
|
||||
LDRH r8,[r1,#4]
|
||||
LDRH r9,[r1,#2]
|
||||
LDRH r2,[r1,#0]
|
||||
LDRH r12,[r1,#-2]
|
||||
ADD r8,r0,r8
|
||||
ADD r9,r0,r9
|
||||
ADD r2,r0,r2
|
||||
ADD r12,r0,r12
|
||||
LDR r7,[r9,#0]
|
||||
LDR r6,[r8,#0]
|
||||
LDR r5,[r2,#0]
|
||||
LDR r4,[r12,#0]
|
||||
STR r6,[r9,#0]
|
||||
STR r7,[r8,#0]
|
||||
STR r5,[r12,#0]
|
||||
STR r4,[r2,#0]
|
||||
LDR r7,[r9,#4]
|
||||
LDR r6,[r8,#4]
|
||||
LDR r5,[r2,#4]
|
||||
LDR r4,[r12,#4]
|
||||
STR r6,[r9,#4]
|
||||
STR r7,[r8,#4]
|
||||
STR r5,[r12,#4]
|
||||
STR r4,[r2,#4]
|
||||
ADDS r1,r1,#8
|
||||
SUBS r3,r3,#1
|
||||
BNE arm_bitreversal_32_0
|
||||
POP {r4-r9}
|
||||
BX lr
|
||||
ENDP
|
||||
|
||||
arm_bitreversal_16 PROC
|
||||
ADDS r3,r1,#1
|
||||
CMP r3,#1
|
||||
IT LS
|
||||
BXLS lr
|
||||
PUSH {r4-r9}
|
||||
ADDS r1,r2,#2
|
||||
LSRS r3,r3,#2
|
||||
arm_bitreversal_16_0 LABEL ;/* loop unrolled by 2 */
|
||||
LDRH r8,[r1,#4]
|
||||
LDRH r9,[r1,#2]
|
||||
LDRH r2,[r1,#0]
|
||||
LDRH r12,[r1,#-2]
|
||||
ADD r8,r0,r8,LSR #1
|
||||
ADD r9,r0,r9,LSR #1
|
||||
ADD r2,r0,r2,LSR #1
|
||||
ADD r12,r0,r12,LSR #1
|
||||
LDR r7,[r9,#0]
|
||||
LDR r6,[r8,#0]
|
||||
LDR r5,[r2,#0]
|
||||
LDR r4,[r12,#0]
|
||||
STR r6,[r9,#0]
|
||||
STR r7,[r8,#0]
|
||||
STR r5,[r12,#0]
|
||||
STR r4,[r2,#0]
|
||||
ADDS r1,r1,#8
|
||||
SUBS r3,r3,#1
|
||||
BNE arm_bitreversal_16_0
|
||||
POP {r4-r9}
|
||||
BX lr
|
||||
ENDP
|
||||
|
||||
#endif
|
||||
|
||||
END
|
||||
629
NSPE/Firmware/CMSIS/DSP_Lib_v1.6.0/source/arm_cfft_f32.c
Normal file
629
NSPE/Firmware/CMSIS/DSP_Lib_v1.6.0/source/arm_cfft_f32.c
Normal file
@ -0,0 +1,629 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
* Project: CMSIS DSP Library
|
||||
* Title: arm_cfft_f32.c
|
||||
* Description: Combined Radix Decimation in Frequency CFFT Floating point processing function
|
||||
*
|
||||
* $Date: 18. March 2019
|
||||
* $Revision: V1.6.0
|
||||
*
|
||||
* Target Processor: Cortex-M cores
|
||||
* -------------------------------------------------------------------- */
|
||||
/*
|
||||
* Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "arm_math.h"
|
||||
#include "arm_common_tables.h"
|
||||
|
||||
extern void arm_radix8_butterfly_f32(
|
||||
float32_t * pSrc,
|
||||
uint16_t fftLen,
|
||||
const float32_t * pCoef,
|
||||
uint16_t twidCoefModifier);
|
||||
|
||||
extern void arm_bitreversal_32(
|
||||
uint32_t * pSrc,
|
||||
const uint16_t bitRevLen,
|
||||
const uint16_t * pBitRevTable);
|
||||
|
||||
/**
|
||||
@ingroup groupTransforms
|
||||
*/
|
||||
|
||||
/**
|
||||
@defgroup ComplexFFT Complex FFT Functions
|
||||
|
||||
@par
|
||||
The Fast Fourier Transform (FFT) is an efficient algorithm for computing the
|
||||
Discrete Fourier Transform (DFT). The FFT can be orders of magnitude faster
|
||||
than the DFT, especially for long lengths.
|
||||
The algorithms described in this section
|
||||
operate on complex data. A separate set of functions is devoted to handling
|
||||
of real sequences.
|
||||
@par
|
||||
There are separate algorithms for handling floating-point, Q15, and Q31 data
|
||||
types. The algorithms available for each data type are described next.
|
||||
@par
|
||||
The FFT functions operate in-place. That is, the array holding the input data
|
||||
will also be used to hold the corresponding result. The input data is complex
|
||||
and contains <code>2*fftLen</code> interleaved values as shown below.
|
||||
<pre>{real[0], imag[0], real[1], imag[1], ...} </pre>
|
||||
The FFT result will be contained in the same array and the frequency domain
|
||||
values will have the same interleaving.
|
||||
|
||||
@par Floating-point
|
||||
The floating-point complex FFT uses a mixed-radix algorithm. Multiple radix-8
|
||||
stages are performed along with a single radix-2 or radix-4 stage, as needed.
|
||||
The algorithm supports lengths of [16, 32, 64, ..., 4096] and each length uses
|
||||
a different twiddle factor table.
|
||||
@par
|
||||
The function uses the standard FFT definition and output values may grow by a
|
||||
factor of <code>fftLen</code> when computing the forward transform. The
|
||||
inverse transform includes a scale of <code>1/fftLen</code> as part of the
|
||||
calculation and this matches the textbook definition of the inverse FFT.
|
||||
@par
|
||||
Pre-initialized data structures containing twiddle factors and bit reversal
|
||||
tables are provided and defined in <code>arm_const_structs.h</code>. Include
|
||||
this header in your function and then pass one of the constant structures as
|
||||
an argument to arm_cfft_f32. For example:
|
||||
@par
|
||||
<code>arm_cfft_f32(arm_cfft_sR_f32_len64, pSrc, 1, 1)</code>
|
||||
@par
|
||||
computes a 64-point inverse complex FFT including bit reversal.
|
||||
The data structures are treated as constant data and not modified during the
|
||||
calculation. The same data structure can be reused for multiple transforms
|
||||
including mixing forward and inverse transforms.
|
||||
@par
|
||||
Earlier releases of the library provided separate radix-2 and radix-4
|
||||
algorithms that operated on floating-point data. These functions are still
|
||||
provided but are deprecated. The older functions are slower and less general
|
||||
than the new functions.
|
||||
@par
|
||||
An example of initialization of the constants for the arm_cfft_f32 function follows:
|
||||
@code
|
||||
const static arm_cfft_instance_f32 *S;
|
||||
...
|
||||
switch (length) {
|
||||
case 16:
|
||||
S = &arm_cfft_sR_f32_len16;
|
||||
break;
|
||||
case 32:
|
||||
S = &arm_cfft_sR_f32_len32;
|
||||
break;
|
||||
case 64:
|
||||
S = &arm_cfft_sR_f32_len64;
|
||||
break;
|
||||
case 128:
|
||||
S = &arm_cfft_sR_f32_len128;
|
||||
break;
|
||||
case 256:
|
||||
S = &arm_cfft_sR_f32_len256;
|
||||
break;
|
||||
case 512:
|
||||
S = &arm_cfft_sR_f32_len512;
|
||||
break;
|
||||
case 1024:
|
||||
S = &arm_cfft_sR_f32_len1024;
|
||||
break;
|
||||
case 2048:
|
||||
S = &arm_cfft_sR_f32_len2048;
|
||||
break;
|
||||
case 4096:
|
||||
S = &arm_cfft_sR_f32_len4096;
|
||||
break;
|
||||
}
|
||||
@endcode
|
||||
@par Q15 and Q31
|
||||
The floating-point complex FFT uses a mixed-radix algorithm. Multiple radix-4
|
||||
stages are performed along with a single radix-2 stage, as needed.
|
||||
The algorithm supports lengths of [16, 32, 64, ..., 4096] and each length uses
|
||||
a different twiddle factor table.
|
||||
@par
|
||||
The function uses the standard FFT definition and output values may grow by a
|
||||
factor of <code>fftLen</code> when computing the forward transform. The
|
||||
inverse transform includes a scale of <code>1/fftLen</code> as part of the
|
||||
calculation and this matches the textbook definition of the inverse FFT.
|
||||
@par
|
||||
Pre-initialized data structures containing twiddle factors and bit reversal
|
||||
tables are provided and defined in <code>arm_const_structs.h</code>. Include
|
||||
this header in your function and then pass one of the constant structures as
|
||||
an argument to arm_cfft_q31. For example:
|
||||
@par
|
||||
<code>arm_cfft_q31(arm_cfft_sR_q31_len64, pSrc, 1, 1)</code>
|
||||
@par
|
||||
computes a 64-point inverse complex FFT including bit reversal.
|
||||
The data structures are treated as constant data and not modified during the
|
||||
calculation. The same data structure can be reused for multiple transforms
|
||||
including mixing forward and inverse transforms.
|
||||
@par
|
||||
Earlier releases of the library provided separate radix-2 and radix-4
|
||||
algorithms that operated on floating-point data. These functions are still
|
||||
provided but are deprecated. The older functions are slower and less general
|
||||
than the new functions.
|
||||
@par
|
||||
An example of initialization of the constants for the arm_cfft_q31 function follows:
|
||||
@code
|
||||
const static arm_cfft_instance_q31 *S;
|
||||
...
|
||||
switch (length) {
|
||||
case 16:
|
||||
S = &arm_cfft_sR_q31_len16;
|
||||
break;
|
||||
case 32:
|
||||
S = &arm_cfft_sR_q31_len32;
|
||||
break;
|
||||
case 64:
|
||||
S = &arm_cfft_sR_q31_len64;
|
||||
break;
|
||||
case 128:
|
||||
S = &arm_cfft_sR_q31_len128;
|
||||
break;
|
||||
case 256:
|
||||
S = &arm_cfft_sR_q31_len256;
|
||||
break;
|
||||
case 512:
|
||||
S = &arm_cfft_sR_q31_len512;
|
||||
break;
|
||||
case 1024:
|
||||
S = &arm_cfft_sR_q31_len1024;
|
||||
break;
|
||||
case 2048:
|
||||
S = &arm_cfft_sR_q31_len2048;
|
||||
break;
|
||||
case 4096:
|
||||
S = &arm_cfft_sR_q31_len4096;
|
||||
break;
|
||||
}
|
||||
@endcode
|
||||
|
||||
*/
|
||||
|
||||
void arm_cfft_radix8by2_f32 (arm_cfft_instance_f32 * S, float32_t * p1)
|
||||
{
|
||||
uint32_t L = S->fftLen;
|
||||
float32_t * pCol1, * pCol2, * pMid1, * pMid2;
|
||||
float32_t * p2 = p1 + L;
|
||||
const float32_t * tw = (float32_t *) S->pTwiddle;
|
||||
float32_t t1[4], t2[4], t3[4], t4[4], twR, twI;
|
||||
float32_t m0, m1, m2, m3;
|
||||
uint32_t l;
|
||||
|
||||
pCol1 = p1;
|
||||
pCol2 = p2;
|
||||
|
||||
/* Define new length */
|
||||
L >>= 1;
|
||||
|
||||
/* Initialize mid pointers */
|
||||
pMid1 = p1 + L;
|
||||
pMid2 = p2 + L;
|
||||
|
||||
/* do two dot Fourier transform */
|
||||
for (l = L >> 2; l > 0; l-- )
|
||||
{
|
||||
t1[0] = p1[0];
|
||||
t1[1] = p1[1];
|
||||
t1[2] = p1[2];
|
||||
t1[3] = p1[3];
|
||||
|
||||
t2[0] = p2[0];
|
||||
t2[1] = p2[1];
|
||||
t2[2] = p2[2];
|
||||
t2[3] = p2[3];
|
||||
|
||||
t3[0] = pMid1[0];
|
||||
t3[1] = pMid1[1];
|
||||
t3[2] = pMid1[2];
|
||||
t3[3] = pMid1[3];
|
||||
|
||||
t4[0] = pMid2[0];
|
||||
t4[1] = pMid2[1];
|
||||
t4[2] = pMid2[2];
|
||||
t4[3] = pMid2[3];
|
||||
|
||||
*p1++ = t1[0] + t2[0];
|
||||
*p1++ = t1[1] + t2[1];
|
||||
*p1++ = t1[2] + t2[2];
|
||||
*p1++ = t1[3] + t2[3]; /* col 1 */
|
||||
|
||||
t2[0] = t1[0] - t2[0];
|
||||
t2[1] = t1[1] - t2[1];
|
||||
t2[2] = t1[2] - t2[2];
|
||||
t2[3] = t1[3] - t2[3]; /* for col 2 */
|
||||
|
||||
*pMid1++ = t3[0] + t4[0];
|
||||
*pMid1++ = t3[1] + t4[1];
|
||||
*pMid1++ = t3[2] + t4[2];
|
||||
*pMid1++ = t3[3] + t4[3]; /* col 1 */
|
||||
|
||||
t4[0] = t4[0] - t3[0];
|
||||
t4[1] = t4[1] - t3[1];
|
||||
t4[2] = t4[2] - t3[2];
|
||||
t4[3] = t4[3] - t3[3]; /* for col 2 */
|
||||
|
||||
twR = *tw++;
|
||||
twI = *tw++;
|
||||
|
||||
/* multiply by twiddle factors */
|
||||
m0 = t2[0] * twR;
|
||||
m1 = t2[1] * twI;
|
||||
m2 = t2[1] * twR;
|
||||
m3 = t2[0] * twI;
|
||||
|
||||
/* R = R * Tr - I * Ti */
|
||||
*p2++ = m0 + m1;
|
||||
/* I = I * Tr + R * Ti */
|
||||
*p2++ = m2 - m3;
|
||||
|
||||
/* use vertical symmetry */
|
||||
/* 0.9988 - 0.0491i <==> -0.0491 - 0.9988i */
|
||||
m0 = t4[0] * twI;
|
||||
m1 = t4[1] * twR;
|
||||
m2 = t4[1] * twI;
|
||||
m3 = t4[0] * twR;
|
||||
|
||||
*pMid2++ = m0 - m1;
|
||||
*pMid2++ = m2 + m3;
|
||||
|
||||
twR = *tw++;
|
||||
twI = *tw++;
|
||||
|
||||
m0 = t2[2] * twR;
|
||||
m1 = t2[3] * twI;
|
||||
m2 = t2[3] * twR;
|
||||
m3 = t2[2] * twI;
|
||||
|
||||
*p2++ = m0 + m1;
|
||||
*p2++ = m2 - m3;
|
||||
|
||||
m0 = t4[2] * twI;
|
||||
m1 = t4[3] * twR;
|
||||
m2 = t4[3] * twI;
|
||||
m3 = t4[2] * twR;
|
||||
|
||||
*pMid2++ = m0 - m1;
|
||||
*pMid2++ = m2 + m3;
|
||||
}
|
||||
|
||||
/* first col */
|
||||
arm_radix8_butterfly_f32 (pCol1, L, (float32_t *) S->pTwiddle, 2U);
|
||||
|
||||
/* second col */
|
||||
arm_radix8_butterfly_f32 (pCol2, L, (float32_t *) S->pTwiddle, 2U);
|
||||
}
|
||||
|
||||
void arm_cfft_radix8by4_f32 (arm_cfft_instance_f32 * S, float32_t * p1)
|
||||
{
|
||||
uint32_t L = S->fftLen >> 1;
|
||||
float32_t * pCol1, *pCol2, *pCol3, *pCol4, *pEnd1, *pEnd2, *pEnd3, *pEnd4;
|
||||
const float32_t *tw2, *tw3, *tw4;
|
||||
float32_t * p2 = p1 + L;
|
||||
float32_t * p3 = p2 + L;
|
||||
float32_t * p4 = p3 + L;
|
||||
float32_t t2[4], t3[4], t4[4], twR, twI;
|
||||
float32_t p1ap3_0, p1sp3_0, p1ap3_1, p1sp3_1;
|
||||
float32_t m0, m1, m2, m3;
|
||||
uint32_t l, twMod2, twMod3, twMod4;
|
||||
|
||||
pCol1 = p1; /* points to real values by default */
|
||||
pCol2 = p2;
|
||||
pCol3 = p3;
|
||||
pCol4 = p4;
|
||||
pEnd1 = p2 - 1; /* points to imaginary values by default */
|
||||
pEnd2 = p3 - 1;
|
||||
pEnd3 = p4 - 1;
|
||||
pEnd4 = pEnd3 + L;
|
||||
|
||||
tw2 = tw3 = tw4 = (float32_t *) S->pTwiddle;
|
||||
|
||||
L >>= 1;
|
||||
|
||||
/* do four dot Fourier transform */
|
||||
|
||||
twMod2 = 2;
|
||||
twMod3 = 4;
|
||||
twMod4 = 6;
|
||||
|
||||
/* TOP */
|
||||
p1ap3_0 = p1[0] + p3[0];
|
||||
p1sp3_0 = p1[0] - p3[0];
|
||||
p1ap3_1 = p1[1] + p3[1];
|
||||
p1sp3_1 = p1[1] - p3[1];
|
||||
|
||||
/* col 2 */
|
||||
t2[0] = p1sp3_0 + p2[1] - p4[1];
|
||||
t2[1] = p1sp3_1 - p2[0] + p4[0];
|
||||
/* col 3 */
|
||||
t3[0] = p1ap3_0 - p2[0] - p4[0];
|
||||
t3[1] = p1ap3_1 - p2[1] - p4[1];
|
||||
/* col 4 */
|
||||
t4[0] = p1sp3_0 - p2[1] + p4[1];
|
||||
t4[1] = p1sp3_1 + p2[0] - p4[0];
|
||||
/* col 1 */
|
||||
*p1++ = p1ap3_0 + p2[0] + p4[0];
|
||||
*p1++ = p1ap3_1 + p2[1] + p4[1];
|
||||
|
||||
/* Twiddle factors are ones */
|
||||
*p2++ = t2[0];
|
||||
*p2++ = t2[1];
|
||||
*p3++ = t3[0];
|
||||
*p3++ = t3[1];
|
||||
*p4++ = t4[0];
|
||||
*p4++ = t4[1];
|
||||
|
||||
tw2 += twMod2;
|
||||
tw3 += twMod3;
|
||||
tw4 += twMod4;
|
||||
|
||||
for (l = (L - 2) >> 1; l > 0; l-- )
|
||||
{
|
||||
/* TOP */
|
||||
p1ap3_0 = p1[0] + p3[0];
|
||||
p1sp3_0 = p1[0] - p3[0];
|
||||
p1ap3_1 = p1[1] + p3[1];
|
||||
p1sp3_1 = p1[1] - p3[1];
|
||||
/* col 2 */
|
||||
t2[0] = p1sp3_0 + p2[1] - p4[1];
|
||||
t2[1] = p1sp3_1 - p2[0] + p4[0];
|
||||
/* col 3 */
|
||||
t3[0] = p1ap3_0 - p2[0] - p4[0];
|
||||
t3[1] = p1ap3_1 - p2[1] - p4[1];
|
||||
/* col 4 */
|
||||
t4[0] = p1sp3_0 - p2[1] + p4[1];
|
||||
t4[1] = p1sp3_1 + p2[0] - p4[0];
|
||||
/* col 1 - top */
|
||||
*p1++ = p1ap3_0 + p2[0] + p4[0];
|
||||
*p1++ = p1ap3_1 + p2[1] + p4[1];
|
||||
|
||||
/* BOTTOM */
|
||||
p1ap3_1 = pEnd1[-1] + pEnd3[-1];
|
||||
p1sp3_1 = pEnd1[-1] - pEnd3[-1];
|
||||
p1ap3_0 = pEnd1[ 0] + pEnd3[0];
|
||||
p1sp3_0 = pEnd1[ 0] - pEnd3[0];
|
||||
/* col 2 */
|
||||
t2[2] = pEnd2[0] - pEnd4[0] + p1sp3_1;
|
||||
t2[3] = pEnd1[0] - pEnd3[0] - pEnd2[-1] + pEnd4[-1];
|
||||
/* col 3 */
|
||||
t3[2] = p1ap3_1 - pEnd2[-1] - pEnd4[-1];
|
||||
t3[3] = p1ap3_0 - pEnd2[ 0] - pEnd4[ 0];
|
||||
/* col 4 */
|
||||
t4[2] = pEnd2[ 0] - pEnd4[ 0] - p1sp3_1;
|
||||
t4[3] = pEnd4[-1] - pEnd2[-1] - p1sp3_0;
|
||||
/* col 1 - Bottom */
|
||||
*pEnd1-- = p1ap3_0 + pEnd2[ 0] + pEnd4[ 0];
|
||||
*pEnd1-- = p1ap3_1 + pEnd2[-1] + pEnd4[-1];
|
||||
|
||||
/* COL 2 */
|
||||
/* read twiddle factors */
|
||||
twR = *tw2++;
|
||||
twI = *tw2++;
|
||||
/* multiply by twiddle factors */
|
||||
/* let Z1 = a + i(b), Z2 = c + i(d) */
|
||||
/* => Z1 * Z2 = (a*c - b*d) + i(b*c + a*d) */
|
||||
|
||||
/* Top */
|
||||
m0 = t2[0] * twR;
|
||||
m1 = t2[1] * twI;
|
||||
m2 = t2[1] * twR;
|
||||
m3 = t2[0] * twI;
|
||||
|
||||
*p2++ = m0 + m1;
|
||||
*p2++ = m2 - m3;
|
||||
/* use vertical symmetry col 2 */
|
||||
/* 0.9997 - 0.0245i <==> 0.0245 - 0.9997i */
|
||||
/* Bottom */
|
||||
m0 = t2[3] * twI;
|
||||
m1 = t2[2] * twR;
|
||||
m2 = t2[2] * twI;
|
||||
m3 = t2[3] * twR;
|
||||
|
||||
*pEnd2-- = m0 - m1;
|
||||
*pEnd2-- = m2 + m3;
|
||||
|
||||
/* COL 3 */
|
||||
twR = tw3[0];
|
||||
twI = tw3[1];
|
||||
tw3 += twMod3;
|
||||
/* Top */
|
||||
m0 = t3[0] * twR;
|
||||
m1 = t3[1] * twI;
|
||||
m2 = t3[1] * twR;
|
||||
m3 = t3[0] * twI;
|
||||
|
||||
*p3++ = m0 + m1;
|
||||
*p3++ = m2 - m3;
|
||||
/* use vertical symmetry col 3 */
|
||||
/* 0.9988 - 0.0491i <==> -0.9988 - 0.0491i */
|
||||
/* Bottom */
|
||||
m0 = -t3[3] * twR;
|
||||
m1 = t3[2] * twI;
|
||||
m2 = t3[2] * twR;
|
||||
m3 = t3[3] * twI;
|
||||
|
||||
*pEnd3-- = m0 - m1;
|
||||
*pEnd3-- = m3 - m2;
|
||||
|
||||
/* COL 4 */
|
||||
twR = tw4[0];
|
||||
twI = tw4[1];
|
||||
tw4 += twMod4;
|
||||
/* Top */
|
||||
m0 = t4[0] * twR;
|
||||
m1 = t4[1] * twI;
|
||||
m2 = t4[1] * twR;
|
||||
m3 = t4[0] * twI;
|
||||
|
||||
*p4++ = m0 + m1;
|
||||
*p4++ = m2 - m3;
|
||||
/* use vertical symmetry col 4 */
|
||||
/* 0.9973 - 0.0736i <==> -0.0736 + 0.9973i */
|
||||
/* Bottom */
|
||||
m0 = t4[3] * twI;
|
||||
m1 = t4[2] * twR;
|
||||
m2 = t4[2] * twI;
|
||||
m3 = t4[3] * twR;
|
||||
|
||||
*pEnd4-- = m0 - m1;
|
||||
*pEnd4-- = m2 + m3;
|
||||
}
|
||||
|
||||
/* MIDDLE */
|
||||
/* Twiddle factors are */
|
||||
/* 1.0000 0.7071-0.7071i -1.0000i -0.7071-0.7071i */
|
||||
p1ap3_0 = p1[0] + p3[0];
|
||||
p1sp3_0 = p1[0] - p3[0];
|
||||
p1ap3_1 = p1[1] + p3[1];
|
||||
p1sp3_1 = p1[1] - p3[1];
|
||||
|
||||
/* col 2 */
|
||||
t2[0] = p1sp3_0 + p2[1] - p4[1];
|
||||
t2[1] = p1sp3_1 - p2[0] + p4[0];
|
||||
/* col 3 */
|
||||
t3[0] = p1ap3_0 - p2[0] - p4[0];
|
||||
t3[1] = p1ap3_1 - p2[1] - p4[1];
|
||||
/* col 4 */
|
||||
t4[0] = p1sp3_0 - p2[1] + p4[1];
|
||||
t4[1] = p1sp3_1 + p2[0] - p4[0];
|
||||
/* col 1 - Top */
|
||||
*p1++ = p1ap3_0 + p2[0] + p4[0];
|
||||
*p1++ = p1ap3_1 + p2[1] + p4[1];
|
||||
|
||||
/* COL 2 */
|
||||
twR = tw2[0];
|
||||
twI = tw2[1];
|
||||
|
||||
m0 = t2[0] * twR;
|
||||
m1 = t2[1] * twI;
|
||||
m2 = t2[1] * twR;
|
||||
m3 = t2[0] * twI;
|
||||
|
||||
*p2++ = m0 + m1;
|
||||
*p2++ = m2 - m3;
|
||||
/* COL 3 */
|
||||
twR = tw3[0];
|
||||
twI = tw3[1];
|
||||
|
||||
m0 = t3[0] * twR;
|
||||
m1 = t3[1] * twI;
|
||||
m2 = t3[1] * twR;
|
||||
m3 = t3[0] * twI;
|
||||
|
||||
*p3++ = m0 + m1;
|
||||
*p3++ = m2 - m3;
|
||||
/* COL 4 */
|
||||
twR = tw4[0];
|
||||
twI = tw4[1];
|
||||
|
||||
m0 = t4[0] * twR;
|
||||
m1 = t4[1] * twI;
|
||||
m2 = t4[1] * twR;
|
||||
m3 = t4[0] * twI;
|
||||
|
||||
*p4++ = m0 + m1;
|
||||
*p4++ = m2 - m3;
|
||||
|
||||
/* first col */
|
||||
arm_radix8_butterfly_f32 (pCol1, L, (float32_t *) S->pTwiddle, 4U);
|
||||
|
||||
/* second col */
|
||||
arm_radix8_butterfly_f32 (pCol2, L, (float32_t *) S->pTwiddle, 4U);
|
||||
|
||||
/* third col */
|
||||
arm_radix8_butterfly_f32 (pCol3, L, (float32_t *) S->pTwiddle, 4U);
|
||||
|
||||
/* fourth col */
|
||||
arm_radix8_butterfly_f32 (pCol4, L, (float32_t *) S->pTwiddle, 4U);
|
||||
}
|
||||
|
||||
/**
|
||||
@addtogroup ComplexFFT
|
||||
@{
|
||||
*/
|
||||
|
||||
/**
|
||||
@brief Processing function for the floating-point complex FFT.
|
||||
@param[in] S points to an instance of the floating-point CFFT structure
|
||||
@param[in,out] p1 points to the complex data buffer of size <code>2*fftLen</code>. Processing occurs in-place
|
||||
@param[in] ifftFlag flag that selects transform direction
|
||||
- value = 0: forward transform
|
||||
- value = 1: inverse transform
|
||||
@param[in] bitReverseFlag flag that enables / disables bit reversal of output
|
||||
- value = 0: disables bit reversal of output
|
||||
- value = 1: enables bit reversal of output
|
||||
@return none
|
||||
*/
|
||||
|
||||
void arm_cfft_f32(
|
||||
const arm_cfft_instance_f32 * S,
|
||||
float32_t * p1,
|
||||
uint8_t ifftFlag,
|
||||
uint8_t bitReverseFlag)
|
||||
{
|
||||
uint32_t L = S->fftLen, l;
|
||||
float32_t invL, * pSrc;
|
||||
|
||||
if (ifftFlag == 1U)
|
||||
{
|
||||
/* Conjugate input data */
|
||||
pSrc = p1 + 1;
|
||||
for (l = 0; l < L; l++)
|
||||
{
|
||||
*pSrc = -*pSrc;
|
||||
pSrc += 2;
|
||||
}
|
||||
}
|
||||
|
||||
switch (L)
|
||||
{
|
||||
case 16:
|
||||
case 128:
|
||||
case 1024:
|
||||
arm_cfft_radix8by2_f32 ( (arm_cfft_instance_f32 *) S, p1);
|
||||
break;
|
||||
case 32:
|
||||
case 256:
|
||||
case 2048:
|
||||
arm_cfft_radix8by4_f32 ( (arm_cfft_instance_f32 *) S, p1);
|
||||
break;
|
||||
case 64:
|
||||
case 512:
|
||||
case 4096:
|
||||
arm_radix8_butterfly_f32 ( p1, L, (float32_t *) S->pTwiddle, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
if ( bitReverseFlag )
|
||||
arm_bitreversal_32 ((uint32_t*) p1, S->bitRevLength, S->pBitRevTable);
|
||||
|
||||
if (ifftFlag == 1U)
|
||||
{
|
||||
invL = 1.0f / (float32_t)L;
|
||||
|
||||
/* Conjugate and scale output data */
|
||||
pSrc = p1;
|
||||
for (l= 0; l < L; l++)
|
||||
{
|
||||
*pSrc++ *= invL ;
|
||||
*pSrc = -(*pSrc) * invL;
|
||||
pSrc++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@} end of ComplexFFT group
|
||||
*/
|
||||
470
NSPE/Firmware/CMSIS/DSP_Lib_v1.6.0/source/arm_cfft_radix2_f32.c
Normal file
470
NSPE/Firmware/CMSIS/DSP_Lib_v1.6.0/source/arm_cfft_radix2_f32.c
Normal file
@ -0,0 +1,470 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
* Project: CMSIS DSP Library
|
||||
* Title: arm_cfft_radix2_f32.c
|
||||
* Description: Radix-2 Decimation in Frequency CFFT & CIFFT Floating point processing function
|
||||
*
|
||||
* $Date: 18. March 2019
|
||||
* $Revision: V1.6.0
|
||||
*
|
||||
* Target Processor: Cortex-M cores
|
||||
* -------------------------------------------------------------------- */
|
||||
/*
|
||||
* Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "arm_math.h"
|
||||
|
||||
void arm_radix2_butterfly_f32(
|
||||
float32_t * pSrc,
|
||||
uint32_t fftLen,
|
||||
const float32_t * pCoef,
|
||||
uint16_t twidCoefModifier);
|
||||
|
||||
void arm_radix2_butterfly_inverse_f32(
|
||||
float32_t * pSrc,
|
||||
uint32_t fftLen,
|
||||
const float32_t * pCoef,
|
||||
uint16_t twidCoefModifier,
|
||||
float32_t onebyfftLen);
|
||||
|
||||
extern void arm_bitreversal_f32(
|
||||
float32_t * pSrc,
|
||||
uint16_t fftSize,
|
||||
uint16_t bitRevFactor,
|
||||
const uint16_t * pBitRevTab);
|
||||
|
||||
/**
|
||||
@ingroup groupTransforms
|
||||
*/
|
||||
|
||||
/**
|
||||
@addtogroup ComplexFFT
|
||||
@{
|
||||
*/
|
||||
|
||||
/**
|
||||
@brief Radix-2 CFFT/CIFFT.
|
||||
@deprecated Do not use this function. It has been superseded by \ref arm_cfft_f32 and will be removed in the future
|
||||
@param[in] S points to an instance of the floating-point Radix-2 CFFT/CIFFT structure
|
||||
@param[in,out] pSrc points to the complex data buffer of size <code>2*fftLen</code>. Processing occurs in-place
|
||||
@return none
|
||||
*/
|
||||
|
||||
void arm_cfft_radix2_f32(
|
||||
const arm_cfft_radix2_instance_f32 * S,
|
||||
float32_t * pSrc)
|
||||
{
|
||||
|
||||
if (S->ifftFlag == 1U)
|
||||
{
|
||||
/* Complex IFFT radix-2 */
|
||||
arm_radix2_butterfly_inverse_f32(pSrc, S->fftLen, S->pTwiddle,
|
||||
S->twidCoefModifier, S->onebyfftLen);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Complex FFT radix-2 */
|
||||
arm_radix2_butterfly_f32(pSrc, S->fftLen, S->pTwiddle,
|
||||
S->twidCoefModifier);
|
||||
}
|
||||
|
||||
if (S->bitReverseFlag == 1U)
|
||||
{
|
||||
/* Bit Reversal */
|
||||
arm_bitreversal_f32(pSrc, S->fftLen, S->bitRevFactor, S->pBitRevTable);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@} end of ComplexFFT group
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
** Internal helper function used by the FFTs
|
||||
** ------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
brief Core function for the floating-point CFFT butterfly process.
|
||||
param[in,out] pSrc points to in-place buffer of floating-point data type
|
||||
param[in] fftLen length of the FFT
|
||||
param[in] pCoef points to twiddle coefficient buffer
|
||||
param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table
|
||||
return none
|
||||
*/
|
||||
|
||||
void arm_radix2_butterfly_f32(
|
||||
float32_t * pSrc,
|
||||
uint32_t fftLen,
|
||||
const float32_t * pCoef,
|
||||
uint16_t twidCoefModifier)
|
||||
{
|
||||
|
||||
uint32_t i, j, k, l;
|
||||
uint32_t n1, n2, ia;
|
||||
float32_t xt, yt, cosVal, sinVal;
|
||||
float32_t p0, p1, p2, p3;
|
||||
float32_t a0, a1;
|
||||
|
||||
#if defined (ARM_MATH_DSP)
|
||||
|
||||
/* Initializations for the first stage */
|
||||
n2 = fftLen >> 1;
|
||||
ia = 0;
|
||||
i = 0;
|
||||
|
||||
// loop for groups
|
||||
for (k = n2; k > 0; k--)
|
||||
{
|
||||
cosVal = pCoef[ia * 2];
|
||||
sinVal = pCoef[(ia * 2) + 1];
|
||||
|
||||
/* Twiddle coefficients index modifier */
|
||||
ia += twidCoefModifier;
|
||||
|
||||
/* index calculation for the input as, */
|
||||
/* pSrc[i + 0], pSrc[i + fftLen/1] */
|
||||
l = i + n2;
|
||||
|
||||
/* Butterfly implementation */
|
||||
a0 = pSrc[2 * i] + pSrc[2 * l];
|
||||
xt = pSrc[2 * i] - pSrc[2 * l];
|
||||
|
||||
yt = pSrc[2 * i + 1] - pSrc[2 * l + 1];
|
||||
a1 = pSrc[2 * l + 1] + pSrc[2 * i + 1];
|
||||
|
||||
p0 = xt * cosVal;
|
||||
p1 = yt * sinVal;
|
||||
p2 = yt * cosVal;
|
||||
p3 = xt * sinVal;
|
||||
|
||||
pSrc[2 * i] = a0;
|
||||
pSrc[2 * i + 1] = a1;
|
||||
|
||||
pSrc[2 * l] = p0 + p1;
|
||||
pSrc[2 * l + 1] = p2 - p3;
|
||||
|
||||
i++;
|
||||
} // groups loop end
|
||||
|
||||
twidCoefModifier <<= 1U;
|
||||
|
||||
// loop for stage
|
||||
for (k = n2; k > 2; k = k >> 1)
|
||||
{
|
||||
n1 = n2;
|
||||
n2 = n2 >> 1;
|
||||
ia = 0;
|
||||
|
||||
// loop for groups
|
||||
j = 0;
|
||||
do
|
||||
{
|
||||
cosVal = pCoef[ia * 2];
|
||||
sinVal = pCoef[(ia * 2) + 1];
|
||||
ia += twidCoefModifier;
|
||||
|
||||
// loop for butterfly
|
||||
i = j;
|
||||
do
|
||||
{
|
||||
l = i + n2;
|
||||
a0 = pSrc[2 * i] + pSrc[2 * l];
|
||||
xt = pSrc[2 * i] - pSrc[2 * l];
|
||||
|
||||
yt = pSrc[2 * i + 1] - pSrc[2 * l + 1];
|
||||
a1 = pSrc[2 * l + 1] + pSrc[2 * i + 1];
|
||||
|
||||
p0 = xt * cosVal;
|
||||
p1 = yt * sinVal;
|
||||
p2 = yt * cosVal;
|
||||
p3 = xt * sinVal;
|
||||
|
||||
pSrc[2 * i] = a0;
|
||||
pSrc[2 * i + 1] = a1;
|
||||
|
||||
pSrc[2 * l] = p0 + p1;
|
||||
pSrc[2 * l + 1] = p2 - p3;
|
||||
|
||||
i += n1;
|
||||
} while ( i < fftLen ); // butterfly loop end
|
||||
j++;
|
||||
} while ( j < n2); // groups loop end
|
||||
twidCoefModifier <<= 1U;
|
||||
} // stages loop end
|
||||
|
||||
// loop for butterfly
|
||||
for (i = 0; i < fftLen; i += 2)
|
||||
{
|
||||
a0 = pSrc[2 * i] + pSrc[2 * i + 2];
|
||||
xt = pSrc[2 * i] - pSrc[2 * i + 2];
|
||||
|
||||
yt = pSrc[2 * i + 1] - pSrc[2 * i + 3];
|
||||
a1 = pSrc[2 * i + 3] + pSrc[2 * i + 1];
|
||||
|
||||
pSrc[2 * i] = a0;
|
||||
pSrc[2 * i + 1] = a1;
|
||||
pSrc[2 * i + 2] = xt;
|
||||
pSrc[2 * i + 3] = yt;
|
||||
} // groups loop end
|
||||
|
||||
#else /* #if defined (ARM_MATH_DSP) */
|
||||
|
||||
n2 = fftLen;
|
||||
|
||||
// loop for stage
|
||||
for (k = fftLen; k > 1; k = k >> 1)
|
||||
{
|
||||
n1 = n2;
|
||||
n2 = n2 >> 1;
|
||||
ia = 0;
|
||||
|
||||
// loop for groups
|
||||
j = 0;
|
||||
do
|
||||
{
|
||||
cosVal = pCoef[ia * 2];
|
||||
sinVal = pCoef[(ia * 2) + 1];
|
||||
ia += twidCoefModifier;
|
||||
|
||||
// loop for butterfly
|
||||
i = j;
|
||||
do
|
||||
{
|
||||
l = i + n2;
|
||||
a0 = pSrc[2 * i] + pSrc[2 * l];
|
||||
xt = pSrc[2 * i] - pSrc[2 * l];
|
||||
|
||||
yt = pSrc[2 * i + 1] - pSrc[2 * l + 1];
|
||||
a1 = pSrc[2 * l + 1] + pSrc[2 * i + 1];
|
||||
|
||||
p0 = xt * cosVal;
|
||||
p1 = yt * sinVal;
|
||||
p2 = yt * cosVal;
|
||||
p3 = xt * sinVal;
|
||||
|
||||
pSrc[2 * i] = a0;
|
||||
pSrc[2 * i + 1] = a1;
|
||||
|
||||
pSrc[2 * l] = p0 + p1;
|
||||
pSrc[2 * l + 1] = p2 - p3;
|
||||
|
||||
i += n1;
|
||||
} while (i < fftLen);
|
||||
j++;
|
||||
} while (j < n2);
|
||||
twidCoefModifier <<= 1U;
|
||||
}
|
||||
|
||||
#endif /* #if defined (ARM_MATH_DSP) */
|
||||
|
||||
}
|
||||
|
||||
|
||||
void arm_radix2_butterfly_inverse_f32(
|
||||
float32_t * pSrc,
|
||||
uint32_t fftLen,
|
||||
const float32_t * pCoef,
|
||||
uint16_t twidCoefModifier,
|
||||
float32_t onebyfftLen)
|
||||
{
|
||||
|
||||
uint32_t i, j, k, l;
|
||||
uint32_t n1, n2, ia;
|
||||
float32_t xt, yt, cosVal, sinVal;
|
||||
float32_t p0, p1, p2, p3;
|
||||
float32_t a0, a1;
|
||||
|
||||
#if defined (ARM_MATH_DSP)
|
||||
|
||||
n2 = fftLen >> 1;
|
||||
ia = 0;
|
||||
|
||||
// loop for groups
|
||||
for (i = 0; i < n2; i++)
|
||||
{
|
||||
cosVal = pCoef[ia * 2];
|
||||
sinVal = pCoef[(ia * 2) + 1];
|
||||
ia += twidCoefModifier;
|
||||
|
||||
l = i + n2;
|
||||
a0 = pSrc[2 * i] + pSrc[2 * l];
|
||||
xt = pSrc[2 * i] - pSrc[2 * l];
|
||||
|
||||
yt = pSrc[2 * i + 1] - pSrc[2 * l + 1];
|
||||
a1 = pSrc[2 * l + 1] + pSrc[2 * i + 1];
|
||||
|
||||
p0 = xt * cosVal;
|
||||
p1 = yt * sinVal;
|
||||
p2 = yt * cosVal;
|
||||
p3 = xt * sinVal;
|
||||
|
||||
pSrc[2 * i] = a0;
|
||||
pSrc[2 * i + 1] = a1;
|
||||
|
||||
pSrc[2 * l] = p0 - p1;
|
||||
pSrc[2 * l + 1] = p2 + p3;
|
||||
} // groups loop end
|
||||
|
||||
twidCoefModifier <<= 1U;
|
||||
|
||||
// loop for stage
|
||||
for (k = fftLen / 2; k > 2; k = k >> 1)
|
||||
{
|
||||
n1 = n2;
|
||||
n2 = n2 >> 1;
|
||||
ia = 0;
|
||||
|
||||
// loop for groups
|
||||
j = 0;
|
||||
do
|
||||
{
|
||||
cosVal = pCoef[ia * 2];
|
||||
sinVal = pCoef[(ia * 2) + 1];
|
||||
ia += twidCoefModifier;
|
||||
|
||||
// loop for butterfly
|
||||
i = j;
|
||||
do
|
||||
{
|
||||
l = i + n2;
|
||||
a0 = pSrc[2 * i] + pSrc[2 * l];
|
||||
xt = pSrc[2 * i] - pSrc[2 * l];
|
||||
|
||||
yt = pSrc[2 * i + 1] - pSrc[2 * l + 1];
|
||||
a1 = pSrc[2 * l + 1] + pSrc[2 * i + 1];
|
||||
|
||||
p0 = xt * cosVal;
|
||||
p1 = yt * sinVal;
|
||||
p2 = yt * cosVal;
|
||||
p3 = xt * sinVal;
|
||||
|
||||
pSrc[2 * i] = a0;
|
||||
pSrc[2 * i + 1] = a1;
|
||||
|
||||
pSrc[2 * l] = p0 - p1;
|
||||
pSrc[2 * l + 1] = p2 + p3;
|
||||
|
||||
i += n1;
|
||||
} while ( i < fftLen ); // butterfly loop end
|
||||
j++;
|
||||
} while (j < n2); // groups loop end
|
||||
|
||||
twidCoefModifier <<= 1U;
|
||||
} // stages loop end
|
||||
|
||||
// loop for butterfly
|
||||
for (i = 0; i < fftLen; i += 2)
|
||||
{
|
||||
a0 = pSrc[2 * i] + pSrc[2 * i + 2];
|
||||
xt = pSrc[2 * i] - pSrc[2 * i + 2];
|
||||
|
||||
a1 = pSrc[2 * i + 3] + pSrc[2 * i + 1];
|
||||
yt = pSrc[2 * i + 1] - pSrc[2 * i + 3];
|
||||
|
||||
p0 = a0 * onebyfftLen;
|
||||
p2 = xt * onebyfftLen;
|
||||
p1 = a1 * onebyfftLen;
|
||||
p3 = yt * onebyfftLen;
|
||||
|
||||
pSrc[2 * i] = p0;
|
||||
pSrc[2 * i + 1] = p1;
|
||||
pSrc[2 * i + 2] = p2;
|
||||
pSrc[2 * i + 3] = p3;
|
||||
} // butterfly loop end
|
||||
|
||||
#else /* #if defined (ARM_MATH_DSP) */
|
||||
|
||||
n2 = fftLen;
|
||||
|
||||
// loop for stage
|
||||
for (k = fftLen; k > 2; k = k >> 1)
|
||||
{
|
||||
n1 = n2;
|
||||
n2 = n2 >> 1;
|
||||
ia = 0;
|
||||
|
||||
// loop for groups
|
||||
j = 0;
|
||||
do
|
||||
{
|
||||
cosVal = pCoef[ia * 2];
|
||||
sinVal = pCoef[(ia * 2) + 1];
|
||||
ia = ia + twidCoefModifier;
|
||||
|
||||
// loop for butterfly
|
||||
i = j;
|
||||
do
|
||||
{
|
||||
l = i + n2;
|
||||
a0 = pSrc[2 * i] + pSrc[2 * l];
|
||||
xt = pSrc[2 * i] - pSrc[2 * l];
|
||||
|
||||
yt = pSrc[2 * i + 1] - pSrc[2 * l + 1];
|
||||
a1 = pSrc[2 * l + 1] + pSrc[2 * i + 1];
|
||||
|
||||
p0 = xt * cosVal;
|
||||
p1 = yt * sinVal;
|
||||
p2 = yt * cosVal;
|
||||
p3 = xt * sinVal;
|
||||
|
||||
pSrc[2 * i] = a0;
|
||||
pSrc[2 * i + 1] = a1;
|
||||
|
||||
pSrc[2 * l] = p0 - p1;
|
||||
pSrc[2 * l + 1] = p2 + p3;
|
||||
|
||||
i += n1;
|
||||
} while ( i < fftLen ); // butterfly loop end
|
||||
j++;
|
||||
} while ( j < n2 ); // groups loop end
|
||||
|
||||
twidCoefModifier = twidCoefModifier << 1U;
|
||||
} // stages loop end
|
||||
|
||||
n1 = n2;
|
||||
n2 = n2 >> 1;
|
||||
|
||||
// loop for butterfly
|
||||
for (i = 0; i < fftLen; i += n1)
|
||||
{
|
||||
l = i + n2;
|
||||
|
||||
a0 = pSrc[2 * i] + pSrc[2 * l];
|
||||
xt = pSrc[2 * i] - pSrc[2 * l];
|
||||
|
||||
a1 = pSrc[2 * l + 1] + pSrc[2 * i + 1];
|
||||
yt = pSrc[2 * i + 1] - pSrc[2 * l + 1];
|
||||
|
||||
p0 = a0 * onebyfftLen;
|
||||
p2 = xt * onebyfftLen;
|
||||
p1 = a1 * onebyfftLen;
|
||||
p3 = yt * onebyfftLen;
|
||||
|
||||
pSrc[2 * i] = p0;
|
||||
pSrc[2 * l] = p2;
|
||||
|
||||
pSrc[2 * i + 1] = p1;
|
||||
pSrc[2 * l + 1] = p3;
|
||||
} // butterfly loop end
|
||||
|
||||
#endif /* #if defined (ARM_MATH_DSP) */
|
||||
|
||||
}
|
||||
1200
NSPE/Firmware/CMSIS/DSP_Lib_v1.6.0/source/arm_cfft_radix4_f32.c
Normal file
1200
NSPE/Firmware/CMSIS/DSP_Lib_v1.6.0/source/arm_cfft_radix4_f32.c
Normal file
File diff suppressed because it is too large
Load Diff
285
NSPE/Firmware/CMSIS/DSP_Lib_v1.6.0/source/arm_cfft_radix8_f32.c
Normal file
285
NSPE/Firmware/CMSIS/DSP_Lib_v1.6.0/source/arm_cfft_radix8_f32.c
Normal file
@ -0,0 +1,285 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
* Project: CMSIS DSP Library
|
||||
* Title: arm_cfft_radix8_f32.c
|
||||
* Description: Radix-8 Decimation in Frequency CFFT & CIFFT Floating point processing function
|
||||
*
|
||||
* $Date: 18. March 2019
|
||||
* $Revision: V1.6.0
|
||||
*
|
||||
* Target Processor: Cortex-M cores
|
||||
* -------------------------------------------------------------------- */
|
||||
/*
|
||||
* Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "arm_math.h"
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
* Internal helper function used by the FFTs
|
||||
* -------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
brief Core function for the floating-point CFFT butterfly process.
|
||||
param[in,out] pSrc points to the in-place buffer of floating-point data type.
|
||||
param[in] fftLen length of the FFT.
|
||||
param[in] pCoef points to the twiddle coefficient buffer.
|
||||
param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table.
|
||||
return none
|
||||
*/
|
||||
|
||||
void arm_radix8_butterfly_f32(
|
||||
float32_t * pSrc,
|
||||
uint16_t fftLen,
|
||||
const float32_t * pCoef,
|
||||
uint16_t twidCoefModifier)
|
||||
{
|
||||
uint32_t ia1, ia2, ia3, ia4, ia5, ia6, ia7;
|
||||
uint32_t i1, i2, i3, i4, i5, i6, i7, i8;
|
||||
uint32_t id;
|
||||
uint32_t n1, n2, j;
|
||||
|
||||
float32_t r1, r2, r3, r4, r5, r6, r7, r8;
|
||||
float32_t t1, t2;
|
||||
float32_t s1, s2, s3, s4, s5, s6, s7, s8;
|
||||
float32_t p1, p2, p3, p4;
|
||||
float32_t co2, co3, co4, co5, co6, co7, co8;
|
||||
float32_t si2, si3, si4, si5, si6, si7, si8;
|
||||
const float32_t C81 = 0.70710678118f;
|
||||
|
||||
n2 = fftLen;
|
||||
|
||||
do
|
||||
{
|
||||
n1 = n2;
|
||||
n2 = n2 >> 3;
|
||||
i1 = 0;
|
||||
|
||||
do
|
||||
{
|
||||
i2 = i1 + n2;
|
||||
i3 = i2 + n2;
|
||||
i4 = i3 + n2;
|
||||
i5 = i4 + n2;
|
||||
i6 = i5 + n2;
|
||||
i7 = i6 + n2;
|
||||
i8 = i7 + n2;
|
||||
r1 = pSrc[2 * i1] + pSrc[2 * i5];
|
||||
r5 = pSrc[2 * i1] - pSrc[2 * i5];
|
||||
r2 = pSrc[2 * i2] + pSrc[2 * i6];
|
||||
r6 = pSrc[2 * i2] - pSrc[2 * i6];
|
||||
r3 = pSrc[2 * i3] + pSrc[2 * i7];
|
||||
r7 = pSrc[2 * i3] - pSrc[2 * i7];
|
||||
r4 = pSrc[2 * i4] + pSrc[2 * i8];
|
||||
r8 = pSrc[2 * i4] - pSrc[2 * i8];
|
||||
t1 = r1 - r3;
|
||||
r1 = r1 + r3;
|
||||
r3 = r2 - r4;
|
||||
r2 = r2 + r4;
|
||||
pSrc[2 * i1] = r1 + r2;
|
||||
pSrc[2 * i5] = r1 - r2;
|
||||
r1 = pSrc[2 * i1 + 1] + pSrc[2 * i5 + 1];
|
||||
s5 = pSrc[2 * i1 + 1] - pSrc[2 * i5 + 1];
|
||||
r2 = pSrc[2 * i2 + 1] + pSrc[2 * i6 + 1];
|
||||
s6 = pSrc[2 * i2 + 1] - pSrc[2 * i6 + 1];
|
||||
s3 = pSrc[2 * i3 + 1] + pSrc[2 * i7 + 1];
|
||||
s7 = pSrc[2 * i3 + 1] - pSrc[2 * i7 + 1];
|
||||
r4 = pSrc[2 * i4 + 1] + pSrc[2 * i8 + 1];
|
||||
s8 = pSrc[2 * i4 + 1] - pSrc[2 * i8 + 1];
|
||||
t2 = r1 - s3;
|
||||
r1 = r1 + s3;
|
||||
s3 = r2 - r4;
|
||||
r2 = r2 + r4;
|
||||
pSrc[2 * i1 + 1] = r1 + r2;
|
||||
pSrc[2 * i5 + 1] = r1 - r2;
|
||||
pSrc[2 * i3] = t1 + s3;
|
||||
pSrc[2 * i7] = t1 - s3;
|
||||
pSrc[2 * i3 + 1] = t2 - r3;
|
||||
pSrc[2 * i7 + 1] = t2 + r3;
|
||||
r1 = (r6 - r8) * C81;
|
||||
r6 = (r6 + r8) * C81;
|
||||
r2 = (s6 - s8) * C81;
|
||||
s6 = (s6 + s8) * C81;
|
||||
t1 = r5 - r1;
|
||||
r5 = r5 + r1;
|
||||
r8 = r7 - r6;
|
||||
r7 = r7 + r6;
|
||||
t2 = s5 - r2;
|
||||
s5 = s5 + r2;
|
||||
s8 = s7 - s6;
|
||||
s7 = s7 + s6;
|
||||
pSrc[2 * i2] = r5 + s7;
|
||||
pSrc[2 * i8] = r5 - s7;
|
||||
pSrc[2 * i6] = t1 + s8;
|
||||
pSrc[2 * i4] = t1 - s8;
|
||||
pSrc[2 * i2 + 1] = s5 - r7;
|
||||
pSrc[2 * i8 + 1] = s5 + r7;
|
||||
pSrc[2 * i6 + 1] = t2 - r8;
|
||||
pSrc[2 * i4 + 1] = t2 + r8;
|
||||
|
||||
i1 += n1;
|
||||
} while (i1 < fftLen);
|
||||
|
||||
if (n2 < 8)
|
||||
break;
|
||||
|
||||
ia1 = 0;
|
||||
j = 1;
|
||||
|
||||
do
|
||||
{
|
||||
/* index calculation for the coefficients */
|
||||
id = ia1 + twidCoefModifier;
|
||||
ia1 = id;
|
||||
ia2 = ia1 + id;
|
||||
ia3 = ia2 + id;
|
||||
ia4 = ia3 + id;
|
||||
ia5 = ia4 + id;
|
||||
ia6 = ia5 + id;
|
||||
ia7 = ia6 + id;
|
||||
|
||||
co2 = pCoef[2 * ia1];
|
||||
co3 = pCoef[2 * ia2];
|
||||
co4 = pCoef[2 * ia3];
|
||||
co5 = pCoef[2 * ia4];
|
||||
co6 = pCoef[2 * ia5];
|
||||
co7 = pCoef[2 * ia6];
|
||||
co8 = pCoef[2 * ia7];
|
||||
si2 = pCoef[2 * ia1 + 1];
|
||||
si3 = pCoef[2 * ia2 + 1];
|
||||
si4 = pCoef[2 * ia3 + 1];
|
||||
si5 = pCoef[2 * ia4 + 1];
|
||||
si6 = pCoef[2 * ia5 + 1];
|
||||
si7 = pCoef[2 * ia6 + 1];
|
||||
si8 = pCoef[2 * ia7 + 1];
|
||||
|
||||
i1 = j;
|
||||
|
||||
do
|
||||
{
|
||||
/* index calculation for the input */
|
||||
i2 = i1 + n2;
|
||||
i3 = i2 + n2;
|
||||
i4 = i3 + n2;
|
||||
i5 = i4 + n2;
|
||||
i6 = i5 + n2;
|
||||
i7 = i6 + n2;
|
||||
i8 = i7 + n2;
|
||||
r1 = pSrc[2 * i1] + pSrc[2 * i5];
|
||||
r5 = pSrc[2 * i1] - pSrc[2 * i5];
|
||||
r2 = pSrc[2 * i2] + pSrc[2 * i6];
|
||||
r6 = pSrc[2 * i2] - pSrc[2 * i6];
|
||||
r3 = pSrc[2 * i3] + pSrc[2 * i7];
|
||||
r7 = pSrc[2 * i3] - pSrc[2 * i7];
|
||||
r4 = pSrc[2 * i4] + pSrc[2 * i8];
|
||||
r8 = pSrc[2 * i4] - pSrc[2 * i8];
|
||||
t1 = r1 - r3;
|
||||
r1 = r1 + r3;
|
||||
r3 = r2 - r4;
|
||||
r2 = r2 + r4;
|
||||
pSrc[2 * i1] = r1 + r2;
|
||||
r2 = r1 - r2;
|
||||
s1 = pSrc[2 * i1 + 1] + pSrc[2 * i5 + 1];
|
||||
s5 = pSrc[2 * i1 + 1] - pSrc[2 * i5 + 1];
|
||||
s2 = pSrc[2 * i2 + 1] + pSrc[2 * i6 + 1];
|
||||
s6 = pSrc[2 * i2 + 1] - pSrc[2 * i6 + 1];
|
||||
s3 = pSrc[2 * i3 + 1] + pSrc[2 * i7 + 1];
|
||||
s7 = pSrc[2 * i3 + 1] - pSrc[2 * i7 + 1];
|
||||
s4 = pSrc[2 * i4 + 1] + pSrc[2 * i8 + 1];
|
||||
s8 = pSrc[2 * i4 + 1] - pSrc[2 * i8 + 1];
|
||||
t2 = s1 - s3;
|
||||
s1 = s1 + s3;
|
||||
s3 = s2 - s4;
|
||||
s2 = s2 + s4;
|
||||
r1 = t1 + s3;
|
||||
t1 = t1 - s3;
|
||||
pSrc[2 * i1 + 1] = s1 + s2;
|
||||
s2 = s1 - s2;
|
||||
s1 = t2 - r3;
|
||||
t2 = t2 + r3;
|
||||
p1 = co5 * r2;
|
||||
p2 = si5 * s2;
|
||||
p3 = co5 * s2;
|
||||
p4 = si5 * r2;
|
||||
pSrc[2 * i5] = p1 + p2;
|
||||
pSrc[2 * i5 + 1] = p3 - p4;
|
||||
p1 = co3 * r1;
|
||||
p2 = si3 * s1;
|
||||
p3 = co3 * s1;
|
||||
p4 = si3 * r1;
|
||||
pSrc[2 * i3] = p1 + p2;
|
||||
pSrc[2 * i3 + 1] = p3 - p4;
|
||||
p1 = co7 * t1;
|
||||
p2 = si7 * t2;
|
||||
p3 = co7 * t2;
|
||||
p4 = si7 * t1;
|
||||
pSrc[2 * i7] = p1 + p2;
|
||||
pSrc[2 * i7 + 1] = p3 - p4;
|
||||
r1 = (r6 - r8) * C81;
|
||||
r6 = (r6 + r8) * C81;
|
||||
s1 = (s6 - s8) * C81;
|
||||
s6 = (s6 + s8) * C81;
|
||||
t1 = r5 - r1;
|
||||
r5 = r5 + r1;
|
||||
r8 = r7 - r6;
|
||||
r7 = r7 + r6;
|
||||
t2 = s5 - s1;
|
||||
s5 = s5 + s1;
|
||||
s8 = s7 - s6;
|
||||
s7 = s7 + s6;
|
||||
r1 = r5 + s7;
|
||||
r5 = r5 - s7;
|
||||
r6 = t1 + s8;
|
||||
t1 = t1 - s8;
|
||||
s1 = s5 - r7;
|
||||
s5 = s5 + r7;
|
||||
s6 = t2 - r8;
|
||||
t2 = t2 + r8;
|
||||
p1 = co2 * r1;
|
||||
p2 = si2 * s1;
|
||||
p3 = co2 * s1;
|
||||
p4 = si2 * r1;
|
||||
pSrc[2 * i2] = p1 + p2;
|
||||
pSrc[2 * i2 + 1] = p3 - p4;
|
||||
p1 = co8 * r5;
|
||||
p2 = si8 * s5;
|
||||
p3 = co8 * s5;
|
||||
p4 = si8 * r5;
|
||||
pSrc[2 * i8] = p1 + p2;
|
||||
pSrc[2 * i8 + 1] = p3 - p4;
|
||||
p1 = co6 * r6;
|
||||
p2 = si6 * s6;
|
||||
p3 = co6 * s6;
|
||||
p4 = si6 * r6;
|
||||
pSrc[2 * i6] = p1 + p2;
|
||||
pSrc[2 * i6 + 1] = p3 - p4;
|
||||
p1 = co4 * t1;
|
||||
p2 = si4 * t2;
|
||||
p3 = co4 * t2;
|
||||
p4 = si4 * t1;
|
||||
pSrc[2 * i4] = p1 + p2;
|
||||
pSrc[2 * i4 + 1] = p3 - p4;
|
||||
|
||||
i1 += n1;
|
||||
} while (i1 < fftLen);
|
||||
|
||||
j++;
|
||||
} while (j < n2);
|
||||
|
||||
twidCoefModifier <<= 3;
|
||||
} while (n2 > 7);
|
||||
}
|
||||
22151
NSPE/Firmware/CMSIS/DSP_Lib_v1.6.0/source/arm_common_tables.c
Normal file
22151
NSPE/Firmware/CMSIS/DSP_Lib_v1.6.0/source/arm_common_tables.c
Normal file
File diff suppressed because it is too large
Load Diff
381
NSPE/Firmware/CMSIS/DSP_Lib_v1.6.0/source/arm_const_structs.c
Normal file
381
NSPE/Firmware/CMSIS/DSP_Lib_v1.6.0/source/arm_const_structs.c
Normal file
@ -0,0 +1,381 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
* Project: CMSIS DSP Library
|
||||
* Title: arm_const_structs.c
|
||||
* Description: Constant structs that are initialized for user convenience.
|
||||
* For example, some can be given as arguments to the arm_cfft_f32() or arm_rfft_f32() functions.
|
||||
*
|
||||
* $Date: 27. January 2017
|
||||
* $Revision: V.1.5.1
|
||||
*
|
||||
* Target Processor: Cortex-M cores
|
||||
* -------------------------------------------------------------------- */
|
||||
/*
|
||||
* Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "arm_const_structs.h"
|
||||
|
||||
/* Floating-point structs */
|
||||
const arm_cfft_instance_f32 arm_cfft_sR_f32_len16 = {
|
||||
16, twiddleCoef_16, armBitRevIndexTable16, ARMBITREVINDEXTABLE_16_TABLE_LENGTH
|
||||
};
|
||||
|
||||
const arm_cfft_instance_f32 arm_cfft_sR_f32_len32 = {
|
||||
32, twiddleCoef_32, armBitRevIndexTable32, ARMBITREVINDEXTABLE_32_TABLE_LENGTH
|
||||
};
|
||||
|
||||
const arm_cfft_instance_f32 arm_cfft_sR_f32_len64 = {
|
||||
64, twiddleCoef_64, armBitRevIndexTable64, ARMBITREVINDEXTABLE_64_TABLE_LENGTH
|
||||
};
|
||||
|
||||
const arm_cfft_instance_f32 arm_cfft_sR_f32_len128 = {
|
||||
128, twiddleCoef_128, armBitRevIndexTable128, ARMBITREVINDEXTABLE_128_TABLE_LENGTH
|
||||
};
|
||||
|
||||
const arm_cfft_instance_f32 arm_cfft_sR_f32_len256 = {
|
||||
256, twiddleCoef_256, armBitRevIndexTable256, ARMBITREVINDEXTABLE_256_TABLE_LENGTH
|
||||
};
|
||||
|
||||
const arm_cfft_instance_f32 arm_cfft_sR_f32_len512 = {
|
||||
512, twiddleCoef_512, armBitRevIndexTable512, ARMBITREVINDEXTABLE_512_TABLE_LENGTH
|
||||
};
|
||||
|
||||
const arm_cfft_instance_f32 arm_cfft_sR_f32_len1024 = {
|
||||
1024, twiddleCoef_1024, armBitRevIndexTable1024, ARMBITREVINDEXTABLE_1024_TABLE_LENGTH
|
||||
};
|
||||
|
||||
const arm_cfft_instance_f32 arm_cfft_sR_f32_len2048 = {
|
||||
2048, twiddleCoef_2048, armBitRevIndexTable2048, ARMBITREVINDEXTABLE_2048_TABLE_LENGTH
|
||||
};
|
||||
|
||||
const arm_cfft_instance_f32 arm_cfft_sR_f32_len4096 = {
|
||||
4096, twiddleCoef_4096, armBitRevIndexTable4096, ARMBITREVINDEXTABLE_4096_TABLE_LENGTH
|
||||
};
|
||||
|
||||
/* Fixed-point structs */
|
||||
const arm_cfft_instance_q31 arm_cfft_sR_q31_len16 = {
|
||||
16, twiddleCoef_16_q31, armBitRevIndexTable_fixed_16, ARMBITREVINDEXTABLE_FIXED_16_TABLE_LENGTH
|
||||
};
|
||||
|
||||
const arm_cfft_instance_q31 arm_cfft_sR_q31_len32 = {
|
||||
32, twiddleCoef_32_q31, armBitRevIndexTable_fixed_32, ARMBITREVINDEXTABLE_FIXED_32_TABLE_LENGTH
|
||||
};
|
||||
|
||||
const arm_cfft_instance_q31 arm_cfft_sR_q31_len64 = {
|
||||
64, twiddleCoef_64_q31, armBitRevIndexTable_fixed_64, ARMBITREVINDEXTABLE_FIXED_64_TABLE_LENGTH
|
||||
};
|
||||
|
||||
const arm_cfft_instance_q31 arm_cfft_sR_q31_len128 = {
|
||||
128, twiddleCoef_128_q31, armBitRevIndexTable_fixed_128, ARMBITREVINDEXTABLE_FIXED_128_TABLE_LENGTH
|
||||
};
|
||||
|
||||
const arm_cfft_instance_q31 arm_cfft_sR_q31_len256 = {
|
||||
256, twiddleCoef_256_q31, armBitRevIndexTable_fixed_256, ARMBITREVINDEXTABLE_FIXED_256_TABLE_LENGTH
|
||||
};
|
||||
|
||||
const arm_cfft_instance_q31 arm_cfft_sR_q31_len512 = {
|
||||
512, twiddleCoef_512_q31, armBitRevIndexTable_fixed_512, ARMBITREVINDEXTABLE_FIXED_512_TABLE_LENGTH
|
||||
};
|
||||
|
||||
const arm_cfft_instance_q31 arm_cfft_sR_q31_len1024 = {
|
||||
1024, twiddleCoef_1024_q31, armBitRevIndexTable_fixed_1024, ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH
|
||||
};
|
||||
|
||||
const arm_cfft_instance_q31 arm_cfft_sR_q31_len2048 = {
|
||||
2048, twiddleCoef_2048_q31, armBitRevIndexTable_fixed_2048, ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH
|
||||
};
|
||||
|
||||
const arm_cfft_instance_q31 arm_cfft_sR_q31_len4096 = {
|
||||
4096, twiddleCoef_4096_q31, armBitRevIndexTable_fixed_4096, ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH
|
||||
};
|
||||
|
||||
const arm_cfft_instance_q15 arm_cfft_sR_q15_len16 = {
|
||||
16, twiddleCoef_16_q15, armBitRevIndexTable_fixed_16, ARMBITREVINDEXTABLE_FIXED_16_TABLE_LENGTH
|
||||
};
|
||||
|
||||
const arm_cfft_instance_q15 arm_cfft_sR_q15_len32 = {
|
||||
32, twiddleCoef_32_q15, armBitRevIndexTable_fixed_32, ARMBITREVINDEXTABLE_FIXED_32_TABLE_LENGTH
|
||||
};
|
||||
|
||||
const arm_cfft_instance_q15 arm_cfft_sR_q15_len64 = {
|
||||
64, twiddleCoef_64_q15, armBitRevIndexTable_fixed_64, ARMBITREVINDEXTABLE_FIXED_64_TABLE_LENGTH
|
||||
};
|
||||
|
||||
const arm_cfft_instance_q15 arm_cfft_sR_q15_len128 = {
|
||||
128, twiddleCoef_128_q15, armBitRevIndexTable_fixed_128, ARMBITREVINDEXTABLE_FIXED_128_TABLE_LENGTH
|
||||
};
|
||||
|
||||
const arm_cfft_instance_q15 arm_cfft_sR_q15_len256 = {
|
||||
256, twiddleCoef_256_q15, armBitRevIndexTable_fixed_256, ARMBITREVINDEXTABLE_FIXED_256_TABLE_LENGTH
|
||||
};
|
||||
|
||||
const arm_cfft_instance_q15 arm_cfft_sR_q15_len512 = {
|
||||
512, twiddleCoef_512_q15, armBitRevIndexTable_fixed_512, ARMBITREVINDEXTABLE_FIXED_512_TABLE_LENGTH
|
||||
};
|
||||
|
||||
const arm_cfft_instance_q15 arm_cfft_sR_q15_len1024 = {
|
||||
1024, twiddleCoef_1024_q15, armBitRevIndexTable_fixed_1024, ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH
|
||||
};
|
||||
|
||||
const arm_cfft_instance_q15 arm_cfft_sR_q15_len2048 = {
|
||||
2048, twiddleCoef_2048_q15, armBitRevIndexTable_fixed_2048, ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH
|
||||
};
|
||||
|
||||
const arm_cfft_instance_q15 arm_cfft_sR_q15_len4096 = {
|
||||
4096, twiddleCoef_4096_q15, armBitRevIndexTable_fixed_4096, ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH
|
||||
};
|
||||
|
||||
/* Structure for real-value inputs */
|
||||
/* Floating-point structs */
|
||||
const arm_rfft_fast_instance_f32 arm_rfft_fast_sR_f32_len32 = {
|
||||
{ 16, twiddleCoef_32, armBitRevIndexTable32, ARMBITREVINDEXTABLE_16_TABLE_LENGTH },
|
||||
32U,
|
||||
(float32_t *)twiddleCoef_rfft_32
|
||||
};
|
||||
|
||||
const arm_rfft_fast_instance_f32 arm_rfft_fast_sR_f32_len64 = {
|
||||
{ 32, twiddleCoef_32, armBitRevIndexTable32, ARMBITREVINDEXTABLE_32_TABLE_LENGTH },
|
||||
64U,
|
||||
(float32_t *)twiddleCoef_rfft_64
|
||||
};
|
||||
|
||||
const arm_rfft_fast_instance_f32 arm_rfft_fast_sR_f32_len128 = {
|
||||
{ 64, twiddleCoef_64, armBitRevIndexTable64, ARMBITREVINDEXTABLE_64_TABLE_LENGTH },
|
||||
128U,
|
||||
(float32_t *)twiddleCoef_rfft_128
|
||||
};
|
||||
|
||||
const arm_rfft_fast_instance_f32 arm_rfft_fast_sR_f32_len256 = {
|
||||
{ 128, twiddleCoef_128, armBitRevIndexTable128, ARMBITREVINDEXTABLE_128_TABLE_LENGTH },
|
||||
256U,
|
||||
(float32_t *)twiddleCoef_rfft_256
|
||||
};
|
||||
|
||||
const arm_rfft_fast_instance_f32 arm_rfft_fast_sR_f32_len512 = {
|
||||
{ 256, twiddleCoef_256, armBitRevIndexTable256, ARMBITREVINDEXTABLE_256_TABLE_LENGTH },
|
||||
512U,
|
||||
(float32_t *)twiddleCoef_rfft_512
|
||||
};
|
||||
|
||||
const arm_rfft_fast_instance_f32 arm_rfft_fast_sR_f32_len1024 = {
|
||||
{ 512, twiddleCoef_512, armBitRevIndexTable512, ARMBITREVINDEXTABLE_512_TABLE_LENGTH },
|
||||
1024U,
|
||||
(float32_t *)twiddleCoef_rfft_1024
|
||||
};
|
||||
|
||||
const arm_rfft_fast_instance_f32 arm_rfft_fast_sR_f32_len2048 = {
|
||||
{ 1024, twiddleCoef_1024, armBitRevIndexTable1024, ARMBITREVINDEXTABLE_1024_TABLE_LENGTH },
|
||||
2048U,
|
||||
(float32_t *)twiddleCoef_rfft_2048
|
||||
};
|
||||
|
||||
const arm_rfft_fast_instance_f32 arm_rfft_fast_sR_f32_len4096 = {
|
||||
{ 2048, twiddleCoef_2048, armBitRevIndexTable2048, ARMBITREVINDEXTABLE_2048_TABLE_LENGTH },
|
||||
4096U,
|
||||
(float32_t *)twiddleCoef_rfft_4096
|
||||
};
|
||||
|
||||
#if 0
|
||||
/* Fixed-point structs */
|
||||
/* q31_t */
|
||||
extern const q31_t realCoefAQ31[8192];
|
||||
extern const q31_t realCoefBQ31[8192];
|
||||
|
||||
const arm_rfft_instance_q31 arm_rfft_sR_q31_len32 = {
|
||||
32U,
|
||||
0,
|
||||
1,
|
||||
256U,
|
||||
(q31_t*)realCoefAQ31,
|
||||
(q31_t*)realCoefBQ31,
|
||||
&arm_cfft_sR_q31_len16
|
||||
};
|
||||
|
||||
const arm_rfft_instance_q31 arm_rfft_sR_q31_len64 = {
|
||||
64U,
|
||||
0,
|
||||
1,
|
||||
128U,
|
||||
(q31_t*)realCoefAQ31,
|
||||
(q31_t*)realCoefBQ31,
|
||||
&arm_cfft_sR_q31_len32
|
||||
};
|
||||
|
||||
const arm_rfft_instance_q31 arm_rfft_sR_q31_len128 = {
|
||||
128U,
|
||||
0,
|
||||
1,
|
||||
64U,
|
||||
(q31_t*)realCoefAQ31,
|
||||
(q31_t*)realCoefBQ31,
|
||||
&arm_cfft_sR_q31_len64
|
||||
};
|
||||
|
||||
const arm_rfft_instance_q31 arm_rfft_sR_q31_len256 = {
|
||||
256U,
|
||||
0,
|
||||
1,
|
||||
32U,
|
||||
(q31_t*)realCoefAQ31,
|
||||
(q31_t*)realCoefBQ31,
|
||||
&arm_cfft_sR_q31_len128
|
||||
};
|
||||
|
||||
const arm_rfft_instance_q31 arm_rfft_sR_q31_len512 = {
|
||||
512U,
|
||||
0,
|
||||
1,
|
||||
16U,
|
||||
(q31_t*)realCoefAQ31,
|
||||
(q31_t*)realCoefBQ31,
|
||||
&arm_cfft_sR_q31_len256
|
||||
};
|
||||
|
||||
const arm_rfft_instance_q31 arm_rfft_sR_q31_len1024 = {
|
||||
1024U,
|
||||
0,
|
||||
1,
|
||||
8U,
|
||||
(q31_t*)realCoefAQ31,
|
||||
(q31_t*)realCoefBQ31,
|
||||
&arm_cfft_sR_q31_len512
|
||||
};
|
||||
|
||||
const arm_rfft_instance_q31 arm_rfft_sR_q31_len2048 = {
|
||||
2048U,
|
||||
0,
|
||||
1,
|
||||
4U,
|
||||
(q31_t*)realCoefAQ31,
|
||||
(q31_t*)realCoefBQ31,
|
||||
&arm_cfft_sR_q31_len1024
|
||||
};
|
||||
|
||||
const arm_rfft_instance_q31 arm_rfft_sR_q31_len4096 = {
|
||||
4096U,
|
||||
0,
|
||||
1,
|
||||
2U,
|
||||
(q31_t*)realCoefAQ31,
|
||||
(q31_t*)realCoefBQ31,
|
||||
&arm_cfft_sR_q31_len2048
|
||||
};
|
||||
|
||||
const arm_rfft_instance_q31 arm_rfft_sR_q31_len8192 = {
|
||||
8192U,
|
||||
0,
|
||||
1,
|
||||
1U,
|
||||
(q31_t*)realCoefAQ31,
|
||||
(q31_t*)realCoefBQ31,
|
||||
&arm_cfft_sR_q31_len4096
|
||||
};
|
||||
|
||||
/* q15_t */
|
||||
extern const q15_t realCoefAQ15[8192];
|
||||
extern const q15_t realCoefBQ15[8192];
|
||||
|
||||
const arm_rfft_instance_q15 arm_rfft_sR_q15_len32 = {
|
||||
32U,
|
||||
0,
|
||||
1,
|
||||
256U,
|
||||
(q15_t*)realCoefAQ15,
|
||||
(q15_t*)realCoefBQ15,
|
||||
&arm_cfft_sR_q15_len16
|
||||
};
|
||||
|
||||
const arm_rfft_instance_q15 arm_rfft_sR_q15_len64 = {
|
||||
64U,
|
||||
0,
|
||||
1,
|
||||
128U,
|
||||
(q15_t*)realCoefAQ15,
|
||||
(q15_t*)realCoefBQ15,
|
||||
&arm_cfft_sR_q15_len32
|
||||
};
|
||||
|
||||
const arm_rfft_instance_q15 arm_rfft_sR_q15_len128 = {
|
||||
128U,
|
||||
0,
|
||||
1,
|
||||
64U,
|
||||
(q15_t*)realCoefAQ15,
|
||||
(q15_t*)realCoefBQ15,
|
||||
&arm_cfft_sR_q15_len64
|
||||
};
|
||||
|
||||
const arm_rfft_instance_q15 arm_rfft_sR_q15_len256 = {
|
||||
256U,
|
||||
0,
|
||||
1,
|
||||
32U,
|
||||
(q15_t*)realCoefAQ15,
|
||||
(q15_t*)realCoefBQ15,
|
||||
&arm_cfft_sR_q15_len128
|
||||
};
|
||||
|
||||
const arm_rfft_instance_q15 arm_rfft_sR_q15_len512 = {
|
||||
512U,
|
||||
0,
|
||||
1,
|
||||
16U,
|
||||
(q15_t*)realCoefAQ15,
|
||||
(q15_t*)realCoefBQ15,
|
||||
&arm_cfft_sR_q15_len256
|
||||
};
|
||||
|
||||
const arm_rfft_instance_q15 arm_rfft_sR_q15_len1024 = {
|
||||
1024U,
|
||||
0,
|
||||
1,
|
||||
8U,
|
||||
(q15_t*)realCoefAQ15,
|
||||
(q15_t*)realCoefBQ15,
|
||||
&arm_cfft_sR_q15_len512
|
||||
};
|
||||
|
||||
const arm_rfft_instance_q15 arm_rfft_sR_q15_len2048 = {
|
||||
2048U,
|
||||
0,
|
||||
1,
|
||||
4U,
|
||||
(q15_t*)realCoefAQ15,
|
||||
(q15_t*)realCoefBQ15,
|
||||
&arm_cfft_sR_q15_len1024
|
||||
};
|
||||
|
||||
const arm_rfft_instance_q15 arm_rfft_sR_q15_len4096 = {
|
||||
4096U,
|
||||
0,
|
||||
1,
|
||||
2U,
|
||||
(q15_t*)realCoefAQ15,
|
||||
(q15_t*)realCoefBQ15,
|
||||
&arm_cfft_sR_q15_len2048
|
||||
};
|
||||
|
||||
const arm_rfft_instance_q15 arm_rfft_sR_q15_len8192 = {
|
||||
8192U,
|
||||
0,
|
||||
1,
|
||||
1U,
|
||||
(q15_t*)realCoefAQ15,
|
||||
(q15_t*)realCoefBQ15,
|
||||
&arm_cfft_sR_q15_len4096
|
||||
};
|
||||
#endif
|
||||
122
NSPE/Firmware/CMSIS/DSP_Lib_v1.6.0/source/arm_cos_f32.c
Normal file
122
NSPE/Firmware/CMSIS/DSP_Lib_v1.6.0/source/arm_cos_f32.c
Normal file
@ -0,0 +1,122 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
* Project: CMSIS DSP Library
|
||||
* Title: arm_cos_f32.c
|
||||
* Description: Fast cosine calculation for floating-point values
|
||||
*
|
||||
* $Date: 18. March 2019
|
||||
* $Revision: V1.6.0
|
||||
*
|
||||
* Target Processor: Cortex-M cores
|
||||
* -------------------------------------------------------------------- */
|
||||
/*
|
||||
* Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "arm_math.h"
|
||||
#include "arm_common_tables.h"
|
||||
|
||||
/**
|
||||
@ingroup groupFastMath
|
||||
*/
|
||||
|
||||
/**
|
||||
@defgroup cos Cosine
|
||||
|
||||
Computes the trigonometric cosine function using a combination of table lookup
|
||||
and linear interpolation. There are separate functions for
|
||||
Q15, Q31, and floating-point data types.
|
||||
The input to the floating-point version is in radians while the
|
||||
fixed-point Q15 and Q31 have a scaled input with the range
|
||||
[0 +0.9999] mapping to [0 2*pi). The fixed-point range is chosen so that a
|
||||
value of 2*pi wraps around to 0.
|
||||
|
||||
The implementation is based on table lookup using 256 values together with linear interpolation.
|
||||
The steps used are:
|
||||
-# Calculation of the nearest integer table index
|
||||
-# Compute the fractional portion (fract) of the table index.
|
||||
-# The final result equals <code>(1.0f-fract)*a + fract*b;</code>
|
||||
|
||||
where
|
||||
<pre>
|
||||
b = Table[index];
|
||||
c = Table[index+1];
|
||||
</pre>
|
||||
*/
|
||||
|
||||
/**
|
||||
@addtogroup cos
|
||||
@{
|
||||
*/
|
||||
|
||||
/**
|
||||
@brief Fast approximation to the trigonometric cosine function for floating-point data.
|
||||
@param[in] x input value in radians
|
||||
@return cos(x)
|
||||
*/
|
||||
|
||||
float32_t arm_cos_f32(
|
||||
float32_t x)
|
||||
{
|
||||
float32_t cosVal, fract, in; /* Temporary input, output variables */
|
||||
uint16_t index; /* Index variable */
|
||||
float32_t a, b; /* Two nearest output values */
|
||||
int32_t n;
|
||||
float32_t findex;
|
||||
|
||||
/* input x is in radians */
|
||||
/* Scale input to [0 1] range from [0 2*PI] , divide input by 2*pi, add 0.25 (pi/2) to read sine table */
|
||||
in = x * 0.159154943092f + 0.25f;
|
||||
|
||||
/* Calculation of floor value of input */
|
||||
n = (int32_t) in;
|
||||
|
||||
/* Make negative values towards -infinity */
|
||||
if (in < 0.0f)
|
||||
{
|
||||
n--;
|
||||
}
|
||||
|
||||
/* Map input value to [0 1] */
|
||||
in = in - (float32_t) n;
|
||||
|
||||
/* Calculation of index of the table */
|
||||
findex = (float32_t)FAST_MATH_TABLE_SIZE * in;
|
||||
index = (uint16_t)findex;
|
||||
|
||||
/* when "in" is exactly 1, we need to rotate the index down to 0 */
|
||||
if (index >= FAST_MATH_TABLE_SIZE) {
|
||||
index = 0;
|
||||
findex -= (float32_t)FAST_MATH_TABLE_SIZE;
|
||||
}
|
||||
|
||||
/* fractional value calculation */
|
||||
fract = findex - (float32_t) index;
|
||||
|
||||
/* Read two nearest values of input value from the cos table */
|
||||
a = sinTable_f32[index];
|
||||
b = sinTable_f32[index+1];
|
||||
|
||||
/* Linear interpolation process */
|
||||
cosVal = (1.0f - fract) * a + fract * b;
|
||||
|
||||
/* Return output value */
|
||||
return (cosVal);
|
||||
}
|
||||
|
||||
/**
|
||||
@} end of cos group
|
||||
*/
|
||||
146
NSPE/Firmware/CMSIS/DSP_Lib_v1.6.0/source/arm_sin_cos_f32.c
Normal file
146
NSPE/Firmware/CMSIS/DSP_Lib_v1.6.0/source/arm_sin_cos_f32.c
Normal file
@ -0,0 +1,146 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
* Project: CMSIS DSP Library
|
||||
* Title: arm_sin_cos_f32.c
|
||||
* Description: Sine and Cosine calculation for floating-point values
|
||||
*
|
||||
* $Date: 18. March 2019
|
||||
* $Revision: V1.6.0
|
||||
*
|
||||
* Target Processor: Cortex-M cores
|
||||
* -------------------------------------------------------------------- */
|
||||
/*
|
||||
* Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "arm_math.h"
|
||||
#include "arm_common_tables.h"
|
||||
|
||||
/**
|
||||
@ingroup groupController
|
||||
*/
|
||||
|
||||
/**
|
||||
@defgroup SinCos Sine Cosine
|
||||
|
||||
Computes the trigonometric sine and cosine values using a combination of table lookup
|
||||
and linear interpolation.
|
||||
There are separate functions for Q31 and floating-point data types.
|
||||
The input to the floating-point version is in degrees while the
|
||||
fixed-point Q31 have a scaled input with the range
|
||||
[-1 0.9999] mapping to [-180 +180] degrees.
|
||||
|
||||
The floating point function also allows values that are out of the usual range. When this happens, the function will
|
||||
take extra time to adjust the input value to the range of [-180 180].
|
||||
|
||||
The result is accurate to 5 digits after the decimal point.
|
||||
|
||||
The implementation is based on table lookup using 360 values together with linear interpolation.
|
||||
The steps used are:
|
||||
-# Calculation of the nearest integer table index.
|
||||
-# Compute the fractional portion (fract) of the input.
|
||||
-# Fetch the value corresponding to \c index from sine table to \c y0 and also value from \c index+1 to \c y1.
|
||||
-# Sine value is computed as <code> *psinVal = y0 + (fract * (y1 - y0))</code>.
|
||||
-# Fetch the value corresponding to \c index from cosine table to \c y0 and also value from \c index+1 to \c y1.
|
||||
-# Cosine value is computed as <code> *pcosVal = y0 + (fract * (y1 - y0))</code>.
|
||||
*/
|
||||
|
||||
/**
|
||||
@addtogroup SinCos
|
||||
@{
|
||||
*/
|
||||
|
||||
/**
|
||||
@brief Floating-point sin_cos function.
|
||||
@param[in] theta input value in degrees
|
||||
@param[out] pSinVal points to processed sine output
|
||||
@param[out] pCosVal points to processed cosine output
|
||||
@return none
|
||||
*/
|
||||
|
||||
void arm_sin_cos_f32(
|
||||
float32_t theta,
|
||||
float32_t * pSinVal,
|
||||
float32_t * pCosVal)
|
||||
{
|
||||
float32_t fract, in; /* Temporary input, output variables */
|
||||
uint16_t indexS, indexC; /* Index variable */
|
||||
float32_t f1, f2, d1, d2; /* Two nearest output values */
|
||||
float32_t Dn, Df;
|
||||
float32_t temp, findex;
|
||||
|
||||
/* input x is in degrees */
|
||||
/* Scale input, divide input by 360, for cosine add 0.25 (pi/2) to read sine table */
|
||||
in = theta * 0.00277777777778f;
|
||||
|
||||
if (in < 0.0f)
|
||||
{
|
||||
in = -in;
|
||||
}
|
||||
|
||||
in = in - (int32_t)in;
|
||||
|
||||
/* Calculate the nearest index */
|
||||
findex = (float32_t)FAST_MATH_TABLE_SIZE * in;
|
||||
indexS = ((uint16_t)findex) & 0x1ff;
|
||||
indexC = (indexS + (FAST_MATH_TABLE_SIZE / 4)) & 0x1ff;
|
||||
|
||||
/* Calculation of fractional value */
|
||||
fract = findex - (float32_t) indexS;
|
||||
|
||||
/* Read two nearest values of input value from the cos & sin tables */
|
||||
f1 = sinTable_f32[indexC ];
|
||||
f2 = sinTable_f32[indexC+1];
|
||||
d1 = -sinTable_f32[indexS ];
|
||||
d2 = -sinTable_f32[indexS+1];
|
||||
|
||||
temp = (1.0f - fract) * f1 + fract * f2;
|
||||
|
||||
Dn = 0.0122718463030f; /* delta between the two points (fixed), in this case 2*pi/FAST_MATH_TABLE_SIZE */
|
||||
Df = f2 - f1; /* delta between the values of the functions */
|
||||
|
||||
temp = Dn * (d1 + d2) - 2 * Df;
|
||||
temp = fract * temp + (3 * Df - (d2 + 2 * d1) * Dn);
|
||||
temp = fract * temp + d1 * Dn;
|
||||
|
||||
/* Calculation of cosine value */
|
||||
*pCosVal = fract * temp + f1;
|
||||
|
||||
/* Read two nearest values of input value from the cos & sin tables */
|
||||
f1 = sinTable_f32[indexS ];
|
||||
f2 = sinTable_f32[indexS+1];
|
||||
d1 = sinTable_f32[indexC ];
|
||||
d2 = sinTable_f32[indexC+1];
|
||||
|
||||
temp = (1.0f - fract) * f1 + fract * f2;
|
||||
|
||||
Df = f2 - f1; // delta between the values of the functions
|
||||
temp = Dn * (d1 + d2) - 2 * Df;
|
||||
temp = fract * temp + (3 * Df - (d2 + 2 * d1) * Dn);
|
||||
temp = fract * temp + d1 * Dn;
|
||||
|
||||
/* Calculation of sine value */
|
||||
*pSinVal = fract * temp + f1;
|
||||
|
||||
if (theta < 0.0f)
|
||||
{
|
||||
*pSinVal = -*pSinVal;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@} end of SinCos group
|
||||
*/
|
||||
122
NSPE/Firmware/CMSIS/DSP_Lib_v1.6.0/source/arm_sin_f32.c
Normal file
122
NSPE/Firmware/CMSIS/DSP_Lib_v1.6.0/source/arm_sin_f32.c
Normal file
@ -0,0 +1,122 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
* Project: CMSIS DSP Library
|
||||
* Title: arm_sin_f32.c
|
||||
* Description: Fast sine calculation for floating-point values
|
||||
*
|
||||
* $Date: 18. March 2019
|
||||
* $Revision: V1.6.0
|
||||
*
|
||||
* Target Processor: Cortex-M cores
|
||||
* -------------------------------------------------------------------- */
|
||||
/*
|
||||
* Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "arm_math.h"
|
||||
#include "arm_common_tables.h"
|
||||
|
||||
/**
|
||||
@ingroup groupFastMath
|
||||
*/
|
||||
|
||||
/**
|
||||
@defgroup sin Sine
|
||||
|
||||
Computes the trigonometric sine function using a combination of table lookup
|
||||
and linear interpolation. There are separate functions for
|
||||
Q15, Q31, and floating-point data types.
|
||||
The input to the floating-point version is in radians while the
|
||||
fixed-point Q15 and Q31 have a scaled input with the range
|
||||
[0 +0.9999] mapping to [0 2*pi). The fixed-point range is chosen so that a
|
||||
value of 2*pi wraps around to 0.
|
||||
|
||||
The implementation is based on table lookup using 256 values together with linear interpolation.
|
||||
The steps used are:
|
||||
-# Calculation of the nearest integer table index
|
||||
-# Compute the fractional portion (fract) of the table index.
|
||||
-# The final result equals <code>(1.0f-fract)*a + fract*b;</code>
|
||||
|
||||
where
|
||||
<pre>
|
||||
b = Table[index];
|
||||
c = Table[index+1];
|
||||
</pre>
|
||||
*/
|
||||
|
||||
/**
|
||||
@addtogroup sin
|
||||
@{
|
||||
*/
|
||||
|
||||
/**
|
||||
@brief Fast approximation to the trigonometric sine function for floating-point data.
|
||||
@param[in] x input value in radians.
|
||||
@return sin(x)
|
||||
*/
|
||||
|
||||
float32_t arm_sin_f32(
|
||||
float32_t x)
|
||||
{
|
||||
float32_t sinVal, fract, in; /* Temporary input, output variables */
|
||||
uint16_t index; /* Index variable */
|
||||
float32_t a, b; /* Two nearest output values */
|
||||
int32_t n;
|
||||
float32_t findex;
|
||||
|
||||
/* input x is in radians */
|
||||
/* Scale input to [0 1] range from [0 2*PI] , divide input by 2*pi */
|
||||
in = x * 0.159154943092f;
|
||||
|
||||
/* Calculation of floor value of input */
|
||||
n = (int32_t) in;
|
||||
|
||||
/* Make negative values towards -infinity */
|
||||
if (in < 0.0f)
|
||||
{
|
||||
n--;
|
||||
}
|
||||
|
||||
/* Map input value to [0 1] */
|
||||
in = in - (float32_t) n;
|
||||
|
||||
/* Calculation of index of the table */
|
||||
findex = (float32_t)FAST_MATH_TABLE_SIZE * in;
|
||||
index = (uint16_t)findex;
|
||||
|
||||
/* when "in" is exactly 1, we need to rotate the index down to 0 */
|
||||
if (index >= FAST_MATH_TABLE_SIZE) {
|
||||
index = 0;
|
||||
findex -= (float32_t)FAST_MATH_TABLE_SIZE;
|
||||
}
|
||||
|
||||
/* fractional value calculation */
|
||||
fract = findex - (float32_t) index;
|
||||
|
||||
/* Read two nearest values of input value from the sin table */
|
||||
a = sinTable_f32[index];
|
||||
b = sinTable_f32[index+1];
|
||||
|
||||
/* Linear interpolation process */
|
||||
sinVal = (1.0f - fract) * a + fract * b;
|
||||
|
||||
/* Return output value */
|
||||
return (sinVal);
|
||||
}
|
||||
|
||||
/**
|
||||
@} end of sin group
|
||||
*/
|
||||
Reference in New Issue
Block a user