259 #define __CMSIS_GENERIC
261 #if defined (ARM_MATH_CM4)
263 #elif defined (ARM_MATH_CM3)
265 #elif defined (ARM_MATH_CM0)
269 #warning "Define either ARM_MATH_CM4 OR ARM_MATH_CM3...By Default building on ARM_MATH_CM4....."
272 #undef __CMSIS_GENERIC
285 #define DELTA_Q31 (0x100)
286 #define DELTA_Q15 0x5
287 #define INDEX_MASK 0x0000003F
289 #define PI 3.14159265358979f
296 #define TABLE_SIZE 256
297 #define TABLE_SPACING_Q31 0x800000
298 #define TABLE_SPACING_Q15 0x80
305 #define INPUT_SPACING 0xB60B61
310 #ifndef UNALIGNED_SUPPORT_DISABLE
313 #if defined (__GNUC__)
314 #define ALIGN4 __attribute__((aligned(4)))
316 #define ALIGN4 __align(4)
368 #if defined (__GNUC__)
369 #define __SIMD32(addr) (*( int32_t **) & (addr))
370 #define _SIMD32_OFFSET(addr) (*( int32_t * ) (addr))
372 #define __SIMD32(addr) (*(__packed int32_t **) & (addr))
373 #define _SIMD32_OFFSET(addr) (*(__packed int32_t * ) (addr))
376 #define __SIMD64(addr) (*(int64_t **) & (addr))
378 #if defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0)
382 #define __PKHBT(ARG1, ARG2, ARG3) ( (((int32_t)(ARG1) << 0) & (int32_t)0x0000FFFF) | \
383 (((int32_t)(ARG2) << ARG3) & (int32_t)0xFFFF0000) )
384 #define __PKHTB(ARG1, ARG2, ARG3) ( (((int32_t)(ARG1) << 0) & (int32_t)0xFFFF0000) | \
385 (((int32_t)(ARG2) >> ARG3) & (int32_t)0x0000FFFF) )
393 #ifndef ARM_MATH_BIG_ENDIAN
395 #define __PACKq7(v0,v1,v2,v3) ( (((int32_t)(v0) << 0) & (int32_t)0x000000FF) | \
396 (((int32_t)(v1) << 8) & (int32_t)0x0000FF00) | \
397 (((int32_t)(v2) << 16) & (int32_t)0x00FF0000) | \
398 (((int32_t)(v3) << 24) & (int32_t)0xFF000000) )
401 #define __PACKq7(v0,v1,v2,v3) ( (((int32_t)(v3) << 0) & (int32_t)0x000000FF) | \
402 (((int32_t)(v2) << 8) & (int32_t)0x0000FF00) | \
403 (((int32_t)(v1) << 16) & (int32_t)0x00FF0000) | \
404 (((int32_t)(v0) << 24) & (int32_t)0xFF000000) )
415 return ((q31_t) (x >> 32) != ((q31_t) x >> 31)) ?
416 ((0x7FFFFFFF ^ ((
q31_t) (x >> 63)))) : (q31_t)
x;
425 return ((q31_t) (x >> 32) != ((q31_t) x >> 31)) ?
426 ((0x7FFF ^ ((
q15_t) (x >> 63)))) : (q15_t) (x >> 15);
435 return ((q31_t) (x >> 24) != ((q31_t) x >> 23)) ?
436 ((0x7F ^ ((
q7_t) (x >> 31)))) : (q7_t)
x;
445 return ((q31_t) (x >> 16) != ((q31_t) x >> 15)) ?
446 ((0x7FFF ^ ((
q15_t) (x >> 31)))) : (q15_t)
x;
457 return ((((q63_t) (x & 0x00000000FFFFFFFF) * y) >> 32) +
458 (((q63_t) (x >> 32) * y)));
462 #if defined (ARM_MATH_CM0) && defined ( __CC_ARM )
466 #if defined (ARM_MATH_CM0) && defined ( __TASKING__ )
470 #if defined (ARM_MATH_CM0) && ((defined (__ICCARM__)) ||(defined (__GNUC__)) )
472 __STATIC_INLINE
uint32_t __CLZ(q31_t data);
475 __STATIC_INLINE
uint32_t __CLZ(q31_t data)
480 while((data & mask) == 0)
508 signBits = __CLZ(in) - 1;
512 signBits = __CLZ(-in) - 1;
523 out = pRecipTable[index];
527 for (i = 0u; i < 2u; i++)
529 tempVal = (
q31_t) (((q63_t) in * out) >> 31u);
530 tempVal = 0x7FFFFFFF - tempVal;
540 return (signBits + 1u);
559 signBits = __CLZ(in) - 17;
563 signBits = __CLZ(-in) - 17;
574 out = pRecipTable[index];
578 for (i = 0; i < 2; i++)
580 tempVal = (
q15_t) (((q31_t) in * out) >> 15);
581 tempVal = 0x7FFF - tempVal;
583 out = (
q15_t) (((q31_t) out * tempVal) >> 14);
590 return (signBits + 1);
598 #if defined(ARM_MATH_CM0)
600 __STATIC_INLINE q31_t __SSAT(
608 for (i = 0; i < (y - 1); i++)
615 posMax = (posMax - 1);
643 #if defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0)
648 __STATIC_INLINE q31_t __QADD8(
659 r = __SSAT((q31_t) (r + s), 8);
660 s = __SSAT(((q31_t) (((x << 16) >> 24) + ((y << 16) >> 24))), 8);
661 t = __SSAT(((q31_t) (((x << 8) >> 24) + ((y << 8) >> 24))), 8);
662 u = __SSAT(((q31_t) ((x >> 24) + (y >> 24))), 8);
665 (((
q31_t) u << 24) & 0xFF000000) | (((q31_t) t << 16) & 0x00FF0000) |
666 (((
q31_t) s << 8) & 0x0000FF00) | (r & 0x000000FF);
675 __STATIC_INLINE q31_t __QSUB8(
686 r = __SSAT((r - s), 8);
687 s = __SSAT(((q31_t) (((x << 16) >> 24) - ((y << 16) >> 24))), 8) << 8;
688 t = __SSAT(((q31_t) (((x << 8) >> 24) - ((y << 8) >> 24))), 8) << 16;
689 u = __SSAT(((q31_t) ((x >> 24) - (y >> 24))), 8) << 24;
692 (u & 0xFF000000) | (t & 0x00FF0000) | (s & 0x0000FF00) | (r &
705 __STATIC_INLINE q31_t __QADD16(
716 r = __SSAT(r + s, 16);
717 s = __SSAT(((q31_t) ((x >> 16) + (y >> 16))), 16) << 16;
719 sum = (s & 0xFFFF0000) | (r & 0x0000FFFF);
728 __STATIC_INLINE q31_t __SHADD16(
739 r = ((r >> 1) + (s >> 1));
740 s = ((
q31_t) ((x >> 17) + (y >> 17))) << 16;
742 sum = (s & 0xFFFF0000) | (r & 0x0000FFFF);
751 __STATIC_INLINE q31_t __QSUB16(
762 r = __SSAT(r - s, 16);
763 s = __SSAT(((q31_t) ((x >> 16) - (y >> 16))), 16) << 16;
765 sum = (s & 0xFFFF0000) | (r & 0x0000FFFF);
773 __STATIC_INLINE q31_t __SHSUB16(
784 r = ((r >> 1) - (s >> 1));
785 s = (((x >> 17) - (y >> 17)) << 16);
787 diff = (s & 0xFFFF0000) | (r & 0x0000FFFF);
795 __STATIC_INLINE q31_t __QASX(
813 __STATIC_INLINE q31_t __SHASX(
824 r = ((r >> 1) - (y >> 17));
825 s = (((x >> 17) + (s >> 1)) << 16);
827 sum = (s & 0xFFFF0000) | (r & 0x0000FFFF);
836 __STATIC_INLINE q31_t __QSAX(
854 __STATIC_INLINE q31_t __SHSAX(
865 r = ((r >> 1) + (y >> 17));
866 s = (((x >> 17) - (s >> 1)) << 16);
868 sum = (s & 0xFFFF0000) | (r & 0x0000FFFF);
876 __STATIC_INLINE q31_t __SMUSDX(
881 return ((q31_t) (((
short) x * (
short) (y >> 16)) -
882 ((
short) (x >> 16) * (
short) y)));
888 __STATIC_INLINE q31_t __SMUADX(
893 return ((q31_t) (((
short) x * (
short) (y >> 16)) +
894 ((
short) (x >> 16) * (
short) y)));
900 __STATIC_INLINE q31_t __QADD(
910 __STATIC_INLINE q31_t __QSUB(
920 __STATIC_INLINE q31_t __SMLAD(
926 return (sum + ((
short) (x >> 16) * (
short) (y >> 16)) +
927 ((
short) x * (
short) y));
933 __STATIC_INLINE q31_t __SMLADX(
939 return (sum + ((
short) (x >> 16) * (
short) (y)) +
940 ((
short) x * (
short) (y >> 16)));
946 __STATIC_INLINE q31_t __SMLSDX(
952 return (sum - ((
short) (x >> 16) * (
short) (y)) +
953 ((
short) x * (
short) (y >> 16)));
959 __STATIC_INLINE q63_t __SMLALD(
965 return (sum + ((
short) (x >> 16) * (
short) (y >> 16)) +
966 ((
short) x * (
short) y));
972 __STATIC_INLINE q63_t __SMLALDX(
978 return (sum + ((
short) (x >> 16) * (
short) y)) +
979 ((short) x * (
short) (y >> 16));
985 __STATIC_INLINE q31_t __SMUAD(
990 return (((x >> 16) * (y >> 16)) +
991 (((x << 16) >> 16) * ((y << 16) >> 16)));
997 __STATIC_INLINE q31_t __SMUSD(
1002 return (-((x >> 16) * (y >> 16)) +
1003 (((x << 16) >> 16) * ((y << 16) >> 16)));
1010 __STATIC_INLINE q31_t __SXTB16(
1014 return ((((x << 24) >> 24) & 0x0000FFFF) |
1015 (((x << 8) >> 8) & 0xFFFF0000));
1211 float32_t * pCoeffs,
1378 float32_t * pCoeffs,
1379 float32_t * pState);
2223 float32_t onebyfftLen);
2345 float32_t onebyfftLen);
2594 float32_t normalize);
2607 float32_t * pInlineBuffer);
2654 q31_t * pInlineBuffer);
2701 q15_t * pInlineBuffer);
2954 float32_t * result);
3707 float32_t * pCoeffs,
3956 float32_t * pCoeffs,
4047 float32_t * pCoeffs,
4048 float32_t * pState);
4158 float32_t * pCoeffs,
4159 float32_t * pState);
4238 float32_t * pkCoeffs,
4239 float32_t * pvCoeffs,
4360 float32_t * pCoeffs,
4521 float32_t * pCoeffs,
4876 float32_t * pScratchIn,
4894 float32_t * pCoeffs,
4954 q31_t * pScratchOut,
4995 q31_t * pScratchOut,
5030 float32_t * pSinVal,
5031 float32_t * pCcosVal);
5209 out = (S->
A0 * in) +
5248 acc += (q63_t) S->
A1 * S->
state[0];
5254 out = (q31_t) (acc >> 31u);
5302 acc = (
q31_t) __SMUAD(S->
A0, in);
5310 acc += (q31_t) S->A2 * S->
state[1];
5323 out = (q15_t) (__SSAT((acc >> 15), 16));
5399 float32_t * pIalpha,
5407 ((
float32_t) 0.57735026919 * Ia + (float32_t) 1.15470053838 * Ib);
5432 q31_t product1, product2;
5438 product1 = (
q31_t) (((q63_t) Ia * 0x24F34E8B) >> 30);
5441 product2 = (
q31_t) (((q63_t) Ib * 0x49E69D16) >> 30);
5444 *pIbeta = __QADD(product1, product2);
5511 *pIb = -0.5 * Ialpha + (
float32_t) 0.8660254039 *Ibeta;
5536 q31_t product1, product2;
5542 product1 = (
q31_t) (((q63_t) (Ialpha) * (0x40000000)) >> 31);
5545 product2 = (
q31_t) (((q63_t) (Ibeta) * (0x6ED9EBA1)) >> 31);
5548 *pIb = __QSUB(product2, product1);
5626 *pId = Ialpha * cosVal + Ibeta * sinVal;
5629 *pIq = -Ialpha * sinVal + Ibeta * cosVal;
5659 q31_t product1, product2;
5660 q31_t product3, product4;
5663 product1 = (
q31_t) (((q63_t) (Ialpha) * (cosVal)) >> 31);
5666 product2 = (
q31_t) (((q63_t) (Ibeta) * (sinVal)) >> 31);
5670 product3 = (
q31_t) (((q63_t) (Ialpha) * (sinVal)) >> 31);
5673 product4 = (
q31_t) (((q63_t) (Ibeta) * (cosVal)) >> 31);
5676 *pId = __QADD(product1, product2);
5679 *pIq = __QSUB(product4, product3);
5739 float32_t * pIalpha,
5745 *pIalpha = Id * cosVal - Iq * sinVal;
5748 *pIbeta = Id * sinVal + Iq * cosVal;
5779 q31_t product1, product2;
5780 q31_t product3, product4;
5783 product1 = (
q31_t) (((q63_t) (Id) * (cosVal)) >> 31);
5786 product2 = (
q31_t) (((q63_t) (Iq) * (sinVal)) >> 31);
5790 product3 = (
q31_t) (((q63_t) (Id) * (sinVal)) >> 31);
5793 product4 = (
q31_t) (((q63_t) (Iq) * (cosVal)) >> 31);
5796 *pIalpha = __QSUB(product1, product2);
5799 *pIbeta = __QADD(product4, product3);
5879 float32_t *pYData = S->
pYData;
5882 i = (x - S->
x1) / xSpacing;
5897 x0 = S->
x1 + i * xSpacing;
5898 x1 = S->
x1 + (i + 1) * xSpacing;
5905 y = y0 + (x - x0) * ((y1 - y0) / (x1 - x0));
5941 index = ((x & 0xFFF00000) >> 20);
5943 if(index >= (nValues - 1))
5945 return (pYData[nValues - 1]);
5956 fract = (x & 0x000FFFFF) << 11;
5960 y1 = pYData[index + 1u];
5963 y = ((
q31_t) ((q63_t) y0 * (0x7FFFFFFF - fract) >> 32));
5966 y += ((
q31_t) (((q63_t) y1 * fract) >> 32));
6003 index = ((x & 0xFFF00000) >> 20u);
6005 if(index >= (nValues - 1))
6007 return (pYData[nValues - 1]);
6017 fract = (x & 0x000FFFFF);
6021 y1 = pYData[index + 1u];
6024 y = ((
q63_t) y0 * (0xFFFFF - fract));
6027 y += ((
q63_t) y1 * (fract));
6063 index = ((x & 0xFFF00000) >> 20u);
6066 if(index >= (nValues - 1))
6068 return (pYData[nValues - 1]);
6079 fract = (x & 0x000FFFFF);
6083 y1 = pYData[index + 1u];
6086 y = ((y0 * (0xFFFFF - fract)));
6203 #if (__FPU_USED == 1) && defined ( __CC_ARM )
6204 *pOut = __sqrtf(in);
6205 #elif (__FPU_USED == 1) && defined ( __TMS_740 )
6206 *pOut = __builtin_sqrtf(in);
6271 wOffset = *writeOffset;
6279 circBuffer[wOffset] = *src;
6285 wOffset += bufferInc;
6294 *writeOffset = wOffset;
6318 rOffset = *readOffset;
6319 dst_end = (
int32_t) (dst_base + dst_length);
6327 *dst = circBuffer[rOffset];
6332 if(dst == (
int32_t *) dst_end)
6338 rOffset += bufferInc;
6350 *readOffset = rOffset;
6371 wOffset = *writeOffset;
6379 circBuffer[wOffset] = *src;
6385 wOffset += bufferInc;
6394 *writeOffset = wOffset;
6418 rOffset = *readOffset;
6420 dst_end = (
int32_t) (dst_base + dst_length);
6428 *dst = circBuffer[rOffset];
6433 if(dst == (q15_t *) dst_end)
6439 rOffset += bufferInc;
6451 *readOffset = rOffset;
6473 wOffset = *writeOffset;
6481 circBuffer[wOffset] = *src;
6487 wOffset += bufferInc;
6496 *writeOffset = wOffset;
6520 rOffset = *readOffset;
6522 dst_end = (
int32_t) (dst_base + dst_length);
6530 *dst = circBuffer[rOffset];
6535 if(dst == (q7_t *) dst_end)
6541 rOffset += bufferInc;
6553 *readOffset = rOffset;
6581 float32_t * pResult);
6656 float32_t * pResult);
6669 float32_t * pResult);
6708 float32_t * pResult);
6747 float32_t * pResult);
6829 q31_t * imagResult);
6846 q63_t * imagResult);
6862 float32_t * realResult,
6863 float32_t * imagResult);
6905 float32_t * pSrcCmplx,
6906 float32_t * pSrcReal,
6907 float32_t * pCmplxDst,
6966 float32_t * pResult,
7026 float32_t * pResult,
7251 float32_t f00, f01, f10, f11;
7252 float32_t *pData = S->
pData;
7253 int32_t xIndex, yIndex, index;
7254 float32_t xdiff, ydiff;
7255 float32_t b1, b2, b3, b4;
7262 if(xIndex < 0 || xIndex > (S->
numRows - 1) || yIndex < 0
7269 index = (xIndex - 1) + (yIndex - 1) * S->
numCols;
7274 f01 = pData[index + 1];
7277 index = (xIndex - 1) + (yIndex) * S->
numCols;
7282 f11 = pData[index + 1];
7288 b4 = f00 - f01 - f10 + f11;
7297 out = b1 + b2 * xdiff + b3 * ydiff + b4 * xdiff * ydiff;
7320 q31_t xfract, yfract;
7321 q31_t x1, x2, y1, y2;
7323 q31_t *pYData = S->
pData;
7330 rI = ((X & 0xFFF00000) >> 20u);
7335 cI = ((Y & 0xFFF00000) >> 20u);
7339 if(rI < 0 || rI > (S->
numRows - 1) || cI < 0 || cI > (S->
numCols - 1))
7346 xfract = (X & 0x000FFFFF) << 11u;
7349 x1 = pYData[(rI) + nCols * (cI)];
7350 x2 = pYData[(rI) + nCols * (cI) + 1u];
7354 yfract = (Y & 0x000FFFFF) << 11u;
7357 y1 = pYData[(rI) + nCols * (cI + 1)];
7358 y2 = pYData[(rI) + nCols * (cI + 1) + 1u];
7361 out = ((
q31_t) (((q63_t) x1 * (0x7FFFFFFF - xfract)) >> 32));
7362 acc = ((
q31_t) (((q63_t) out * (0x7FFFFFFF - yfract)) >> 32));
7365 out = ((
q31_t) ((q63_t) x2 * (0x7FFFFFFF - yfract) >> 32));
7366 acc += ((
q31_t) ((q63_t) out * (xfract) >> 32));
7369 out = ((
q31_t) ((q63_t) y1 * (0x7FFFFFFF - xfract) >> 32));
7370 acc += ((
q31_t) ((q63_t) out * (yfract) >> 32));
7373 out = ((
q31_t) ((q63_t) y2 * (xfract) >> 32));
7374 acc += ((
q31_t) ((q63_t) out * (yfract) >> 32));
7396 q15_t x1, x2, y1, y2;
7397 q31_t xfract, yfract;
7399 q15_t *pYData = S->
pData;
7405 rI = ((X & 0xFFF00000) >> 20);
7410 cI = ((Y & 0xFFF00000) >> 20);
7414 if(rI < 0 || rI > (S->
numRows - 1) || cI < 0 || cI > (S->
numCols - 1))
7421 xfract = (X & 0x000FFFFF);
7424 x1 = pYData[(rI) + nCols * (cI)];
7425 x2 = pYData[(rI) + nCols * (cI) + 1u];
7430 yfract = (Y & 0x000FFFFF);
7433 y1 = pYData[(rI) + nCols * (cI + 1)];
7434 y2 = pYData[(rI) + nCols * (cI + 1) + 1u];
7440 out = (
q31_t) (((q63_t) x1 * (0xFFFFF - xfract)) >> 4u);
7441 acc = ((
q63_t) out * (0xFFFFF - yfract));
7444 out = (
q31_t) (((q63_t) x2 * (0xFFFFF - yfract)) >> 4u);
7445 acc += ((
q63_t) out * (xfract));
7448 out = (
q31_t) (((q63_t) y1 * (0xFFFFF - xfract)) >> 4u);
7449 acc += ((
q63_t) out * (yfract));
7452 out = (
q31_t) (((q63_t) y2 * (xfract)) >> 4u);
7453 acc += ((
q63_t) out * (yfract));
7476 q31_t xfract, yfract;
7477 q7_t x1, x2, y1, y2;
7479 q7_t *pYData = S->
pData;
7485 rI = ((X & 0xFFF00000) >> 20);
7490 cI = ((Y & 0xFFF00000) >> 20);
7494 if(rI < 0 || rI > (S->
numRows - 1) || cI < 0 || cI > (S->
numCols - 1))
7501 xfract = (X & 0x000FFFFF);
7504 x1 = pYData[(rI) + nCols * (cI)];
7505 x2 = pYData[(rI) + nCols * (cI) + 1u];
7510 yfract = (Y & 0x000FFFFF);
7513 y1 = pYData[(rI) + nCols * (cI + 1)];
7514 y2 = pYData[(rI) + nCols * (cI + 1) + 1u];
7517 out = ((x1 * (0xFFFFF - xfract)));
7518 acc = (((
q63_t) out * (0xFFFFF - yfract)));
7521 out = ((x2 * (0xFFFFF - yfract)));
7522 acc += (((
q63_t) out * (xfract)));
7525 out = ((y1 * (0xFFFFF - xfract)));
7526 acc += (((
q63_t) out * (yfract)));
7529 out = ((y2 * (yfract)));
7530 acc += (((
q63_t) out * (xfract)));