arm_not_u16.c 3.0 KB

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