1 /* ----------------------------------------------------------------------
2 * Copyright (C) 2010 ARM Limited. All rights reserved.
7 * Project: CMSIS DSP Library
10 * Description: Q31 vector addition.
12 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
14 * Version 1.0.10 2011/7/15
15 * Big Endian support added and Merged M0 and M3/M4 Source code.
17 * Version 1.0.3 2010/11/29
18 * Re-organized the CMSIS folders and updated documentation.
20 * Version 1.0.2 2010/11/11
21 * Documentation updated.
23 * Version 1.0.1 2010/10/05
24 * Production release and review comments incorporated.
26 * Version 1.0.0 2010/09/20
27 * Production release and review comments incorporated.
29 * Version 0.0.7 2010/06/10
30 * Misra-C changes done
31 * -------------------------------------------------------------------- */
40 * @addtogroup BasicAdd
46 * @brief Q31 vector addition.
47 * @param[in] *pSrcA points to the first input vector
48 * @param[in] *pSrcB points to the second input vector
49 * @param[out] *pDst points to the output vector
50 * @param[in] blockSize number of samples in each vector
53 * <b>Scaling and Overflow Behavior:</b>
55 * The function uses saturating arithmetic.
56 * Results outside of the allowable Q31 range[0x80000000 0x7FFFFFFF] will be saturated.
65 uint32_t blkCnt; /* loop counter */
69 /* Run the below code for Cortex-M4 and Cortex-M3 */
73 blkCnt = blockSize >> 2u;
75 /* First part of the processing with loop unrolling. Compute 4 outputs at a time.
76 ** a second loop below computes the remaining 1 to 3 samples. */
80 /* Add and then store the results in the destination buffer. */
81 *pDst++ = __QADD(*pSrcA++, *pSrcB++);
82 *pDst++ = __QADD(*pSrcA++, *pSrcB++);
83 *pDst++ = __QADD(*pSrcA++, *pSrcB++);
84 *pDst++ = __QADD(*pSrcA++, *pSrcB++);
86 /* Decrement the loop counter */
90 /* If the blockSize is not a multiple of 4, compute any remaining output samples here.
91 ** No loop unrolling is used. */
92 blkCnt = blockSize % 0x4u;
97 /* Add and then store the results in the destination buffer. */
98 *pDst++ = __QADD(*pSrcA++, *pSrcB++);
100 /* Decrement the loop counter */
106 /* Run the below code for Cortex-M0 */
110 /* Initialize blkCnt with number of samples */
116 /* Add and then store the results in the destination buffer. */
117 *pDst++ = (q31_t) clip_q63_to_q31((q63_t) * pSrcA++ + *pSrcB++);
119 /* Decrement the loop counter */
123 #endif /* #ifndef ARM_MATH_CM0 */
128 * @} end of BasicAdd group