arm_and_u32.c 3.1 KB

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