arm_not_u16.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /* ----------------------------------------------------------------------
  2. * Project: CMSIS DSP Library
  3. * Title: arm_not_u16.c
  4. * Description: uint16_t bitwise NOT
  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. #include "dsp/basic_math_functions.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 uint32_t, uint16_t, and uint8_t 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. */
  47. void arm_not_u16(
  48. const uint16_t * pSrc,
  49. uint16_t * pDst,
  50. uint32_t blockSize)
  51. {
  52. uint32_t blkCnt; /* Loop counter */
  53. #if defined(ARM_MATH_MVEI) && !defined(ARM_MATH_AUTOVECTORIZE)
  54. uint16x8_t vecSrc;
  55. /* Compute 8 outputs at a time */
  56. blkCnt = blockSize >> 3;
  57. while (blkCnt > 0U)
  58. {
  59. vecSrc = vld1q(pSrc);
  60. vst1q(pDst, vmvnq_u16(vecSrc) );
  61. pSrc += 8;
  62. pDst += 8;
  63. /* Decrement the loop counter */
  64. blkCnt--;
  65. }
  66. /* Tail */
  67. blkCnt = blockSize & 7;
  68. if (blkCnt > 0U)
  69. {
  70. mve_pred16_t p0 = vctp16q(blkCnt);
  71. vecSrc = vld1q(pSrc);
  72. vstrhq_p(pDst, vmvnq_u16(vecSrc), p0);
  73. }
  74. #else
  75. #if defined(ARM_MATH_NEON) && !defined(ARM_MATH_AUTOVECTORIZE)
  76. uint16x8_t inV;
  77. /* Compute 8 outputs at a time */
  78. blkCnt = blockSize >> 3U;
  79. while (blkCnt > 0U)
  80. {
  81. inV = vld1q_u16(pSrc);
  82. vst1q_u16(pDst, vmvnq_u16(inV) );
  83. pSrc += 8;
  84. pDst += 8;
  85. /* Decrement the loop counter */
  86. blkCnt--;
  87. }
  88. /* Tail */
  89. blkCnt = blockSize & 7;
  90. #else
  91. /* Initialize blkCnt with number of samples */
  92. blkCnt = blockSize;
  93. #endif
  94. while (blkCnt > 0U)
  95. {
  96. *pDst++ = ~(*pSrc++);
  97. /* Decrement the loop counter */
  98. blkCnt--;
  99. }
  100. #endif /* if defined(ARM_MATH_MVEI) */
  101. }
  102. /**
  103. @} end of Not group
  104. */