1 /* ----------------------------------------------------------------------
2 * Project: CMSIS DSP Library
3 * Title: arm_fill_q31.c
4 * Description: Fills a constant value into a Q31 vector
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
29 #include "dsp/support_functions.h"
30
31 /**
32 @ingroup groupSupport
33 */
34
35 /**
36 @addtogroup Fill
37 @{
38 */
39
40 /**
41 @brief Fills a constant value into a Q31 vector.
42 @param[in] value input value to be filled
43 @param[out] pDst points to output vector
44 @param[in] blockSize number of samples in each vector
45 */
46 #if defined(ARM_MATH_MVEI) && !defined(ARM_MATH_AUTOVECTORIZE)
arm_fill_q31(q31_t value,q31_t * pDst,uint32_t blockSize)47 void arm_fill_q31(
48 q31_t value,
49 q31_t * pDst,
50 uint32_t blockSize)
51 {
52 uint32_t blkCnt;
53 blkCnt = blockSize >> 2U;
54
55 /* Compute 4 outputs at a time */
56 while (blkCnt > 0U)
57 {
58
59 vstrwq_s32(pDst,vdupq_n_s32(value));
60 /*
61 * Decrement the blockSize loop counter
62 * Advance vector source and destination pointers
63 */
64 pDst += 4;
65 blkCnt --;
66 }
67
68 blkCnt = blockSize & 3;
69 while (blkCnt > 0U)
70 {
71 /* C = value */
72
73 /* Fill value in destination buffer */
74 *pDst++ = value;
75
76 /* Decrement loop counter */
77 blkCnt--;
78 }
79
80 }
81
82 #else
arm_fill_q31(q31_t value,q31_t * pDst,uint32_t blockSize)83 void arm_fill_q31(
84 q31_t value,
85 q31_t * pDst,
86 uint32_t blockSize)
87 {
88 uint32_t blkCnt; /* Loop counter */
89
90 #if defined (ARM_MATH_LOOPUNROLL)
91
92 /* Loop unrolling: Compute 4 outputs at a time */
93 blkCnt = blockSize >> 2U;
94
95 while (blkCnt > 0U)
96 {
97 /* C = value */
98
99 /* Fill value in destination buffer */
100 *pDst++ = value;
101 *pDst++ = value;
102 *pDst++ = value;
103 *pDst++ = value;
104
105 /* Decrement loop counter */
106 blkCnt--;
107 }
108
109 /* Loop unrolling: Compute remaining outputs */
110 blkCnt = blockSize % 0x4U;
111
112 #else
113
114 /* Initialize blkCnt with number of samples */
115 blkCnt = blockSize;
116
117 #endif /* #if defined (ARM_MATH_LOOPUNROLL) */
118
119 while (blkCnt > 0U)
120 {
121 /* C = value */
122
123 /* Fill value in destination buffer */
124 *pDst++ = value;
125
126 /* Decrement loop counter */
127 blkCnt--;
128 }
129 }
130 #endif /* defined(ARM_MATH_MVEI) */
131
132 /**
133 @} end of Fill group
134 */
135