• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* ----------------------------------------------------------------------
2  * Project:      CMSIS DSP Library
3  * Title:        arm_bitreversal_f16.c
4  * Description:  Bitreversal functions
5  *
6  * $Date:        23 April 2021
7  * $Revision:    V1.9.0
8  *
9  * Target Processor: Cortex-M and Cortex-A cores
10  * -------------------------------------------------------------------- */
11 /*
12  * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved.
13  *
14  * SPDX-License-Identifier: Apache-2.0
15  *
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
19  *
20  * www.apache.org/licenses/LICENSE-2.0
21  *
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.
27  */
28 
29 #include "dsp/transform_functions_f16.h"
30 
31 /*
32 * @brief  In-place bit reversal function.
33 * @param[in, out] *pSrc        points to the in-place buffer of floating-point data type.
34 * @param[in]      fftSize      length of the FFT.
35 * @param[in]      bitRevFactor bit reversal modifier that supports different size FFTs with the same bit reversal table.
36 * @param[in]      *pBitRevTab  points to the bit reversal table.
37 * @return none.
38 */
39 
40 #if defined(ARM_FLOAT16_SUPPORTED)
41 
arm_bitreversal_f16(float16_t * pSrc,uint16_t fftSize,uint16_t bitRevFactor,const uint16_t * pBitRevTab)42 void arm_bitreversal_f16(
43 float16_t * pSrc,
44 uint16_t fftSize,
45 uint16_t bitRevFactor,
46 const uint16_t * pBitRevTab)
47 {
48    uint16_t fftLenBy2, fftLenBy2p1;
49    uint16_t i, j;
50    float16_t in;
51 
52    /*  Initializations */
53    j = 0U;
54    fftLenBy2 = fftSize >> 1U;
55    fftLenBy2p1 = (fftSize >> 1U) + 1U;
56 
57    /* Bit Reversal Implementation */
58    for (i = 0U; i <= (fftLenBy2 - 2U); i += 2U)
59    {
60       if (i < j)
61       {
62          /*  pSrc[i] <-> pSrc[j]; */
63          in = pSrc[2U * i];
64          pSrc[2U * i] = pSrc[2U * j];
65          pSrc[2U * j] = in;
66 
67          /*  pSrc[i+1U] <-> pSrc[j+1U] */
68          in = pSrc[(2U * i) + 1U];
69          pSrc[(2U * i) + 1U] = pSrc[(2U * j) + 1U];
70          pSrc[(2U * j) + 1U] = in;
71 
72          /*  pSrc[i+fftLenBy2p1] <-> pSrc[j+fftLenBy2p1] */
73          in = pSrc[2U * (i + fftLenBy2p1)];
74          pSrc[2U * (i + fftLenBy2p1)] = pSrc[2U * (j + fftLenBy2p1)];
75          pSrc[2U * (j + fftLenBy2p1)] = in;
76 
77          /*  pSrc[i+fftLenBy2p1+1U] <-> pSrc[j+fftLenBy2p1+1U] */
78          in = pSrc[(2U * (i + fftLenBy2p1)) + 1U];
79          pSrc[(2U * (i + fftLenBy2p1)) + 1U] =
80          pSrc[(2U * (j + fftLenBy2p1)) + 1U];
81          pSrc[(2U * (j + fftLenBy2p1)) + 1U] = in;
82 
83       }
84 
85       /*  pSrc[i+1U] <-> pSrc[j+1U] */
86       in = pSrc[2U * (i + 1U)];
87       pSrc[2U * (i + 1U)] = pSrc[2U * (j + fftLenBy2)];
88       pSrc[2U * (j + fftLenBy2)] = in;
89 
90       /*  pSrc[i+2U] <-> pSrc[j+2U] */
91       in = pSrc[(2U * (i + 1U)) + 1U];
92       pSrc[(2U * (i + 1U)) + 1U] = pSrc[(2U * (j + fftLenBy2)) + 1U];
93       pSrc[(2U * (j + fftLenBy2)) + 1U] = in;
94 
95       /*  Reading the index for the bit reversal */
96       j = *pBitRevTab;
97 
98       /*  Updating the bit reversal index depending on the fft length  */
99       pBitRevTab += bitRevFactor;
100    }
101 }
102 #endif /* #if defined(ARM_FLOAT16_SUPPORTED) */