Fork of mbed-dsp. CMSIS-DSP library of supporting NEON
Dependents: mbed-os-example-cmsis_dsp_neon
Fork of mbed-dsp by
Information
Japanese version is available in lower part of this page.
このページの後半に日本語版が用意されています.
CMSIS-DSP of supporting NEON
What is this ?
A library for CMSIS-DSP of supporting NEON.
We supported the NEON to CMSIS-DSP Ver1.4.3(CMSIS V4.1) that ARM supplied, has achieved the processing speed improvement.
If you use the mbed-dsp library, you can use to replace this library.
CMSIS-DSP of supporting NEON is provied as a library.
Library Creation environment
CMSIS-DSP library of supporting NEON was created by the following environment.
- Compiler
ARMCC Version 5.03 - Compile option switch[C Compiler]
-DARM_MATH_MATRIX_CHECK -DARM_MATH_ROUNDING -O3 -Otime --cpu=Cortex-A9 --littleend --arm --apcs=/interwork --no_unaligned_access --fpu=vfpv3_fp16 --fpmode=fast --apcs=/hardfp --vectorize --asm
- Compile option switch[Assembler]
--cpreproc --cpu=Cortex-A9 --littleend --arm --apcs=/interwork --no_unaligned_access --fpu=vfpv3_fp16 --fpmode=fast --apcs=/hardfp
Effects of NEON support
In the data which passes to each function, large size will be expected more effective than small size.
Also if the data is a multiple of 16, effect will be expected in every function in the CMSIS-DSP.
NEON対応CMSIS-DSP
概要
NEON対応したCMSIS-DSPのライブラリです。
ARM社提供のCMSIS-DSP Ver1.4.3(CMSIS V4.1)をターゲットにNEON対応を行ない、処理速度向上を実現しております。
mbed-dspライブラリを使用している場合は、本ライブラリに置き換えて使用することができます。
NEON対応したCMSIS-DSPはライブラリで提供します。
ライブラリ作成環境
NEON対応CMSIS-DSPライブラリは、以下の環境で作成しています。
- コンパイラ
ARMCC Version 5.03 - コンパイルオプションスイッチ[C Compiler]
-DARM_MATH_MATRIX_CHECK -DARM_MATH_ROUNDING -O3 -Otime --cpu=Cortex-A9 --littleend --arm --apcs=/interwork --no_unaligned_access --fpu=vfpv3_fp16 --fpmode=fast --apcs=/hardfp --vectorize --asm
- コンパイルオプションスイッチ[Assembler]
--cpreproc --cpu=Cortex-A9 --littleend --arm --apcs=/interwork --no_unaligned_access --fpu=vfpv3_fp16 --fpmode=fast --apcs=/hardfp
NEON対応による効果について
CMSIS-DSP内の各関数へ渡すデータは、小さいサイズよりも大きいサイズの方が効果が見込めます。
また、16の倍数のデータであれば、CMSIS-DSP内のどの関数でも効果が見込めます。
cmsis_dsp/TransformFunctions/arm_rfft_q31.c@2:da51fb522205, 2013-05-30 (annotated)
- Committer:
- emilmont
- Date:
- Thu May 30 17:10:11 2013 +0100
- Revision:
- 2:da51fb522205
- Parent:
- 1:fdd22bb7aa52
- Child:
- 3:7a284390b0ce
Keep "cmsis-dsp" module in synch with its source
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
emilmont | 1:fdd22bb7aa52 | 1 | /* ---------------------------------------------------------------------- |
emilmont | 1:fdd22bb7aa52 | 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. |
emilmont | 1:fdd22bb7aa52 | 3 | * |
emilmont | 1:fdd22bb7aa52 | 4 | * $Date: 15. February 2012 |
emilmont | 2:da51fb522205 | 5 | * $Revision: V1.1.0 |
emilmont | 1:fdd22bb7aa52 | 6 | * |
emilmont | 2:da51fb522205 | 7 | * Project: CMSIS DSP Library |
emilmont | 2:da51fb522205 | 8 | * Title: arm_rfft_q31.c |
emilmont | 1:fdd22bb7aa52 | 9 | * |
emilmont | 2:da51fb522205 | 10 | * Description: RFFT & RIFFT Q31 process function |
emilmont | 1:fdd22bb7aa52 | 11 | * |
emilmont | 1:fdd22bb7aa52 | 12 | * |
emilmont | 1:fdd22bb7aa52 | 13 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 |
emilmont | 1:fdd22bb7aa52 | 14 | * |
emilmont | 1:fdd22bb7aa52 | 15 | * Version 1.1.0 2012/02/15 |
emilmont | 1:fdd22bb7aa52 | 16 | * Updated with more optimizations, bug fixes and minor API changes. |
emilmont | 1:fdd22bb7aa52 | 17 | * |
emilmont | 1:fdd22bb7aa52 | 18 | * Version 1.0.10 2011/7/15 |
emilmont | 1:fdd22bb7aa52 | 19 | * Big Endian support added and Merged M0 and M3/M4 Source code. |
emilmont | 1:fdd22bb7aa52 | 20 | * |
emilmont | 1:fdd22bb7aa52 | 21 | * Version 1.0.3 2010/11/29 |
emilmont | 1:fdd22bb7aa52 | 22 | * Re-organized the CMSIS folders and updated documentation. |
emilmont | 1:fdd22bb7aa52 | 23 | * |
emilmont | 1:fdd22bb7aa52 | 24 | * Version 1.0.2 2010/11/11 |
emilmont | 1:fdd22bb7aa52 | 25 | * Documentation updated. |
emilmont | 1:fdd22bb7aa52 | 26 | * |
emilmont | 1:fdd22bb7aa52 | 27 | * Version 1.0.1 2010/10/05 |
emilmont | 1:fdd22bb7aa52 | 28 | * Production release and review comments incorporated. |
emilmont | 1:fdd22bb7aa52 | 29 | * |
emilmont | 1:fdd22bb7aa52 | 30 | * Version 1.0.0 2010/09/20 |
emilmont | 1:fdd22bb7aa52 | 31 | * Production release and review comments incorporated. |
emilmont | 1:fdd22bb7aa52 | 32 | * |
emilmont | 1:fdd22bb7aa52 | 33 | * Version 0.0.7 2010/06/10 |
emilmont | 1:fdd22bb7aa52 | 34 | * Misra-C changes done |
emilmont | 1:fdd22bb7aa52 | 35 | * -------------------------------------------------------------------- */ |
emilmont | 1:fdd22bb7aa52 | 36 | |
emilmont | 1:fdd22bb7aa52 | 37 | #include "arm_math.h" |
emilmont | 1:fdd22bb7aa52 | 38 | |
emilmont | 1:fdd22bb7aa52 | 39 | /*-------------------------------------------------------------------- |
emilmont | 2:da51fb522205 | 40 | * Internal functions prototypes |
emilmont | 1:fdd22bb7aa52 | 41 | --------------------------------------------------------------------*/ |
emilmont | 1:fdd22bb7aa52 | 42 | |
emilmont | 1:fdd22bb7aa52 | 43 | void arm_split_rfft_q31( |
emilmont | 1:fdd22bb7aa52 | 44 | q31_t * pSrc, |
emilmont | 1:fdd22bb7aa52 | 45 | uint32_t fftLen, |
emilmont | 1:fdd22bb7aa52 | 46 | q31_t * pATable, |
emilmont | 1:fdd22bb7aa52 | 47 | q31_t * pBTable, |
emilmont | 1:fdd22bb7aa52 | 48 | q31_t * pDst, |
emilmont | 1:fdd22bb7aa52 | 49 | uint32_t modifier); |
emilmont | 1:fdd22bb7aa52 | 50 | |
emilmont | 1:fdd22bb7aa52 | 51 | void arm_split_rifft_q31( |
emilmont | 1:fdd22bb7aa52 | 52 | q31_t * pSrc, |
emilmont | 1:fdd22bb7aa52 | 53 | uint32_t fftLen, |
emilmont | 1:fdd22bb7aa52 | 54 | q31_t * pATable, |
emilmont | 1:fdd22bb7aa52 | 55 | q31_t * pBTable, |
emilmont | 1:fdd22bb7aa52 | 56 | q31_t * pDst, |
emilmont | 1:fdd22bb7aa52 | 57 | uint32_t modifier); |
emilmont | 1:fdd22bb7aa52 | 58 | |
emilmont | 1:fdd22bb7aa52 | 59 | /** |
emilmont | 1:fdd22bb7aa52 | 60 | * @addtogroup RFFT_RIFFT |
emilmont | 1:fdd22bb7aa52 | 61 | * @{ |
emilmont | 1:fdd22bb7aa52 | 62 | */ |
emilmont | 1:fdd22bb7aa52 | 63 | |
emilmont | 1:fdd22bb7aa52 | 64 | /** |
emilmont | 1:fdd22bb7aa52 | 65 | * @brief Processing function for the Q31 RFFT/RIFFT. |
emilmont | 1:fdd22bb7aa52 | 66 | * @param[in] *S points to an instance of the Q31 RFFT/RIFFT structure. |
emilmont | 1:fdd22bb7aa52 | 67 | * @param[in] *pSrc points to the input buffer. |
emilmont | 1:fdd22bb7aa52 | 68 | * @param[out] *pDst points to the output buffer. |
emilmont | 1:fdd22bb7aa52 | 69 | * @return none. |
emilmont | 1:fdd22bb7aa52 | 70 | * |
emilmont | 1:fdd22bb7aa52 | 71 | * \par Input an output formats: |
emilmont | 1:fdd22bb7aa52 | 72 | * \par |
emilmont | 1:fdd22bb7aa52 | 73 | * Internally input is downscaled by 2 for every stage to avoid saturations inside CFFT/CIFFT process. |
emilmont | 1:fdd22bb7aa52 | 74 | * Hence the output format is different for different RFFT sizes. |
emilmont | 1:fdd22bb7aa52 | 75 | * 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: |
emilmont | 1:fdd22bb7aa52 | 76 | * \par |
emilmont | 1:fdd22bb7aa52 | 77 | * \image html RFFTQ31.gif "Input and Output Formats for Q31 RFFT" |
emilmont | 1:fdd22bb7aa52 | 78 | * |
emilmont | 1:fdd22bb7aa52 | 79 | * \par |
emilmont | 1:fdd22bb7aa52 | 80 | * \image html RIFFTQ31.gif "Input and Output Formats for Q31 RIFFT" |
emilmont | 1:fdd22bb7aa52 | 81 | */ |
emilmont | 1:fdd22bb7aa52 | 82 | |
emilmont | 1:fdd22bb7aa52 | 83 | void arm_rfft_q31( |
emilmont | 1:fdd22bb7aa52 | 84 | const arm_rfft_instance_q31 * S, |
emilmont | 1:fdd22bb7aa52 | 85 | q31_t * pSrc, |
emilmont | 1:fdd22bb7aa52 | 86 | q31_t * pDst) |
emilmont | 1:fdd22bb7aa52 | 87 | { |
emilmont | 1:fdd22bb7aa52 | 88 | const arm_cfft_radix4_instance_q31 *S_CFFT = S->pCfft; |
emilmont | 1:fdd22bb7aa52 | 89 | |
emilmont | 1:fdd22bb7aa52 | 90 | /* Calculation of RIFFT of input */ |
emilmont | 1:fdd22bb7aa52 | 91 | if(S->ifftFlagR == 1u) |
emilmont | 1:fdd22bb7aa52 | 92 | { |
emilmont | 1:fdd22bb7aa52 | 93 | /* Real IFFT core process */ |
emilmont | 1:fdd22bb7aa52 | 94 | arm_split_rifft_q31(pSrc, S->fftLenBy2, S->pTwiddleAReal, |
emilmont | 1:fdd22bb7aa52 | 95 | S->pTwiddleBReal, pDst, S->twidCoefRModifier); |
emilmont | 1:fdd22bb7aa52 | 96 | |
emilmont | 1:fdd22bb7aa52 | 97 | /* Complex readix-4 IFFT process */ |
emilmont | 1:fdd22bb7aa52 | 98 | arm_radix4_butterfly_inverse_q31(pDst, S_CFFT->fftLen, |
emilmont | 1:fdd22bb7aa52 | 99 | S_CFFT->pTwiddle, |
emilmont | 1:fdd22bb7aa52 | 100 | S_CFFT->twidCoefModifier); |
emilmont | 1:fdd22bb7aa52 | 101 | /* Bit reversal process */ |
emilmont | 1:fdd22bb7aa52 | 102 | if(S->bitReverseFlagR == 1u) |
emilmont | 1:fdd22bb7aa52 | 103 | { |
emilmont | 1:fdd22bb7aa52 | 104 | arm_bitreversal_q31(pDst, S_CFFT->fftLen, |
emilmont | 1:fdd22bb7aa52 | 105 | S_CFFT->bitRevFactor, S_CFFT->pBitRevTable); |
emilmont | 1:fdd22bb7aa52 | 106 | } |
emilmont | 1:fdd22bb7aa52 | 107 | } |
emilmont | 1:fdd22bb7aa52 | 108 | else |
emilmont | 1:fdd22bb7aa52 | 109 | { |
emilmont | 1:fdd22bb7aa52 | 110 | /* Calculation of RFFT of input */ |
emilmont | 1:fdd22bb7aa52 | 111 | |
emilmont | 1:fdd22bb7aa52 | 112 | /* Complex readix-4 FFT process */ |
emilmont | 1:fdd22bb7aa52 | 113 | arm_radix4_butterfly_q31(pSrc, S_CFFT->fftLen, |
emilmont | 1:fdd22bb7aa52 | 114 | S_CFFT->pTwiddle, S_CFFT->twidCoefModifier); |
emilmont | 1:fdd22bb7aa52 | 115 | |
emilmont | 1:fdd22bb7aa52 | 116 | /* Bit reversal process */ |
emilmont | 1:fdd22bb7aa52 | 117 | if(S->bitReverseFlagR == 1u) |
emilmont | 1:fdd22bb7aa52 | 118 | { |
emilmont | 1:fdd22bb7aa52 | 119 | arm_bitreversal_q31(pSrc, S_CFFT->fftLen, |
emilmont | 1:fdd22bb7aa52 | 120 | S_CFFT->bitRevFactor, S_CFFT->pBitRevTable); |
emilmont | 1:fdd22bb7aa52 | 121 | } |
emilmont | 1:fdd22bb7aa52 | 122 | |
emilmont | 1:fdd22bb7aa52 | 123 | /* Real FFT core process */ |
emilmont | 1:fdd22bb7aa52 | 124 | arm_split_rfft_q31(pSrc, S->fftLenBy2, S->pTwiddleAReal, |
emilmont | 1:fdd22bb7aa52 | 125 | S->pTwiddleBReal, pDst, S->twidCoefRModifier); |
emilmont | 1:fdd22bb7aa52 | 126 | } |
emilmont | 1:fdd22bb7aa52 | 127 | |
emilmont | 1:fdd22bb7aa52 | 128 | } |
emilmont | 1:fdd22bb7aa52 | 129 | |
emilmont | 1:fdd22bb7aa52 | 130 | |
emilmont | 1:fdd22bb7aa52 | 131 | /** |
emilmont | 1:fdd22bb7aa52 | 132 | * @} end of RFFT_RIFFT group |
emilmont | 1:fdd22bb7aa52 | 133 | */ |
emilmont | 1:fdd22bb7aa52 | 134 | |
emilmont | 1:fdd22bb7aa52 | 135 | /** |
emilmont | 1:fdd22bb7aa52 | 136 | * @brief Core Real FFT process |
emilmont | 2:da51fb522205 | 137 | * @param[in] *pSrc points to the input buffer. |
emilmont | 2:da51fb522205 | 138 | * @param[in] fftLen length of FFT. |
emilmont | 2:da51fb522205 | 139 | * @param[in] *pATable points to the twiddle Coef A buffer. |
emilmont | 2:da51fb522205 | 140 | * @param[in] *pBTable points to the twiddle Coef B buffer. |
emilmont | 2:da51fb522205 | 141 | * @param[out] *pDst points to the output buffer. |
emilmont | 2:da51fb522205 | 142 | * @param[in] modifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. |
emilmont | 1:fdd22bb7aa52 | 143 | * @return none. |
emilmont | 1:fdd22bb7aa52 | 144 | */ |
emilmont | 1:fdd22bb7aa52 | 145 | |
emilmont | 1:fdd22bb7aa52 | 146 | void arm_split_rfft_q31( |
emilmont | 1:fdd22bb7aa52 | 147 | q31_t * pSrc, |
emilmont | 1:fdd22bb7aa52 | 148 | uint32_t fftLen, |
emilmont | 1:fdd22bb7aa52 | 149 | q31_t * pATable, |
emilmont | 1:fdd22bb7aa52 | 150 | q31_t * pBTable, |
emilmont | 1:fdd22bb7aa52 | 151 | q31_t * pDst, |
emilmont | 1:fdd22bb7aa52 | 152 | uint32_t modifier) |
emilmont | 1:fdd22bb7aa52 | 153 | { |
emilmont | 1:fdd22bb7aa52 | 154 | uint32_t i; /* Loop Counter */ |
emilmont | 1:fdd22bb7aa52 | 155 | q31_t outR, outI; /* Temporary variables for output */ |
emilmont | 1:fdd22bb7aa52 | 156 | q31_t *pCoefA, *pCoefB; /* Temporary pointers for twiddle factors */ |
emilmont | 1:fdd22bb7aa52 | 157 | q31_t CoefA1, CoefA2, CoefB1; /* Temporary variables for twiddle coefficients */ |
emilmont | 1:fdd22bb7aa52 | 158 | q31_t *pOut1 = &pDst[2], *pOut2 = &pDst[(4u * fftLen) - 1u]; |
emilmont | 1:fdd22bb7aa52 | 159 | q31_t *pIn1 = &pSrc[2], *pIn2 = &pSrc[(2u * fftLen) - 1u]; |
emilmont | 1:fdd22bb7aa52 | 160 | |
emilmont | 1:fdd22bb7aa52 | 161 | /* Init coefficient pointers */ |
emilmont | 1:fdd22bb7aa52 | 162 | pCoefA = &pATable[modifier * 2u]; |
emilmont | 1:fdd22bb7aa52 | 163 | pCoefB = &pBTable[modifier * 2u]; |
emilmont | 1:fdd22bb7aa52 | 164 | |
emilmont | 1:fdd22bb7aa52 | 165 | i = fftLen - 1u; |
emilmont | 1:fdd22bb7aa52 | 166 | |
emilmont | 1:fdd22bb7aa52 | 167 | while(i > 0u) |
emilmont | 1:fdd22bb7aa52 | 168 | { |
emilmont | 1:fdd22bb7aa52 | 169 | /* |
emilmont | 1:fdd22bb7aa52 | 170 | outR = (pSrc[2 * i] * pATable[2 * i] - pSrc[2 * i + 1] * pATable[2 * i + 1] |
emilmont | 1:fdd22bb7aa52 | 171 | + pSrc[2 * n - 2 * i] * pBTable[2 * i] + |
emilmont | 1:fdd22bb7aa52 | 172 | pSrc[2 * n - 2 * i + 1] * pBTable[2 * i + 1]); |
emilmont | 1:fdd22bb7aa52 | 173 | */ |
emilmont | 1:fdd22bb7aa52 | 174 | |
emilmont | 1:fdd22bb7aa52 | 175 | /* outI = (pIn[2 * i + 1] * pATable[2 * i] + pIn[2 * i] * pATable[2 * i + 1] + |
emilmont | 1:fdd22bb7aa52 | 176 | pIn[2 * n - 2 * i] * pBTable[2 * i + 1] - |
emilmont | 1:fdd22bb7aa52 | 177 | pIn[2 * n - 2 * i + 1] * pBTable[2 * i]); */ |
emilmont | 1:fdd22bb7aa52 | 178 | |
emilmont | 1:fdd22bb7aa52 | 179 | CoefA1 = *pCoefA++; |
emilmont | 1:fdd22bb7aa52 | 180 | CoefA2 = *pCoefA; |
emilmont | 1:fdd22bb7aa52 | 181 | |
emilmont | 1:fdd22bb7aa52 | 182 | /* outR = (pSrc[2 * i] * pATable[2 * i] */ |
emilmont | 1:fdd22bb7aa52 | 183 | outR = ((int32_t) (((q63_t) * pIn1 * CoefA1) >> 32)); |
emilmont | 1:fdd22bb7aa52 | 184 | |
emilmont | 1:fdd22bb7aa52 | 185 | /* outI = pIn[2 * i] * pATable[2 * i + 1] */ |
emilmont | 1:fdd22bb7aa52 | 186 | outI = ((int32_t) (((q63_t) * pIn1++ * CoefA2) >> 32)); |
emilmont | 1:fdd22bb7aa52 | 187 | |
emilmont | 1:fdd22bb7aa52 | 188 | /* - pSrc[2 * i + 1] * pATable[2 * i + 1] */ |
emilmont | 1:fdd22bb7aa52 | 189 | outR = |
emilmont | 1:fdd22bb7aa52 | 190 | (q31_t) ((((q63_t) outR << 32) + ((q63_t) * pIn1 * (-CoefA2))) >> 32); |
emilmont | 1:fdd22bb7aa52 | 191 | |
emilmont | 1:fdd22bb7aa52 | 192 | /* (pIn[2 * i + 1] * pATable[2 * i] */ |
emilmont | 1:fdd22bb7aa52 | 193 | outI = |
emilmont | 1:fdd22bb7aa52 | 194 | (q31_t) ((((q63_t) outI << 32) + ((q63_t) * pIn1++ * (CoefA1))) >> 32); |
emilmont | 1:fdd22bb7aa52 | 195 | |
emilmont | 1:fdd22bb7aa52 | 196 | /* pSrc[2 * n - 2 * i] * pBTable[2 * i] */ |
emilmont | 1:fdd22bb7aa52 | 197 | outR = |
emilmont | 1:fdd22bb7aa52 | 198 | (q31_t) ((((q63_t) outR << 32) + ((q63_t) * pIn2 * (-CoefA2))) >> 32); |
emilmont | 1:fdd22bb7aa52 | 199 | CoefB1 = *pCoefB; |
emilmont | 1:fdd22bb7aa52 | 200 | |
emilmont | 1:fdd22bb7aa52 | 201 | /* pIn[2 * n - 2 * i] * pBTable[2 * i + 1] */ |
emilmont | 1:fdd22bb7aa52 | 202 | outI = |
emilmont | 1:fdd22bb7aa52 | 203 | (q31_t) ((((q63_t) outI << 32) + ((q63_t) * pIn2-- * (-CoefB1))) >> 32); |
emilmont | 1:fdd22bb7aa52 | 204 | |
emilmont | 1:fdd22bb7aa52 | 205 | /* pSrc[2 * n - 2 * i + 1] * pBTable[2 * i + 1] */ |
emilmont | 1:fdd22bb7aa52 | 206 | outR = |
emilmont | 1:fdd22bb7aa52 | 207 | (q31_t) ((((q63_t) outR << 32) + ((q63_t) * pIn2 * (CoefB1))) >> 32); |
emilmont | 1:fdd22bb7aa52 | 208 | |
emilmont | 1:fdd22bb7aa52 | 209 | /* pIn[2 * n - 2 * i + 1] * pBTable[2 * i] */ |
emilmont | 1:fdd22bb7aa52 | 210 | outI = |
emilmont | 1:fdd22bb7aa52 | 211 | (q31_t) ((((q63_t) outI << 32) + ((q63_t) * pIn2-- * (-CoefA2))) >> 32); |
emilmont | 1:fdd22bb7aa52 | 212 | |
emilmont | 1:fdd22bb7aa52 | 213 | /* write output */ |
emilmont | 1:fdd22bb7aa52 | 214 | *pOut1++ = (outR << 1u); |
emilmont | 1:fdd22bb7aa52 | 215 | *pOut1++ = (outI << 1u); |
emilmont | 1:fdd22bb7aa52 | 216 | |
emilmont | 1:fdd22bb7aa52 | 217 | /* write complex conjugate output */ |
emilmont | 1:fdd22bb7aa52 | 218 | *pOut2-- = -(outI << 1u); |
emilmont | 1:fdd22bb7aa52 | 219 | *pOut2-- = (outR << 1u); |
emilmont | 1:fdd22bb7aa52 | 220 | |
emilmont | 1:fdd22bb7aa52 | 221 | /* update coefficient pointer */ |
emilmont | 1:fdd22bb7aa52 | 222 | pCoefB = pCoefB + (modifier * 2u); |
emilmont | 1:fdd22bb7aa52 | 223 | pCoefA = pCoefA + ((modifier * 2u) - 1u); |
emilmont | 1:fdd22bb7aa52 | 224 | |
emilmont | 1:fdd22bb7aa52 | 225 | i--; |
emilmont | 1:fdd22bb7aa52 | 226 | |
emilmont | 1:fdd22bb7aa52 | 227 | } |
emilmont | 1:fdd22bb7aa52 | 228 | |
emilmont | 1:fdd22bb7aa52 | 229 | pDst[2u * fftLen] = pSrc[0] - pSrc[1]; |
emilmont | 1:fdd22bb7aa52 | 230 | pDst[(2u * fftLen) + 1u] = 0; |
emilmont | 1:fdd22bb7aa52 | 231 | |
emilmont | 1:fdd22bb7aa52 | 232 | pDst[0] = pSrc[0] + pSrc[1]; |
emilmont | 1:fdd22bb7aa52 | 233 | pDst[1] = 0; |
emilmont | 1:fdd22bb7aa52 | 234 | |
emilmont | 1:fdd22bb7aa52 | 235 | } |
emilmont | 1:fdd22bb7aa52 | 236 | |
emilmont | 1:fdd22bb7aa52 | 237 | |
emilmont | 1:fdd22bb7aa52 | 238 | /** |
emilmont | 1:fdd22bb7aa52 | 239 | * @brief Core Real IFFT process |
emilmont | 2:da51fb522205 | 240 | * @param[in] *pSrc points to the input buffer. |
emilmont | 2:da51fb522205 | 241 | * @param[in] fftLen length of FFT. |
emilmont | 2:da51fb522205 | 242 | * @param[in] *pATable points to the twiddle Coef A buffer. |
emilmont | 2:da51fb522205 | 243 | * @param[in] *pBTable points to the twiddle Coef B buffer. |
emilmont | 2:da51fb522205 | 244 | * @param[out] *pDst points to the output buffer. |
emilmont | 2:da51fb522205 | 245 | * @param[in] modifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. |
emilmont | 1:fdd22bb7aa52 | 246 | * @return none. |
emilmont | 1:fdd22bb7aa52 | 247 | */ |
emilmont | 1:fdd22bb7aa52 | 248 | |
emilmont | 1:fdd22bb7aa52 | 249 | void arm_split_rifft_q31( |
emilmont | 1:fdd22bb7aa52 | 250 | q31_t * pSrc, |
emilmont | 1:fdd22bb7aa52 | 251 | uint32_t fftLen, |
emilmont | 1:fdd22bb7aa52 | 252 | q31_t * pATable, |
emilmont | 1:fdd22bb7aa52 | 253 | q31_t * pBTable, |
emilmont | 1:fdd22bb7aa52 | 254 | q31_t * pDst, |
emilmont | 1:fdd22bb7aa52 | 255 | uint32_t modifier) |
emilmont | 1:fdd22bb7aa52 | 256 | { |
emilmont | 1:fdd22bb7aa52 | 257 | q31_t outR, outI; /* Temporary variables for output */ |
emilmont | 1:fdd22bb7aa52 | 258 | q31_t *pCoefA, *pCoefB; /* Temporary pointers for twiddle factors */ |
emilmont | 1:fdd22bb7aa52 | 259 | q31_t CoefA1, CoefA2, CoefB1; /* Temporary variables for twiddle coefficients */ |
emilmont | 1:fdd22bb7aa52 | 260 | q31_t *pIn1 = &pSrc[0], *pIn2 = &pSrc[(2u * fftLen) + 1u]; |
emilmont | 1:fdd22bb7aa52 | 261 | |
emilmont | 1:fdd22bb7aa52 | 262 | pCoefA = &pATable[0]; |
emilmont | 1:fdd22bb7aa52 | 263 | pCoefB = &pBTable[0]; |
emilmont | 1:fdd22bb7aa52 | 264 | |
emilmont | 1:fdd22bb7aa52 | 265 | while(fftLen > 0u) |
emilmont | 1:fdd22bb7aa52 | 266 | { |
emilmont | 1:fdd22bb7aa52 | 267 | /* |
emilmont | 1:fdd22bb7aa52 | 268 | outR = (pIn[2 * i] * pATable[2 * i] + pIn[2 * i + 1] * pATable[2 * i + 1] + |
emilmont | 1:fdd22bb7aa52 | 269 | pIn[2 * n - 2 * i] * pBTable[2 * i] - |
emilmont | 1:fdd22bb7aa52 | 270 | pIn[2 * n - 2 * i + 1] * pBTable[2 * i + 1]); |
emilmont | 1:fdd22bb7aa52 | 271 | |
emilmont | 1:fdd22bb7aa52 | 272 | outI = (pIn[2 * i + 1] * pATable[2 * i] - pIn[2 * i] * pATable[2 * i + 1] - |
emilmont | 1:fdd22bb7aa52 | 273 | pIn[2 * n - 2 * i] * pBTable[2 * i + 1] - |
emilmont | 1:fdd22bb7aa52 | 274 | pIn[2 * n - 2 * i + 1] * pBTable[2 * i]); |
emilmont | 1:fdd22bb7aa52 | 275 | |
emilmont | 1:fdd22bb7aa52 | 276 | */ |
emilmont | 1:fdd22bb7aa52 | 277 | CoefA1 = *pCoefA++; |
emilmont | 1:fdd22bb7aa52 | 278 | CoefA2 = *pCoefA; |
emilmont | 1:fdd22bb7aa52 | 279 | |
emilmont | 1:fdd22bb7aa52 | 280 | /* outR = (pIn[2 * i] * pATable[2 * i] */ |
emilmont | 1:fdd22bb7aa52 | 281 | outR = ((int32_t) (((q63_t) * pIn1 * CoefA1) >> 32)); |
emilmont | 1:fdd22bb7aa52 | 282 | |
emilmont | 1:fdd22bb7aa52 | 283 | /* - pIn[2 * i] * pATable[2 * i + 1] */ |
emilmont | 1:fdd22bb7aa52 | 284 | outI = -((int32_t) (((q63_t) * pIn1++ * CoefA2) >> 32)); |
emilmont | 1:fdd22bb7aa52 | 285 | |
emilmont | 1:fdd22bb7aa52 | 286 | /* pIn[2 * i + 1] * pATable[2 * i + 1] */ |
emilmont | 1:fdd22bb7aa52 | 287 | outR = |
emilmont | 1:fdd22bb7aa52 | 288 | (q31_t) ((((q63_t) outR << 32) + ((q63_t) * pIn1 * (CoefA2))) >> 32); |
emilmont | 1:fdd22bb7aa52 | 289 | |
emilmont | 1:fdd22bb7aa52 | 290 | /* pIn[2 * i + 1] * pATable[2 * i] */ |
emilmont | 1:fdd22bb7aa52 | 291 | outI = |
emilmont | 1:fdd22bb7aa52 | 292 | (q31_t) ((((q63_t) outI << 32) + ((q63_t) * pIn1++ * (CoefA1))) >> 32); |
emilmont | 1:fdd22bb7aa52 | 293 | |
emilmont | 1:fdd22bb7aa52 | 294 | /* pIn[2 * n - 2 * i] * pBTable[2 * i] */ |
emilmont | 1:fdd22bb7aa52 | 295 | outR = |
emilmont | 1:fdd22bb7aa52 | 296 | (q31_t) ((((q63_t) outR << 32) + ((q63_t) * pIn2 * (CoefA2))) >> 32); |
emilmont | 1:fdd22bb7aa52 | 297 | |
emilmont | 1:fdd22bb7aa52 | 298 | CoefB1 = *pCoefB; |
emilmont | 1:fdd22bb7aa52 | 299 | |
emilmont | 1:fdd22bb7aa52 | 300 | /* pIn[2 * n - 2 * i] * pBTable[2 * i + 1] */ |
emilmont | 1:fdd22bb7aa52 | 301 | outI = |
emilmont | 1:fdd22bb7aa52 | 302 | (q31_t) ((((q63_t) outI << 32) - ((q63_t) * pIn2-- * (CoefB1))) >> 32); |
emilmont | 1:fdd22bb7aa52 | 303 | |
emilmont | 1:fdd22bb7aa52 | 304 | /* pIn[2 * n - 2 * i + 1] * pBTable[2 * i + 1] */ |
emilmont | 1:fdd22bb7aa52 | 305 | outR = |
emilmont | 1:fdd22bb7aa52 | 306 | (q31_t) ((((q63_t) outR << 32) + ((q63_t) * pIn2 * (CoefB1))) >> 32); |
emilmont | 1:fdd22bb7aa52 | 307 | |
emilmont | 1:fdd22bb7aa52 | 308 | /* pIn[2 * n - 2 * i + 1] * pBTable[2 * i] */ |
emilmont | 1:fdd22bb7aa52 | 309 | outI = |
emilmont | 1:fdd22bb7aa52 | 310 | (q31_t) ((((q63_t) outI << 32) + ((q63_t) * pIn2-- * (CoefA2))) >> 32); |
emilmont | 1:fdd22bb7aa52 | 311 | |
emilmont | 1:fdd22bb7aa52 | 312 | /* write output */ |
emilmont | 1:fdd22bb7aa52 | 313 | *pDst++ = (outR << 1u); |
emilmont | 1:fdd22bb7aa52 | 314 | *pDst++ = (outI << 1u); |
emilmont | 1:fdd22bb7aa52 | 315 | |
emilmont | 1:fdd22bb7aa52 | 316 | /* update coefficient pointer */ |
emilmont | 1:fdd22bb7aa52 | 317 | pCoefB = pCoefB + (modifier * 2u); |
emilmont | 1:fdd22bb7aa52 | 318 | pCoefA = pCoefA + ((modifier * 2u) - 1u); |
emilmont | 1:fdd22bb7aa52 | 319 | |
emilmont | 1:fdd22bb7aa52 | 320 | /* Decrement loop count */ |
emilmont | 1:fdd22bb7aa52 | 321 | fftLen--; |
emilmont | 1:fdd22bb7aa52 | 322 | |
emilmont | 1:fdd22bb7aa52 | 323 | } |
emilmont | 1:fdd22bb7aa52 | 324 | |
emilmont | 1:fdd22bb7aa52 | 325 | |
emilmont | 1:fdd22bb7aa52 | 326 | } |