1 /* ----------------------------------------------------------------------
2 * Project: CMSIS DSP Library
3 * Title: arm_cfft_q31.c
4 * Description: Combined Radix Decimation in Frequency CFFT fixed point processing function
6 * $Date: 27. January 2017
9 * Target Processor: Cortex-M cores
10 * -------------------------------------------------------------------- */
12 * Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved.
14 * SPDX-License-Identifier: Apache-2.0
16 * Licensed under the Apache License, Version 2.0 (the License); you may
17 * not use this file except in compliance with the License.
18 * You may obtain a copy of the License at
20 * www.apache.org/licenses/LICENSE-2.0
22 * Unless required by applicable law or agreed to in writing, software
23 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
24 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25 * See the License for the specific language governing permissions and
26 * limitations under the License.
31 extern void arm_radix4_butterfly_q31(
35 uint32_t twidCoefModifier
);
37 extern void arm_radix4_butterfly_inverse_q31(
41 uint32_t twidCoefModifier
);
43 extern void arm_bitreversal_32(
45 const uint16_t bitRevLen
,
46 const uint16_t * pBitRevTable
);
48 void arm_cfft_radix4by2_q31(
53 void arm_cfft_radix4by2_inverse_q31(
59 * @ingroup groupTransforms
63 * @addtogroup ComplexFFT
69 * @brief Processing function for the fixed-point complex FFT in Q31 format.
70 * @param[in] *S points to an instance of the fixed-point CFFT structure.
71 * @param[in, out] *p1 points to the complex data buffer of size <code>2*fftLen</code>. Processing occurs in-place.
72 * @param[in] ifftFlag flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform.
73 * @param[in] bitReverseFlag flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output.
78 const arm_cfft_instance_q31
* S
,
81 uint8_t bitReverseFlag
)
83 uint32_t L
= S
->fftLen
;
94 arm_radix4_butterfly_inverse_q31 ( p1
, L
, (q31_t
*)S
->pTwiddle
, 1 );
101 arm_cfft_radix4by2_inverse_q31 ( p1
, L
, S
->pTwiddle
);
114 arm_radix4_butterfly_q31 ( p1
, L
, (q31_t
*)S
->pTwiddle
, 1 );
121 arm_cfft_radix4by2_q31 ( p1
, L
, S
->pTwiddle
);
126 if ( bitReverseFlag
)
127 arm_bitreversal_32((uint32_t*)p1
,S
->bitRevLength
,S
->pBitRevTable
);
131 * @} end of ComplexFFT group
134 void arm_cfft_radix4by2_q31(
141 q31_t xt
, yt
, cosVal
, sinVal
;
146 for (i
= 0; i
< n2
; i
++)
148 cosVal
= pCoef
[2*ia
];
149 sinVal
= pCoef
[2*ia
+ 1];
153 xt
= (pSrc
[2 * i
] >> 2) - (pSrc
[2 * l
] >> 2);
154 pSrc
[2 * i
] = (pSrc
[2 * i
] >> 2) + (pSrc
[2 * l
] >> 2);
156 yt
= (pSrc
[2 * i
+ 1] >> 2) - (pSrc
[2 * l
+ 1] >> 2);
157 pSrc
[2 * i
+ 1] = (pSrc
[2 * l
+ 1] >> 2) + (pSrc
[2 * i
+ 1] >> 2);
159 mult_32x32_keep32_R(p0
, xt
, cosVal
);
160 mult_32x32_keep32_R(p1
, yt
, cosVal
);
161 multAcc_32x32_keep32_R(p0
, yt
, sinVal
);
162 multSub_32x32_keep32_R(p1
, xt
, sinVal
);
164 pSrc
[2U * l
] = p0
<< 1;
165 pSrc
[2U * l
+ 1U] = p1
<< 1;
170 arm_radix4_butterfly_q31( pSrc
, n2
, (q31_t
*)pCoef
, 2U);
172 arm_radix4_butterfly_q31( pSrc
+ fftLen
, n2
, (q31_t
*)pCoef
, 2U);
174 for (i
= 0; i
< fftLen
>> 1; i
++)
194 void arm_cfft_radix4by2_inverse_q31(
201 q31_t xt
, yt
, cosVal
, sinVal
;
206 for (i
= 0; i
< n2
; i
++)
208 cosVal
= pCoef
[2*ia
];
209 sinVal
= pCoef
[2*ia
+ 1];
213 xt
= (pSrc
[2 * i
] >> 2) - (pSrc
[2 * l
] >> 2);
214 pSrc
[2 * i
] = (pSrc
[2 * i
] >> 2) + (pSrc
[2 * l
] >> 2);
216 yt
= (pSrc
[2 * i
+ 1] >> 2) - (pSrc
[2 * l
+ 1] >> 2);
217 pSrc
[2 * i
+ 1] = (pSrc
[2 * l
+ 1] >> 2) + (pSrc
[2 * i
+ 1] >> 2);
219 mult_32x32_keep32_R(p0
, xt
, cosVal
);
220 mult_32x32_keep32_R(p1
, yt
, cosVal
);
221 multSub_32x32_keep32_R(p0
, yt
, sinVal
);
222 multAcc_32x32_keep32_R(p1
, xt
, sinVal
);
224 pSrc
[2U * l
] = p0
<< 1;
225 pSrc
[2U * l
+ 1U] = p1
<< 1;
230 arm_radix4_butterfly_inverse_q31( pSrc
, n2
, (q31_t
*)pCoef
, 2U);
232 arm_radix4_butterfly_inverse_q31( pSrc
+ fftLen
, n2
, (q31_t
*)pCoef
, 2U);
234 for (i
= 0; i
< fftLen
>> 1; i
++)