arm_not_q15.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /* ----------------------------------------------------------------------
  2. * Project: CMSIS DSP Library
  3. * Title: arm_not_q15.c
  4. * Description: Q15 bitwise NOT
  5. *
  6. * $Date: 14 November 2019
  7. * $Revision: V1.6.0
  8. *
  9. * Target Processor: Cortex-M cores
  10. * -------------------------------------------------------------------- */
  11. /*
  12. * Copyright (C) 2010-2019 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. #include "arm_math.h"
  29. /**
  30. @ingroup groupMath
  31. */
  32. /**
  33. @defgroup Not Vector bitwise NOT
  34. Compute the logical bitwise NOT.
  35. There are separate functions for Q31, Q15, and Q7 data types.
  36. */
  37. /**
  38. @addtogroup Not
  39. @{
  40. */
  41. /**
  42. @brief Compute the logical bitwise NOT of a fixed-point vector.
  43. @param[in] pSrc points to input vector
  44. @param[out] pDst points to output vector
  45. @param[in] blockSize number of samples in each vector
  46. @return none
  47. */
  48. void arm_not_q15(
  49. const q15_t * pSrc,
  50. q15_t * pDst,
  51. uint32_t blockSize)
  52. {
  53. uint32_t blkCnt; /* Loop counter */
  54. #if defined(ARM_MATH_NEON)
  55. int16x8_t inV;
  56. /* Compute 8 outputs at a time */
  57. blkCnt = blockSize >> 3U;
  58. while (blkCnt > 0U)
  59. {
  60. inV = vld1q_s16(pSrc);
  61. vst1q_s16(pDst, vmvnq_s16(inV) );
  62. pSrc += 8;
  63. pDst += 8;
  64. /* Decrement the loop counter */
  65. blkCnt--;
  66. }
  67. /* Tail */
  68. blkCnt = blockSize & 7;
  69. #else
  70. /* Initialize blkCnt with number of samples */
  71. blkCnt = blockSize;
  72. #endif
  73. while (blkCnt > 0U)
  74. {
  75. *pDst++ = ~(*pSrc++);
  76. /* Decrement the loop counter */
  77. blkCnt--;
  78. }
  79. }
  80. /**
  81. @} end of Not group
  82. */