arm_not_u32.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /* ----------------------------------------------------------------------
  2. * Project: CMSIS DSP Library
  3. * Title: arm_not_u32.c
  4. * Description: uint32_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. @addtogroup Not
  34. @{
  35. */
  36. /**
  37. @brief Compute the logical bitwise NOT of a fixed-point vector.
  38. @param[in] pSrc points to input vector
  39. @param[out] pDst points to output vector
  40. @param[in] blockSize number of samples in each vector
  41. @return none
  42. */
  43. void arm_not_u32(
  44. const uint32_t * pSrc,
  45. uint32_t * pDst,
  46. uint32_t blockSize)
  47. {
  48. uint32_t blkCnt; /* Loop counter */
  49. #if defined(ARM_MATH_MVEI) && !defined(ARM_MATH_AUTOVECTORIZE)
  50. q31x4_t vecSrc;
  51. /* Compute 8 outputs at a time */
  52. blkCnt = blockSize >> 2;
  53. while (blkCnt > 0U)
  54. {
  55. vecSrc = vld1q(pSrc);
  56. vst1q(pDst, vmvnq_u32(vecSrc) );
  57. pSrc += 4;
  58. pDst += 4;
  59. /* Decrement the loop counter */
  60. blkCnt--;
  61. }
  62. /* Tail */
  63. blkCnt = blockSize & 3;
  64. if (blkCnt > 0U)
  65. {
  66. mve_pred16_t p0 = vctp32q(blkCnt);
  67. vecSrc = vld1q(pSrc);
  68. vstrwq_p(pDst, vmvnq_u32(vecSrc), p0);
  69. }
  70. #else
  71. #if defined(ARM_MATH_NEON) && !defined(ARM_MATH_AUTOVECTORIZE)
  72. uint32x4_t inV;
  73. /* Compute 4 outputs at a time */
  74. blkCnt = blockSize >> 2U;
  75. while (blkCnt > 0U)
  76. {
  77. inV = vld1q_u32(pSrc);
  78. vst1q_u32(pDst, vmvnq_u32(inV) );
  79. pSrc += 4;
  80. pDst += 4;
  81. /* Decrement the loop counter */
  82. blkCnt--;
  83. }
  84. /* Tail */
  85. blkCnt = blockSize & 3;
  86. #else
  87. /* Initialize blkCnt with number of samples */
  88. blkCnt = blockSize;
  89. #endif
  90. while (blkCnt > 0U)
  91. {
  92. *pDst++ = ~(*pSrc++);
  93. /* Decrement the loop counter */
  94. blkCnt--;
  95. }
  96. #endif /* if defined(ARM_MATH_MVEI) */
  97. }
  98. /**
  99. @} end of Not group
  100. */