123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917 |
- /* ----------------------------------------------------------------------
- * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
- *
- * $Date: 17. January 2013
- * $Revision: V1.4.1
- *
- * Project: CMSIS DSP Library
- * Title: arm_cfft_radix4_q15.c
- *
- * Description: This file has function definition of Radix-4 FFT & IFFT function and
- * In-place bit reversal using bit reversal table
- *
- * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * - Neither the name of ARM LIMITED nor the names of its contributors
- * may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- * -------------------------------------------------------------------- */
-
- #include "arm_math.h"
-
-
- void arm_radix4_butterfly_q15(
- q15_t * pSrc16,
- uint32_t fftLen,
- q15_t * pCoef16,
- uint32_t twidCoefModifier);
-
- void arm_radix4_butterfly_inverse_q15(
- q15_t * pSrc16,
- uint32_t fftLen,
- q15_t * pCoef16,
- uint32_t twidCoefModifier);
-
- void arm_bitreversal_q15(
- q15_t * pSrc,
- uint32_t fftLen,
- uint16_t bitRevFactor,
- uint16_t * pBitRevTab);
-
- /**
- * @ingroup groupTransforms
- */
-
- /**
- * @addtogroup ComplexFFT
- * @{
- */
-
-
- /**
- * @details
- * @brief Processing function for the Q15 CFFT/CIFFT.
- * @param[in] *S points to an instance of the Q15 CFFT/CIFFT structure.
- * @param[in, out] *pSrc points to the complex data buffer. Processing occurs in-place.
- * @return none.
- *
- * \par Input and output formats:
- * \par
- * Internally input is downscaled by 2 for every stage to avoid saturations inside CFFT/CIFFT process.
- * Hence the output format is different for different FFT sizes.
- * The input and output formats for different FFT sizes and number of bits to upscale are mentioned in the tables below for CFFT and CIFFT:
- * \par
- * \image html CFFTQ15.gif "Input and Output Formats for Q15 CFFT"
- * \image html CIFFTQ15.gif "Input and Output Formats for Q15 CIFFT"
- */
-
- void arm_cfft_radix4_q15(
- const arm_cfft_radix4_instance_q15 * S,
- q15_t * pSrc)
- {
- if(S->ifftFlag == 1u)
- {
- /* Complex IFFT radix-4 */
- arm_radix4_butterfly_inverse_q15(pSrc, S->fftLen, S->pTwiddle,
- S->twidCoefModifier);
- }
- else
- {
- /* Complex FFT radix-4 */
- arm_radix4_butterfly_q15(pSrc, S->fftLen, S->pTwiddle,
- S->twidCoefModifier);
- }
-
- if(S->bitReverseFlag == 1u)
- {
- /* Bit Reversal */
- arm_bitreversal_q15(pSrc, S->fftLen, S->bitRevFactor, S->pBitRevTable);
- }
-
- }
-
- /**
- * @} end of ComplexFFT group
- */
-
- /*
- * Radix-4 FFT algorithm used is :
- *
- * Input real and imaginary data:
- * x(n) = xa + j * ya
- * x(n+N/4 ) = xb + j * yb
- * x(n+N/2 ) = xc + j * yc
- * x(n+3N 4) = xd + j * yd
- *
- *
- * Output real and imaginary data:
- * x(4r) = xa'+ j * ya'
- * x(4r+1) = xb'+ j * yb'
- * x(4r+2) = xc'+ j * yc'
- * x(4r+3) = xd'+ j * yd'
- *
- *
- * Twiddle factors for radix-4 FFT:
- * Wn = co1 + j * (- si1)
- * W2n = co2 + j * (- si2)
- * W3n = co3 + j * (- si3)
-
- * The real and imaginary output values for the radix-4 butterfly are
- * xa' = xa + xb + xc + xd
- * ya' = ya + yb + yc + yd
- * xb' = (xa+yb-xc-yd)* co1 + (ya-xb-yc+xd)* (si1)
- * yb' = (ya-xb-yc+xd)* co1 - (xa+yb-xc-yd)* (si1)
- * xc' = (xa-xb+xc-xd)* co2 + (ya-yb+yc-yd)* (si2)
- * yc' = (ya-yb+yc-yd)* co2 - (xa-xb+xc-xd)* (si2)
- * xd' = (xa-yb-xc+yd)* co3 + (ya+xb-yc-xd)* (si3)
- * yd' = (ya+xb-yc-xd)* co3 - (xa-yb-xc+yd)* (si3)
- *
- */
-
- /**
- * @brief Core function for the Q15 CFFT butterfly process.
- * @param[in, out] *pSrc16 points to the in-place buffer of Q15 data type.
- * @param[in] fftLen length of the FFT.
- * @param[in] *pCoef16 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_radix4_butterfly_q15(
- q15_t * pSrc16,
- uint32_t fftLen,
- q15_t * pCoef16,
- uint32_t twidCoefModifier)
- {
-
- #ifndef ARM_MATH_CM0_FAMILY
-
- /* Run the below code for Cortex-M4 and Cortex-M3 */
-
- q31_t R, S, T, U;
- q31_t C1, C2, C3, out1, out2;
- uint32_t n1, n2, ic, i0, i1, i2, i3, j, k;
- q15_t in;
-
- q15_t *ptr1;
-
-
-
- q31_t xaya, xbyb, xcyc, xdyd;
-
- /* Total process is divided into three stages */
-
- /* process first stage, middle stages, & last stage */
-
- /* Initializations for the first stage */
- n2 = fftLen;
- n1 = n2;
-
- /* n2 = fftLen/4 */
- n2 >>= 2u;
-
- /* Index for twiddle coefficient */
- ic = 0u;
-
- /* Index for input read and output write */
- i0 = 0u;
- j = n2;
-
- /* Input is in 1.15(q15) format */
-
- /* start of first stage process */
- do
- {
- /* Butterfly implementation */
-
- /* index calculation for the input as, */
- /* pSrc16[i0 + 0], pSrc16[i0 + fftLen/4], pSrc16[i0 + fftLen/2], pSrc16[i0 + 3fftLen/4] */
- i1 = i0 + n2;
- i2 = i1 + n2;
- i3 = i2 + n2;
-
- /* Reading i0, i0+fftLen/2 inputs */
- /* Read ya (real), xa(imag) input */
- T = _SIMD32_OFFSET(pSrc16 + (2u * i0));
- in = ((int16_t) (T & 0xFFFF)) >> 2;
- T = ((T >> 2) & 0xFFFF0000) | (in & 0xFFFF);
-
- /* Read yc (real), xc(imag) input */
- S = _SIMD32_OFFSET(pSrc16 + (2u * i2));
- in = ((int16_t) (S & 0xFFFF)) >> 2;
- S = ((S >> 2) & 0xFFFF0000) | (in & 0xFFFF);
-
- /* R = packed((ya + yc), (xa + xc) ) */
- R = __QADD16(T, S);
-
- /* S = packed((ya - yc), (xa - xc) ) */
- S = __QSUB16(T, S);
-
- /* Reading i0+fftLen/4 , i0+3fftLen/4 inputs */
- /* Read yb (real), xb(imag) input */
- T = _SIMD32_OFFSET(pSrc16 + (2u * i1));
- in = ((int16_t) (T & 0xFFFF)) >> 2;
- T = ((T >> 2) & 0xFFFF0000) | (in & 0xFFFF);
-
- /* Read yd (real), xd(imag) input */
- U = _SIMD32_OFFSET(pSrc16 + (2u * i3));
- in = ((int16_t) (U & 0xFFFF)) >> 2;
- U = ((U >> 2) & 0xFFFF0000) | (in & 0xFFFF);
-
- /* T = packed((yb + yd), (xb + xd) ) */
- T = __QADD16(T, U);
-
- /* writing the butterfly processed i0 sample */
- /* xa' = xa + xb + xc + xd */
- /* ya' = ya + yb + yc + yd */
- _SIMD32_OFFSET(pSrc16 + (2u * i0)) = __SHADD16(R, T);
-
- /* R = packed((ya + yc) - (yb + yd), (xa + xc)- (xb + xd)) */
- R = __QSUB16(R, T);
-
- /* co2 & si2 are read from SIMD Coefficient pointer */
- C2 = _SIMD32_OFFSET(pCoef16 + (4u * ic));
-
- #ifndef ARM_MATH_BIG_ENDIAN
-
- /* xc' = (xa-xb+xc-xd)* co2 + (ya-yb+yc-yd)* (si2) */
- out1 = __SMUAD(C2, R) >> 16u;
- /* yc' = (ya-yb+yc-yd)* co2 - (xa-xb+xc-xd)* (si2) */
- out2 = __SMUSDX(C2, R);
-
- #else
-
- /* xc' = (ya-yb+yc-yd)* co2 - (xa-xb+xc-xd)* (si2) */
- out1 = __SMUSDX(R, C2) >> 16u;
- /* yc' = (xa-xb+xc-xd)* co2 + (ya-yb+yc-yd)* (si2) */
- out2 = __SMUAD(C2, R);
-
- #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
-
- /* Reading i0+fftLen/4 */
- /* T = packed(yb, xb) */
- T = _SIMD32_OFFSET(pSrc16 + (2u * i1));
- in = ((int16_t) (T & 0xFFFF)) >> 2;
- T = ((T >> 2) & 0xFFFF0000) | (in & 0xFFFF);
-
- /* writing the butterfly processed i0 + fftLen/4 sample */
- /* writing output(xc', yc') in little endian format */
- _SIMD32_OFFSET(pSrc16 + (2u * i1)) =
- (q31_t) ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF);
-
- /* Butterfly calculations */
- /* U = packed(yd, xd) */
- U = _SIMD32_OFFSET(pSrc16 + (2u * i3));
- in = ((int16_t) (U & 0xFFFF)) >> 2;
- U = ((U >> 2) & 0xFFFF0000) | (in & 0xFFFF);
-
- /* T = packed(yb-yd, xb-xd) */
- T = __QSUB16(T, U);
-
- #ifndef ARM_MATH_BIG_ENDIAN
-
- /* R = packed((ya-yc) + (xb- xd) , (xa-xc) - (yb-yd)) */
- R = __QASX(S, T);
- /* S = packed((ya-yc) - (xb- xd), (xa-xc) + (yb-yd)) */
- S = __QSAX(S, T);
-
- #else
-
- /* R = packed((ya-yc) + (xb- xd) , (xa-xc) - (yb-yd)) */
- R = __QSAX(S, T);
- /* S = packed((ya-yc) - (xb- xd), (xa-xc) + (yb-yd)) */
- S = __QASX(S, T);
-
- #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
-
- /* co1 & si1 are read from SIMD Coefficient pointer */
- C1 = _SIMD32_OFFSET(pCoef16 + (2u * ic));
- /* Butterfly process for the i0+fftLen/2 sample */
-
- #ifndef ARM_MATH_BIG_ENDIAN
-
- /* xb' = (xa+yb-xc-yd)* co1 + (ya-xb-yc+xd)* (si1) */
- out1 = __SMUAD(C1, S) >> 16u;
- /* yb' = (ya-xb-yc+xd)* co1 - (xa+yb-xc-yd)* (si1) */
- out2 = __SMUSDX(C1, S);
-
- #else
-
- /* xb' = (ya-xb-yc+xd)* co1 - (xa+yb-xc-yd)* (si1) */
- out1 = __SMUSDX(S, C1) >> 16u;
- /* yb' = (xa+yb-xc-yd)* co1 + (ya-xb-yc+xd)* (si1) */
- out2 = __SMUAD(C1, S);
-
- #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
-
- /* writing output(xb', yb') in little endian format */
- _SIMD32_OFFSET(pSrc16 + (2u * i2)) =
- ((out2) & 0xFFFF0000) | ((out1) & 0x0000FFFF);
-
-
- /* co3 & si3 are read from SIMD Coefficient pointer */
- C3 = _SIMD32_OFFSET(pCoef16 + (6u * ic));
- /* Butterfly process for the i0+3fftLen/4 sample */
-
- #ifndef ARM_MATH_BIG_ENDIAN
-
- /* xd' = (xa-yb-xc+yd)* co3 + (ya+xb-yc-xd)* (si3) */
- out1 = __SMUAD(C3, R) >> 16u;
- /* yd' = (ya+xb-yc-xd)* co3 - (xa-yb-xc+yd)* (si3) */
- out2 = __SMUSDX(C3, R);
-
- #else
-
- /* xd' = (ya+xb-yc-xd)* co3 - (xa-yb-xc+yd)* (si3) */
- out1 = __SMUSDX(R, C3) >> 16u;
- /* yd' = (xa-yb-xc+yd)* co3 + (ya+xb-yc-xd)* (si3) */
- out2 = __SMUAD(C3, R);
-
- #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
-
- /* writing output(xd', yd') in little endian format */
- _SIMD32_OFFSET(pSrc16 + (2u * i3)) =
- ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF);
-
- /* Twiddle coefficients index modifier */
- ic = ic + twidCoefModifier;
-
- /* Updating input index */
- i0 = i0 + 1u;
-
- } while(--j);
- /* data is in 4.11(q11) format */
-
- /* end of first stage process */
-
-
- /* start of middle stage process */
-
- /* Twiddle coefficients index modifier */
- twidCoefModifier <<= 2u;
-
- /* Calculation of Middle stage */
- for (k = fftLen / 4u; k > 4u; k >>= 2u)
- {
- /* Initializations for the middle stage */
- n1 = n2;
- n2 >>= 2u;
- ic = 0u;
-
- for (j = 0u; j <= (n2 - 1u); j++)
- {
- /* index calculation for the coefficients */
- C1 = _SIMD32_OFFSET(pCoef16 + (2u * ic));
- C2 = _SIMD32_OFFSET(pCoef16 + (4u * ic));
- C3 = _SIMD32_OFFSET(pCoef16 + (6u * ic));
-
- /* Twiddle coefficients index modifier */
- ic = ic + twidCoefModifier;
-
- /* Butterfly implementation */
- for (i0 = j; i0 < fftLen; i0 += n1)
- {
- /* index calculation for the input as, */
- /* pSrc16[i0 + 0], pSrc16[i0 + fftLen/4], pSrc16[i0 + fftLen/2], pSrc16[i0 + 3fftLen/4] */
- i1 = i0 + n2;
- i2 = i1 + n2;
- i3 = i2 + n2;
-
- /* Reading i0, i0+fftLen/2 inputs */
- /* Read ya (real), xa(imag) input */
- T = _SIMD32_OFFSET(pSrc16 + (2u * i0));
-
- /* Read yc (real), xc(imag) input */
- S = _SIMD32_OFFSET(pSrc16 + (2u * i2));
-
- /* R = packed( (ya + yc), (xa + xc)) */
- R = __QADD16(T, S);
-
- /* S = packed((ya - yc), (xa - xc)) */
- S = __QSUB16(T, S);
-
- /* Reading i0+fftLen/4 , i0+3fftLen/4 inputs */
- /* Read yb (real), xb(imag) input */
- T = _SIMD32_OFFSET(pSrc16 + (2u * i1));
-
- /* Read yd (real), xd(imag) input */
- U = _SIMD32_OFFSET(pSrc16 + (2u * i3));
-
- /* T = packed( (yb + yd), (xb + xd)) */
- T = __QADD16(T, U);
-
- /* writing the butterfly processed i0 sample */
-
- /* xa' = xa + xb + xc + xd */
- /* ya' = ya + yb + yc + yd */
- out1 = __SHADD16(R, T);
- in = ((int16_t) (out1 & 0xFFFF)) >> 1;
- out1 = ((out1 >> 1) & 0xFFFF0000) | (in & 0xFFFF);
- _SIMD32_OFFSET(pSrc16 + (2u * i0)) = out1;
-
- /* R = packed( (ya + yc) - (yb + yd), (xa + xc) - (xb + xd)) */
- R = __SHSUB16(R, T);
-
- #ifndef ARM_MATH_BIG_ENDIAN
-
- /* (ya-yb+yc-yd)* (si2) + (xa-xb+xc-xd)* co2 */
- out1 = __SMUAD(C2, R) >> 16u;
-
- /* (ya-yb+yc-yd)* co2 - (xa-xb+xc-xd)* (si2) */
- out2 = __SMUSDX(C2, R);
-
- #else
-
- /* (ya-yb+yc-yd)* co2 - (xa-xb+xc-xd)* (si2) */
- out1 = __SMUSDX(R, C2) >> 16u;
-
- /* (ya-yb+yc-yd)* (si2) + (xa-xb+xc-xd)* co2 */
- out2 = __SMUAD(C2, R);
-
- #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
-
- /* Reading i0+3fftLen/4 */
- /* Read yb (real), xb(imag) input */
- T = _SIMD32_OFFSET(pSrc16 + (2u * i1));
-
- /* writing the butterfly processed i0 + fftLen/4 sample */
- /* xc' = (xa-xb+xc-xd)* co2 + (ya-yb+yc-yd)* (si2) */
- /* yc' = (ya-yb+yc-yd)* co2 - (xa-xb+xc-xd)* (si2) */
- _SIMD32_OFFSET(pSrc16 + (2u * i1)) =
- ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF);
-
- /* Butterfly calculations */
-
- /* Read yd (real), xd(imag) input */
- U = _SIMD32_OFFSET(pSrc16 + (2u * i3));
-
- /* T = packed(yb-yd, xb-xd) */
- T = __QSUB16(T, U);
-
- #ifndef ARM_MATH_BIG_ENDIAN
-
- /* R = packed((ya-yc) + (xb- xd) , (xa-xc) - (yb-yd)) */
- R = __SHASX(S, T);
-
- /* S = packed((ya-yc) - (xb- xd), (xa-xc) + (yb-yd)) */
- S = __SHSAX(S, T);
-
-
- /* Butterfly process for the i0+fftLen/2 sample */
- out1 = __SMUAD(C1, S) >> 16u;
- out2 = __SMUSDX(C1, S);
-
- #else
-
- /* R = packed((ya-yc) + (xb- xd) , (xa-xc) - (yb-yd)) */
- R = __SHSAX(S, T);
-
- /* S = packed((ya-yc) - (xb- xd), (xa-xc) + (yb-yd)) */
- S = __SHASX(S, T);
-
-
- /* Butterfly process for the i0+fftLen/2 sample */
- out1 = __SMUSDX(S, C1) >> 16u;
- out2 = __SMUAD(C1, S);
-
- #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
-
- /* xb' = (xa+yb-xc-yd)* co1 + (ya-xb-yc+xd)* (si1) */
- /* yb' = (ya-xb-yc+xd)* co1 - (xa+yb-xc-yd)* (si1) */
- _SIMD32_OFFSET(pSrc16 + (2u * i2)) =
- ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF);
-
- /* Butterfly process for the i0+3fftLen/4 sample */
-
- #ifndef ARM_MATH_BIG_ENDIAN
-
- out1 = __SMUAD(C3, R) >> 16u;
- out2 = __SMUSDX(C3, R);
-
- #else
-
- out1 = __SMUSDX(R, C3) >> 16u;
- out2 = __SMUAD(C3, R);
-
- #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
-
- /* xd' = (xa-yb-xc+yd)* co3 + (ya+xb-yc-xd)* (si3) */
- /* yd' = (ya+xb-yc-xd)* co3 - (xa-yb-xc+yd)* (si3) */
- _SIMD32_OFFSET(pSrc16 + (2u * i3)) =
- ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF);
- }
- }
- /* Twiddle coefficients index modifier */
- twidCoefModifier <<= 2u;
- }
- /* end of middle stage process */
-
-
- /* data is in 10.6(q6) format for the 1024 point */
- /* data is in 8.8(q8) format for the 256 point */
- /* data is in 6.10(q10) format for the 64 point */
- /* data is in 4.12(q12) format for the 16 point */
-
- /* Initializations for the last stage */
- j = fftLen >> 2;
-
- ptr1 = &pSrc16[0];
-
- /* start of last stage process */
-
- /* Butterfly implementation */
- do
- {
- /* Read xa (real), ya(imag) input */
- xaya = *__SIMD32(ptr1)++;
-
- /* Read xb (real), yb(imag) input */
- xbyb = *__SIMD32(ptr1)++;
-
- /* Read xc (real), yc(imag) input */
- xcyc = *__SIMD32(ptr1)++;
-
- /* Read xd (real), yd(imag) input */
- xdyd = *__SIMD32(ptr1)++;
-
- /* R = packed((ya + yc), (xa + xc)) */
- R = __QADD16(xaya, xcyc);
-
- /* T = packed((yb + yd), (xb + xd)) */
- T = __QADD16(xbyb, xdyd);
-
- /* pointer updation for writing */
- ptr1 = ptr1 - 8u;
-
-
- /* xa' = xa + xb + xc + xd */
- /* ya' = ya + yb + yc + yd */
- *__SIMD32(ptr1)++ = __SHADD16(R, T);
-
- /* T = packed((yb + yd), (xb + xd)) */
- T = __QADD16(xbyb, xdyd);
-
- /* xc' = (xa-xb+xc-xd) */
- /* yc' = (ya-yb+yc-yd) */
- *__SIMD32(ptr1)++ = __SHSUB16(R, T);
-
- /* S = packed((ya - yc), (xa - xc)) */
- S = __QSUB16(xaya, xcyc);
-
- /* Read yd (real), xd(imag) input */
- /* T = packed( (yb - yd), (xb - xd)) */
- U = __QSUB16(xbyb, xdyd);
-
- #ifndef ARM_MATH_BIG_ENDIAN
-
- /* xb' = (xa+yb-xc-yd) */
- /* yb' = (ya-xb-yc+xd) */
- *__SIMD32(ptr1)++ = __SHSAX(S, U);
-
-
- /* xd' = (xa-yb-xc+yd) */
- /* yd' = (ya+xb-yc-xd) */
- *__SIMD32(ptr1)++ = __SHASX(S, U);
-
- #else
-
- /* xb' = (xa+yb-xc-yd) */
- /* yb' = (ya-xb-yc+xd) */
- *__SIMD32(ptr1)++ = __SHASX(S, U);
-
-
- /* xd' = (xa-yb-xc+yd) */
- /* yd' = (ya+xb-yc-xd) */
- *__SIMD32(ptr1)++ = __SHSAX(S, U);
-
- #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
-
- } while(--j);
-
- /* end of last stage process */
-
- /* output is in 11.5(q5) format for the 1024 point */
- /* output is in 9.7(q7) format for the 256 point */
- /* output is in 7.9(q9) format for the 64 point */
- /* output is in 5.11(q11) format for the 16 point */
-
-
- #else
-
- /* Run the below code for Cortex-M0 */
-
- q15_t R0, R1, S0, S1, T0, T1, U0, U1;
- q15_t Co1, Si1, Co2, Si2, Co3, Si3, out1, out2;
- uint32_t n1, n2, ic, i0, i1, i2, i3, j, k;
-
- /* Total process is divided into three stages */
-
- /* process first stage, middle stages, & last stage */
-
- /* Initializations for the first stage */
- n2 = fftLen;
- n1 = n2;
-
- /* n2 = fftLen/4 */
- n2 >>= 2u;
-
- /* Index for twiddle coefficient */
- ic = 0u;
-
- /* Index for input read and output write */
- i0 = 0u;
- j = n2;
-
- /* Input is in 1.15(q15) format */
-
- /* start of first stage process */
- do
- {
- /* Butterfly implementation */
-
- /* index calculation for the input as, */
- /* pSrc16[i0 + 0], pSrc16[i0 + fftLen/4], pSrc16[i0 + fftLen/2], pSrc16[i0 + 3fftLen/4] */
- i1 = i0 + n2;
- i2 = i1 + n2;
- i3 = i2 + n2;
-
- /* Reading i0, i0+fftLen/2 inputs */
-
- /* input is down scale by 4 to avoid overflow */
- /* Read ya (real), xa(imag) input */
- T0 = pSrc16[i0 * 2u] >> 2u;
- T1 = pSrc16[(i0 * 2u) + 1u] >> 2u;
-
- /* input is down scale by 4 to avoid overflow */
- /* Read yc (real), xc(imag) input */
- S0 = pSrc16[i2 * 2u] >> 2u;
- S1 = pSrc16[(i2 * 2u) + 1u] >> 2u;
-
- /* R0 = (ya + yc) */
- R0 = __SSAT(T0 + S0, 16u);
- /* R1 = (xa + xc) */
- R1 = __SSAT(T1 + S1, 16u);
-
- /* S0 = (ya - yc) */
- S0 = __SSAT(T0 - S0, 16);
- /* S1 = (xa - xc) */
- S1 = __SSAT(T1 - S1, 16);
-
- /* Reading i0+fftLen/4 , i0+3fftLen/4 inputs */
- /* input is down scale by 4 to avoid overflow */
- /* Read yb (real), xb(imag) input */
- T0 = pSrc16[i1 * 2u] >> 2u;
- T1 = pSrc16[(i1 * 2u) + 1u] >> 2u;
-
- /* input is down scale by 4 to avoid overflow */
- /* Read yd (real), xd(imag) input */
- U0 = pSrc16[i3 * 2u] >> 2u;
- U1 = pSrc16[(i3 * 2u) + 1] >> 2u;
-
- /* T0 = (yb + yd) */
- T0 = __SSAT(T0 + U0, 16u);
- /* T1 = (xb + xd) */
- T1 = __SSAT(T1 + U1, 16u);
-
- /* writing the butterfly processed i0 sample */
- /* ya' = ya + yb + yc + yd */
- /* xa' = xa + xb + xc + xd */
- pSrc16[i0 * 2u] = (R0 >> 1u) + (T0 >> 1u);
- pSrc16[(i0 * 2u) + 1u] = (R1 >> 1u) + (T1 >> 1u);
-
- /* R0 = (ya + yc) - (yb + yd) */
- /* R1 = (xa + xc) - (xb + xd) */
- R0 = __SSAT(R0 - T0, 16u);
- R1 = __SSAT(R1 - T1, 16u);
-
- /* co2 & si2 are read from Coefficient pointer */
- Co2 = pCoef16[2u * ic * 2u];
- Si2 = pCoef16[(2u * ic * 2u) + 1];
-
- /* xc' = (xa-xb+xc-xd)* co2 + (ya-yb+yc-yd)* (si2) */
- out1 = (short) ((Co2 * R0 + Si2 * R1) >> 16u);
- /* yc' = (ya-yb+yc-yd)* co2 - (xa-xb+xc-xd)* (si2) */
- out2 = (short) ((-Si2 * R0 + Co2 * R1) >> 16u);
-
- /* Reading i0+fftLen/4 */
- /* input is down scale by 4 to avoid overflow */
- /* T0 = yb, T1 = xb */
- T0 = pSrc16[i1 * 2u] >> 2;
- T1 = pSrc16[(i1 * 2u) + 1] >> 2;
-
- /* writing the butterfly processed i0 + fftLen/4 sample */
- /* writing output(xc', yc') in little endian format */
- pSrc16[i1 * 2u] = out1;
- pSrc16[(i1 * 2u) + 1] = out2;
-
- /* Butterfly calculations */
- /* input is down scale by 4 to avoid overflow */
- /* U0 = yd, U1 = xd */
- U0 = pSrc16[i3 * 2u] >> 2;
- U1 = pSrc16[(i3 * 2u) + 1] >> 2;
- /* T0 = yb-yd */
- T0 = __SSAT(T0 - U0, 16);
- /* T1 = xb-xd */
- T1 = __SSAT(T1 - U1, 16);
-
- /* R1 = (ya-yc) + (xb- xd), R0 = (xa-xc) - (yb-yd)) */
- R0 = (short) __SSAT((q31_t) (S0 - T1), 16);
- R1 = (short) __SSAT((q31_t) (S1 + T0), 16);
-
- /* S1 = (ya-yc) - (xb- xd), S0 = (xa-xc) + (yb-yd)) */
- S0 = (short) __SSAT(((q31_t) S0 + T1), 16u);
- S1 = (short) __SSAT(((q31_t) S1 - T0), 16u);
-
- /* co1 & si1 are read from Coefficient pointer */
- Co1 = pCoef16[ic * 2u];
- Si1 = pCoef16[(ic * 2u) + 1];
- /* Butterfly process for the i0+fftLen/2 sample */
- /* xb' = (xa+yb-xc-yd)* co1 + (ya-xb-yc+xd)* (si1) */
- out1 = (short) ((Si1 * S1 + Co1 * S0) >> 16);
- /* yb' = (ya-xb-yc+xd)* co1 - (xa+yb-xc-yd)* (si1) */
- out2 = (short) ((-Si1 * S0 + Co1 * S1) >> 16);
-
- /* writing output(xb', yb') in little endian format */
- pSrc16[i2 * 2u] = out1;
- pSrc16[(i2 * 2u) + 1] = out2;
-
- /* Co3 & si3 are read from Coefficient pointer */
- Co3 = pCoef16[3u * (ic * 2u)];
- Si3 = pCoef16[(3u * (ic * 2u)) + 1];
- /* Butterfly process for the i0+3fftLen/4 sample */
- /* xd' = (xa-yb-xc+yd)* Co3 + (ya+xb-yc-xd)* (si3) */
- out1 = (short) ((Si3 * R1 + Co3 * R0) >> 16u);
- /* yd' = (ya+xb-yc-xd)* Co3 - (xa-yb-xc+yd)* (si3) */
- out2 = (short) ((-Si3 * R0 + Co3 * R1) >> 16u);
- /* writing output(xd', yd') in little endian format */
- pSrc16[i3 * 2u] = out1;
- pSrc16[(i3 * 2u) + 1] = out2;
-
- /* Twiddle coefficients index modifier */
- ic = ic + twidCoefModifier;
-
- /* Updating input index */
- i0 = i0 + 1u;
-
- } while(--j);
- /* data is in 4.11(q11) format */
-
- /* end of first stage process */
-
-
- /* start of middle stage process */
-
- /* Twiddle coefficients index modifier */
- twidCoefModifier <<= 2u;
-
- /* Calculation of Middle stage */
- for (k = fftLen / 4u; k > 4u; k >>= 2u)
- {
- /* Initializations for the middle stage */
- n1 = n2;
- n2 >>= 2u;
- ic = 0u;
-
- for (j = 0u; j <= (n2 - 1u); j++)
- {
- /* index calculation for the coefficients */
- Co1 = pCoef16[ic * 2u];
- Si1 = pCoef16[(ic * 2u) + 1u];
- Co2 = pCoef16[2u * (ic * 2u)];
- Si2 = pCoef16[(2u * (ic * 2u)) + 1u];
- Co3 = pCoef16[3u * (ic * 2u)];
- Si3 = pCoef16[(3u * (ic * 2u)) + 1u];
-
- /* Twiddle coefficients index modifier */
- ic = ic + twidCoefModifier;
-
- /* Butterfly implementation */
- for (i0 = j; i0 < fftLen; i0 += n1)
- {
- /* index calculation for the input as, */
- /* pSrc16[i0 + 0], pSrc16[i0 + fftLen/4], pSrc16[i0 + fftLen/2], pSrc16[i0 + 3fftLen/4] */
- i1 = i0 + n2;
- i2 = i1 + n2;
- i3 = i2 + n2;
-
- /* Reading i0, i0+fftLen/2 inputs */
- /* Read ya (real), xa(imag) input */
- T0 = pSrc16[i0 * 2u];
- T1 = pSrc16[(i0 * 2u) + 1u];
-
- /* Read yc (real), xc(imag) input */
- S0 = pSrc16[i2 * 2u];
- S1 = pSrc16[(i2 * 2u) + 1u];
-
- /* R0 = (ya + yc), R1 = (xa + xc) */
- R0 = __SSAT(T0 + S0, 16);
- R1 = __SSAT(T1 + S1, 16);
-
- /* S0 = (ya - yc), S1 =(xa - xc) */
- S0 = __SSAT(T0 - S0, 16);
- S1 = __SSAT(T1 - S1, 16);
-
- /* Reading i0+fftLen/4 , i0+3fftLen/4 inputs */
- /* Read yb (real), xb(imag) input */
- T0 = pSrc16[i1 * 2u];
- T1 = pSrc16[(i1 * 2u) + 1u];
-
- /* Read yd (real), xd(imag) input */
- U0 = pSrc16[i3 * 2u];
- U1 = pSrc16[(i3 * 2u) + 1u];
-
-
- /* T0 = (yb + yd), T1 = (xb + xd) */
- T0 = __SSAT(T0 + U0, 16);
- T1 = __SSAT(T1 + U1, 16);
-
- /* writing the butterfly processed i0 sample */
-
- /* xa' = xa + xb + xc + xd */
- /* ya' = ya + yb + yc + yd */
- out1 = ((R0 >> 1u) + (T0 >> 1u)) >> 1u;
- out2 = ((R1 >> 1u) + (T1 >> 1u)) >> 1u;
-
- pSrc16[i0 * 2u] = out1;
- pSrc16[(2u * i0) + 1u] = out2;
-
- /* R0 = (ya + yc) - (yb + yd), R1 = (xa + xc) - (xb + xd) */
- R0 = (R0 >> 1u) - (T0 >> 1u);
- R1 = (R1 >> 1u) - (T1 >> 1u);
-
- /* (ya-yb+yc-yd)* (si2) + (xa-xb+xc-xd)* co2 */
- out1 = (short) ((Co2 * R0 + Si2 * R1) >> 16u);
-
- /* (ya-yb+yc-yd)* co2 - (xa-xb+xc-xd)* (si2) */
- out2 = (short) ((-Si2 * R0 + Co2 * R1) >> 16u);
-
- /* Reading i0+3fftLen/4 */
- /* Read yb (real), xb(imag) input */
- T0 = pSrc16[i1 * 2u];
- T1 = pSrc16[(i1 * 2u) + 1u];
-
- /* writing the butterfly processed i0 + fftLen/4 sample */
- /* xc' = (xa-xb+xc-xd)* co2 + (ya-yb+yc-yd)* (si2) */
- /* yc' = (ya-yb+yc-yd)* co2 - (xa-xb+xc-xd)* (si2) */
- pSrc16[i1 * 2u] = out1;
- pSrc16[(i1 * 2u) + 1u] = out2;
-
- /* Butterfly calculations */
-
- /* Read yd (real), xd(imag) input */
- U0 = pSrc16[i3 * 2u];
- U1 = pSrc16[(i3 * 2u) + 1u];
-
- /* T0 = yb-yd, T1 = xb-xd */
- T0 = __SSAT(T0 - U0, 16);
- T1 = __SSAT(T1 - U1, 16);
-
- /* R0 = (ya-yc) + (xb- xd), R1 = (xa-xc) - (yb-yd)) */
- R0 = (S0 >> 1u) - (T1 >> 1u);
- R1 = (S1 >> 1u) + (T0 >> 1u);
-
- /* S0 = (ya-yc) - (xb- xd), S1 = (xa-xc) + (yb-yd)) */
- S0 = (S0 >> 1u) + (T1 >> 1u);
- S1 = (S1 >> 1u) - (T0 >> 1u);
-
- /* Butterfly process for the i0+fftLen/2 sample */
- out1 = (short) ((Co1 * S0 + Si1 * S1) >> 16u);
-
- out2 = (short) ((-Si1 * S0 + Co1 * S1) >> 16u);
-
- /* xb' = (xa+yb-xc-yd)* co1 + (ya-xb-yc+xd)* (si1) */
- /* yb' = (ya-xb-yc+xd)* co1 - (xa+yb-xc-yd)* (si1) */
- pSrc16[i2 * 2u] = out1;
- pSrc16[(i2 * 2u) + 1u] = out2;
-
- /* Butterfly process for the i0+3fftLen/4 sample */
- out1 = (short) ((Si3 * R1 + Co3 * R0) >> 16u);
-
- out2 = (short) ((-Si3 * R0 + Co3 * R1) >> 16u);
- /* xd' = (xa-yb-xc+yd)* Co3 + (ya+xb-yc-xd)* (si3) */
- /* yd' = (ya+xb-yc-xd)* Co3 - (xa-yb-xc+yd)* (si3) */
- pSrc16[i3 * 2u] = out1;
- pSrc16[(i3 * 2u) + 1u] = out2;
- }
- }
- /* Twiddle coefficients index modifier */
- twidCoefModifier <<= 2u;
- }
- /* end of middle stage process */
-
-
- /* data is in 10.6(q6) format for the 1024 point */
- /* data is in 8.8(q8) format for the 256 point */
- /* data is in 6.10(q10) format for the 64 point */
- /* data is in 4.12(q12) format for the 16 point */
-
- /* Initializations for the last stage */
- n1 = n2;
- n2 >>= 2u;
-
- /* start of last stage process */
-
- /* Butterfly implementation */
- for (i0 = 0u; i0 <= (fftLen - n1); i0 += n1)
- {
- /* index calculation for the input as, */
- /* pSrc16[i0 + 0], pSrc16[i0 + fftLen/4], pSrc16[i0 + fftLen/2], pSrc16[i0 + 3fftLen/4] */
- i1 = i0 + n2;
- i2 = i1 + n2;
- i3 = i2 + n2;
-
- /* Reading i0, i0+fftLen/2 inputs */
- /* Read ya (real), xa(imag) input */
- T0 = pSrc16[i0 * 2u];
- T1 = pSrc16[(i0 * 2u) + 1u];
-
- /* Read yc (real), xc(imag) input */
- S0 = pSrc16[i2 * 2u];
- S1 = pSrc16[(i2 * 2u) + 1u];
-
- /* R0 = (ya + yc), R1 = (xa + xc) */
- R0 = __SSAT(T0 + S0, 16u);
- R1 = __SSAT(T1 + S1, 16u);
-
- /* S0 = (ya - yc), S1 = (xa - xc) */
- S0 = __SSAT(T0 - S0, 16u);
- S1 = __SSAT(T1 - S1, 16u);
-
- /* Reading i0+fftLen/4 , i0+3fftLen/4 inputs */
- /* Read yb (real), xb(imag) input */
- T0 = pSrc16[i1 * 2u];
- T1 = pSrc16[(i1 * 2u) + 1u];
- /* Read yd (real), xd(imag) input */
- U0 = pSrc16[i3 * 2u];
- U1 = pSrc16[(i3 * 2u) + 1u];
-
- /* T0 = (yb + yd), T1 = (xb + xd)) */
- T0 = __SSAT(T0 + U0, 16u);
- T1 = __SSAT(T1 + U1, 16u);
-
- /* writing the butterfly processed i0 sample */
- /* xa' = xa + xb + xc + xd */
- /* ya' = ya + yb + yc + yd */
- pSrc16[i0 * 2u] = (R0 >> 1u) + (T0 >> 1u);
- pSrc16[(i0 * 2u) + 1u] = (R1 >> 1u) + (T1 >> 1u);
-
- /* R0 = (ya + yc) - (yb + yd), R1 = (xa + xc) - (xb + xd) */
- R0 = (R0 >> 1u) - (T0 >> 1u);
- R1 = (R1 >> 1u) - (T1 >> 1u);
- /* Read yb (real), xb(imag) input */
- T0 = pSrc16[i1 * 2u];
- T1 = pSrc16[(i1 * 2u) + 1u];
-
- /* writing the butterfly processed i0 + fftLen/4 sample */
- /* xc' = (xa-xb+xc-xd) */
- /* yc' = (ya-yb+yc-yd) */
- pSrc16[i1 * 2u] = R0;
- pSrc16[(i1 * 2u) + 1u] = R1;
-
- /* Read yd (real), xd(imag) input */
- U0 = pSrc16[i3 * 2u];
- U1 = pSrc16[(i3 * 2u) + 1u];
- /* T0 = (yb - yd), T1 = (xb - xd) */
- T0 = __SSAT(T0 - U0, 16u);
- T1 = __SSAT(T1 - U1, 16u);
-
- /* writing the butterfly processed i0 + fftLen/2 sample */
- /* xb' = (xa+yb-xc-yd) */
- /* yb' = (ya-xb-yc+xd) */
- pSrc16[i2 * 2u] = (S0 >> 1u) + (T1 >> 1u);
- pSrc16[(i2 * 2u) + 1u] = (S1 >> 1u) - (T0 >> 1u);
-
- /* writing the butterfly processed i0 + 3fftLen/4 sample */
- /* xd' = (xa-yb-xc+yd) */
- /* yd' = (ya+xb-yc-xd) */
- pSrc16[i3 * 2u] = (S0 >> 1u) - (T1 >> 1u);
- pSrc16[(i3 * 2u) + 1u] = (S1 >> 1u) + (T0 >> 1u);
-
- }
-
- /* end of last stage process */
-
- /* output is in 11.5(q5) format for the 1024 point */
- /* output is in 9.7(q7) format for the 256 point */
- /* output is in 7.9(q9) format for the 64 point */
- /* output is in 5.11(q11) format for the 16 point */
-
- #endif /* #ifndef ARM_MATH_CM0_FAMILY */
-
- }
-
-
- /**
- * @brief Core function for the Q15 CIFFT butterfly process.
- * @param[in, out] *pSrc16 points to the in-place buffer of Q15 data type.
- * @param[in] fftLen length of the FFT.
- * @param[in] *pCoef16 points to twiddle coefficient buffer.
- * @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table.
- * @return none.
- */
-
- /*
- * Radix-4 IFFT algorithm used is :
- *
- * CIFFT uses same twiddle coefficients as CFFT function
- * x[k] = x[n] + (j)k * x[n + fftLen/4] + (-1)k * x[n+fftLen/2] + (-j)k * x[n+3*fftLen/4]
- *
- *
- * IFFT is implemented with following changes in equations from FFT
- *
- * Input real and imaginary data:
- * x(n) = xa + j * ya
- * x(n+N/4 ) = xb + j * yb
- * x(n+N/2 ) = xc + j * yc
- * x(n+3N 4) = xd + j * yd
- *
- *
- * Output real and imaginary data:
- * x(4r) = xa'+ j * ya'
- * x(4r+1) = xb'+ j * yb'
- * x(4r+2) = xc'+ j * yc'
- * x(4r+3) = xd'+ j * yd'
- *
- *
- * Twiddle factors for radix-4 IFFT:
- * Wn = co1 + j * (si1)
- * W2n = co2 + j * (si2)
- * W3n = co3 + j * (si3)
-
- * The real and imaginary output values for the radix-4 butterfly are
- * xa' = xa + xb + xc + xd
- * ya' = ya + yb + yc + yd
- * xb' = (xa-yb-xc+yd)* co1 - (ya+xb-yc-xd)* (si1)
- * yb' = (ya+xb-yc-xd)* co1 + (xa-yb-xc+yd)* (si1)
- * xc' = (xa-xb+xc-xd)* co2 - (ya-yb+yc-yd)* (si2)
- * yc' = (ya-yb+yc-yd)* co2 + (xa-xb+xc-xd)* (si2)
- * xd' = (xa+yb-xc-yd)* co3 - (ya-xb-yc+xd)* (si3)
- * yd' = (ya-xb-yc+xd)* co3 + (xa+yb-xc-yd)* (si3)
- *
- */
-
- void arm_radix4_butterfly_inverse_q15(
- q15_t * pSrc16,
- uint32_t fftLen,
- q15_t * pCoef16,
- uint32_t twidCoefModifier)
- {
-
- #ifndef ARM_MATH_CM0_FAMILY
-
- /* Run the below code for Cortex-M4 and Cortex-M3 */
-
- q31_t R, S, T, U;
- q31_t C1, C2, C3, out1, out2;
- uint32_t n1, n2, ic, i0, i1, i2, i3, j, k;
- q15_t in;
-
- q15_t *ptr1;
-
-
-
- q31_t xaya, xbyb, xcyc, xdyd;
-
- /* Total process is divided into three stages */
-
- /* process first stage, middle stages, & last stage */
-
- /* Initializations for the first stage */
- n2 = fftLen;
- n1 = n2;
-
- /* n2 = fftLen/4 */
- n2 >>= 2u;
-
- /* Index for twiddle coefficient */
- ic = 0u;
-
- /* Index for input read and output write */
- i0 = 0u;
- j = n2;
-
- /* Input is in 1.15(q15) format */
-
- /* start of first stage process */
- do
- {
- /* Butterfly implementation */
-
- /* index calculation for the input as, */
- /* pSrc16[i0 + 0], pSrc16[i0 + fftLen/4], pSrc16[i0 + fftLen/2], pSrc16[i0 + 3fftLen/4] */
- i1 = i0 + n2;
- i2 = i1 + n2;
- i3 = i2 + n2;
-
- /* Reading i0, i0+fftLen/2 inputs */
- /* Read ya (real), xa(imag) input */
- T = _SIMD32_OFFSET(pSrc16 + (2u * i0));
- in = ((int16_t) (T & 0xFFFF)) >> 2;
- T = ((T >> 2) & 0xFFFF0000) | (in & 0xFFFF);
-
- /* Read yc (real), xc(imag) input */
- S = _SIMD32_OFFSET(pSrc16 + (2u * i2));
- in = ((int16_t) (S & 0xFFFF)) >> 2;
- S = ((S >> 2) & 0xFFFF0000) | (in & 0xFFFF);
-
- /* R = packed((ya + yc), (xa + xc) ) */
- R = __QADD16(T, S);
-
- /* S = packed((ya - yc), (xa - xc) ) */
- S = __QSUB16(T, S);
-
- /* Reading i0+fftLen/4 , i0+3fftLen/4 inputs */
- /* Read yb (real), xb(imag) input */
- T = _SIMD32_OFFSET(pSrc16 + (2u * i1));
- in = ((int16_t) (T & 0xFFFF)) >> 2;
- T = ((T >> 2) & 0xFFFF0000) | (in & 0xFFFF);
-
- /* Read yd (real), xd(imag) input */
- U = _SIMD32_OFFSET(pSrc16 + (2u * i3));
- in = ((int16_t) (U & 0xFFFF)) >> 2;
- U = ((U >> 2) & 0xFFFF0000) | (in & 0xFFFF);
-
- /* T = packed((yb + yd), (xb + xd) ) */
- T = __QADD16(T, U);
-
- /* writing the butterfly processed i0 sample */
- /* xa' = xa + xb + xc + xd */
- /* ya' = ya + yb + yc + yd */
- _SIMD32_OFFSET(pSrc16 + (2u * i0)) = __SHADD16(R, T);
-
- /* R = packed((ya + yc) - (yb + yd), (xa + xc)- (xb + xd)) */
- R = __QSUB16(R, T);
-
- /* co2 & si2 are read from SIMD Coefficient pointer */
- C2 = _SIMD32_OFFSET(pCoef16 + (4u * ic));
-
- #ifndef ARM_MATH_BIG_ENDIAN
-
- /* xc' = (xa-xb+xc-xd)* co2 + (ya-yb+yc-yd)* (si2) */
- out1 = __SMUSD(C2, R) >> 16u;
- /* yc' = (ya-yb+yc-yd)* co2 - (xa-xb+xc-xd)* (si2) */
- out2 = __SMUADX(C2, R);
-
- #else
-
- /* xc' = (ya-yb+yc-yd)* co2 - (xa-xb+xc-xd)* (si2) */
- out1 = __SMUADX(C2, R) >> 16u;
- /* yc' = (xa-xb+xc-xd)* co2 + (ya-yb+yc-yd)* (si2) */
- out2 = __SMUSD(__QSUB16(0, C2), R);
-
- #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
-
- /* Reading i0+fftLen/4 */
- /* T = packed(yb, xb) */
- T = _SIMD32_OFFSET(pSrc16 + (2u * i1));
- in = ((int16_t) (T & 0xFFFF)) >> 2;
- T = ((T >> 2) & 0xFFFF0000) | (in & 0xFFFF);
-
- /* writing the butterfly processed i0 + fftLen/4 sample */
- /* writing output(xc', yc') in little endian format */
- _SIMD32_OFFSET(pSrc16 + (2u * i1)) =
- (q31_t) ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF);
-
- /* Butterfly calculations */
- /* U = packed(yd, xd) */
- U = _SIMD32_OFFSET(pSrc16 + (2u * i3));
- in = ((int16_t) (U & 0xFFFF)) >> 2;
- U = ((U >> 2) & 0xFFFF0000) | (in & 0xFFFF);
-
- /* T = packed(yb-yd, xb-xd) */
- T = __QSUB16(T, U);
-
- #ifndef ARM_MATH_BIG_ENDIAN
-
- /* R = packed((ya-yc) + (xb- xd) , (xa-xc) - (yb-yd)) */
- R = __QSAX(S, T);
- /* S = packed((ya-yc) + (xb- xd), (xa-xc) - (yb-yd)) */
- S = __QASX(S, T);
-
- #else
-
- /* R = packed((ya-yc) + (xb- xd) , (xa-xc) - (yb-yd)) */
- R = __QASX(S, T);
- /* S = packed((ya-yc) - (xb- xd), (xa-xc) + (yb-yd)) */
- S = __QSAX(S, T);
-
- #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
-
- /* co1 & si1 are read from SIMD Coefficient pointer */
- C1 = _SIMD32_OFFSET(pCoef16 + (2u * ic));
- /* Butterfly process for the i0+fftLen/2 sample */
-
- #ifndef ARM_MATH_BIG_ENDIAN
-
- /* xb' = (xa+yb-xc-yd)* co1 + (ya-xb-yc+xd)* (si1) */
- out1 = __SMUSD(C1, S) >> 16u;
- /* yb' = (ya-xb-yc+xd)* co1 - (xa+yb-xc-yd)* (si1) */
- out2 = __SMUADX(C1, S);
-
- #else
-
- /* xb' = (ya-xb-yc+xd)* co1 - (xa+yb-xc-yd)* (si1) */
- out1 = __SMUADX(C1, S) >> 16u;
- /* yb' = (xa+yb-xc-yd)* co1 + (ya-xb-yc+xd)* (si1) */
- out2 = __SMUSD(__QSUB16(0, C1), S);
-
- #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
-
- /* writing output(xb', yb') in little endian format */
- _SIMD32_OFFSET(pSrc16 + (2u * i2)) =
- ((out2) & 0xFFFF0000) | ((out1) & 0x0000FFFF);
-
-
- /* co3 & si3 are read from SIMD Coefficient pointer */
- C3 = _SIMD32_OFFSET(pCoef16 + (6u * ic));
- /* Butterfly process for the i0+3fftLen/4 sample */
-
- #ifndef ARM_MATH_BIG_ENDIAN
-
- /* xd' = (xa-yb-xc+yd)* co3 + (ya+xb-yc-xd)* (si3) */
- out1 = __SMUSD(C3, R) >> 16u;
- /* yd' = (ya+xb-yc-xd)* co3 - (xa-yb-xc+yd)* (si3) */
- out2 = __SMUADX(C3, R);
-
- #else
-
- /* xd' = (ya+xb-yc-xd)* co3 - (xa-yb-xc+yd)* (si3) */
- out1 = __SMUADX(C3, R) >> 16u;
- /* yd' = (xa-yb-xc+yd)* co3 + (ya+xb-yc-xd)* (si3) */
- out2 = __SMUSD(__QSUB16(0, C3), R);
-
- #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
-
- /* writing output(xd', yd') in little endian format */
- _SIMD32_OFFSET(pSrc16 + (2u * i3)) =
- ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF);
-
- /* Twiddle coefficients index modifier */
- ic = ic + twidCoefModifier;
-
- /* Updating input index */
- i0 = i0 + 1u;
-
- } while(--j);
- /* data is in 4.11(q11) format */
-
- /* end of first stage process */
-
-
- /* start of middle stage process */
-
- /* Twiddle coefficients index modifier */
- twidCoefModifier <<= 2u;
-
- /* Calculation of Middle stage */
- for (k = fftLen / 4u; k > 4u; k >>= 2u)
- {
- /* Initializations for the middle stage */
- n1 = n2;
- n2 >>= 2u;
- ic = 0u;
-
- for (j = 0u; j <= (n2 - 1u); j++)
- {
- /* index calculation for the coefficients */
- C1 = _SIMD32_OFFSET(pCoef16 + (2u * ic));
- C2 = _SIMD32_OFFSET(pCoef16 + (4u * ic));
- C3 = _SIMD32_OFFSET(pCoef16 + (6u * ic));
-
- /* Twiddle coefficients index modifier */
- ic = ic + twidCoefModifier;
-
- /* Butterfly implementation */
- for (i0 = j; i0 < fftLen; i0 += n1)
- {
- /* index calculation for the input as, */
- /* pSrc16[i0 + 0], pSrc16[i0 + fftLen/4], pSrc16[i0 + fftLen/2], pSrc16[i0 + 3fftLen/4] */
- i1 = i0 + n2;
- i2 = i1 + n2;
- i3 = i2 + n2;
-
- /* Reading i0, i0+fftLen/2 inputs */
- /* Read ya (real), xa(imag) input */
- T = _SIMD32_OFFSET(pSrc16 + (2u * i0));
-
- /* Read yc (real), xc(imag) input */
- S = _SIMD32_OFFSET(pSrc16 + (2u * i2));
-
- /* R = packed( (ya + yc), (xa + xc)) */
- R = __QADD16(T, S);
-
- /* S = packed((ya - yc), (xa - xc)) */
- S = __QSUB16(T, S);
-
- /* Reading i0+fftLen/4 , i0+3fftLen/4 inputs */
- /* Read yb (real), xb(imag) input */
- T = _SIMD32_OFFSET(pSrc16 + (2u * i1));
-
- /* Read yd (real), xd(imag) input */
- U = _SIMD32_OFFSET(pSrc16 + (2u * i3));
-
- /* T = packed( (yb + yd), (xb + xd)) */
- T = __QADD16(T, U);
-
- /* writing the butterfly processed i0 sample */
-
- /* xa' = xa + xb + xc + xd */
- /* ya' = ya + yb + yc + yd */
- out1 = __SHADD16(R, T);
- in = ((int16_t) (out1 & 0xFFFF)) >> 1;
- out1 = ((out1 >> 1) & 0xFFFF0000) | (in & 0xFFFF);
- _SIMD32_OFFSET(pSrc16 + (2u * i0)) = out1;
-
- /* R = packed( (ya + yc) - (yb + yd), (xa + xc) - (xb + xd)) */
- R = __SHSUB16(R, T);
-
- #ifndef ARM_MATH_BIG_ENDIAN
-
- /* (ya-yb+yc-yd)* (si2) + (xa-xb+xc-xd)* co2 */
- out1 = __SMUSD(C2, R) >> 16u;
-
- /* (ya-yb+yc-yd)* co2 - (xa-xb+xc-xd)* (si2) */
- out2 = __SMUADX(C2, R);
-
- #else
-
- /* (ya-yb+yc-yd)* co2 - (xa-xb+xc-xd)* (si2) */
- out1 = __SMUADX(R, C2) >> 16u;
-
- /* (ya-yb+yc-yd)* (si2) + (xa-xb+xc-xd)* co2 */
- out2 = __SMUSD(__QSUB16(0, C2), R);
-
- #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
-
- /* Reading i0+3fftLen/4 */
- /* Read yb (real), xb(imag) input */
- T = _SIMD32_OFFSET(pSrc16 + (2u * i1));
-
- /* writing the butterfly processed i0 + fftLen/4 sample */
- /* xc' = (xa-xb+xc-xd)* co2 + (ya-yb+yc-yd)* (si2) */
- /* yc' = (ya-yb+yc-yd)* co2 - (xa-xb+xc-xd)* (si2) */
- _SIMD32_OFFSET(pSrc16 + (2u * i1)) =
- ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF);
-
- /* Butterfly calculations */
-
- /* Read yd (real), xd(imag) input */
- U = _SIMD32_OFFSET(pSrc16 + (2u * i3));
-
- /* T = packed(yb-yd, xb-xd) */
- T = __QSUB16(T, U);
-
- #ifndef ARM_MATH_BIG_ENDIAN
-
- /* R = packed((ya-yc) + (xb- xd) , (xa-xc) - (yb-yd)) */
- R = __SHSAX(S, T);
-
- /* S = packed((ya-yc) - (xb- xd), (xa-xc) + (yb-yd)) */
- S = __SHASX(S, T);
-
-
- /* Butterfly process for the i0+fftLen/2 sample */
- out1 = __SMUSD(C1, S) >> 16u;
- out2 = __SMUADX(C1, S);
-
- #else
-
- /* R = packed((ya-yc) + (xb- xd) , (xa-xc) - (yb-yd)) */
- R = __SHASX(S, T);
-
- /* S = packed((ya-yc) - (xb- xd), (xa-xc) + (yb-yd)) */
- S = __SHSAX(S, T);
-
-
- /* Butterfly process for the i0+fftLen/2 sample */
- out1 = __SMUADX(S, C1) >> 16u;
- out2 = __SMUSD(__QSUB16(0, C1), S);
-
- #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
-
- /* xb' = (xa+yb-xc-yd)* co1 + (ya-xb-yc+xd)* (si1) */
- /* yb' = (ya-xb-yc+xd)* co1 - (xa+yb-xc-yd)* (si1) */
- _SIMD32_OFFSET(pSrc16 + (2u * i2)) =
- ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF);
-
- /* Butterfly process for the i0+3fftLen/4 sample */
-
- #ifndef ARM_MATH_BIG_ENDIAN
-
- out1 = __SMUSD(C3, R) >> 16u;
- out2 = __SMUADX(C3, R);
-
- #else
-
- out1 = __SMUADX(C3, R) >> 16u;
- out2 = __SMUSD(__QSUB16(0, C3), R);
-
- #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
-
- /* xd' = (xa-yb-xc+yd)* co3 + (ya+xb-yc-xd)* (si3) */
- /* yd' = (ya+xb-yc-xd)* co3 - (xa-yb-xc+yd)* (si3) */
- _SIMD32_OFFSET(pSrc16 + (2u * i3)) =
- ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF);
- }
- }
- /* Twiddle coefficients index modifier */
- twidCoefModifier <<= 2u;
- }
- /* end of middle stage process */
-
- /* data is in 10.6(q6) format for the 1024 point */
- /* data is in 8.8(q8) format for the 256 point */
- /* data is in 6.10(q10) format for the 64 point */
- /* data is in 4.12(q12) format for the 16 point */
-
- /* Initializations for the last stage */
- j = fftLen >> 2;
-
- ptr1 = &pSrc16[0];
-
- /* start of last stage process */
-
- /* Butterfly implementation */
- do
- {
- /* Read xa (real), ya(imag) input */
- xaya = *__SIMD32(ptr1)++;
-
- /* Read xb (real), yb(imag) input */
- xbyb = *__SIMD32(ptr1)++;
-
- /* Read xc (real), yc(imag) input */
- xcyc = *__SIMD32(ptr1)++;
-
- /* Read xd (real), yd(imag) input */
- xdyd = *__SIMD32(ptr1)++;
-
- /* R = packed((ya + yc), (xa + xc)) */
- R = __QADD16(xaya, xcyc);
-
- /* T = packed((yb + yd), (xb + xd)) */
- T = __QADD16(xbyb, xdyd);
-
- /* pointer updation for writing */
- ptr1 = ptr1 - 8u;
-
-
- /* xa' = xa + xb + xc + xd */
- /* ya' = ya + yb + yc + yd */
- *__SIMD32(ptr1)++ = __SHADD16(R, T);
-
- /* T = packed((yb + yd), (xb + xd)) */
- T = __QADD16(xbyb, xdyd);
-
- /* xc' = (xa-xb+xc-xd) */
- /* yc' = (ya-yb+yc-yd) */
- *__SIMD32(ptr1)++ = __SHSUB16(R, T);
-
- /* S = packed((ya - yc), (xa - xc)) */
- S = __QSUB16(xaya, xcyc);
-
- /* Read yd (real), xd(imag) input */
- /* T = packed( (yb - yd), (xb - xd)) */
- U = __QSUB16(xbyb, xdyd);
-
- #ifndef ARM_MATH_BIG_ENDIAN
-
- /* xb' = (xa+yb-xc-yd) */
- /* yb' = (ya-xb-yc+xd) */
- *__SIMD32(ptr1)++ = __SHASX(S, U);
-
-
- /* xd' = (xa-yb-xc+yd) */
- /* yd' = (ya+xb-yc-xd) */
- *__SIMD32(ptr1)++ = __SHSAX(S, U);
-
- #else
-
- /* xb' = (xa+yb-xc-yd) */
- /* yb' = (ya-xb-yc+xd) */
- *__SIMD32(ptr1)++ = __SHSAX(S, U);
-
-
- /* xd' = (xa-yb-xc+yd) */
- /* yd' = (ya+xb-yc-xd) */
- *__SIMD32(ptr1)++ = __SHASX(S, U);
-
-
- #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
-
- } while(--j);
-
- /* end of last stage process */
-
- /* output is in 11.5(q5) format for the 1024 point */
- /* output is in 9.7(q7) format for the 256 point */
- /* output is in 7.9(q9) format for the 64 point */
- /* output is in 5.11(q11) format for the 16 point */
-
-
- #else
-
- /* Run the below code for Cortex-M0 */
-
- q15_t R0, R1, S0, S1, T0, T1, U0, U1;
- q15_t Co1, Si1, Co2, Si2, Co3, Si3, out1, out2;
- uint32_t n1, n2, ic, i0, i1, i2, i3, j, k;
-
- /* Total process is divided into three stages */
-
- /* process first stage, middle stages, & last stage */
-
- /* Initializations for the first stage */
- n2 = fftLen;
- n1 = n2;
-
- /* n2 = fftLen/4 */
- n2 >>= 2u;
-
- /* Index for twiddle coefficient */
- ic = 0u;
-
- /* Index for input read and output write */
- i0 = 0u;
-
- j = n2;
-
- /* Input is in 1.15(q15) format */
-
- /* Start of first stage process */
- do
- {
- /* Butterfly implementation */
-
- /* index calculation for the input as, */
- /* pSrc16[i0 + 0], pSrc16[i0 + fftLen/4], pSrc16[i0 + fftLen/2], pSrc16[i0 + 3fftLen/4] */
- i1 = i0 + n2;
- i2 = i1 + n2;
- i3 = i2 + n2;
-
- /* Reading i0, i0+fftLen/2 inputs */
- /* input is down scale by 4 to avoid overflow */
- /* Read ya (real), xa(imag) input */
- T0 = pSrc16[i0 * 2u] >> 2u;
- T1 = pSrc16[(i0 * 2u) + 1u] >> 2u;
- /* input is down scale by 4 to avoid overflow */
- /* Read yc (real), xc(imag) input */
- S0 = pSrc16[i2 * 2u] >> 2u;
- S1 = pSrc16[(i2 * 2u) + 1u] >> 2u;
-
- /* R0 = (ya + yc), R1 = (xa + xc) */
- R0 = __SSAT(T0 + S0, 16u);
- R1 = __SSAT(T1 + S1, 16u);
- /* S0 = (ya - yc), S1 = (xa - xc) */
- S0 = __SSAT(T0 - S0, 16u);
- S1 = __SSAT(T1 - S1, 16u);
-
- /* Reading i0+fftLen/4 , i0+3fftLen/4 inputs */
- /* input is down scale by 4 to avoid overflow */
- /* Read yb (real), xb(imag) input */
- T0 = pSrc16[i1 * 2u] >> 2u;
- T1 = pSrc16[(i1 * 2u) + 1u] >> 2u;
- /* Read yd (real), xd(imag) input */
- /* input is down scale by 4 to avoid overflow */
- U0 = pSrc16[i3 * 2u] >> 2u;
- U1 = pSrc16[(i3 * 2u) + 1u] >> 2u;
-
- /* T0 = (yb + yd), T1 = (xb + xd) */
- T0 = __SSAT(T0 + U0, 16u);
- T1 = __SSAT(T1 + U1, 16u);
-
- /* writing the butterfly processed i0 sample */
- /* xa' = xa + xb + xc + xd */
- /* ya' = ya + yb + yc + yd */
- pSrc16[i0 * 2u] = (R0 >> 1u) + (T0 >> 1u);
- pSrc16[(i0 * 2u) + 1u] = (R1 >> 1u) + (T1 >> 1u);
-
- /* R0 = (ya + yc) - (yb + yd), R1 = (xa + xc)- (xb + xd) */
- R0 = __SSAT(R0 - T0, 16u);
- R1 = __SSAT(R1 - T1, 16u);
- /* co2 & si2 are read from Coefficient pointer */
- Co2 = pCoef16[2u * ic * 2u];
- Si2 = pCoef16[(2u * ic * 2u) + 1u];
- /* xc' = (xa-xb+xc-xd)* co2 - (ya-yb+yc-yd)* (si2) */
- out1 = (short) ((Co2 * R0 - Si2 * R1) >> 16u);
- /* yc' = (ya-yb+yc-yd)* co2 + (xa-xb+xc-xd)* (si2) */
- out2 = (short) ((Si2 * R0 + Co2 * R1) >> 16u);
-
- /* Reading i0+fftLen/4 */
- /* input is down scale by 4 to avoid overflow */
- /* T0 = yb, T1 = xb */
- T0 = pSrc16[i1 * 2u] >> 2u;
- T1 = pSrc16[(i1 * 2u) + 1u] >> 2u;
-
- /* writing the butterfly processed i0 + fftLen/4 sample */
- /* writing output(xc', yc') in little endian format */
- pSrc16[i1 * 2u] = out1;
- pSrc16[(i1 * 2u) + 1u] = out2;
-
- /* Butterfly calculations */
- /* input is down scale by 4 to avoid overflow */
- /* U0 = yd, U1 = xd) */
- U0 = pSrc16[i3 * 2u] >> 2u;
- U1 = pSrc16[(i3 * 2u) + 1u] >> 2u;
-
- /* T0 = yb-yd, T1 = xb-xd) */
- T0 = __SSAT(T0 - U0, 16u);
- T1 = __SSAT(T1 - U1, 16u);
- /* R0 = (ya-yc) - (xb- xd) , R1 = (xa-xc) + (yb-yd) */
- R0 = (short) __SSAT((q31_t) (S0 + T1), 16);
- R1 = (short) __SSAT((q31_t) (S1 - T0), 16);
- /* S = (ya-yc) + (xb- xd), S1 = (xa-xc) - (yb-yd) */
- S0 = (short) __SSAT((q31_t) (S0 - T1), 16);
- S1 = (short) __SSAT((q31_t) (S1 + T0), 16);
-
- /* co1 & si1 are read from Coefficient pointer */
- Co1 = pCoef16[ic * 2u];
- Si1 = pCoef16[(ic * 2u) + 1u];
- /* Butterfly process for the i0+fftLen/2 sample */
- /* xb' = (xa-yb-xc+yd)* co1 - (ya+xb-yc-xd)* (si1) */
- out1 = (short) ((Co1 * S0 - Si1 * S1) >> 16u);
- /* yb' = (ya+xb-yc-xd)* co1 + (xa-yb-xc+yd)* (si1) */
- out2 = (short) ((Si1 * S0 + Co1 * S1) >> 16u);
- /* writing output(xb', yb') in little endian format */
- pSrc16[i2 * 2u] = out1;
- pSrc16[(i2 * 2u) + 1u] = out2;
-
- /* Co3 & si3 are read from Coefficient pointer */
- Co3 = pCoef16[3u * ic * 2u];
- Si3 = pCoef16[(3u * ic * 2u) + 1u];
- /* Butterfly process for the i0+3fftLen/4 sample */
- /* xd' = (xa+yb-xc-yd)* Co3 - (ya-xb-yc+xd)* (si3) */
- out1 = (short) ((Co3 * R0 - Si3 * R1) >> 16u);
- /* yd' = (ya-xb-yc+xd)* Co3 + (xa+yb-xc-yd)* (si3) */
- out2 = (short) ((Si3 * R0 + Co3 * R1) >> 16u);
- /* writing output(xd', yd') in little endian format */
- pSrc16[i3 * 2u] = out1;
- pSrc16[(i3 * 2u) + 1u] = out2;
-
- /* Twiddle coefficients index modifier */
- ic = ic + twidCoefModifier;
-
- /* Updating input index */
- i0 = i0 + 1u;
-
- } while(--j);
-
- /* End of first stage process */
-
- /* data is in 4.11(q11) format */
-
-
- /* Start of Middle stage process */
-
- /* Twiddle coefficients index modifier */
- twidCoefModifier <<= 2u;
-
- /* Calculation of Middle stage */
- for (k = fftLen / 4u; k > 4u; k >>= 2u)
- {
- /* Initializations for the middle stage */
- n1 = n2;
- n2 >>= 2u;
- ic = 0u;
-
- for (j = 0u; j <= (n2 - 1u); j++)
- {
- /* index calculation for the coefficients */
- Co1 = pCoef16[ic * 2u];
- Si1 = pCoef16[(ic * 2u) + 1u];
- Co2 = pCoef16[2u * ic * 2u];
- Si2 = pCoef16[2u * ic * 2u + 1u];
- Co3 = pCoef16[3u * ic * 2u];
- Si3 = pCoef16[(3u * ic * 2u) + 1u];
-
- /* Twiddle coefficients index modifier */
- ic = ic + twidCoefModifier;
-
- /* Butterfly implementation */
- for (i0 = j; i0 < fftLen; i0 += n1)
- {
- /* index calculation for the input as, */
- /* pSrc16[i0 + 0], pSrc16[i0 + fftLen/4], pSrc16[i0 + fftLen/2], pSrc16[i0 + 3fftLen/4] */
- i1 = i0 + n2;
- i2 = i1 + n2;
- i3 = i2 + n2;
-
- /* Reading i0, i0+fftLen/2 inputs */
- /* Read ya (real), xa(imag) input */
- T0 = pSrc16[i0 * 2u];
- T1 = pSrc16[(i0 * 2u) + 1u];
-
- /* Read yc (real), xc(imag) input */
- S0 = pSrc16[i2 * 2u];
- S1 = pSrc16[(i2 * 2u) + 1u];
-
-
- /* R0 = (ya + yc), R1 = (xa + xc) */
- R0 = __SSAT(T0 + S0, 16u);
- R1 = __SSAT(T1 + S1, 16u);
- /* S0 = (ya - yc), S1 = (xa - xc) */
- S0 = __SSAT(T0 - S0, 16u);
- S1 = __SSAT(T1 - S1, 16u);
-
- /* Reading i0+fftLen/4 , i0+3fftLen/4 inputs */
- /* Read yb (real), xb(imag) input */
- T0 = pSrc16[i1 * 2u];
- T1 = pSrc16[(i1 * 2u) + 1u];
-
- /* Read yd (real), xd(imag) input */
- U0 = pSrc16[i3 * 2u];
- U1 = pSrc16[(i3 * 2u) + 1u];
-
- /* T0 = (yb + yd), T1 = (xb + xd) */
- T0 = __SSAT(T0 + U0, 16u);
- T1 = __SSAT(T1 + U1, 16u);
-
- /* writing the butterfly processed i0 sample */
- /* xa' = xa + xb + xc + xd */
- /* ya' = ya + yb + yc + yd */
- pSrc16[i0 * 2u] = ((R0 >> 1u) + (T0 >> 1u)) >> 1u;
- pSrc16[(i0 * 2u) + 1u] = ((R1 >> 1u) + (T1 >> 1u)) >> 1u;
-
- /* R0 = (ya + yc) - (yb + yd), R1 = (xa + xc) - (xb + xd) */
- R0 = (R0 >> 1u) - (T0 >> 1u);
- R1 = (R1 >> 1u) - (T1 >> 1u);
-
- /* (ya-yb+yc-yd)* (si2) - (xa-xb+xc-xd)* co2 */
- out1 = (short) ((Co2 * R0 - Si2 * R1) >> 16);
- /* (ya-yb+yc-yd)* co2 + (xa-xb+xc-xd)* (si2) */
- out2 = (short) ((Si2 * R0 + Co2 * R1) >> 16);
-
- /* Reading i0+3fftLen/4 */
- /* Read yb (real), xb(imag) input */
- T0 = pSrc16[i1 * 2u];
- T1 = pSrc16[(i1 * 2u) + 1u];
-
- /* writing the butterfly processed i0 + fftLen/4 sample */
- /* xc' = (xa-xb+xc-xd)* co2 - (ya-yb+yc-yd)* (si2) */
- /* yc' = (ya-yb+yc-yd)* co2 + (xa-xb+xc-xd)* (si2) */
- pSrc16[i1 * 2u] = out1;
- pSrc16[(i1 * 2u) + 1u] = out2;
-
- /* Butterfly calculations */
- /* Read yd (real), xd(imag) input */
- U0 = pSrc16[i3 * 2u];
- U1 = pSrc16[(i3 * 2u) + 1u];
-
- /* T0 = yb-yd, T1 = xb-xd) */
- T0 = __SSAT(T0 - U0, 16u);
- T1 = __SSAT(T1 - U1, 16u);
-
- /* R0 = (ya-yc) - (xb- xd) , R1 = (xa-xc) + (yb-yd) */
- R0 = (S0 >> 1u) + (T1 >> 1u);
- R1 = (S1 >> 1u) - (T0 >> 1u);
-
- /* S1 = (ya-yc) + (xb- xd), S1 = (xa-xc) - (yb-yd) */
- S0 = (S0 >> 1u) - (T1 >> 1u);
- S1 = (S1 >> 1u) + (T0 >> 1u);
-
- /* Butterfly process for the i0+fftLen/2 sample */
- out1 = (short) ((Co1 * S0 - Si1 * S1) >> 16u);
- out2 = (short) ((Si1 * S0 + Co1 * S1) >> 16u);
- /* xb' = (xa-yb-xc+yd)* co1 - (ya+xb-yc-xd)* (si1) */
- /* yb' = (ya+xb-yc-xd)* co1 + (xa-yb-xc+yd)* (si1) */
- pSrc16[i2 * 2u] = out1;
- pSrc16[(i2 * 2u) + 1u] = out2;
-
- /* Butterfly process for the i0+3fftLen/4 sample */
- out1 = (short) ((Co3 * R0 - Si3 * R1) >> 16u);
-
- out2 = (short) ((Si3 * R0 + Co3 * R1) >> 16u);
- /* xd' = (xa+yb-xc-yd)* Co3 - (ya-xb-yc+xd)* (si3) */
- /* yd' = (ya-xb-yc+xd)* Co3 + (xa+yb-xc-yd)* (si3) */
- pSrc16[i3 * 2u] = out1;
- pSrc16[(i3 * 2u) + 1u] = out2;
-
-
- }
- }
- /* Twiddle coefficients index modifier */
- twidCoefModifier <<= 2u;
- }
- /* End of Middle stages process */
-
-
- /* data is in 10.6(q6) format for the 1024 point */
- /* data is in 8.8(q8) format for the 256 point */
- /* data is in 6.10(q10) format for the 64 point */
- /* data is in 4.12(q12) format for the 16 point */
-
- /* start of last stage process */
-
-
- /* Initializations for the last stage */
- n1 = n2;
- n2 >>= 2u;
-
- /* Butterfly implementation */
- for (i0 = 0u; i0 <= (fftLen - n1); i0 += n1)
- {
- /* index calculation for the input as, */
- /* pSrc16[i0 + 0], pSrc16[i0 + fftLen/4], pSrc16[i0 + fftLen/2], pSrc16[i0 + 3fftLen/4] */
- i1 = i0 + n2;
- i2 = i1 + n2;
- i3 = i2 + n2;
-
- /* Reading i0, i0+fftLen/2 inputs */
- /* Read ya (real), xa(imag) input */
- T0 = pSrc16[i0 * 2u];
- T1 = pSrc16[(i0 * 2u) + 1u];
- /* Read yc (real), xc(imag) input */
- S0 = pSrc16[i2 * 2u];
- S1 = pSrc16[(i2 * 2u) + 1u];
-
- /* R0 = (ya + yc), R1 = (xa + xc) */
- R0 = __SSAT(T0 + S0, 16u);
- R1 = __SSAT(T1 + S1, 16u);
- /* S0 = (ya - yc), S1 = (xa - xc) */
- S0 = __SSAT(T0 - S0, 16u);
- S1 = __SSAT(T1 - S1, 16u);
-
- /* Reading i0+fftLen/4 , i0+3fftLen/4 inputs */
- /* Read yb (real), xb(imag) input */
- T0 = pSrc16[i1 * 2u];
- T1 = pSrc16[(i1 * 2u) + 1u];
- /* Read yd (real), xd(imag) input */
- U0 = pSrc16[i3 * 2u];
- U1 = pSrc16[(i3 * 2u) + 1u];
-
- /* T0 = (yb + yd), T1 = (xb + xd) */
- T0 = __SSAT(T0 + U0, 16u);
- T1 = __SSAT(T1 + U1, 16u);
-
- /* writing the butterfly processed i0 sample */
- /* xa' = xa + xb + xc + xd */
- /* ya' = ya + yb + yc + yd */
- pSrc16[i0 * 2u] = (R0 >> 1u) + (T0 >> 1u);
- pSrc16[(i0 * 2u) + 1u] = (R1 >> 1u) + (T1 >> 1u);
-
- /* R0 = (ya + yc) - (yb + yd), R1 = (xa + xc) - (xb + xd) */
- R0 = (R0 >> 1u) - (T0 >> 1u);
- R1 = (R1 >> 1u) - (T1 >> 1u);
-
- /* Read yb (real), xb(imag) input */
- T0 = pSrc16[i1 * 2u];
- T1 = pSrc16[(i1 * 2u) + 1u];
-
- /* writing the butterfly processed i0 + fftLen/4 sample */
- /* xc' = (xa-xb+xc-xd) */
- /* yc' = (ya-yb+yc-yd) */
- pSrc16[i1 * 2u] = R0;
- pSrc16[(i1 * 2u) + 1u] = R1;
-
- /* Read yd (real), xd(imag) input */
- U0 = pSrc16[i3 * 2u];
- U1 = pSrc16[(i3 * 2u) + 1u];
- /* T0 = (yb - yd), T1 = (xb - xd) */
- T0 = __SSAT(T0 - U0, 16u);
- T1 = __SSAT(T1 - U1, 16u);
-
- /* writing the butterfly processed i0 + fftLen/2 sample */
- /* xb' = (xa-yb-xc+yd) */
- /* yb' = (ya+xb-yc-xd) */
- pSrc16[i2 * 2u] = (S0 >> 1u) - (T1 >> 1u);
- pSrc16[(i2 * 2u) + 1u] = (S1 >> 1u) + (T0 >> 1u);
-
-
- /* writing the butterfly processed i0 + 3fftLen/4 sample */
- /* xd' = (xa+yb-xc-yd) */
- /* yd' = (ya-xb-yc+xd) */
- pSrc16[i3 * 2u] = (S0 >> 1u) + (T1 >> 1u);
- pSrc16[(i3 * 2u) + 1u] = (S1 >> 1u) - (T0 >> 1u);
- }
- /* end of last stage process */
-
- /* output is in 11.5(q5) format for the 1024 point */
- /* output is in 9.7(q7) format for the 256 point */
- /* output is in 7.9(q9) format for the 64 point */
- /* output is in 5.11(q11) format for the 16 point */
-
- #endif /* #ifndef ARM_MATH_CM0_FAMILY */
-
- }
|