1*10465441SEvalZero /*
2*10465441SEvalZero * Copyright (C) 2017 C-SKY Microsystems Co., Ltd. All rights reserved.
3*10465441SEvalZero *
4*10465441SEvalZero * Licensed under the Apache License, Version 2.0 (the "License");
5*10465441SEvalZero * you may not use this file except in compliance with the License.
6*10465441SEvalZero * You may obtain a copy of the License at
7*10465441SEvalZero *
8*10465441SEvalZero * http://www.apache.org/licenses/LICENSE-2.0
9*10465441SEvalZero *
10*10465441SEvalZero * Unless required by applicable law or agreed to in writing, software
11*10465441SEvalZero * distributed under the License is distributed on an "AS IS" BASIS,
12*10465441SEvalZero * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*10465441SEvalZero * See the License for the specific language governing permissions and
14*10465441SEvalZero * limitations under the License.
15*10465441SEvalZero */
16*10465441SEvalZero
17*10465441SEvalZero /******************************************************************************
18*10465441SEvalZero * @file csi_simd.h
19*10465441SEvalZero * @brief CSI Single Instruction Multiple Data (SIMD) Header File for GCC.
20*10465441SEvalZero * @version V1.0
21*10465441SEvalZero * @date 02. June 2017
22*10465441SEvalZero ******************************************************************************/
23*10465441SEvalZero
24*10465441SEvalZero #ifndef _CSI_SIMD_H_
25*10465441SEvalZero #define _CSI_SIMD_H_
26*10465441SEvalZero
27*10465441SEvalZero /**
28*10465441SEvalZero \brief Halfword packing instruction. Combines bits[15:0] of val1 with bits[31:16]
29*10465441SEvalZero of val2 levitated with the val3.
30*10465441SEvalZero \details Combine a halfword from one register with a halfword from another register.
31*10465441SEvalZero The second argument can be left-shifted before extraction of the halfword.
32*10465441SEvalZero \param [in] val1 first 16-bit operands
33*10465441SEvalZero \param [in] val2 second 16-bit operands
34*10465441SEvalZero \param [in] val3 value for left-shifting val2. Value range [0..31].
35*10465441SEvalZero \return the combination of halfwords.
36*10465441SEvalZero \remark
37*10465441SEvalZero res[15:0] = val1[15:0] \n
38*10465441SEvalZero res[31:16] = val2[31:16] << val3
39*10465441SEvalZero */
__PKHBT(uint32_t val1,uint32_t val2,uint32_t val3)40*10465441SEvalZero __ALWAYS_INLINE uint32_t __PKHBT(uint32_t val1, uint32_t val2, uint32_t val3)
41*10465441SEvalZero {
42*10465441SEvalZero return ((((int32_t)(val1) << 0) & (int32_t)0x0000FFFF) | (((int32_t)(val2) << val3) & (int32_t)0xFFFF0000));
43*10465441SEvalZero }
44*10465441SEvalZero
45*10465441SEvalZero /**
46*10465441SEvalZero \brief Halfword packing instruction. Combines bits[31:16] of val1 with bits[15:0]
47*10465441SEvalZero of val2 right-shifted with the val3.
48*10465441SEvalZero \details Combine a halfword from one register with a halfword from another register.
49*10465441SEvalZero The second argument can be right-shifted before extraction of the halfword.
50*10465441SEvalZero \param [in] val1 first 16-bit operands
51*10465441SEvalZero \param [in] val2 second 16-bit operands
52*10465441SEvalZero \param [in] val3 value for right-shifting val2. Value range [1..32].
53*10465441SEvalZero \return the combination of halfwords.
54*10465441SEvalZero \remark
55*10465441SEvalZero res[15:0] = val2[15:0] >> val3 \n
56*10465441SEvalZero res[31:16] = val1[31:16]
57*10465441SEvalZero */
__PKHTB(uint32_t val1,uint32_t val2,uint32_t val3)58*10465441SEvalZero __ALWAYS_INLINE uint32_t __PKHTB(uint32_t val1, uint32_t val2, uint32_t val3)
59*10465441SEvalZero {
60*10465441SEvalZero return ((((int32_t)(val1) << 0) & (int32_t)0xFFFF0000) | (((int32_t)(val2) >> val3) & (int32_t)0x0000FFFF));
61*10465441SEvalZero }
62*10465441SEvalZero
63*10465441SEvalZero /**
64*10465441SEvalZero \brief Dual 16-bit signed saturate.
65*10465441SEvalZero \details This function saturates a signed value.
66*10465441SEvalZero \param [in] x two signed 16-bit values to be saturated.
67*10465441SEvalZero \param [in] y bit position for saturation, an integral constant expression in the range 1 to 16.
68*10465441SEvalZero \return the sum of the absolute differences of the following bytes, added to the accumulation value:\n
69*10465441SEvalZero the signed saturation of the low halfword in val1, saturated to the bit position specified in
70*10465441SEvalZero val2 and returned in the low halfword of the return value.\n
71*10465441SEvalZero the signed saturation of the high halfword in val1, saturated to the bit position specified in
72*10465441SEvalZero val2 and returned in the high halfword of the return value.
73*10465441SEvalZero */
__SSAT16(int32_t x,const uint32_t y)74*10465441SEvalZero __ALWAYS_INLINE uint32_t __SSAT16(int32_t x, const uint32_t y)
75*10465441SEvalZero {
76*10465441SEvalZero int32_t r = 0, s = 0;
77*10465441SEvalZero
78*10465441SEvalZero r = __SSAT((((int32_t)x << 16) >> 16), y) & (int32_t)0x0000FFFF;
79*10465441SEvalZero s = __SSAT((((int32_t)x) >> 16), y) & (int32_t)0x0000FFFF;
80*10465441SEvalZero
81*10465441SEvalZero return ((uint32_t)((s << 16) | (r)));
82*10465441SEvalZero }
83*10465441SEvalZero
84*10465441SEvalZero /**
85*10465441SEvalZero \brief Dual 16-bit unsigned saturate.
86*10465441SEvalZero \details This function enables you to saturate two signed 16-bit values to a selected unsigned range.
87*10465441SEvalZero \param [in] x two signed 16-bit values to be saturated.
88*10465441SEvalZero \param [in] y bit position for saturation, an integral constant expression in the range 1 to 16.
89*10465441SEvalZero \return the saturation of the two signed 16-bit values, as non-negative values:
90*10465441SEvalZero the saturation of the low halfword in val1, saturated to the bit position specified in
91*10465441SEvalZero val2 and returned in the low halfword of the return value.\n
92*10465441SEvalZero the saturation of the high halfword in val1, saturated to the bit position specified in
93*10465441SEvalZero val2 and returned in the high halfword of the return value.
94*10465441SEvalZero */
__USAT16(uint32_t x,const uint32_t y)95*10465441SEvalZero __ALWAYS_INLINE uint32_t __USAT16(uint32_t x, const uint32_t y)
96*10465441SEvalZero {
97*10465441SEvalZero int32_t r = 0, s = 0;
98*10465441SEvalZero
99*10465441SEvalZero r = __IUSAT(((x << 16) >> 16), y) & 0x0000FFFF;
100*10465441SEvalZero s = __IUSAT(((x) >> 16), y) & 0x0000FFFF;
101*10465441SEvalZero
102*10465441SEvalZero return ((s << 16) | (r));
103*10465441SEvalZero }
104*10465441SEvalZero
105*10465441SEvalZero /**
106*10465441SEvalZero \brief Quad 8-bit saturating addition.
107*10465441SEvalZero \details This function enables you to perform four 8-bit integer additions,
108*10465441SEvalZero saturating the results to the 8-bit signed integer range -2^7 <= x <= 2^7 - 1.
109*10465441SEvalZero \param [in] x first four 8-bit summands.
110*10465441SEvalZero \param [in] y second four 8-bit summands.
111*10465441SEvalZero \return the saturated addition of the first byte of each operand in the first byte of the return value.\n
112*10465441SEvalZero the saturated addition of the second byte of each operand in the second byte of the return value.\n
113*10465441SEvalZero the saturated addition of the third byte of each operand in the third byte of the return value.\n
114*10465441SEvalZero the saturated addition of the fourth byte of each operand in the fourth byte of the return value.\n
115*10465441SEvalZero The returned results are saturated to the 8-bit signed integer range -2^7 <= x <= 2^7 - 1.
116*10465441SEvalZero \remark
117*10465441SEvalZero res[7:0] = val1[7:0] + val2[7:0] \n
118*10465441SEvalZero res[15:8] = val1[15:8] + val2[15:8] \n
119*10465441SEvalZero res[23:16] = val1[23:16] + val2[23:16] \n
120*10465441SEvalZero res[31:24] = val1[31:24] + val2[31:24]
121*10465441SEvalZero */
__QADD8(uint32_t x,uint32_t y)122*10465441SEvalZero __ALWAYS_INLINE uint32_t __QADD8(uint32_t x, uint32_t y)
123*10465441SEvalZero {
124*10465441SEvalZero int32_t r, s, t, u;
125*10465441SEvalZero
126*10465441SEvalZero r = __SSAT(((((int32_t)x << 24) >> 24) + (((int32_t)y << 24) >> 24)), 8) & (int32_t)0x000000FF;
127*10465441SEvalZero s = __SSAT(((((int32_t)x << 16) >> 24) + (((int32_t)y << 16) >> 24)), 8) & (int32_t)0x000000FF;
128*10465441SEvalZero t = __SSAT(((((int32_t)x << 8) >> 24) + (((int32_t)y << 8) >> 24)), 8) & (int32_t)0x000000FF;
129*10465441SEvalZero u = __SSAT(((((int32_t)x) >> 24) + (((int32_t)y) >> 24)), 8) & (int32_t)0x000000FF;
130*10465441SEvalZero
131*10465441SEvalZero return ((uint32_t)((u << 24) | (t << 16) | (s << 8) | (r)));
132*10465441SEvalZero }
133*10465441SEvalZero
134*10465441SEvalZero /**
135*10465441SEvalZero \brief Quad 8-bit unsigned saturating addition.
136*10465441SEvalZero \details This function enables you to perform four unsigned 8-bit integer additions,
137*10465441SEvalZero saturating the results to the 8-bit unsigned integer range 0 < x < 2^8 - 1.
138*10465441SEvalZero \param [in] x first four 8-bit summands.
139*10465441SEvalZero \param [in] y second four 8-bit summands.
140*10465441SEvalZero \return the saturated addition of the first byte of each operand in the first byte of the return value.\n
141*10465441SEvalZero the saturated addition of the second byte of each operand in the second byte of the return value.\n
142*10465441SEvalZero the saturated addition of the third byte of each operand in the third byte of the return value.\n
143*10465441SEvalZero the saturated addition of the fourth byte of each operand in the fourth byte of the return value.\n
144*10465441SEvalZero The returned results are saturated to the 8-bit signed integer range 0 <= x <= 2^8 - 1.
145*10465441SEvalZero \remark
146*10465441SEvalZero res[7:0] = val1[7:0] + val2[7:0] \n
147*10465441SEvalZero res[15:8] = val1[15:8] + val2[15:8] \n
148*10465441SEvalZero res[23:16] = val1[23:16] + val2[23:16] \n
149*10465441SEvalZero res[31:24] = val1[31:24] + val2[31:24]
150*10465441SEvalZero */
__UQADD8(uint32_t x,uint32_t y)151*10465441SEvalZero __ALWAYS_INLINE uint32_t __UQADD8(uint32_t x, uint32_t y)
152*10465441SEvalZero {
153*10465441SEvalZero int32_t r, s, t, u;
154*10465441SEvalZero
155*10465441SEvalZero r = __IUSAT((((x << 24) >> 24) + ((y << 24) >> 24)), 8) & 0x000000FF;
156*10465441SEvalZero s = __IUSAT((((x << 16) >> 24) + ((y << 16) >> 24)), 8) & 0x000000FF;
157*10465441SEvalZero t = __IUSAT((((x << 8) >> 24) + ((y << 8) >> 24)), 8) & 0x000000FF;
158*10465441SEvalZero u = __IUSAT((((x) >> 24) + ((y) >> 24)), 8) & 0x000000FF;
159*10465441SEvalZero
160*10465441SEvalZero return ((u << 24) | (t << 16) | (s << 8) | (r));
161*10465441SEvalZero }
162*10465441SEvalZero
163*10465441SEvalZero /**
164*10465441SEvalZero \brief Quad 8-bit signed addition.
165*10465441SEvalZero \details This function performs four 8-bit signed integer additions.
166*10465441SEvalZero \param [in] x first four 8-bit summands.
167*10465441SEvalZero \param [in] y second four 8-bit summands.
168*10465441SEvalZero \return the addition of the first bytes from each operand, in the first byte of the return value.\n
169*10465441SEvalZero the addition of the second bytes of each operand, in the second byte of the return value.\n
170*10465441SEvalZero the addition of the third bytes of each operand, in the third byte of the return value.\n
171*10465441SEvalZero the addition of the fourth bytes of each operand, in the fourth byte of the return value.
172*10465441SEvalZero \remark
173*10465441SEvalZero res[7:0] = val1[7:0] + val2[7:0] \n
174*10465441SEvalZero res[15:8] = val1[15:8] + val2[15:8] \n
175*10465441SEvalZero res[23:16] = val1[23:16] + val2[23:16] \n
176*10465441SEvalZero res[31:24] = val1[31:24] + val2[31:24]
177*10465441SEvalZero */
__SADD8(uint32_t x,uint32_t y)178*10465441SEvalZero __ALWAYS_INLINE uint32_t __SADD8(uint32_t x, uint32_t y)
179*10465441SEvalZero {
180*10465441SEvalZero int32_t r, s, t, u;
181*10465441SEvalZero
182*10465441SEvalZero r = ((((int32_t)x << 24) >> 24) + (((int32_t)y << 24) >> 24)) & (int32_t)0x000000FF;
183*10465441SEvalZero s = ((((int32_t)x << 16) >> 24) + (((int32_t)y << 16) >> 24)) & (int32_t)0x000000FF;
184*10465441SEvalZero t = ((((int32_t)x << 8) >> 24) + (((int32_t)y << 8) >> 24)) & (int32_t)0x000000FF;
185*10465441SEvalZero u = ((((int32_t)x) >> 24) + (((int32_t)y) >> 24)) & (int32_t)0x000000FF;
186*10465441SEvalZero
187*10465441SEvalZero return ((uint32_t)((u << 24) | (t << 16) | (s << 8) | (r)));
188*10465441SEvalZero }
189*10465441SEvalZero
190*10465441SEvalZero /**
191*10465441SEvalZero \brief Quad 8-bit unsigned addition.
192*10465441SEvalZero \details This function performs four unsigned 8-bit integer additions.
193*10465441SEvalZero \param [in] x first four 8-bit summands.
194*10465441SEvalZero \param [in] y second four 8-bit summands.
195*10465441SEvalZero \return the addition of the first bytes from each operand, in the first byte of the return value.\n
196*10465441SEvalZero the addition of the second bytes of each operand, in the second byte of the return value.\n
197*10465441SEvalZero the addition of the third bytes of each operand, in the third byte of the return value.\n
198*10465441SEvalZero the addition of the fourth bytes of each operand, in the fourth byte of the return value.
199*10465441SEvalZero \remark
200*10465441SEvalZero res[7:0] = val1[7:0] + val2[7:0] \n
201*10465441SEvalZero res[15:8] = val1[15:8] + val2[15:8] \n
202*10465441SEvalZero res[23:16] = val1[23:16] + val2[23:16] \n
203*10465441SEvalZero res[31:24] = val1[31:24] + val2[31:24]
204*10465441SEvalZero */
__UADD8(uint32_t x,uint32_t y)205*10465441SEvalZero __ALWAYS_INLINE uint32_t __UADD8(uint32_t x, uint32_t y)
206*10465441SEvalZero {
207*10465441SEvalZero int32_t r, s, t, u;
208*10465441SEvalZero
209*10465441SEvalZero r = (((x << 24) >> 24) + ((y << 24) >> 24)) & 0x000000FF;
210*10465441SEvalZero s = (((x << 16) >> 24) + ((y << 16) >> 24)) & 0x000000FF;
211*10465441SEvalZero t = (((x << 8) >> 24) + ((y << 8) >> 24)) & 0x000000FF;
212*10465441SEvalZero u = (((x) >> 24) + ((y) >> 24)) & 0x000000FF;
213*10465441SEvalZero
214*10465441SEvalZero return ((u << 24) | (t << 16) | (s << 8) | (r));
215*10465441SEvalZero }
216*10465441SEvalZero
217*10465441SEvalZero /**
218*10465441SEvalZero \brief Quad 8-bit saturating subtract.
219*10465441SEvalZero \details This function enables you to perform four 8-bit integer subtractions,
220*10465441SEvalZero saturating the results to the 8-bit signed integer range -2^7 <= x <= 2^7 - 1.
221*10465441SEvalZero \param [in] x first four 8-bit summands.
222*10465441SEvalZero \param [in] y second four 8-bit summands.
223*10465441SEvalZero \return the subtraction of the first byte of each operand in the first byte of the return value.\n
224*10465441SEvalZero the subtraction of the second byte of each operand in the second byte of the return value.\n
225*10465441SEvalZero the subtraction of the third byte of each operand in the third byte of the return value.\n
226*10465441SEvalZero the subtraction of the fourth byte of each operand in the fourth byte of the return value.\n
227*10465441SEvalZero The returned results are saturated to the 8-bit signed integer range -2^7 <= x <= 2^7 - 1.
228*10465441SEvalZero \remark
229*10465441SEvalZero res[7:0] = val1[7:0] - val2[7:0] \n
230*10465441SEvalZero res[15:8] = val1[15:8] - val2[15:8] \n
231*10465441SEvalZero res[23:16] = val1[23:16] - val2[23:16] \n
232*10465441SEvalZero res[31:24] = val1[31:24] - val2[31:24]
233*10465441SEvalZero */
__QSUB8(uint32_t x,uint32_t y)234*10465441SEvalZero __ALWAYS_INLINE uint32_t __QSUB8(uint32_t x, uint32_t y)
235*10465441SEvalZero {
236*10465441SEvalZero int32_t r, s, t, u;
237*10465441SEvalZero
238*10465441SEvalZero r = __SSAT(((((int32_t)x << 24) >> 24) - (((int32_t)y << 24) >> 24)), 8) & (int32_t)0x000000FF;
239*10465441SEvalZero s = __SSAT(((((int32_t)x << 16) >> 24) - (((int32_t)y << 16) >> 24)), 8) & (int32_t)0x000000FF;
240*10465441SEvalZero t = __SSAT(((((int32_t)x << 8) >> 24) - (((int32_t)y << 8) >> 24)), 8) & (int32_t)0x000000FF;
241*10465441SEvalZero u = __SSAT(((((int32_t)x) >> 24) - (((int32_t)y) >> 24)), 8) & (int32_t)0x000000FF;
242*10465441SEvalZero
243*10465441SEvalZero return ((uint32_t)((u << 24) | (t << 16) | (s << 8) | (r)));
244*10465441SEvalZero }
245*10465441SEvalZero
246*10465441SEvalZero /**
247*10465441SEvalZero \brief Quad 8-bit unsigned saturating subtraction.
248*10465441SEvalZero \details This function enables you to perform four unsigned 8-bit integer subtractions,
249*10465441SEvalZero saturating the results to the 8-bit unsigned integer range 0 < x < 2^8 - 1.
250*10465441SEvalZero \param [in] x first four 8-bit summands.
251*10465441SEvalZero \param [in] y second four 8-bit summands.
252*10465441SEvalZero \return the subtraction of the first byte of each operand in the first byte of the return value.\n
253*10465441SEvalZero the subtraction of the second byte of each operand in the second byte of the return value.\n
254*10465441SEvalZero the subtraction of the third byte of each operand in the third byte of the return value.\n
255*10465441SEvalZero the subtraction of the fourth byte of each operand in the fourth byte of the return value.\n
256*10465441SEvalZero The returned results are saturated to the 8-bit unsigned integer range 0 <= x <= 2^8 - 1.
257*10465441SEvalZero \remark
258*10465441SEvalZero res[7:0] = val1[7:0] - val2[7:0] \n
259*10465441SEvalZero res[15:8] = val1[15:8] - val2[15:8] \n
260*10465441SEvalZero res[23:16] = val1[23:16] - val2[23:16] \n
261*10465441SEvalZero res[31:24] = val1[31:24] - val2[31:24]
262*10465441SEvalZero */
__UQSUB8(uint32_t x,uint32_t y)263*10465441SEvalZero __ALWAYS_INLINE uint32_t __UQSUB8(uint32_t x, uint32_t y)
264*10465441SEvalZero {
265*10465441SEvalZero int32_t r, s, t, u;
266*10465441SEvalZero
267*10465441SEvalZero r = __IUSAT((((x << 24) >> 24) - ((y << 24) >> 24)), 8) & 0x000000FF;
268*10465441SEvalZero s = __IUSAT((((x << 16) >> 24) - ((y << 16) >> 24)), 8) & 0x000000FF;
269*10465441SEvalZero t = __IUSAT((((x << 8) >> 24) - ((y << 8) >> 24)), 8) & 0x000000FF;
270*10465441SEvalZero u = __IUSAT((((x) >> 24) - ((y) >> 24)), 8) & 0x000000FF;
271*10465441SEvalZero
272*10465441SEvalZero return ((u << 24) | (t << 16) | (s << 8) | (r));
273*10465441SEvalZero }
274*10465441SEvalZero
275*10465441SEvalZero /**
276*10465441SEvalZero \brief Quad 8-bit signed subtraction.
277*10465441SEvalZero \details This function enables you to perform four 8-bit signed integer subtractions.
278*10465441SEvalZero \param [in] x first four 8-bit operands of each subtraction.
279*10465441SEvalZero \param [in] y second four 8-bit operands of each subtraction.
280*10465441SEvalZero \return the subtraction of the first bytes from each operand, in the first byte of the return value.\n
281*10465441SEvalZero the subtraction of the second bytes of each operand, in the second byte of the return value.\n
282*10465441SEvalZero the subtraction of the third bytes of each operand, in the third byte of the return value.\n
283*10465441SEvalZero the subtraction of the fourth bytes of each operand, in the fourth byte of the return value.
284*10465441SEvalZero \remark
285*10465441SEvalZero res[7:0] = val1[7:0] - val2[7:0] \n
286*10465441SEvalZero res[15:8] = val1[15:8] - val2[15:8] \n
287*10465441SEvalZero res[23:16] = val1[23:16] - val2[23:16] \n
288*10465441SEvalZero res[31:24] = val1[31:24] - val2[31:24]
289*10465441SEvalZero */
__SSUB8(uint32_t x,uint32_t y)290*10465441SEvalZero __ALWAYS_INLINE uint32_t __SSUB8(uint32_t x, uint32_t y)
291*10465441SEvalZero {
292*10465441SEvalZero int32_t r, s, t, u;
293*10465441SEvalZero
294*10465441SEvalZero r = ((((int32_t)x << 24) >> 24) - (((int32_t)y << 24) >> 24)) & (int32_t)0x000000FF;
295*10465441SEvalZero s = ((((int32_t)x << 16) >> 24) - (((int32_t)y << 16) >> 24)) & (int32_t)0x000000FF;
296*10465441SEvalZero t = ((((int32_t)x << 8) >> 24) - (((int32_t)y << 8) >> 24)) & (int32_t)0x000000FF;
297*10465441SEvalZero u = ((((int32_t)x) >> 24) - (((int32_t)y) >> 24)) & (int32_t)0x000000FF;
298*10465441SEvalZero
299*10465441SEvalZero return ((uint32_t)((u << 24) | (t << 16) | (s << 8) | (r)));
300*10465441SEvalZero }
301*10465441SEvalZero
302*10465441SEvalZero /**
303*10465441SEvalZero \brief Quad 8-bit unsigned subtract.
304*10465441SEvalZero \details This function enables you to perform four 8-bit unsigned integer subtractions.
305*10465441SEvalZero \param [in] x first four 8-bit operands of each subtraction.
306*10465441SEvalZero \param [in] y second four 8-bit operands of each subtraction.
307*10465441SEvalZero \return the subtraction of the first bytes from each operand, in the first byte of the return value.\n
308*10465441SEvalZero the subtraction of the second bytes of each operand, in the second byte of the return value.\n
309*10465441SEvalZero the subtraction of the third bytes of each operand, in the third byte of the return value.\n
310*10465441SEvalZero the subtraction of the fourth bytes of each operand, in the fourth byte of the return value.
311*10465441SEvalZero \remark
312*10465441SEvalZero res[7:0] = val1[7:0] - val2[7:0] \n
313*10465441SEvalZero res[15:8] = val1[15:8] - val2[15:8] \n
314*10465441SEvalZero res[23:16] = val1[23:16] - val2[23:16] \n
315*10465441SEvalZero res[31:24] = val1[31:24] - val2[31:24]
316*10465441SEvalZero */
__USUB8(uint32_t x,uint32_t y)317*10465441SEvalZero __ALWAYS_INLINE uint32_t __USUB8(uint32_t x, uint32_t y)
318*10465441SEvalZero {
319*10465441SEvalZero int32_t r, s, t, u;
320*10465441SEvalZero
321*10465441SEvalZero r = (((x << 24) >> 24) - ((y << 24) >> 24)) & 0x000000FF;
322*10465441SEvalZero s = (((x << 16) >> 24) - ((y << 16) >> 24)) & 0x000000FF;
323*10465441SEvalZero t = (((x << 8) >> 24) - ((y << 8) >> 24)) & 0x000000FF;
324*10465441SEvalZero u = (((x) >> 24) - ((y) >> 24)) & 0x000000FF;
325*10465441SEvalZero
326*10465441SEvalZero return ((u << 24) | (t << 16) | (s << 8) | (r));
327*10465441SEvalZero }
328*10465441SEvalZero
329*10465441SEvalZero /**
330*10465441SEvalZero \brief Unsigned sum of quad 8-bit unsigned absolute difference.
331*10465441SEvalZero \details This function enables you to perform four unsigned 8-bit subtractions, and add the absolute values
332*10465441SEvalZero of the differences together, returning the result as a single unsigned integer.
333*10465441SEvalZero \param [in] x first four 8-bit operands of each subtraction.
334*10465441SEvalZero \param [in] y second four 8-bit operands of each subtraction.
335*10465441SEvalZero \return the subtraction of the first bytes from each operand, in the first byte of the return value.\n
336*10465441SEvalZero the subtraction of the second bytes of each operand, in the second byte of the return value.\n
337*10465441SEvalZero the subtraction of the third bytes of each operand, in the third byte of the return value.\n
338*10465441SEvalZero the subtraction of the fourth bytes of each operand, in the fourth byte of the return value.\n
339*10465441SEvalZero The sum is returned as a single unsigned integer.
340*10465441SEvalZero \remark
341*10465441SEvalZero absdiff1 = val1[7:0] - val2[7:0] \n
342*10465441SEvalZero absdiff2 = val1[15:8] - val2[15:8] \n
343*10465441SEvalZero absdiff3 = val1[23:16] - val2[23:16] \n
344*10465441SEvalZero absdiff4 = val1[31:24] - val2[31:24] \n
345*10465441SEvalZero res[31:0] = absdiff1 + absdiff2 + absdiff3 + absdiff4
346*10465441SEvalZero */
__USAD8(uint32_t x,uint32_t y)347*10465441SEvalZero __ALWAYS_INLINE uint32_t __USAD8(uint32_t x, uint32_t y)
348*10465441SEvalZero {
349*10465441SEvalZero int32_t r, s, t, u;
350*10465441SEvalZero
351*10465441SEvalZero r = (((x << 24) >> 24) - ((y << 24) >> 24)) & 0x000000FF;
352*10465441SEvalZero s = (((x << 16) >> 24) - ((y << 16) >> 24)) & 0x000000FF;
353*10465441SEvalZero t = (((x << 8) >> 24) - ((y << 8) >> 24)) & 0x000000FF;
354*10465441SEvalZero u = (((x) >> 24) - ((y) >> 24)) & 0x000000FF;
355*10465441SEvalZero
356*10465441SEvalZero return (u + t + s + r);
357*10465441SEvalZero }
358*10465441SEvalZero
359*10465441SEvalZero /**
360*10465441SEvalZero \brief Unsigned sum of quad 8-bit unsigned absolute difference with 32-bit accumulate.
361*10465441SEvalZero \details This function enables you to perform four unsigned 8-bit subtractions, and add the absolute values
362*10465441SEvalZero of the differences to a 32-bit accumulate operand.
363*10465441SEvalZero \param [in] x first four 8-bit operands of each subtraction.
364*10465441SEvalZero \param [in] y second four 8-bit operands of each subtraction.
365*10465441SEvalZero \param [in] sum accumulation value.
366*10465441SEvalZero \return the sum of the absolute differences of the following bytes, added to the accumulation value:
367*10465441SEvalZero the subtraction of the first bytes from each operand, in the first byte of the return value.\n
368*10465441SEvalZero the subtraction of the second bytes of each operand, in the second byte of the return value.\n
369*10465441SEvalZero the subtraction of the third bytes of each operand, in the third byte of the return value.\n
370*10465441SEvalZero the subtraction of the fourth bytes of each operand, in the fourth byte of the return value.
371*10465441SEvalZero \remark
372*10465441SEvalZero absdiff1 = val1[7:0] - val2[7:0] \n
373*10465441SEvalZero absdiff2 = val1[15:8] - val2[15:8] \n
374*10465441SEvalZero absdiff3 = val1[23:16] - val2[23:16] \n
375*10465441SEvalZero absdiff4 = val1[31:24] - val2[31:24] \n
376*10465441SEvalZero sum = absdiff1 + absdiff2 + absdiff3 + absdiff4 \n
377*10465441SEvalZero res[31:0] = sum[31:0] + val3[31:0]
378*10465441SEvalZero */
__USADA8(uint32_t x,uint32_t y,uint32_t sum)379*10465441SEvalZero __ALWAYS_INLINE uint32_t __USADA8(uint32_t x, uint32_t y, uint32_t sum)
380*10465441SEvalZero {
381*10465441SEvalZero int32_t r, s, t, u;
382*10465441SEvalZero
383*10465441SEvalZero r = (abs(((x << 24) >> 24) - ((y << 24) >> 24))) & 0x000000FF;
384*10465441SEvalZero s = (abs(((x << 16) >> 24) - ((y << 16) >> 24))) & 0x000000FF;
385*10465441SEvalZero t = (abs(((x << 8) >> 24) - ((y << 8) >> 24))) & 0x000000FF;
386*10465441SEvalZero u = (abs(((x) >> 24) - ((y) >> 24))) & 0x000000FF;
387*10465441SEvalZero
388*10465441SEvalZero return (u + t + s + r + sum);
389*10465441SEvalZero }
390*10465441SEvalZero
391*10465441SEvalZero /**
392*10465441SEvalZero \brief Dual 16-bit saturating addition.
393*10465441SEvalZero \details This function enables you to perform two 16-bit integer arithmetic additions in parallel,
394*10465441SEvalZero saturating the results to the 16-bit signed integer range -2^15 <= x <= 2^15 - 1.
395*10465441SEvalZero \param [in] x first two 16-bit summands.
396*10465441SEvalZero \param [in] y second two 16-bit summands.
397*10465441SEvalZero \return the saturated addition of the low halfwords, in the low halfword of the return value.\n
398*10465441SEvalZero the saturated addition of the high halfwords, in the high halfword of the return value.\n
399*10465441SEvalZero The returned results are saturated to the 16-bit signed integer range -2^15 <= x <= 2^15 - 1.
400*10465441SEvalZero \remark
401*10465441SEvalZero res[15:0] = val1[15:0] + val2[15:0] \n
402*10465441SEvalZero res[31:16] = val1[31:16] + val2[31:16]
403*10465441SEvalZero */
__QADD16(uint32_t x,uint32_t y)404*10465441SEvalZero __ALWAYS_INLINE uint32_t __QADD16(uint32_t x, uint32_t y)
405*10465441SEvalZero {
406*10465441SEvalZero int32_t r = 0, s = 0;
407*10465441SEvalZero
408*10465441SEvalZero r = __SSAT(((((int32_t)x << 16) >> 16) + (((int32_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF;
409*10465441SEvalZero s = __SSAT(((((int32_t)x) >> 16) + (((int32_t)y) >> 16)), 16) & (int32_t)0x0000FFFF;
410*10465441SEvalZero
411*10465441SEvalZero return ((uint32_t)((s << 16) | (r)));
412*10465441SEvalZero }
413*10465441SEvalZero
414*10465441SEvalZero /**
415*10465441SEvalZero \brief Dual 16-bit unsigned saturating addition.
416*10465441SEvalZero \details This function enables you to perform two unsigned 16-bit integer additions, saturating
417*10465441SEvalZero the results to the 16-bit unsigned integer range 0 < x < 2^16 - 1.
418*10465441SEvalZero \param [in] x first two 16-bit summands.
419*10465441SEvalZero \param [in] y second two 16-bit summands.
420*10465441SEvalZero \return the saturated addition of the low halfwords, in the low halfword of the return value.\n
421*10465441SEvalZero the saturated addition of the high halfwords, in the high halfword of the return value.\n
422*10465441SEvalZero The results are saturated to the 16-bit unsigned integer range 0 < x < 2^16 - 1.
423*10465441SEvalZero \remark
424*10465441SEvalZero res[15:0] = val1[15:0] + val2[15:0] \n
425*10465441SEvalZero res[31:16] = val1[31:16] + val2[31:16]
426*10465441SEvalZero */
__UQADD16(uint32_t x,uint32_t y)427*10465441SEvalZero __ALWAYS_INLINE uint32_t __UQADD16(uint32_t x, uint32_t y)
428*10465441SEvalZero {
429*10465441SEvalZero int32_t r = 0, s = 0;
430*10465441SEvalZero
431*10465441SEvalZero r = __IUSAT((((x << 16) >> 16) + ((y << 16) >> 16)), 16) & 0x0000FFFF;
432*10465441SEvalZero s = __IUSAT((((x) >> 16) + ((y) >> 16)), 16) & 0x0000FFFF;
433*10465441SEvalZero
434*10465441SEvalZero return ((s << 16) | (r));
435*10465441SEvalZero }
436*10465441SEvalZero
437*10465441SEvalZero /**
438*10465441SEvalZero \brief Dual 16-bit signed addition.
439*10465441SEvalZero \details This function enables you to perform two 16-bit signed integer additions.
440*10465441SEvalZero \param [in] x first two 16-bit summands.
441*10465441SEvalZero \param [in] y second two 16-bit summands.
442*10465441SEvalZero \return the addition of the low halfwords in the low halfword of the return value.\n
443*10465441SEvalZero the addition of the high halfwords in the high halfword of the return value.
444*10465441SEvalZero \remark
445*10465441SEvalZero res[15:0] = val1[15:0] + val2[15:0] \n
446*10465441SEvalZero res[31:16] = val1[31:16] + val2[31:16]
447*10465441SEvalZero */
__SADD16(uint32_t x,uint32_t y)448*10465441SEvalZero __ALWAYS_INLINE uint32_t __SADD16(uint32_t x, uint32_t y)
449*10465441SEvalZero {
450*10465441SEvalZero int32_t r = 0, s = 0;
451*10465441SEvalZero
452*10465441SEvalZero r = ((((int32_t)x << 16) >> 16) + (((int32_t)y << 16) >> 16)) & (int32_t)0x0000FFFF;
453*10465441SEvalZero s = ((((int32_t)x) >> 16) + (((int32_t)y) >> 16)) & (int32_t)0x0000FFFF;
454*10465441SEvalZero
455*10465441SEvalZero return ((uint32_t)((s << 16) | (r)));
456*10465441SEvalZero }
457*10465441SEvalZero
458*10465441SEvalZero /**
459*10465441SEvalZero \brief Dual 16-bit unsigned addition
460*10465441SEvalZero \details This function enables you to perform two 16-bit unsigned integer additions.
461*10465441SEvalZero \param [in] x first two 16-bit summands for each addition.
462*10465441SEvalZero \param [in] y second two 16-bit summands for each addition.
463*10465441SEvalZero \return the addition of the low halfwords in the low halfword of the return value.\n
464*10465441SEvalZero the addition of the high halfwords in the high halfword of the return value.
465*10465441SEvalZero \remark
466*10465441SEvalZero res[15:0] = val1[15:0] + val2[15:0] \n
467*10465441SEvalZero res[31:16] = val1[31:16] + val2[31:16]
468*10465441SEvalZero */
__UADD16(uint32_t x,uint32_t y)469*10465441SEvalZero __ALWAYS_INLINE uint32_t __UADD16(uint32_t x, uint32_t y)
470*10465441SEvalZero {
471*10465441SEvalZero int32_t r = 0, s = 0;
472*10465441SEvalZero
473*10465441SEvalZero r = (((x << 16) >> 16) + ((y << 16) >> 16)) & 0x0000FFFF;
474*10465441SEvalZero s = (((x) >> 16) + ((y) >> 16)) & 0x0000FFFF;
475*10465441SEvalZero
476*10465441SEvalZero return ((s << 16) | (r));
477*10465441SEvalZero }
478*10465441SEvalZero
479*10465441SEvalZero
480*10465441SEvalZero /**
481*10465441SEvalZero \brief Dual 16-bit signed addition with halved results.
482*10465441SEvalZero \details This function enables you to perform two signed 16-bit integer additions, halving the results.
483*10465441SEvalZero \param [in] x first two 16-bit summands.
484*10465441SEvalZero \param [in] y second two 16-bit summands.
485*10465441SEvalZero \return the halved addition of the low halfwords, in the low halfword of the return value.\n
486*10465441SEvalZero the halved addition of the high halfwords, in the high halfword of the return value.
487*10465441SEvalZero \remark
488*10465441SEvalZero res[15:0] = (val1[15:0] + val2[15:0]) >> 1 \n
489*10465441SEvalZero res[31:16] = (val1[31:16] + val2[31:16]) >> 1
490*10465441SEvalZero */
__SHADD16(uint32_t x,uint32_t y)491*10465441SEvalZero __ALWAYS_INLINE uint32_t __SHADD16(uint32_t x, uint32_t y)
492*10465441SEvalZero {
493*10465441SEvalZero int32_t r, s;
494*10465441SEvalZero
495*10465441SEvalZero r = (((((int32_t)x << 16) >> 16) + (((int32_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF;
496*10465441SEvalZero s = (((((int32_t)x) >> 16) + (((int32_t)y) >> 16)) >> 1) & (int32_t)0x0000FFFF;
497*10465441SEvalZero
498*10465441SEvalZero return ((uint32_t)((s << 16) | (r)));
499*10465441SEvalZero }
500*10465441SEvalZero
501*10465441SEvalZero /**
502*10465441SEvalZero \brief Dual 16-bit unsigned addition with halved results.
503*10465441SEvalZero \details This function enables you to perform two unsigned 16-bit integer additions, halving the results.
504*10465441SEvalZero \param [in] x first two 16-bit summands.
505*10465441SEvalZero \param [in] y second two 16-bit summands.
506*10465441SEvalZero \return the halved addition of the low halfwords, in the low halfword of the return value.\n
507*10465441SEvalZero the halved addition of the high halfwords, in the high halfword of the return value.
508*10465441SEvalZero \remark
509*10465441SEvalZero res[15:0] = (val1[15:0] + val2[15:0]) >> 1 \n
510*10465441SEvalZero res[31:16] = (val1[31:16] + val2[31:16]) >> 1
511*10465441SEvalZero */
__UHADD16(uint32_t x,uint32_t y)512*10465441SEvalZero __ALWAYS_INLINE uint32_t __UHADD16(uint32_t x, uint32_t y)
513*10465441SEvalZero {
514*10465441SEvalZero int32_t r, s;
515*10465441SEvalZero
516*10465441SEvalZero r = ((((x << 16) >> 16) + ((y << 16) >> 16)) >> 1) & 0x0000FFFF;
517*10465441SEvalZero s = ((((x) >> 16) + ((y) >> 16)) >> 1) & 0x0000FFFF;
518*10465441SEvalZero
519*10465441SEvalZero return ((s << 16) | (r));
520*10465441SEvalZero }
521*10465441SEvalZero
522*10465441SEvalZero /**
523*10465441SEvalZero \brief Quad 8-bit signed addition with halved results.
524*10465441SEvalZero \details This function enables you to perform four signed 8-bit integer additions, halving the results.
525*10465441SEvalZero \param [in] x first four 8-bit summands.
526*10465441SEvalZero \param [in] y second four 8-bit summands.
527*10465441SEvalZero \return the halved addition of the first bytes from each operand, in the first byte of the return value.\n
528*10465441SEvalZero the halved addition of the second bytes from each operand, in the second byte of the return value.\n
529*10465441SEvalZero the halved addition of the third bytes from each operand, in the third byte of the return value.\n
530*10465441SEvalZero the halved addition of the fourth bytes from each operand, in the fourth byte of the return value.
531*10465441SEvalZero \remark
532*10465441SEvalZero res[7:0] = (val1[7:0] + val2[7:0] ) >> 1 \n
533*10465441SEvalZero res[15:8] = (val1[15:8] + val2[15:8] ) >> 1 \n
534*10465441SEvalZero res[23:16] = (val1[23:16] + val2[23:16]) >> 1 \n
535*10465441SEvalZero res[31:24] = (val1[31:24] + val2[31:24]) >> 1
536*10465441SEvalZero */
__SHADD8(uint32_t x,uint32_t y)537*10465441SEvalZero __ALWAYS_INLINE uint32_t __SHADD8(uint32_t x, uint32_t y)
538*10465441SEvalZero {
539*10465441SEvalZero int32_t r, s, t, u;
540*10465441SEvalZero
541*10465441SEvalZero r = (((((int32_t)x << 24) >> 24) + (((int32_t)y << 24) >> 24)) >> 1) & (int32_t)0x000000FF;
542*10465441SEvalZero s = (((((int32_t)x << 16) >> 24) + (((int32_t)y << 16) >> 24)) >> 1) & (int32_t)0x000000FF;
543*10465441SEvalZero t = (((((int32_t)x << 8) >> 24) + (((int32_t)y << 8) >> 24)) >> 1) & (int32_t)0x000000FF;
544*10465441SEvalZero u = (((((int32_t)x) >> 24) + (((int32_t)y) >> 24)) >> 1) & (int32_t)0x000000FF;
545*10465441SEvalZero
546*10465441SEvalZero return ((uint32_t)((u << 24) | (t << 16) | (s << 8) | (r)));
547*10465441SEvalZero }
548*10465441SEvalZero
549*10465441SEvalZero /**
550*10465441SEvalZero \brief Quad 8-bit unsigned addition with halved results.
551*10465441SEvalZero \details This function enables you to perform four unsigned 8-bit integer additions, halving the results.
552*10465441SEvalZero \param [in] x first four 8-bit summands.
553*10465441SEvalZero \param [in] y second four 8-bit summands.
554*10465441SEvalZero \return the halved addition of the first bytes from each operand, in the first byte of the return value.\n
555*10465441SEvalZero the halved addition of the second bytes from each operand, in the second byte of the return value.\n
556*10465441SEvalZero the halved addition of the third bytes from each operand, in the third byte of the return value.\n
557*10465441SEvalZero the halved addition of the fourth bytes from each operand, in the fourth byte of the return value.
558*10465441SEvalZero \remark
559*10465441SEvalZero res[7:0] = (val1[7:0] + val2[7:0] ) >> 1 \n
560*10465441SEvalZero res[15:8] = (val1[15:8] + val2[15:8] ) >> 1 \n
561*10465441SEvalZero res[23:16] = (val1[23:16] + val2[23:16]) >> 1 \n
562*10465441SEvalZero res[31:24] = (val1[31:24] + val2[31:24]) >> 1
563*10465441SEvalZero */
__UHADD8(uint32_t x,uint32_t y)564*10465441SEvalZero __ALWAYS_INLINE uint32_t __UHADD8(uint32_t x, uint32_t y)
565*10465441SEvalZero {
566*10465441SEvalZero int32_t r, s, t, u;
567*10465441SEvalZero
568*10465441SEvalZero r = ((((x << 24) >> 24) + ((y << 24) >> 24)) >> 1) & 0x000000FF;
569*10465441SEvalZero s = ((((x << 16) >> 24) + ((y << 16) >> 24)) >> 1) & 0x000000FF;
570*10465441SEvalZero t = ((((x << 8) >> 24) + ((y << 8) >> 24)) >> 1) & 0x000000FF;
571*10465441SEvalZero u = ((((x) >> 24) + ((y) >> 24)) >> 1) & 0x000000FF;
572*10465441SEvalZero
573*10465441SEvalZero return ((u << 24) | (t << 16) | (s << 8) | (r));
574*10465441SEvalZero }
575*10465441SEvalZero
576*10465441SEvalZero /**
577*10465441SEvalZero \brief Dual 16-bit saturating subtract.
578*10465441SEvalZero \details This function enables you to perform two 16-bit integer subtractions in parallel,
579*10465441SEvalZero saturating the results to the 16-bit signed integer range -2^15 <= x <= 2^15 - 1.
580*10465441SEvalZero \param [in] x first two 16-bit summands.
581*10465441SEvalZero \param [in] y second two 16-bit summands.
582*10465441SEvalZero \return the saturated subtraction of the low halfwords, in the low halfword of the return value.\n
583*10465441SEvalZero the saturated subtraction of the high halfwords, in the high halfword of the return value.\n
584*10465441SEvalZero The returned results are saturated to the 16-bit signed integer range -2^15 <= x <= 2^15 - 1.
585*10465441SEvalZero \remark
586*10465441SEvalZero res[15:0] = val1[15:0] - val2[15:0] \n
587*10465441SEvalZero res[31:16] = val1[31:16] - val2[31:16]
588*10465441SEvalZero */
__QSUB16(uint32_t x,uint32_t y)589*10465441SEvalZero __ALWAYS_INLINE uint32_t __QSUB16(uint32_t x, uint32_t y)
590*10465441SEvalZero {
591*10465441SEvalZero int32_t r, s;
592*10465441SEvalZero
593*10465441SEvalZero r = __SSAT(((((int32_t)x << 16) >> 16) - (((int32_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF;
594*10465441SEvalZero s = __SSAT(((((int32_t)x) >> 16) - (((int32_t)y) >> 16)), 16) & (int32_t)0x0000FFFF;
595*10465441SEvalZero
596*10465441SEvalZero return ((uint32_t)((s << 16) | (r)));
597*10465441SEvalZero }
598*10465441SEvalZero
599*10465441SEvalZero /**
600*10465441SEvalZero \brief Dual 16-bit unsigned saturating subtraction.
601*10465441SEvalZero \details This function enables you to perform two unsigned 16-bit integer subtractions,
602*10465441SEvalZero saturating the results to the 16-bit unsigned integer range 0 < x < 2^16 - 1.
603*10465441SEvalZero \param [in] x first two 16-bit operands for each subtraction.
604*10465441SEvalZero \param [in] y second two 16-bit operands for each subtraction.
605*10465441SEvalZero \return the saturated subtraction of the low halfwords, in the low halfword of the return value.\n
606*10465441SEvalZero the saturated subtraction of the high halfwords, in the high halfword of the return value.\n
607*10465441SEvalZero The returned results are saturated to the 16-bit signed integer range -2^15 <= x <= 2^15 - 1.
608*10465441SEvalZero \remark
609*10465441SEvalZero res[15:0] = val1[15:0] - val2[15:0] \n
610*10465441SEvalZero res[31:16] = val1[31:16] - val2[31:16]
611*10465441SEvalZero */
__UQSUB16(uint32_t x,uint32_t y)612*10465441SEvalZero __ALWAYS_INLINE uint32_t __UQSUB16(uint32_t x, uint32_t y)
613*10465441SEvalZero {
614*10465441SEvalZero int32_t r, s;
615*10465441SEvalZero
616*10465441SEvalZero r = __IUSAT((((x << 16) >> 16) - ((y << 16) >> 16)), 16) & 0x0000FFFF;
617*10465441SEvalZero s = __IUSAT((((x) >> 16) - ((y) >> 16)), 16) & 0x0000FFFF;
618*10465441SEvalZero
619*10465441SEvalZero return ((s << 16) | (r));
620*10465441SEvalZero }
621*10465441SEvalZero
622*10465441SEvalZero /**
623*10465441SEvalZero \brief Dual 16-bit signed subtraction.
624*10465441SEvalZero \details This function enables you to perform two 16-bit signed integer subtractions.
625*10465441SEvalZero \param [in] x first two 16-bit operands of each subtraction.
626*10465441SEvalZero \param [in] y second two 16-bit operands of each subtraction.
627*10465441SEvalZero \return the subtraction of the low halfword in the second operand from the low
628*10465441SEvalZero halfword in the first operand, in the low halfword of the return value. \n
629*10465441SEvalZero the subtraction of the high halfword in the second operand from the high
630*10465441SEvalZero halfword in the first operand, in the high halfword of the return value.
631*10465441SEvalZero \remark
632*10465441SEvalZero res[15:0] = val1[15:0] - val2[15:0] \n
633*10465441SEvalZero res[31:16] = val1[31:16] - val2[31:16]
634*10465441SEvalZero */
__SSUB16(uint32_t x,uint32_t y)635*10465441SEvalZero __ALWAYS_INLINE uint32_t __SSUB16(uint32_t x, uint32_t y)
636*10465441SEvalZero {
637*10465441SEvalZero int32_t r, s;
638*10465441SEvalZero
639*10465441SEvalZero r = ((((int32_t)x << 16) >> 16) - (((int32_t)y << 16) >> 16)) & (int32_t)0x0000FFFF;
640*10465441SEvalZero s = ((((int32_t)x) >> 16) - (((int32_t)y) >> 16)) & (int32_t)0x0000FFFF;
641*10465441SEvalZero
642*10465441SEvalZero return ((uint32_t)((s << 16) | (r)));
643*10465441SEvalZero }
644*10465441SEvalZero
645*10465441SEvalZero /**
646*10465441SEvalZero \brief Dual 16-bit unsigned subtract.
647*10465441SEvalZero \details This function enables you to perform two 16-bit unsigned integer subtractions.
648*10465441SEvalZero \param [in] x first two 16-bit operands of each subtraction.
649*10465441SEvalZero \param [in] y second two 16-bit operands of each subtraction.
650*10465441SEvalZero \return the subtraction of the low halfword in the second operand from the low
651*10465441SEvalZero halfword in the first operand, in the low halfword of the return value. \n
652*10465441SEvalZero the subtraction of the high halfword in the second operand from the high
653*10465441SEvalZero halfword in the first operand, in the high halfword of the return value.
654*10465441SEvalZero \remark
655*10465441SEvalZero res[15:0] = val1[15:0] - val2[15:0] \n
656*10465441SEvalZero res[31:16] = val1[31:16] - val2[31:16]
657*10465441SEvalZero */
__USUB16(uint32_t x,uint32_t y)658*10465441SEvalZero __ALWAYS_INLINE uint32_t __USUB16(uint32_t x, uint32_t y)
659*10465441SEvalZero {
660*10465441SEvalZero int32_t r, s;
661*10465441SEvalZero
662*10465441SEvalZero r = (((x << 16) >> 16) - ((y << 16) >> 16)) & 0x0000FFFF;
663*10465441SEvalZero s = (((x) >> 16) - ((y) >> 16)) & 0x0000FFFF;
664*10465441SEvalZero
665*10465441SEvalZero return ((s << 16) | (r));
666*10465441SEvalZero }
667*10465441SEvalZero
668*10465441SEvalZero /**
669*10465441SEvalZero \brief Dual 16-bit signed subtraction with halved results.
670*10465441SEvalZero \details This function enables you to perform two signed 16-bit integer subtractions, halving the results.
671*10465441SEvalZero \param [in] x first two 16-bit summands.
672*10465441SEvalZero \param [in] y second two 16-bit summands.
673*10465441SEvalZero \return the halved subtraction of the low halfwords, in the low halfword of the return value.\n
674*10465441SEvalZero the halved subtraction of the high halfwords, in the high halfword of the return value.
675*10465441SEvalZero \remark
676*10465441SEvalZero res[15:0] = (val1[15:0] - val2[15:0]) >> 1 \n
677*10465441SEvalZero res[31:16] = (val1[31:16] - val2[31:16]) >> 1
678*10465441SEvalZero */
__SHSUB16(uint32_t x,uint32_t y)679*10465441SEvalZero __ALWAYS_INLINE uint32_t __SHSUB16(uint32_t x, uint32_t y)
680*10465441SEvalZero {
681*10465441SEvalZero int32_t r, s;
682*10465441SEvalZero
683*10465441SEvalZero r = (((((int32_t)x << 16) >> 16) - (((int32_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF;
684*10465441SEvalZero s = (((((int32_t)x) >> 16) - (((int32_t)y) >> 16)) >> 1) & (int32_t)0x0000FFFF;
685*10465441SEvalZero
686*10465441SEvalZero return ((uint32_t)((s << 16) | (r)));
687*10465441SEvalZero }
688*10465441SEvalZero
689*10465441SEvalZero /**
690*10465441SEvalZero \brief Dual 16-bit unsigned subtraction with halved results.
691*10465441SEvalZero \details This function enables you to perform two unsigned 16-bit integer subtractions, halving the results.
692*10465441SEvalZero \param [in] x first two 16-bit summands.
693*10465441SEvalZero \param [in] y second two 16-bit summands.
694*10465441SEvalZero \return the halved subtraction of the low halfwords, in the low halfword of the return value.\n
695*10465441SEvalZero the halved subtraction of the high halfwords, in the high halfword of the return value.
696*10465441SEvalZero \remark
697*10465441SEvalZero res[15:0] = (val1[15:0] - val2[15:0]) >> 1 \n
698*10465441SEvalZero res[31:16] = (val1[31:16] - val2[31:16]) >> 1
699*10465441SEvalZero */
__UHSUB16(uint32_t x,uint32_t y)700*10465441SEvalZero __ALWAYS_INLINE uint32_t __UHSUB16(uint32_t x, uint32_t y)
701*10465441SEvalZero {
702*10465441SEvalZero int32_t r, s;
703*10465441SEvalZero
704*10465441SEvalZero r = ((((x << 16) >> 16) - ((y << 16) >> 16)) >> 1) & 0x0000FFFF;
705*10465441SEvalZero s = ((((x) >> 16) - ((y) >> 16)) >> 1) & 0x0000FFFF;
706*10465441SEvalZero
707*10465441SEvalZero return ((s << 16) | (r));
708*10465441SEvalZero }
709*10465441SEvalZero
710*10465441SEvalZero /**
711*10465441SEvalZero \brief Quad 8-bit signed addition with halved results.
712*10465441SEvalZero \details This function enables you to perform four signed 8-bit integer subtractions, halving the results.
713*10465441SEvalZero \param [in] x first four 8-bit summands.
714*10465441SEvalZero \param [in] y second four 8-bit summands.
715*10465441SEvalZero \return the halved subtraction of the first bytes from each operand, in the first byte of the return value.\n
716*10465441SEvalZero the halved subtraction of the second bytes from each operand, in the second byte of the return value.\n
717*10465441SEvalZero the halved subtraction of the third bytes from each operand, in the third byte of the return value.\n
718*10465441SEvalZero the halved subtraction of the fourth bytes from each operand, in the fourth byte of the return value.
719*10465441SEvalZero \remark
720*10465441SEvalZero res[7:0] = (val1[7:0] - val2[7:0] ) >> 1 \n
721*10465441SEvalZero res[15:8] = (val1[15:8] - val2[15:8] ) >> 1 \n
722*10465441SEvalZero res[23:16] = (val1[23:16] - val2[23:16]) >> 1 \n
723*10465441SEvalZero res[31:24] = (val1[31:24] - val2[31:24]) >> 1
724*10465441SEvalZero */
__SHSUB8(uint32_t x,uint32_t y)725*10465441SEvalZero __ALWAYS_INLINE uint32_t __SHSUB8(uint32_t x, uint32_t y)
726*10465441SEvalZero {
727*10465441SEvalZero int32_t r, s, t, u;
728*10465441SEvalZero
729*10465441SEvalZero r = (((((int32_t)x << 24) >> 24) - (((int32_t)y << 24) >> 24)) >> 1) & (int32_t)0x000000FF;
730*10465441SEvalZero s = (((((int32_t)x << 16) >> 24) - (((int32_t)y << 16) >> 24)) >> 1) & (int32_t)0x000000FF;
731*10465441SEvalZero t = (((((int32_t)x << 8) >> 24) - (((int32_t)y << 8) >> 24)) >> 1) & (int32_t)0x000000FF;
732*10465441SEvalZero u = (((((int32_t)x) >> 24) - (((int32_t)y) >> 24)) >> 1) & (int32_t)0x000000FF;
733*10465441SEvalZero
734*10465441SEvalZero return ((uint32_t)((u << 24) | (t << 16) | (s << 8) | (r)));
735*10465441SEvalZero }
736*10465441SEvalZero
737*10465441SEvalZero /**
738*10465441SEvalZero \brief Quad 8-bit unsigned subtraction with halved results.
739*10465441SEvalZero \details This function enables you to perform four unsigned 8-bit integer subtractions, halving the results.
740*10465441SEvalZero \param [in] x first four 8-bit summands.
741*10465441SEvalZero \param [in] y second four 8-bit summands.
742*10465441SEvalZero \return the halved subtraction of the first bytes from each operand, in the first byte of the return value.\n
743*10465441SEvalZero the halved subtraction of the second bytes from each operand, in the second byte of the return value.\n
744*10465441SEvalZero the halved subtraction of the third bytes from each operand, in the third byte of the return value.\n
745*10465441SEvalZero the halved subtraction of the fourth bytes from each operand, in the fourth byte of the return value.
746*10465441SEvalZero \remark
747*10465441SEvalZero res[7:0] = (val1[7:0] - val2[7:0] ) >> 1 \n
748*10465441SEvalZero res[15:8] = (val1[15:8] - val2[15:8] ) >> 1 \n
749*10465441SEvalZero res[23:16] = (val1[23:16] - val2[23:16]) >> 1 \n
750*10465441SEvalZero res[31:24] = (val1[31:24] - val2[31:24]) >> 1
751*10465441SEvalZero */
__UHSUB8(uint32_t x,uint32_t y)752*10465441SEvalZero __ALWAYS_INLINE uint32_t __UHSUB8(uint32_t x, uint32_t y)
753*10465441SEvalZero {
754*10465441SEvalZero int32_t r, s, t, u;
755*10465441SEvalZero
756*10465441SEvalZero r = ((((x << 24) >> 24) - ((y << 24) >> 24)) >> 1) & 0x000000FF;
757*10465441SEvalZero s = ((((x << 16) >> 24) - ((y << 16) >> 24)) >> 1) & 0x000000FF;
758*10465441SEvalZero t = ((((x << 8) >> 24) - ((y << 8) >> 24)) >> 1) & 0x000000FF;
759*10465441SEvalZero u = ((((x) >> 24) - ((y) >> 24)) >> 1) & 0x000000FF;
760*10465441SEvalZero
761*10465441SEvalZero return ((u << 24) | (t << 16) | (s << 8) | (r));
762*10465441SEvalZero }
763*10465441SEvalZero
764*10465441SEvalZero /**
765*10465441SEvalZero \brief Dual 16-bit add and subtract with exchange.
766*10465441SEvalZero \details This function enables you to exchange the halfwords of the one operand,
767*10465441SEvalZero then add the high halfwords and subtract the low halfwords,
768*10465441SEvalZero saturating the results to the 16-bit signed integer range -2^15 <= x <= 2^15 - 1.
769*10465441SEvalZero \param [in] x first operand for the subtraction in the low halfword,
770*10465441SEvalZero and the first operand for the addition in the high halfword.
771*10465441SEvalZero \param [in] y second operand for the subtraction in the high halfword,
772*10465441SEvalZero and the second operand for the addition in the low halfword.
773*10465441SEvalZero \return the saturated subtraction of the high halfword in the second operand from the
774*10465441SEvalZero low halfword in the first operand, in the low halfword of the return value.\n
775*10465441SEvalZero the saturated addition of the high halfword in the first operand and the
776*10465441SEvalZero low halfword in the second operand, in the high halfword of the return value.\n
777*10465441SEvalZero The returned results are saturated to the 16-bit signed integer range -2^15 <= x <= 2^15 - 1.
778*10465441SEvalZero \remark
779*10465441SEvalZero res[15:0] = val1[15:0] - val2[31:16] \n
780*10465441SEvalZero res[31:16] = val1[31:16] + val2[15:0]
781*10465441SEvalZero */
__QASX(uint32_t x,uint32_t y)782*10465441SEvalZero __ALWAYS_INLINE uint32_t __QASX(uint32_t x, uint32_t y)
783*10465441SEvalZero {
784*10465441SEvalZero int32_t r, s;
785*10465441SEvalZero
786*10465441SEvalZero r = __SSAT(((((int32_t)x << 16) >> 16) - (((int32_t)y) >> 16)), 16) & (int32_t)0x0000FFFF;
787*10465441SEvalZero s = __SSAT(((((int32_t)x) >> 16) + (((int32_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF;
788*10465441SEvalZero
789*10465441SEvalZero return ((uint32_t)((s << 16) | (r)));
790*10465441SEvalZero }
791*10465441SEvalZero
792*10465441SEvalZero /**
793*10465441SEvalZero \brief Dual 16-bit unsigned saturating addition and subtraction with exchange.
794*10465441SEvalZero \details This function enables you to exchange the halfwords of the second operand and
795*10465441SEvalZero perform one unsigned 16-bit integer addition and one unsigned 16-bit subtraction,
796*10465441SEvalZero saturating the results to the 16-bit unsigned integer range 0 <= x <= 2^16 - 1.
797*10465441SEvalZero \param [in] x first operand for the subtraction in the low halfword,
798*10465441SEvalZero and the first operand for the addition in the high halfword.
799*10465441SEvalZero \param [in] y second operand for the subtraction in the high halfword,
800*10465441SEvalZero and the second operand for the addition in the low halfword.
801*10465441SEvalZero \return the saturated subtraction of the high halfword in the second operand from the
802*10465441SEvalZero low halfword in the first operand, in the low halfword of the return value.\n
803*10465441SEvalZero the saturated addition of the high halfword in the first operand and the
804*10465441SEvalZero low halfword in the second operand, in the high halfword of the return value.\n
805*10465441SEvalZero The returned results are saturated to the 16-bit unsigned integer range 0 <= x <= 2^16 - 1.
806*10465441SEvalZero \remark
807*10465441SEvalZero res[15:0] = val1[15:0] - val2[31:16] \n
808*10465441SEvalZero res[31:16] = val1[31:16] + val2[15:0]
809*10465441SEvalZero */
__UQASX(uint32_t x,uint32_t y)810*10465441SEvalZero __ALWAYS_INLINE uint32_t __UQASX(uint32_t x, uint32_t y)
811*10465441SEvalZero {
812*10465441SEvalZero int32_t r, s;
813*10465441SEvalZero
814*10465441SEvalZero r = __IUSAT((((x << 16) >> 16) - ((y) >> 16)), 16) & 0x0000FFFF;
815*10465441SEvalZero s = __IUSAT((((x) >> 16) + ((y << 16) >> 16)), 16) & 0x0000FFFF;
816*10465441SEvalZero
817*10465441SEvalZero return ((s << 16) | (r));
818*10465441SEvalZero }
819*10465441SEvalZero
820*10465441SEvalZero /**
821*10465441SEvalZero \brief Dual 16-bit addition and subtraction with exchange.
822*10465441SEvalZero \details It enables you to exchange the halfwords of the second operand, add the high halfwords
823*10465441SEvalZero and subtract the low halfwords.
824*10465441SEvalZero \param [in] x first operand for the subtraction in the low halfword,
825*10465441SEvalZero and the first operand for the addition in the high halfword.
826*10465441SEvalZero \param [in] y second operand for the subtraction in the high halfword,
827*10465441SEvalZero and the second operand for the addition in the low halfword.
828*10465441SEvalZero \return the subtraction of the high halfword in the second operand from the
829*10465441SEvalZero low halfword in the first operand, in the low halfword of the return value.\n
830*10465441SEvalZero the addition of the high halfword in the first operand and the
831*10465441SEvalZero low halfword in the second operand, in the high halfword of the return value.
832*10465441SEvalZero \remark
833*10465441SEvalZero res[15:0] = val1[15:0] - val2[31:16] \n
834*10465441SEvalZero res[31:16] = val1[31:16] + val2[15:0]
835*10465441SEvalZero */
__SASX(uint32_t x,uint32_t y)836*10465441SEvalZero __ALWAYS_INLINE uint32_t __SASX(uint32_t x, uint32_t y)
837*10465441SEvalZero {
838*10465441SEvalZero int32_t r, s;
839*10465441SEvalZero
840*10465441SEvalZero r = ((((int32_t)x << 16) >> 16) - (((int32_t)y) >> 16)) & (int32_t)0x0000FFFF;
841*10465441SEvalZero s = ((((int32_t)x) >> 16) + (((int32_t)y << 16) >> 16)) & (int32_t)0x0000FFFF;
842*10465441SEvalZero
843*10465441SEvalZero return ((uint32_t)((s << 16) | (r)));
844*10465441SEvalZero }
845*10465441SEvalZero
846*10465441SEvalZero /**
847*10465441SEvalZero \brief Dual 16-bit unsigned addition and subtraction with exchange.
848*10465441SEvalZero \details This function enables you to exchange the two halfwords of the second operand,
849*10465441SEvalZero add the high halfwords and subtract the low halfwords.
850*10465441SEvalZero \param [in] x first operand for the subtraction in the low halfword,
851*10465441SEvalZero and the first operand for the addition in the high halfword.
852*10465441SEvalZero \param [in] y second operand for the subtraction in the high halfword,
853*10465441SEvalZero and the second operand for the addition in the low halfword.
854*10465441SEvalZero \return the subtraction of the high halfword in the second operand from the
855*10465441SEvalZero low halfword in the first operand, in the low halfword of the return value.\n
856*10465441SEvalZero the addition of the high halfword in the first operand and the
857*10465441SEvalZero low halfword in the second operand, in the high halfword of the return value.
858*10465441SEvalZero \remark
859*10465441SEvalZero res[15:0] = val1[15:0] - val2[31:16] \n
860*10465441SEvalZero res[31:16] = val1[31:16] + val2[15:0]
861*10465441SEvalZero */
__UASX(uint32_t x,uint32_t y)862*10465441SEvalZero __ALWAYS_INLINE uint32_t __UASX(uint32_t x, uint32_t y)
863*10465441SEvalZero {
864*10465441SEvalZero int32_t r, s;
865*10465441SEvalZero
866*10465441SEvalZero r = (((x << 16) >> 16) - ((y) >> 16)) & 0x0000FFFF;
867*10465441SEvalZero s = (((x) >> 16) + ((y << 16) >> 16)) & 0x0000FFFF;
868*10465441SEvalZero
869*10465441SEvalZero return ((s << 16) | (r));
870*10465441SEvalZero }
871*10465441SEvalZero
872*10465441SEvalZero /**
873*10465441SEvalZero \brief Dual 16-bit signed addition and subtraction with halved results.
874*10465441SEvalZero \details This function enables you to exchange the two halfwords of one operand, perform one
875*10465441SEvalZero signed 16-bit integer addition and one signed 16-bit subtraction, and halve the results.
876*10465441SEvalZero \param [in] x first 16-bit operands.
877*10465441SEvalZero \param [in] y second 16-bit operands.
878*10465441SEvalZero \return the halved subtraction of the high halfword in the second operand from the
879*10465441SEvalZero low halfword in the first operand, in the low halfword of the return value.\n
880*10465441SEvalZero the halved addition of the low halfword in the second operand from the high
881*10465441SEvalZero halfword in the first operand, in the high halfword of the return value.
882*10465441SEvalZero \remark
883*10465441SEvalZero res[15:0] = (val1[15:0] - val2[31:16]) >> 1 \n
884*10465441SEvalZero res[31:16] = (val1[31:16] + val2[15:0]) >> 1
885*10465441SEvalZero */
__SHASX(uint32_t x,uint32_t y)886*10465441SEvalZero __ALWAYS_INLINE uint32_t __SHASX(uint32_t x, uint32_t y)
887*10465441SEvalZero {
888*10465441SEvalZero int32_t r, s;
889*10465441SEvalZero
890*10465441SEvalZero r = (((((int32_t)x << 16) >> 16) - (((int32_t)y) >> 16)) >> 1) & (int32_t)0x0000FFFF;
891*10465441SEvalZero s = (((((int32_t)x) >> 16) + (((int32_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF;
892*10465441SEvalZero
893*10465441SEvalZero return ((uint32_t)((s << 16) | (r)));
894*10465441SEvalZero }
895*10465441SEvalZero
896*10465441SEvalZero /**
897*10465441SEvalZero \brief Dual 16-bit unsigned addition and subtraction with halved results and exchange.
898*10465441SEvalZero \details This function enables you to exchange the halfwords of the second operand,
899*10465441SEvalZero add the high halfwords and subtract the low halfwords, halving the results.
900*10465441SEvalZero \param [in] x first operand for the subtraction in the low halfword, and
901*10465441SEvalZero the first operand for the addition in the high halfword.
902*10465441SEvalZero \param [in] y second operand for the subtraction in the high halfword, and
903*10465441SEvalZero the second operand for the addition in the low halfword.
904*10465441SEvalZero \return the halved subtraction of the high halfword in the second operand from the
905*10465441SEvalZero low halfword in the first operand, in the low halfword of the return value.\n
906*10465441SEvalZero the halved addition of the low halfword in the second operand from the high
907*10465441SEvalZero halfword in the first operand, in the high halfword of the return value.
908*10465441SEvalZero \remark
909*10465441SEvalZero res[15:0] = (val1[15:0] - val2[31:16]) >> 1 \n
910*10465441SEvalZero res[31:16] = (val1[31:16] + val2[15:0]) >> 1
911*10465441SEvalZero */
__UHASX(uint32_t x,uint32_t y)912*10465441SEvalZero __ALWAYS_INLINE uint32_t __UHASX(uint32_t x, uint32_t y)
913*10465441SEvalZero {
914*10465441SEvalZero int32_t r, s;
915*10465441SEvalZero
916*10465441SEvalZero r = ((((x << 16) >> 16) - ((y) >> 16)) >> 1) & 0x0000FFFF;
917*10465441SEvalZero s = ((((x) >> 16) + ((y << 16) >> 16)) >> 1) & 0x0000FFFF;
918*10465441SEvalZero
919*10465441SEvalZero return ((s << 16) | (r));
920*10465441SEvalZero }
921*10465441SEvalZero
922*10465441SEvalZero /**
923*10465441SEvalZero \brief Dual 16-bit subtract and add with exchange.
924*10465441SEvalZero \details This function enables you to exchange the halfwords of one operand,
925*10465441SEvalZero then subtract the high halfwords and add the low halfwords,
926*10465441SEvalZero saturating the results to the 16-bit signed integer range -2^15 <= x <= 2^15 - 1.
927*10465441SEvalZero \param [in] x first operand for the addition in the low halfword,
928*10465441SEvalZero and the first operand for the subtraction in the high halfword.
929*10465441SEvalZero \param [in] y second operand for the addition in the high halfword,
930*10465441SEvalZero and the second operand for the subtraction in the low halfword.
931*10465441SEvalZero \return the saturated addition of the low halfword of the first operand and the high
932*10465441SEvalZero halfword of the second operand, in the low halfword of the return value.\n
933*10465441SEvalZero the saturated subtraction of the low halfword of the second operand from the
934*10465441SEvalZero high halfword of the first operand, in the high halfword of the return value.\n
935*10465441SEvalZero The returned results are saturated to the 16-bit signed integer range -2^15 <= x <= 2^15 - 1.
936*10465441SEvalZero \remark
937*10465441SEvalZero res[15:0] = val1[15:0] + val2[31:16] \n
938*10465441SEvalZero res[31:16] = val1[31:16] - val2[15:0]
939*10465441SEvalZero */
__QSAX(uint32_t x,uint32_t y)940*10465441SEvalZero __ALWAYS_INLINE uint32_t __QSAX(uint32_t x, uint32_t y)
941*10465441SEvalZero {
942*10465441SEvalZero int32_t r, s;
943*10465441SEvalZero
944*10465441SEvalZero r = __SSAT(((((int32_t)x << 16) >> 16) + (((int32_t)y) >> 16)), 16) & (int32_t)0x0000FFFF;
945*10465441SEvalZero s = __SSAT(((((int32_t)x) >> 16) - (((int32_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF;
946*10465441SEvalZero
947*10465441SEvalZero return ((uint32_t)((s << 16) | (r)));
948*10465441SEvalZero }
949*10465441SEvalZero
950*10465441SEvalZero /**
951*10465441SEvalZero \brief Dual 16-bit unsigned saturating subtraction and addition with exchange.
952*10465441SEvalZero \details This function enables you to exchange the halfwords of the second operand and perform
953*10465441SEvalZero one unsigned 16-bit integer subtraction and one unsigned 16-bit addition, saturating
954*10465441SEvalZero the results to the 16-bit unsigned integer range 0 <= x <= 2^16 - 1.
955*10465441SEvalZero \param [in] x first operand for the addition in the low halfword,
956*10465441SEvalZero and the first operand for the subtraction in the high halfword.
957*10465441SEvalZero \param [in] y second operand for the addition in the high halfword,
958*10465441SEvalZero and the second operand for the subtraction in the low halfword.
959*10465441SEvalZero \return the saturated addition of the low halfword of the first operand and the high
960*10465441SEvalZero halfword of the second operand, in the low halfword of the return value.\n
961*10465441SEvalZero the saturated subtraction of the low halfword of the second operand from the
962*10465441SEvalZero high halfword of the first operand, in the high halfword of the return value.\n
963*10465441SEvalZero The returned results are saturated to the 16-bit unsigned integer range 0 <= x <= 2^16 - 1.
964*10465441SEvalZero \remark
965*10465441SEvalZero res[15:0] = val1[15:0] + val2[31:16] \n
966*10465441SEvalZero res[31:16] = val1[31:16] - val2[15:0]
967*10465441SEvalZero */
__UQSAX(uint32_t x,uint32_t y)968*10465441SEvalZero __ALWAYS_INLINE uint32_t __UQSAX(uint32_t x, uint32_t y)
969*10465441SEvalZero {
970*10465441SEvalZero int32_t r, s;
971*10465441SEvalZero
972*10465441SEvalZero r = __IUSAT((((x << 16) >> 16) + ((y) >> 16)), 16) & 0x0000FFFF;
973*10465441SEvalZero s = __IUSAT((((x) >> 16) - ((y << 16) >> 16)), 16) & 0x0000FFFF;
974*10465441SEvalZero
975*10465441SEvalZero return ((s << 16) | (r));
976*10465441SEvalZero }
977*10465441SEvalZero
978*10465441SEvalZero /**
979*10465441SEvalZero \brief Dual 16-bit unsigned subtract and add with exchange.
980*10465441SEvalZero \details This function enables you to exchange the halfwords of the second operand,
981*10465441SEvalZero subtract the high halfwords and add the low halfwords.
982*10465441SEvalZero \param [in] x first operand for the addition in the low halfword,
983*10465441SEvalZero and the first operand for the subtraction in the high halfword.
984*10465441SEvalZero \param [in] y second operand for the addition in the high halfword,
985*10465441SEvalZero and the second operand for the subtraction in the low halfword.
986*10465441SEvalZero \return the addition of the low halfword of the first operand and the high
987*10465441SEvalZero halfword of the second operand, in the low halfword of the return value.\n
988*10465441SEvalZero the subtraction of the low halfword of the second operand from the
989*10465441SEvalZero high halfword of the first operand, in the high halfword of the return value.\n
990*10465441SEvalZero \remark
991*10465441SEvalZero res[15:0] = val1[15:0] + val2[31:16] \n
992*10465441SEvalZero res[31:16] = val1[31:16] - val2[15:0]
993*10465441SEvalZero */
__USAX(uint32_t x,uint32_t y)994*10465441SEvalZero __ALWAYS_INLINE uint32_t __USAX(uint32_t x, uint32_t y)
995*10465441SEvalZero {
996*10465441SEvalZero int32_t r, s;
997*10465441SEvalZero
998*10465441SEvalZero r = (((x << 16) >> 16) + ((y) >> 16)) & 0x0000FFFF;
999*10465441SEvalZero s = (((x) >> 16) - ((y << 16) >> 16)) & 0x0000FFFF;
1000*10465441SEvalZero
1001*10465441SEvalZero return ((s << 16) | (r));
1002*10465441SEvalZero }
1003*10465441SEvalZero
1004*10465441SEvalZero /**
1005*10465441SEvalZero \brief Dual 16-bit signed subtraction and addition with exchange.
1006*10465441SEvalZero \details This function enables you to exchange the two halfwords of one operand and perform one
1007*10465441SEvalZero 16-bit integer subtraction and one 16-bit addition.
1008*10465441SEvalZero \param [in] x first operand for the addition in the low halfword, and the first operand
1009*10465441SEvalZero for the subtraction in the high halfword.
1010*10465441SEvalZero \param [in] y second operand for the addition in the high halfword, and the second
1011*10465441SEvalZero operand for the subtraction in the low halfword.
1012*10465441SEvalZero \return the addition of the low halfword of the first operand and the high
1013*10465441SEvalZero halfword of the second operand, in the low halfword of the return value.\n
1014*10465441SEvalZero the subtraction of the low halfword of the second operand from the
1015*10465441SEvalZero high halfword of the first operand, in the high halfword of the return value.\n
1016*10465441SEvalZero \remark
1017*10465441SEvalZero res[15:0] = val1[15:0] + val2[31:16] \n
1018*10465441SEvalZero res[31:16] = val1[31:16] - val2[15:0]
1019*10465441SEvalZero */
__SSAX(uint32_t x,uint32_t y)1020*10465441SEvalZero __ALWAYS_INLINE uint32_t __SSAX(uint32_t x, uint32_t y)
1021*10465441SEvalZero {
1022*10465441SEvalZero int32_t r, s;
1023*10465441SEvalZero
1024*10465441SEvalZero r = ((((int32_t)x << 16) >> 16) + (((int32_t)y) >> 16)) & (int32_t)0x0000FFFF;
1025*10465441SEvalZero s = ((((int32_t)x) >> 16) - (((int32_t)y << 16) >> 16)) & (int32_t)0x0000FFFF;
1026*10465441SEvalZero
1027*10465441SEvalZero return ((uint32_t)((s << 16) | (r)));
1028*10465441SEvalZero }
1029*10465441SEvalZero
1030*10465441SEvalZero
1031*10465441SEvalZero /**
1032*10465441SEvalZero \brief Dual 16-bit signed subtraction and addition with halved results.
1033*10465441SEvalZero \details This function enables you to exchange the two halfwords of one operand, perform one signed
1034*10465441SEvalZero 16-bit integer subtraction and one signed 16-bit addition, and halve the results.
1035*10465441SEvalZero \param [in] x first 16-bit operands.
1036*10465441SEvalZero \param [in] y second 16-bit operands.
1037*10465441SEvalZero \return the halved addition of the low halfword in the first operand and the
1038*10465441SEvalZero high halfword in the second operand, in the low halfword of the return value.\n
1039*10465441SEvalZero the halved subtraction of the low halfword in the second operand from the
1040*10465441SEvalZero high halfword in the first operand, in the high halfword of the return value.
1041*10465441SEvalZero \remark
1042*10465441SEvalZero res[15:0] = (val1[15:0] + val2[31:16]) >> 1 \n
1043*10465441SEvalZero res[31:16] = (val1[31:16] - val2[15:0]) >> 1
1044*10465441SEvalZero */
__SHSAX(uint32_t x,uint32_t y)1045*10465441SEvalZero __ALWAYS_INLINE uint32_t __SHSAX(uint32_t x, uint32_t y)
1046*10465441SEvalZero {
1047*10465441SEvalZero int32_t r, s;
1048*10465441SEvalZero
1049*10465441SEvalZero r = (((((int32_t)x << 16) >> 16) + (((int32_t)y) >> 16)) >> 1) & (int32_t)0x0000FFFF;
1050*10465441SEvalZero s = (((((int32_t)x) >> 16) - (((int32_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF;
1051*10465441SEvalZero
1052*10465441SEvalZero return ((uint32_t)((s << 16) | (r)));
1053*10465441SEvalZero }
1054*10465441SEvalZero
1055*10465441SEvalZero /**
1056*10465441SEvalZero \brief Dual 16-bit unsigned subtraction and addition with halved results and exchange.
1057*10465441SEvalZero \details This function enables you to exchange the halfwords of the second operand,
1058*10465441SEvalZero subtract the high halfwords and add the low halfwords, halving the results.
1059*10465441SEvalZero \param [in] x first operand for the addition in the low halfword, and
1060*10465441SEvalZero the first operand for the subtraction in the high halfword.
1061*10465441SEvalZero \param [in] y second operand for the addition in the high halfword, and
1062*10465441SEvalZero the second operand for the subtraction in the low halfword.
1063*10465441SEvalZero \return the halved addition of the low halfword in the first operand and the
1064*10465441SEvalZero high halfword in the second operand, in the low halfword of the return value.\n
1065*10465441SEvalZero the halved subtraction of the low halfword in the second operand from the
1066*10465441SEvalZero high halfword in the first operand, in the high halfword of the return value.
1067*10465441SEvalZero \remark
1068*10465441SEvalZero res[15:0] = (val1[15:0] + val2[31:16]) >> 1 \n
1069*10465441SEvalZero res[31:16] = (val1[31:16] - val2[15:0]) >> 1
1070*10465441SEvalZero */
__UHSAX(uint32_t x,uint32_t y)1071*10465441SEvalZero __ALWAYS_INLINE uint32_t __UHSAX(uint32_t x, uint32_t y)
1072*10465441SEvalZero {
1073*10465441SEvalZero int32_t r, s;
1074*10465441SEvalZero
1075*10465441SEvalZero r = ((((x << 16) >> 16) + ((y) >> 16)) >> 1) & 0x0000FFFF;
1076*10465441SEvalZero s = ((((x) >> 16) - ((y << 16) >> 16)) >> 1) & 0x0000FFFF;
1077*10465441SEvalZero
1078*10465441SEvalZero return ((s << 16) | (r));
1079*10465441SEvalZero }
1080*10465441SEvalZero
1081*10465441SEvalZero /**
1082*10465441SEvalZero \brief Dual 16-bit signed multiply with exchange returning difference.
1083*10465441SEvalZero \details This function enables you to perform two 16-bit signed multiplications, subtracting
1084*10465441SEvalZero one of the products from the other. The halfwords of the second operand are exchanged
1085*10465441SEvalZero before performing the arithmetic. This produces top * bottom and bottom * top multiplication.
1086*10465441SEvalZero \param [in] x first 16-bit operands for each multiplication.
1087*10465441SEvalZero \param [in] y second 16-bit operands for each multiplication.
1088*10465441SEvalZero \return the difference of the products of the two 16-bit signed multiplications.
1089*10465441SEvalZero \remark
1090*10465441SEvalZero p1 = val1[15:0] * val2[31:16] \n
1091*10465441SEvalZero p2 = val1[31:16] * val2[15:0] \n
1092*10465441SEvalZero res[31:0] = p1 - p2
1093*10465441SEvalZero */
__SMUSDX(uint32_t x,uint32_t y)1094*10465441SEvalZero __ALWAYS_INLINE uint32_t __SMUSDX(uint32_t x, uint32_t y)
1095*10465441SEvalZero {
1096*10465441SEvalZero return ((uint32_t)(((((int32_t)x << 16) >> 16) * (((int32_t)y) >> 16)) -
1097*10465441SEvalZero ((((int32_t)x) >> 16) * (((int32_t)y << 16) >> 16))));
1098*10465441SEvalZero }
1099*10465441SEvalZero
1100*10465441SEvalZero /**
1101*10465441SEvalZero \brief Sum of dual 16-bit signed multiply with exchange.
1102*10465441SEvalZero \details This function enables you to perform two 16-bit signed multiplications with exchanged
1103*10465441SEvalZero halfwords of the second operand, adding the products together.
1104*10465441SEvalZero \param [in] x first 16-bit operands for each multiplication.
1105*10465441SEvalZero \param [in] y second 16-bit operands for each multiplication.
1106*10465441SEvalZero \return the sum of the products of the two 16-bit signed multiplications with exchanged halfwords of the second operand.
1107*10465441SEvalZero \remark
1108*10465441SEvalZero p1 = val1[15:0] * val2[31:16] \n
1109*10465441SEvalZero p2 = val1[31:16] * val2[15:0] \n
1110*10465441SEvalZero res[31:0] = p1 + p2
1111*10465441SEvalZero */
__SMUADX(uint32_t x,uint32_t y)1112*10465441SEvalZero __ALWAYS_INLINE uint32_t __SMUADX(uint32_t x, uint32_t y)
1113*10465441SEvalZero {
1114*10465441SEvalZero return ((uint32_t)(((((int32_t)x << 16) >> 16) * (((int32_t)y) >> 16)) +
1115*10465441SEvalZero ((((int32_t)x) >> 16) * (((int32_t)y << 16) >> 16))));
1116*10465441SEvalZero }
1117*10465441SEvalZero
1118*10465441SEvalZero
1119*10465441SEvalZero /**
1120*10465441SEvalZero \brief Saturating add.
1121*10465441SEvalZero \details This function enables you to obtain the saturating add of two integers.
1122*10465441SEvalZero \param [in] x first summand of the saturating add operation.
1123*10465441SEvalZero \param [in] y second summand of the saturating add operation.
1124*10465441SEvalZero \return the saturating addition of val1 and val2.
1125*10465441SEvalZero \remark
1126*10465441SEvalZero res[31:0] = SAT(val1 + SAT(val2))
1127*10465441SEvalZero */
__QADD(int32_t x,int32_t y)1128*10465441SEvalZero __ALWAYS_INLINE int32_t __QADD(int32_t x, int32_t y)
1129*10465441SEvalZero {
1130*10465441SEvalZero int32_t result;
1131*10465441SEvalZero
1132*10465441SEvalZero if (y >= 0)
1133*10465441SEvalZero {
1134*10465441SEvalZero if (x + y >= x)
1135*10465441SEvalZero {
1136*10465441SEvalZero result = x + y;
1137*10465441SEvalZero }
1138*10465441SEvalZero else
1139*10465441SEvalZero {
1140*10465441SEvalZero result = 0x7FFFFFFF;
1141*10465441SEvalZero }
1142*10465441SEvalZero }
1143*10465441SEvalZero else
1144*10465441SEvalZero {
1145*10465441SEvalZero if (x + y < x)
1146*10465441SEvalZero {
1147*10465441SEvalZero result = x + y;
1148*10465441SEvalZero }
1149*10465441SEvalZero else
1150*10465441SEvalZero {
1151*10465441SEvalZero result = 0x80000000;
1152*10465441SEvalZero }
1153*10465441SEvalZero }
1154*10465441SEvalZero
1155*10465441SEvalZero return result;
1156*10465441SEvalZero }
1157*10465441SEvalZero
1158*10465441SEvalZero /**
1159*10465441SEvalZero \brief Saturating subtract.
1160*10465441SEvalZero \details This function enables you to obtain the saturating add of two integers.
1161*10465441SEvalZero \param [in] x first summand of the saturating add operation.
1162*10465441SEvalZero \param [in] y second summand of the saturating add operation.
1163*10465441SEvalZero \return the saturating addition of val1 and val2.
1164*10465441SEvalZero \remark
1165*10465441SEvalZero res[31:0] = SAT(val1 + SAT(val2))
1166*10465441SEvalZero */
__QSUB(int32_t x,int32_t y)1167*10465441SEvalZero __ALWAYS_INLINE int32_t __QSUB(int32_t x, int32_t y)
1168*10465441SEvalZero {
1169*10465441SEvalZero int64_t tmp;
1170*10465441SEvalZero int32_t result;
1171*10465441SEvalZero
1172*10465441SEvalZero tmp = (int64_t)x - (int64_t)y;
1173*10465441SEvalZero
1174*10465441SEvalZero if (tmp > 0x7fffffff)
1175*10465441SEvalZero {
1176*10465441SEvalZero tmp = 0x7fffffff;
1177*10465441SEvalZero }
1178*10465441SEvalZero else if (tmp < (-2147483647 - 1))
1179*10465441SEvalZero {
1180*10465441SEvalZero tmp = -2147483647 - 1;
1181*10465441SEvalZero }
1182*10465441SEvalZero
1183*10465441SEvalZero result = tmp;
1184*10465441SEvalZero return result;
1185*10465441SEvalZero }
1186*10465441SEvalZero
1187*10465441SEvalZero /**
1188*10465441SEvalZero \brief Dual 16-bit signed multiply with single 32-bit accumulator.
1189*10465441SEvalZero \details This function enables you to perform two signed 16-bit multiplications,
1190*10465441SEvalZero adding both results to a 32-bit accumulate operand.
1191*10465441SEvalZero \param [in] x first 16-bit operands for each multiplication.
1192*10465441SEvalZero \param [in] y second 16-bit operands for each multiplication.
1193*10465441SEvalZero \param [in] sum accumulate value.
1194*10465441SEvalZero \return the product of each multiplication added to the accumulate value, as a 32-bit integer.
1195*10465441SEvalZero \remark
1196*10465441SEvalZero p1 = val1[15:0] * val2[15:0] \n
1197*10465441SEvalZero p2 = val1[31:16] * val2[31:16] \n
1198*10465441SEvalZero res[31:0] = p1 + p2 + val3[31:0]
1199*10465441SEvalZero */
__SMLAD(uint32_t x,uint32_t y,uint32_t sum)1200*10465441SEvalZero __ALWAYS_INLINE uint32_t __SMLAD(uint32_t x, uint32_t y, uint32_t sum)
1201*10465441SEvalZero {
1202*10465441SEvalZero return ((uint32_t)(((((int32_t)x << 16) >> 16) * (((int32_t)y << 16) >> 16)) +
1203*10465441SEvalZero ((((int32_t)x) >> 16) * (((int32_t)y) >> 16)) +
1204*10465441SEvalZero (((int32_t)sum))));
1205*10465441SEvalZero }
1206*10465441SEvalZero
1207*10465441SEvalZero /**
1208*10465441SEvalZero \brief Pre-exchanged dual 16-bit signed multiply with single 32-bit accumulator.
1209*10465441SEvalZero \details This function enables you to perform two signed 16-bit multiplications with exchanged
1210*10465441SEvalZero halfwords of the second operand, adding both results to a 32-bit accumulate operand.
1211*10465441SEvalZero \param [in] x first 16-bit operands for each multiplication.
1212*10465441SEvalZero \param [in] y second 16-bit operands for each multiplication.
1213*10465441SEvalZero \param [in] sum accumulate value.
1214*10465441SEvalZero \return the product of each multiplication with exchanged halfwords of the second
1215*10465441SEvalZero operand added to the accumulate value, as a 32-bit integer.
1216*10465441SEvalZero \remark
1217*10465441SEvalZero p1 = val1[15:0] * val2[31:16] \n
1218*10465441SEvalZero p2 = val1[31:16] * val2[15:0] \n
1219*10465441SEvalZero res[31:0] = p1 + p2 + val3[31:0]
1220*10465441SEvalZero */
__SMLADX(uint32_t x,uint32_t y,uint32_t sum)1221*10465441SEvalZero __ALWAYS_INLINE uint32_t __SMLADX(uint32_t x, uint32_t y, uint32_t sum)
1222*10465441SEvalZero {
1223*10465441SEvalZero return ((uint32_t)(((((int32_t)x << 16) >> 16) * (((int32_t)y) >> 16)) +
1224*10465441SEvalZero ((((int32_t)x) >> 16) * (((int32_t)y << 16) >> 16)) +
1225*10465441SEvalZero (((int32_t)sum))));
1226*10465441SEvalZero }
1227*10465441SEvalZero
1228*10465441SEvalZero /**
1229*10465441SEvalZero \brief Dual 16-bit signed multiply with exchange subtract with 32-bit accumulate.
1230*10465441SEvalZero \details This function enables you to perform two 16-bit signed multiplications, take the
1231*10465441SEvalZero difference of the products, subtracting the high halfword product from the low
1232*10465441SEvalZero halfword product, and add the difference to a 32-bit accumulate operand.
1233*10465441SEvalZero \param [in] x first 16-bit operands for each multiplication.
1234*10465441SEvalZero \param [in] y second 16-bit operands for each multiplication.
1235*10465441SEvalZero \param [in] sum accumulate value.
1236*10465441SEvalZero \return the difference of the product of each multiplication, added to the accumulate value.
1237*10465441SEvalZero \remark
1238*10465441SEvalZero p1 = val1[15:0] * val2[15:0] \n
1239*10465441SEvalZero p2 = val1[31:16] * val2[31:16] \n
1240*10465441SEvalZero res[31:0] = p1 - p2 + val3[31:0]
1241*10465441SEvalZero */
__SMLSD(uint32_t x,uint32_t y,uint32_t sum)1242*10465441SEvalZero __ALWAYS_INLINE uint32_t __SMLSD(uint32_t x, uint32_t y, uint32_t sum)
1243*10465441SEvalZero {
1244*10465441SEvalZero return ((uint32_t)(((((int32_t)x << 16) >> 16) * (((int32_t)y << 16) >> 16)) -
1245*10465441SEvalZero ((((int32_t)x) >> 16) * (((int32_t)y) >> 16)) +
1246*10465441SEvalZero (((int32_t)sum))));
1247*10465441SEvalZero }
1248*10465441SEvalZero
1249*10465441SEvalZero /**
1250*10465441SEvalZero \brief Dual 16-bit signed multiply with exchange subtract with 32-bit accumulate.
1251*10465441SEvalZero \details This function enables you to exchange the halfwords in the second operand, then perform two 16-bit
1252*10465441SEvalZero signed multiplications. The difference of the products is added to a 32-bit accumulate operand.
1253*10465441SEvalZero \param [in] x first 16-bit operands for each multiplication.
1254*10465441SEvalZero \param [in] y second 16-bit operands for each multiplication.
1255*10465441SEvalZero \param [in] sum accumulate value.
1256*10465441SEvalZero \return the difference of the product of each multiplication, added to the accumulate value.
1257*10465441SEvalZero \remark
1258*10465441SEvalZero p1 = val1[15:0] * val2[31:16] \n
1259*10465441SEvalZero p2 = val1[31:16] * val2[15:0] \n
1260*10465441SEvalZero res[31:0] = p1 - p2 + val3[31:0]
1261*10465441SEvalZero */
__SMLSDX(uint32_t x,uint32_t y,uint32_t sum)1262*10465441SEvalZero __ALWAYS_INLINE uint32_t __SMLSDX(uint32_t x, uint32_t y, uint32_t sum)
1263*10465441SEvalZero {
1264*10465441SEvalZero return ((uint32_t)(((((int32_t)x << 16) >> 16) * (((int32_t)y) >> 16)) -
1265*10465441SEvalZero ((((int32_t)x) >> 16) * (((int32_t)y << 16) >> 16)) +
1266*10465441SEvalZero (((int32_t)sum))));
1267*10465441SEvalZero }
1268*10465441SEvalZero
1269*10465441SEvalZero /**
1270*10465441SEvalZero \brief Dual 16-bit signed multiply with single 64-bit accumulator.
1271*10465441SEvalZero \details This function enables you to perform two signed 16-bit multiplications, adding both results
1272*10465441SEvalZero to a 64-bit accumulate operand. Overflow is only possible as a result of the 64-bit addition.
1273*10465441SEvalZero This overflow is not detected if it occurs. Instead, the result wraps around modulo2^64.
1274*10465441SEvalZero \param [in] x first 16-bit operands for each multiplication.
1275*10465441SEvalZero \param [in] y second 16-bit operands for each multiplication.
1276*10465441SEvalZero \param [in] sum accumulate value.
1277*10465441SEvalZero \return the product of each multiplication added to the accumulate value.
1278*10465441SEvalZero \remark
1279*10465441SEvalZero p1 = val1[15:0] * val2[15:0] \n
1280*10465441SEvalZero p2 = val1[31:16] * val2[31:16] \n
1281*10465441SEvalZero sum = p1 + p2 + val3[63:32][31:0] \n
1282*10465441SEvalZero res[63:32] = sum[63:32] \n
1283*10465441SEvalZero res[31:0] = sum[31:0]
1284*10465441SEvalZero */
__SMLALD(uint32_t x,uint32_t y,uint64_t sum)1285*10465441SEvalZero __ALWAYS_INLINE uint64_t __SMLALD(uint32_t x, uint32_t y, uint64_t sum)
1286*10465441SEvalZero {
1287*10465441SEvalZero return ((uint64_t)(((((int32_t)x << 16) >> 16) * (((int32_t)y << 16) >> 16)) +
1288*10465441SEvalZero ((((int32_t)x) >> 16) * (((int32_t)y) >> 16)) +
1289*10465441SEvalZero (((uint64_t)sum))));
1290*10465441SEvalZero }
1291*10465441SEvalZero
1292*10465441SEvalZero /**
1293*10465441SEvalZero \brief Dual 16-bit signed multiply with exchange with single 64-bit accumulator.
1294*10465441SEvalZero \details This function enables you to exchange the halfwords of the second operand, and perform two
1295*10465441SEvalZero signed 16-bit multiplications, adding both results to a 64-bit accumulate operand. Overflow
1296*10465441SEvalZero is only possible as a result of the 64-bit addition. This overflow is not detected if it occurs.
1297*10465441SEvalZero Instead, the result wraps around modulo2^64.
1298*10465441SEvalZero \param [in] x first 16-bit operands for each multiplication.
1299*10465441SEvalZero \param [in] y second 16-bit operands for each multiplication.
1300*10465441SEvalZero \param [in] sum accumulate value.
1301*10465441SEvalZero \return the product of each multiplication added to the accumulate value.
1302*10465441SEvalZero \remark
1303*10465441SEvalZero p1 = val1[15:0] * val2[31:16] \n
1304*10465441SEvalZero p2 = val1[31:16] * val2[15:0] \n
1305*10465441SEvalZero sum = p1 + p2 + val3[63:32][31:0] \n
1306*10465441SEvalZero res[63:32] = sum[63:32] \n
1307*10465441SEvalZero res[31:0] = sum[31:0]
1308*10465441SEvalZero */
__SMLALDX(uint32_t x,uint32_t y,uint64_t sum)1309*10465441SEvalZero __ALWAYS_INLINE uint64_t __SMLALDX(uint32_t x, uint32_t y, uint64_t sum)
1310*10465441SEvalZero {
1311*10465441SEvalZero return ((uint64_t)(((((int32_t)x << 16) >> 16) * (((int32_t)y) >> 16)) +
1312*10465441SEvalZero ((((int32_t)x) >> 16) * (((int32_t)y << 16) >> 16)) +
1313*10465441SEvalZero (((uint64_t)sum))));
1314*10465441SEvalZero }
1315*10465441SEvalZero
1316*10465441SEvalZero /**
1317*10465441SEvalZero \brief dual 16-bit signed multiply subtract with 64-bit accumulate.
1318*10465441SEvalZero \details This function It enables you to perform two 16-bit signed multiplications, take the difference
1319*10465441SEvalZero of the products, subtracting the high halfword product from the low halfword product, and add the
1320*10465441SEvalZero difference to a 64-bit accumulate operand. Overflow cannot occur during the multiplications or the
1321*10465441SEvalZero subtraction. Overflow can occur as a result of the 64-bit addition, and this overflow is not
1322*10465441SEvalZero detected. Instead, the result wraps round to modulo2^64.
1323*10465441SEvalZero \param [in] x first 16-bit operands for each multiplication.
1324*10465441SEvalZero \param [in] y second 16-bit operands for each multiplication.
1325*10465441SEvalZero \param [in] sum accumulate value.
1326*10465441SEvalZero \return the difference of the product of each multiplication, added to the accumulate value.
1327*10465441SEvalZero \remark
1328*10465441SEvalZero p1 = val1[15:0] * val2[15:0] \n
1329*10465441SEvalZero p2 = val1[31:16] * val2[31:16] \n
1330*10465441SEvalZero res[63:0] = p1 - p2 + val3[63:0]
1331*10465441SEvalZero */
__SMLSLD(uint32_t x,uint32_t y,uint64_t sum)1332*10465441SEvalZero __ALWAYS_INLINE uint64_t __SMLSLD(uint32_t x, uint32_t y, uint64_t sum)
1333*10465441SEvalZero {
1334*10465441SEvalZero return ((uint64_t)(((((int32_t)x << 16) >> 16) * (((int32_t)y << 16) >> 16)) -
1335*10465441SEvalZero ((((int32_t)x) >> 16) * (((int32_t)y) >> 16)) +
1336*10465441SEvalZero (((uint64_t)sum))));
1337*10465441SEvalZero }
1338*10465441SEvalZero
1339*10465441SEvalZero /**
1340*10465441SEvalZero \brief Dual 16-bit signed multiply with exchange subtract with 64-bit accumulate.
1341*10465441SEvalZero \details This function enables you to exchange the halfwords of the second operand, perform two 16-bit multiplications,
1342*10465441SEvalZero adding the difference of the products to a 64-bit accumulate operand. Overflow cannot occur during the
1343*10465441SEvalZero multiplications or the subtraction. Overflow can occur as a result of the 64-bit addition, and this overflow
1344*10465441SEvalZero is not detected. Instead, the result wraps round to modulo2^64.
1345*10465441SEvalZero \param [in] x first 16-bit operands for each multiplication.
1346*10465441SEvalZero \param [in] y second 16-bit operands for each multiplication.
1347*10465441SEvalZero \param [in] sum accumulate value.
1348*10465441SEvalZero \return the difference of the product of each multiplication, added to the accumulate value.
1349*10465441SEvalZero \remark
1350*10465441SEvalZero p1 = val1[15:0] * val2[31:16] \n
1351*10465441SEvalZero p2 = val1[31:16] * val2[15:0] \n
1352*10465441SEvalZero res[63:0] = p1 - p2 + val3[63:0]
1353*10465441SEvalZero */
__SMLSLDX(uint32_t x,uint32_t y,uint64_t sum)1354*10465441SEvalZero __ALWAYS_INLINE uint64_t __SMLSLDX(uint32_t x, uint32_t y, uint64_t sum)
1355*10465441SEvalZero {
1356*10465441SEvalZero return ((uint64_t)(((((int32_t)x << 16) >> 16) * (((int32_t)y) >> 16)) -
1357*10465441SEvalZero ((((int32_t)x) >> 16) * (((int32_t)y << 16) >> 16)) +
1358*10465441SEvalZero (((uint64_t)sum))));
1359*10465441SEvalZero }
1360*10465441SEvalZero
1361*10465441SEvalZero /**
1362*10465441SEvalZero \brief 32-bit signed multiply with 32-bit truncated accumulator.
1363*10465441SEvalZero \details This function enables you to perform a signed 32-bit multiplications, adding the most
1364*10465441SEvalZero significant 32 bits of the 64-bit result to a 32-bit accumulate operand.
1365*10465441SEvalZero \param [in] x first operand for multiplication.
1366*10465441SEvalZero \param [in] y second operand for multiplication.
1367*10465441SEvalZero \param [in] sum accumulate value.
1368*10465441SEvalZero \return the product of multiplication (most significant 32 bits) is added to the accumulate value, as a 32-bit integer.
1369*10465441SEvalZero \remark
1370*10465441SEvalZero p = val1 * val2 \n
1371*10465441SEvalZero res[31:0] = p[61:32] + val3[31:0]
1372*10465441SEvalZero */
__SMMLA(int32_t x,int32_t y,int32_t sum)1373*10465441SEvalZero __ALWAYS_INLINE uint32_t __SMMLA(int32_t x, int32_t y, int32_t sum)
1374*10465441SEvalZero {
1375*10465441SEvalZero return (uint32_t)((int32_t)((int64_t)((int64_t)x * (int64_t)y) >> 32) + sum);
1376*10465441SEvalZero }
1377*10465441SEvalZero
1378*10465441SEvalZero /**
1379*10465441SEvalZero \brief Sum of dual 16-bit signed multiply.
1380*10465441SEvalZero \details This function enables you to perform two 16-bit signed multiplications, adding the products together.
1381*10465441SEvalZero \param [in] x first 16-bit operands for each multiplication.
1382*10465441SEvalZero \param [in] y second 16-bit operands for each multiplication.
1383*10465441SEvalZero \return the sum of the products of the two 16-bit signed multiplications.
1384*10465441SEvalZero \remark
1385*10465441SEvalZero p1 = val1[15:0] * val2[15:0] \n
1386*10465441SEvalZero p2 = val1[31:16] * val2[31:16] \n
1387*10465441SEvalZero res[31:0] = p1 + p2
1388*10465441SEvalZero */
__SMUAD(uint32_t x,uint32_t y)1389*10465441SEvalZero __ALWAYS_INLINE uint32_t __SMUAD(uint32_t x, uint32_t y)
1390*10465441SEvalZero {
1391*10465441SEvalZero return ((uint32_t)(((((int32_t)x << 16) >> 16) * (((int32_t)y << 16) >> 16)) +
1392*10465441SEvalZero ((((int32_t)x) >> 16) * (((int32_t)y) >> 16))));
1393*10465441SEvalZero }
1394*10465441SEvalZero
1395*10465441SEvalZero /**
1396*10465441SEvalZero \brief Dual 16-bit signed multiply returning difference.
1397*10465441SEvalZero \details This function enables you to perform two 16-bit signed multiplications, taking the difference
1398*10465441SEvalZero of the products by subtracting the high halfword product from the low halfword product.
1399*10465441SEvalZero \param [in] x first 16-bit operands for each multiplication.
1400*10465441SEvalZero \param [in] y second 16-bit operands for each multiplication.
1401*10465441SEvalZero \return the difference of the products of the two 16-bit signed multiplications.
1402*10465441SEvalZero \remark
1403*10465441SEvalZero p1 = val1[15:0] * val2[15:0] \n
1404*10465441SEvalZero p2 = val1[31:16] * val2[31:16] \n
1405*10465441SEvalZero res[31:0] = p1 - p2
1406*10465441SEvalZero */
__SMUSD(uint32_t x,uint32_t y)1407*10465441SEvalZero __ALWAYS_INLINE uint32_t __SMUSD(uint32_t x, uint32_t y)
1408*10465441SEvalZero {
1409*10465441SEvalZero return ((uint32_t)(((((int32_t)x << 16) >> 16) * (((int32_t)y << 16) >> 16)) -
1410*10465441SEvalZero ((((int32_t)x) >> 16) * (((int32_t)y) >> 16))));
1411*10465441SEvalZero }
1412*10465441SEvalZero
1413*10465441SEvalZero /**
1414*10465441SEvalZero \brief Dual extracted 8-bit to 16-bit signed addition.
1415*10465441SEvalZero \details This function enables you to extract two 8-bit values from the second operand (at bit positions
1416*10465441SEvalZero [7:0] and [23:16]), sign-extend them to 16-bits each, and add the results to the first operand.
1417*10465441SEvalZero \param [in] x values added to the sign-extended to 16-bit values.
1418*10465441SEvalZero \param [in] y two 8-bit values to be extracted and sign-extended.
1419*10465441SEvalZero \return the addition of val1 and val2, where the 8-bit values in val2[7:0] and
1420*10465441SEvalZero val2[23:16] have been extracted and sign-extended prior to the addition.
1421*10465441SEvalZero \remark
1422*10465441SEvalZero res[15:0] = val1[15:0] + SignExtended(val2[7:0]) \n
1423*10465441SEvalZero res[31:16] = val1[31:16] + SignExtended(val2[23:16])
1424*10465441SEvalZero */
__SXTAB16(uint32_t x,uint32_t y)1425*10465441SEvalZero __ALWAYS_INLINE uint32_t __SXTAB16(uint32_t x, uint32_t y)
1426*10465441SEvalZero {
1427*10465441SEvalZero return ((uint32_t)((((((int32_t)y << 24) >> 24) + (((int32_t)x << 16) >> 16)) & (int32_t)0x0000FFFF) |
1428*10465441SEvalZero (((((int32_t)y << 8) >> 8) + (((int32_t)x >> 16) << 16)) & (int32_t)0xFFFF0000)));
1429*10465441SEvalZero }
1430*10465441SEvalZero
1431*10465441SEvalZero /**
1432*10465441SEvalZero \brief Extracted 16-bit to 32-bit unsigned addition.
1433*10465441SEvalZero \details This function enables you to extract two 8-bit values from one operand, zero-extend
1434*10465441SEvalZero them to 16 bits each, and add the results to two 16-bit values from another operand.
1435*10465441SEvalZero \param [in] x values added to the zero-extended to 16-bit values.
1436*10465441SEvalZero \param [in] y two 8-bit values to be extracted and zero-extended.
1437*10465441SEvalZero \return the addition of val1 and val2, where the 8-bit values in val2[7:0] and
1438*10465441SEvalZero val2[23:16] have been extracted and zero-extended prior to the addition.
1439*10465441SEvalZero \remark
1440*10465441SEvalZero res[15:0] = ZeroExt(val2[7:0] to 16 bits) + val1[15:0] \n
1441*10465441SEvalZero res[31:16] = ZeroExt(val2[31:16] to 16 bits) + val1[31:16]
1442*10465441SEvalZero */
__UXTAB16(uint32_t x,uint32_t y)1443*10465441SEvalZero __ALWAYS_INLINE uint32_t __UXTAB16(uint32_t x, uint32_t y)
1444*10465441SEvalZero {
1445*10465441SEvalZero return ((uint32_t)(((((y << 24) >> 24) + ((x << 16) >> 16)) & 0x0000FFFF) |
1446*10465441SEvalZero ((((y << 8) >> 8) + ((x >> 16) << 16)) & 0xFFFF0000)));
1447*10465441SEvalZero }
1448*10465441SEvalZero
1449*10465441SEvalZero /**
1450*10465441SEvalZero \brief Dual extract 8-bits and sign extend each to 16-bits.
1451*10465441SEvalZero \details This function enables you to extract two 8-bit values from an operand and sign-extend them to 16 bits each.
1452*10465441SEvalZero \param [in] x two 8-bit values in val[7:0] and val[23:16] to be sign-extended.
1453*10465441SEvalZero \return the 8-bit values sign-extended to 16-bit values.\n
1454*10465441SEvalZero sign-extended value of val[7:0] in the low halfword of the return value.\n
1455*10465441SEvalZero sign-extended value of val[23:16] in the high halfword of the return value.
1456*10465441SEvalZero \remark
1457*10465441SEvalZero res[15:0] = SignExtended(val[7:0]) \n
1458*10465441SEvalZero res[31:16] = SignExtended(val[23:16])
1459*10465441SEvalZero */
__SXTB16(uint32_t x)1460*10465441SEvalZero __ALWAYS_INLINE uint32_t __SXTB16(uint32_t x)
1461*10465441SEvalZero {
1462*10465441SEvalZero return ((uint32_t)(((((int32_t)x << 24) >> 24) & (int32_t)0x0000FFFF) |
1463*10465441SEvalZero ((((int32_t)x << 8) >> 8) & (int32_t)0xFFFF0000)));
1464*10465441SEvalZero }
1465*10465441SEvalZero
1466*10465441SEvalZero /**
1467*10465441SEvalZero \brief Dual extract 8-bits and zero-extend to 16-bits.
1468*10465441SEvalZero \details This function enables you to extract two 8-bit values from an operand and zero-extend them to 16 bits each.
1469*10465441SEvalZero \param [in] x two 8-bit values in val[7:0] and val[23:16] to be zero-extended.
1470*10465441SEvalZero \return the 8-bit values sign-extended to 16-bit values.\n
1471*10465441SEvalZero sign-extended value of val[7:0] in the low halfword of the return value.\n
1472*10465441SEvalZero sign-extended value of val[23:16] in the high halfword of the return value.
1473*10465441SEvalZero \remark
1474*10465441SEvalZero res[15:0] = SignExtended(val[7:0]) \n
1475*10465441SEvalZero res[31:16] = SignExtended(val[23:16])
1476*10465441SEvalZero */
__UXTB16(uint32_t x)1477*10465441SEvalZero __ALWAYS_INLINE uint32_t __UXTB16(uint32_t x)
1478*10465441SEvalZero {
1479*10465441SEvalZero return ((uint32_t)((((x << 24) >> 24) & 0x0000FFFF) |
1480*10465441SEvalZero (((x << 8) >> 8) & 0xFFFF0000)));
1481*10465441SEvalZero }
1482*10465441SEvalZero
1483*10465441SEvalZero #endif /* _CSI_SIMD_H_ */
1484