1 /*-----------------------------------------------------------------------------
3 * Purpose: CMSIS CORE validation tests implementation
4 *-----------------------------------------------------------------------------
5 * Copyright (c) 2018 Arm Limited. All rights reserved.
6 *----------------------------------------------------------------------------*/
8 #include "CV_Framework.h"
11 /*-----------------------------------------------------------------------------
13 *----------------------------------------------------------------------------*/
15 /*-----------------------------------------------------------------------------
17 *----------------------------------------------------------------------------*/
20 \brief Test case: TC_CoreSimd_SatAddSub
22 - Check Saturating addition and subtraction:
26 void TC_CoreSimd_SatAddSub (void) {
27 #if ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
28 (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)) )
29 volatile int32_t op1_s32, op2_s32;
30 volatile int32_t res_s32;
32 /* --- __QADD Test ---------------------------------------------- */
33 op1_s32 = (int32_t)0x80000003;
34 op2_s32 = (int32_t)0x00000004;
35 res_s32 = __QADD(op1_s32, op2_s32);
36 ASSERT_TRUE(res_s32 == (int32_t)0x80000007);
38 op1_s32 = (int32_t)0x80000000;
39 op2_s32 = (int32_t)0x80000002;
40 res_s32 = __QADD(op1_s32, op2_s32);
41 ASSERT_TRUE(res_s32 == (int32_t)0x80000000);
43 /* --- __QSUB Test ---------------------------------------------- */
44 op1_s32 = (int32_t)0x80000003;
45 op2_s32 = (int32_t)0x00000004;
46 res_s32 = __QSUB(op1_s32, op2_s32);
47 ASSERT_TRUE(res_s32 == (int32_t)0x80000000);
49 op1_s32 = (int32_t)0x80000003;
50 op2_s32 = (int32_t)0x00000002;
51 res_s32 = __QSUB(op1_s32, op2_s32);
52 ASSERT_TRUE(res_s32 == (int32_t)0x80000001);
57 \brief Test case: TC_CoreSimd_ParSat16
59 - Check Parallel 16-bit saturation:
63 void TC_CoreSimd_ParSat16 (void) {
64 #if ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
65 (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)) )
66 volatile int32_t op1_s32;
67 volatile int32_t res_s32;
69 /* --- __SSAT16 Test ---------------------------------------------- */
70 op1_s32 = (int32_t)0x80030168;
71 res_s32 = __SSAT16(op1_s32, 8);
72 ASSERT_TRUE(res_s32 == (int32_t)0xFF80007F);
74 /* --- __USAT16 Test ---------------------------------------------- */
76 res_s32 = __USAT16(op1_s32, 8);
77 ASSERT_TRUE(res_s32 == 0x000300FF);
82 \brief Test case: TC_CoreSimd_PackUnpack
84 - Check Packing and unpacking:
92 void TC_CoreSimd_PackUnpack (void) {
93 #if ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
94 (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)) )
95 volatile int32_t op1_s32, op2_s32;
96 volatile int32_t res_s32;
98 /* --- __SXTB16 Test ---------------------------------------------- */
99 op1_s32 = (int32_t)0x80830168;
100 res_s32 = __SXTB16(op1_s32);
101 ASSERT_TRUE(res_s32 == (int32_t)0xFF830068);
103 /* --- __SXTB16_ROR8 Test ----------------------------------------- */
104 op1_s32 = (int32_t)0x80830168;
105 res_s32 = __SXTB16_RORn(op1_s32, 8);
106 ASSERT_TRUE(res_s32 == (int32_t)0xFF800001);
108 /* --- __SXTB16_ROR16 Test ---------------------------------------- */
109 op1_s32 = (int32_t)0x80830168;
110 res_s32 = __SXTB16_RORn(op1_s32, 16);
111 ASSERT_TRUE(res_s32 == (int32_t)0x68FF83);
113 /* --- __SXTB16_ROR24 Test ---------------------------------------- */
114 op1_s32 = (int32_t)0x80830168;
115 res_s32 = __SXTB16_RORn(op1_s32, 24);
116 ASSERT_TRUE(res_s32 == (int32_t)0x1FF80);
118 /* --- __SXTAB16 Test --------------------------------------------- */
119 op1_s32 = (int32_t)0x000D0008;
120 op2_s32 = (int32_t)0x80830168;
121 res_s32 = __SXTAB16(op1_s32, op2_s32);
122 ASSERT_TRUE(res_s32 == (int32_t)0xFF900070);
124 /* --- __SXTAB16__ROR8 Test --------------------------------------- */
125 op1_s32 = (int32_t)0x000A000A;
126 op2_s32 = (int32_t)0x80830168;
127 res_s32 = __SXTAB16_RORn(op1_s32, op2_s32, 8);
128 ASSERT_TRUE(res_s32 == (int32_t)0xFF8A000B);
130 /* --- __SXTAB16__ROR8 Test --------------------------------------- */
131 op1_s32 = (int32_t)0xFFF6FFF6;
132 op2_s32 = (int32_t)0x80830168;
133 res_s32 = __SXTAB16_RORn(op1_s32, op2_s32, 8);
134 ASSERT_TRUE(res_s32 == (int32_t)0xFF76FFF7);
136 /* --- __SXTAB16__ROR16 Test -------------------------------------- */
137 op1_s32 = (int32_t)0xFFF60015;
138 op2_s32 = (int32_t)0x70880168;
139 res_s32 = __SXTAB16_RORn(op1_s32, op2_s32, 16);
140 ASSERT_TRUE(res_s32 == (int32_t)0x5EFF9D);
142 /* --- __SXTAB16__ROR24 Test -------------------------------------- */
143 op1_s32 = (int32_t)0xFFF60015;
144 op2_s32 = (int32_t)0x70880168;
145 res_s32 = __SXTAB16_RORn(op1_s32, op2_s32, 24);
146 ASSERT_TRUE(res_s32 == (int32_t)0xFFF70085);
148 /* --- __UXTB16 Test ---------------------------------------------- */
149 op1_s32 = (int32_t)0x80830168;
150 res_s32 = __UXTB16(op1_s32);
151 ASSERT_TRUE(res_s32 == 0x00830068);
153 /* --- __UXTAB16 Test --------------------------------------------- */
154 op1_s32 = 0x000D0008;
155 op2_s32 = (int32_t)0x80830168;
156 res_s32 = __UXTAB16(op1_s32, op2_s32);
157 ASSERT_TRUE(res_s32 == 0x00900070);
162 \brief Test case: TC_CoreSimd_ParSel
164 - Check Parallel selection:
167 void TC_CoreSimd_ParSel (void) {
168 #if ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
169 (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)) )
170 volatile uint32_t res_u32;
172 volatile int32_t op1_s32, op2_s32;
173 volatile int32_t res_s32;
178 /* --- __SEL Test ---------------------------------------------- */
179 op1_s32 = 0x33221100;
180 op2_s32 = 0x77665544;
182 res_s32 = __SADD8(0x80808080, 0x00000000); /* __sadd8 sets APSR.GE = 0x00 */
183 res_u32 = __get_APSR();
184 apsr.w = __get_APSR();
185 ASSERT_TRUE( (res_u32 == apsr.w) );
186 xpsr.w = __get_xPSR();
187 ASSERT_TRUE( (((res_u32 >> 16) & 0x0F) == xpsr.b.GE) );
188 res_s32 = __SEL(op1_s32, op2_s32); /* __sel APSR.GE = 0x00 */
189 ASSERT_TRUE( res_s32 == 0x77665544);
191 res_s32 = __SADD8(0x80808000, 0x00000000); /* __sadd8 sets APSR.GE = 0x01 */
192 res_u32 = __get_APSR();
193 apsr.w = __get_APSR();
194 ASSERT_TRUE( (res_u32 == apsr.w) );
195 xpsr.w = __get_xPSR();
196 ASSERT_TRUE( (((res_u32 >> 16) & 0x0F) == xpsr.b.GE) );
197 res_s32 = __SEL(op1_s32, op2_s32); /* __sel APSR.GE = 0x01 */
198 ASSERT_TRUE(res_s32 == 0x77665500);
200 res_s32 = __SADD8(0x80800080, 0x00000000); /* __sadd8 sets APSR.GE = 0x02 */
201 res_u32 = __get_APSR();
202 apsr.w = __get_APSR();
203 ASSERT_TRUE( (res_u32 == apsr.w) );
204 xpsr.w = __get_xPSR();
205 ASSERT_TRUE( (((res_u32 >> 16) & 0x0F) == xpsr.b.GE) );
206 res_s32 = __SEL(op1_s32, op2_s32); /* __sel APSR.GE = 0x02 */
207 ASSERT_TRUE(res_s32 == 0x77661144);
212 \brief Test case: TC_CoreSimd_ParAddSub8
214 - Check Parallel 8-bit addition and subtraction:
216 __SSUB8 Q Signed Saturating
217 __SHADD8 SH Signed Halving
219 __QADD8 UQ Unsigned Saturating
220 __QSUB8 UH Unsigned Halving
228 void TC_CoreSimd_ParAddSub8 (void) {
229 #if ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
230 (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)) )
231 volatile uint32_t op1_u32, op2_u32;
232 volatile uint32_t res_u32;
234 volatile int32_t op1_s32, op2_s32;
235 volatile int32_t res_s32;
237 /* --- __SADD8 Test ---------------------------------------------- */
238 op1_s32 = (int32_t)0x87858381;
239 op2_s32 = (int32_t)0x08060402;
240 res_s32 = __SADD8(op1_s32, op2_s32);
241 ASSERT_TRUE(res_s32 == (int32_t)0x8F8B8783);
243 /* --- __SSUB8 Test ---------------------------------------------- */
244 op1_s32 = (int32_t)0x8F8B8783;
245 op2_s32 = (int32_t)0x08060402;
246 res_s32 = __SSUB8(op1_s32, op2_s32);
247 ASSERT_TRUE(res_s32 == (int32_t)0x87858381);
249 /* --- __SHADD8 Test ---------------------------------------------- */
250 op1_s32 = 0x07050302;
251 op2_s32 = 0x08060402;
252 res_s32 = __SHADD8(op1_s32, op2_s32);
253 ASSERT_TRUE(res_s32 == 0x07050302);
255 /* --- __SHSUB8 Test ---------------------------------------------- */
256 op1_s32 = (int32_t)0x8F8B8783;
257 op2_s32 = 0x08060402;
258 res_s32 = __SHSUB8(op1_s32, op2_s32);
259 ASSERT_TRUE(res_s32 == (int32_t)0xC3C2C1C0);
261 /* --- __QADD8 Test ---------------------------------------------- */
262 op1_s32 = (int32_t)0x8085837F;
263 op2_s32 = (int32_t)0xFF060402;
264 res_s32 = __QADD8(op1_s32, op2_s32);
265 ASSERT_TRUE(res_s32 == (int32_t)0x808B877F);
267 /* --- __QSUB8 Test ---------------------------------------------- */
268 op1_s32 = (int32_t)0x808B8783;
269 op2_s32 = (int32_t)0x08060402;
270 res_s32 = __QSUB8(op1_s32, op2_s32);
271 ASSERT_TRUE(res_s32 == (int32_t)0x80858381);
273 /* --- __UADD8 Test ---------------------------------------------- */
274 op1_u32 = 0x07050301;
275 op2_u32 = 0x08060402;
276 res_u32 = __UADD8(op1_u32, op2_u32);
277 ASSERT_TRUE(res_u32 == 0x0F0B0703);
279 /* --- __USUB8 Test ---------------------------------------------- */
280 op1_u32 = 0x0F0B0703;
281 op2_u32 = 0x08060402;
282 res_u32 = __USUB8(op1_u32, op2_u32);
283 ASSERT_TRUE(res_u32 == 0x07050301);
285 /* --- __UHADD8 Test ---------------------------------------------- */
286 op1_u32 = 0x07050302;
287 op2_u32 = 0x08060402;
288 res_u32 = __UHADD8(op1_u32, op2_u32);
289 ASSERT_TRUE(res_u32 == 0x07050302);
291 /* --- __UHSUB8 Test ---------------------------------------------- */
292 op1_u32 = 0x0F0B0703;
293 op2_u32 = 0x08060402;
294 res_u32 = __UHSUB8(op1_u32, op2_u32);
295 ASSERT_TRUE(res_u32 == 0x03020100);
297 /* --- __UQADD8 Test ---------------------------------------------- */
298 op1_u32 = 0xFF050301;
299 op2_u32 = 0x08060402;
300 res_u32 = __UQADD8(op1_u32, op2_u32);
301 ASSERT_TRUE(res_u32 == 0xFF0B0703);
303 /* --- __UQSUB8 Test ---------------------------------------------- */
304 op1_u32 = 0x080B0702;
305 op2_u32 = 0x0F060408;
306 res_u32 = __UQSUB8(op1_u32, op2_u32);
307 ASSERT_TRUE(res_u32 == 0x00050300);
312 \brief Test case: TC_CoreSimd_AbsDif8
314 - Check Sum of 8-bit absolute differences:
318 void TC_CoreSimd_AbsDif8 (void) {
319 #if ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
320 (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)) )
321 volatile uint32_t op1_u32, op2_u32, op3_u32;
322 volatile uint32_t res_u32;
324 /* --- __USAD8 Test ---------------------------------------------- */
325 op1_u32 = 0x87858381;
326 op2_u32 = 0x08060402;
327 res_u32 = __USAD8(op1_u32, op2_u32);
328 ASSERT_TRUE(res_u32 == 0x000001FC);
330 /* --- __USADA8 Test ---------------------------------------------- */
331 op1_u32 = 0x87858381;
332 op2_u32 = 0x08060402;
333 op3_u32 = 0x00008000;
334 res_u32 = __USADA8(op1_u32, op2_u32, op3_u32);
335 ASSERT_TRUE(res_u32 == 0x000081FC);
340 \brief Test case: TC_CoreSimd_ParAddSub16
342 - Check Parallel 16-bit addition and subtraction:
368 void TC_CoreSimd_ParAddSub16 (void) {
369 #if ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
370 (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)) )
371 volatile uint32_t op1_u32, op2_u32;
372 volatile uint32_t res_u32;
374 volatile int32_t op1_s32, op2_s32;
375 volatile int32_t res_s32;
377 /* --- __SADD16 Test ---------------------------------------------- */
378 op1_s32 = (int32_t)0x80038001;
379 op2_s32 = (int32_t)0x00040002;
380 res_s32 = __SADD16(op1_s32, op2_s32);
381 ASSERT_TRUE(res_s32 == (int32_t)0x80078003);
383 /* --- __SSUB16 Test ---------------------------------------------- */
384 op1_s32 = (int32_t)0x80078003;
385 op2_s32 = (int32_t)0x00040002;
386 res_s32 = __SSUB16(op1_s32, op2_s32);
387 ASSERT_TRUE(res_s32 == (int32_t)0x80038001);
389 /* --- __SASX Test ---------------------------------------------- */
390 op1_s32 = (int32_t)0x80078003;
391 op2_s32 = (int32_t)0x00040002;
392 res_s32 = __SASX(op1_s32, op2_s32);
393 ASSERT_TRUE(res_s32 == (int32_t)0x80097FFF);
395 /* --- __SSAX Test ---------------------------------------------- */
396 op1_s32 = (int32_t)0x80038007;
397 op2_s32 = (int32_t)0x00020004;
398 res_s32 = __SSAX(op1_s32, op2_s32);
399 ASSERT_TRUE(res_s32 == (int32_t)0x7FFF8009);
401 /* --- __SHADD16 Test ---------------------------------------------- */
402 op1_s32 = (int32_t)0x80038001;
403 op2_s32 = (int32_t)0x00040002;
404 res_s32 = __SHADD16(op1_s32, op2_s32);
405 ASSERT_TRUE(res_s32 == (int32_t)0xC003C001);
407 /* --- __SHSUB16 Test ---------------------------------------------- */
408 op1_s32 = (int32_t)0x80078003;
409 op2_s32 = (int32_t)0x00040002;
410 res_s32 = __SHSUB16(op1_s32, op2_s32);
411 ASSERT_TRUE(res_s32 == (int32_t)0xC001C000);
413 /* --- __SHASX Test ---------------------------------------------- */
414 op1_s32 = (int32_t)0x80078003;
415 op2_s32 = (int32_t)0x00040002;
416 res_s32 = __SHASX(op1_s32, op2_s32);
417 ASSERT_TRUE(res_s32 == (int32_t)0xC004BFFF);
419 /* --- __SHSAX Test ---------------------------------------------- */
420 op1_s32 = (int32_t)0x80038007;
421 op2_s32 = (int32_t)0x00020004;
422 res_s32 = __SHSAX(op1_s32, op2_s32);
423 ASSERT_TRUE(res_s32 == (int32_t)0xBFFFC004);
425 /* --- __QADD16 Test ---------------------------------------------- */
426 op1_s32 = (int32_t)0x80038000;
427 op2_s32 = (int32_t)0x00048002;
428 res_s32 = __QADD16(op1_s32, op2_s32);
429 ASSERT_TRUE(res_s32 == (int32_t)0x80078000);
431 /* --- __QSUB16 Test ---------------------------------------------- */
432 op1_s32 = (int32_t)0x80038003;
433 op2_s32 = (int32_t)0x00040002;
434 res_s32 = __QSUB16(op1_s32, op2_s32);
435 ASSERT_TRUE(res_s32 == (int32_t)0x80008001);
437 /* --- __QASX Test ---------------------------------------------- */
438 op1_s32 = (int32_t)0x80078003;
439 op2_s32 = (int32_t)0x00040002;
440 res_s32 = __QASX(op1_s32, op2_s32);
441 ASSERT_TRUE(res_s32 == (int32_t)0x80098000);
443 /* --- __QSAX Test ---------------------------------------------- */
444 op1_s32 = (int32_t)0x80038007;
445 op2_s32 = (int32_t)0x00020004;
446 res_s32 = __QSAX(op1_s32, op2_s32);
447 ASSERT_TRUE(res_s32 == (int32_t)0x80008009);
449 /* --- __UADD16 Test ---------------------------------------------- */
450 op1_u32 = 0x00010002;
451 op2_u32 = 0x00020004;
452 res_u32 = __UADD16(op1_u32, op2_u32);
453 ASSERT_TRUE(res_u32 == 0x00030006);
455 /* --- __USUB16 Test ---------------------------------------------- */
456 op1_u32 = 0x00030006;
457 op2_u32 = 0x00020004;
458 res_u32 = __USUB16(op1_u32, op2_u32);
459 ASSERT_TRUE(res_u32 == 0x00010002);
461 /* --- __UASX Test ---------------------------------------------- */
462 op1_u32 = 0x80078003;
463 op2_u32 = 0x00040002;
464 res_u32 = __UASX(op1_u32, op2_u32);
465 ASSERT_TRUE(res_u32 == 0x80097FFF);
467 /* --- __USAX Test ---------------------------------------------- */
468 op1_u32 = 0x80038007;
469 op2_u32 = 0x00020004;
470 res_u32 = __USAX(op1_u32, op2_u32);
471 ASSERT_TRUE(res_u32 == 0x7FFF8009);
473 /* --- __UHADD16 Test ---------------------------------------------- */
474 op1_u32 = 0x00010002;
475 op2_u32 = 0x00020004;
476 res_u32 = __UHADD16(op1_u32, op2_u32);
477 ASSERT_TRUE(res_u32 == 0x00010003);
479 /* --- __UHSUB16 Test ---------------------------------------------- */
480 op1_u32 = 0x00030006;
481 op2_u32 = 0x00020004;
482 res_u32 = __UHSUB16(op1_u32, op2_u32);
483 ASSERT_TRUE(res_u32 == 0x00000001);
485 /* --- __UHASX Test ---------------------------------------------- */
486 op1_u32 = 0x80078003;
487 op2_u32 = 0x00040002;
488 res_u32 = __UHASX(op1_u32, op2_u32);
489 ASSERT_TRUE(res_u32 == 0x40043FFF);
491 /* --- __UHSAX Test ---------------------------------------------- */
492 op1_u32 = 0x80038007;
493 op2_u32 = 0x00020004;
494 res_u32 = __UHSAX(op1_u32, op2_u32);
495 ASSERT_TRUE(res_u32 == 0x3FFF4004);
497 /* --- __UQADD16 Test ---------------------------------------------- */
498 op1_u32 = 0xFFFE0002;
499 op2_u32 = 0x00020004;
500 res_u32 = __UQADD16(op1_u32, op2_u32);
501 ASSERT_TRUE(res_u32 == 0xFFFF0006);
503 /* --- __UQSUB16 Test ---------------------------------------------- */
504 op1_u32 = 0x00020006;
505 op2_u32 = 0x00030004;
506 res_u32 = __UQSUB16(op1_u32, op2_u32);
507 ASSERT_TRUE(res_u32 == 0x00000002);
509 /* --- __UQASX Test ---------------------------------------------- */
510 op1_u32 = 0xFFF80003;
511 op2_u32 = 0x00040009;
512 res_u32 = __UQASX(op1_u32, op2_u32);
513 ASSERT_TRUE(res_u32 == 0xFFFF0000);
515 /* --- __UQSAX Test ---------------------------------------------- */
516 op1_u32 = 0x0003FFF8;
517 op2_u32 = 0x00090004;
518 res_u32 = __UQSAX(op1_u32, op2_u32);
519 ASSERT_TRUE(res_u32 == 0x0000FFFF);
524 \brief Test case: TC_CoreSimd_ParMul16
526 - Check Parallel 16-bit multiplication:
540 void TC_CoreSimd_ParMul16 (void) {
541 #if ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
542 (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)) )
543 volatile int32_t op1_s32, op2_s32, op3_s32;
544 volatile int32_t res_s32;
546 volatile int64_t op1_s64;
547 volatile int64_t res_s64;
549 /* --- __SMLAD Test ---------------------------------------------- */
550 op1_s32 = 0x00030002;
551 op2_s32 = 0x00050004;
552 op3_s32 = 0x20000000;
553 res_s32 = __SMLAD(op1_s32, op2_s32, op3_s32);
554 ASSERT_TRUE(res_s32 == 0x20000017);
556 /* --- __SMLADX Test ---------------------------------------------- */
557 op1_s32 = 0x00030002;
558 op2_s32 = 0x00050004;
559 op3_s32 = 0x00000800;
560 res_s32 = __SMLADX(op1_s32, op2_s32, op3_s32);
561 ASSERT_TRUE(res_s32 == 0x00000816);
563 /* --- __SMLALD Test ---------------------------------------------- */
564 op1_s32 = 0x00030002;
565 op2_s32 = 0x00050004;
566 op1_s64 = 0x00000000200000000LL;
567 res_s64 = __SMLALD(op1_s32, op2_s32, op1_s64);
568 ASSERT_TRUE(res_s64 == 0x0000000200000017LL);
570 /* --- __SMLALDX Test ---------------------------------------------- */
571 op1_s32 = 0x00030002;
572 op2_s32 = 0x00050004;
573 op1_s64 = 0x00000000200000000LL;
574 res_s64 = __SMLALDX(op1_s32, op2_s32, op1_s64);
575 ASSERT_TRUE(res_s64 == 0x0000000200000016LL);
577 /* --- __SMLSD Test ---------------------------------------------- */
578 op1_s32 = 0x00030006;
579 op2_s32 = 0x00050004;
580 op3_s32 = 0x00000800;
581 res_s32 = __SMLSD(op1_s32, op2_s32, op3_s32);
582 ASSERT_TRUE(res_s32 == 0x00000809);
584 /* --- __SMLSDX Test ---------------------------------------------- */
585 op1_s32 = 0x00030002;
586 op2_s32 = 0x00050004;
587 op3_s32 = 0x00000800;
588 res_s32 = __SMLSDX(op1_s32, op2_s32, op3_s32);
589 ASSERT_TRUE(res_s32 == 0x000007FE);
591 /* --- __SMLSLD Test ---------------------------------------------- */
592 op1_s32 = 0x00030006;
593 op2_s32 = 0x00050004;
594 op1_s64 = 0x00000000200000000LL;
595 res_s64 = __SMLSLD(op1_s32, op2_s32, op1_s64);
596 ASSERT_TRUE(res_s64 == 0x0000000200000009LL);
598 /* --- __SMLSLDX Test ---------------------------------------------- */
599 op1_s32 = 0x00030006;
600 op2_s32 = 0x00050004;
601 op1_s64 = 0x00000000200000000LL;
602 res_s64 = __SMLSLDX(op1_s32, op2_s32, op1_s64);
603 ASSERT_TRUE(res_s64 == 0x0000000200000012LL);
605 /* --- __SMUAD Test ---------------------------------------------- */
606 op1_s32 = 0x00030001;
607 op2_s32 = 0x00040002;
608 res_s32 = __SMUAD(op1_s32,op2_s32);
609 ASSERT_TRUE(res_s32 == 0x0000000E);
611 op1_s32 = (int32_t)0xFFFDFFFF;
612 op2_s32 = (int32_t)0x00040002;
613 res_s32 = __SMUAD(op1_s32,op2_s32);
614 ASSERT_TRUE(res_s32 == (int32_t)0xFFFFFFF2);
616 /* --- __SMUADX Test ---------------------------------------------- */
617 op1_s32 = 0x00030001;
618 op2_s32 = 0x00040002;
619 res_s32 = __SMUADX(op1_s32,op2_s32);
620 ASSERT_TRUE(res_s32 == 0x0000000A);
622 op1_s32 = (int32_t)0xFFFDFFFF;
623 op2_s32 = (int32_t)0x00040002;
624 res_s32 = __SMUADX(op1_s32,op2_s32);
625 ASSERT_TRUE(res_s32 == (int32_t)0xFFFFFFF6);
627 /* --- __SMUSD Test ---------------------------------------------- */
628 op1_s32 = (int32_t)0x00030001;
629 op2_s32 = (int32_t)0x00040002;
630 res_s32 = __SMUSD(op1_s32,op2_s32);
631 ASSERT_TRUE(res_s32 == (int32_t)0xFFFFFFF6);
633 op1_s32 = (int32_t)0xFFFDFFFF;
634 op2_s32 = (int32_t)0x00040002;
635 res_s32 = __SMUSD(op1_s32,op2_s32);
636 ASSERT_TRUE(res_s32 == 0x0000000A);
638 /* --- __SMUSDX Test ---------------------------------------------- */
639 op1_s32 = 0x00030001;
640 op2_s32 = 0x00040002;
641 res_s32 = __SMUSDX(op1_s32,op2_s32);
642 ASSERT_TRUE(res_s32 == (int32_t)0xFFFFFFFE);
644 op1_s32 = (int32_t)0xFFFDFFFF;
645 op2_s32 = (int32_t)0x00040002;
646 res_s32 = __SMUSDX(op1_s32,op2_s32);
647 ASSERT_TRUE(res_s32 == (int32_t)0x00000002);
652 \brief Test case: TC_CoreSimd_Part9
654 - Check Packing Halfword:
658 void TC_CoreSimd_Pack16 (void) {
659 #if ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
660 (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)) )
661 volatile uint32_t op1_u32, op2_u32;
662 volatile uint32_t res_u32;
664 /* --- __PKHBT Test ---------------------------------------------- */
665 op1_u32 = 0x00000111;
666 op2_u32 = 0x22200000;
667 res_u32 = __PKHBT(op1_u32, op2_u32, 0);
668 ASSERT_TRUE(res_u32 == 0x22200111);
670 op1_u32 = 0x00000111;
671 op2_u32 = 0x22200000;
672 res_u32 = __PKHBT(op1_u32, op2_u32, 4);
673 ASSERT_TRUE(res_u32 == 0x22000111);
675 /* --- __PKHTB Test ---------------------------------------------- */
676 op1_u32 = 0x11100000;
677 op2_u32 = 0x00000222;
678 res_u32 = __PKHTB(op1_u32, op2_u32, 0);
679 ASSERT_TRUE(res_u32 == 0x11100222);
681 op1_u32 = 0x11100000;
682 op2_u32 = 0x00000222;
683 res_u32 = __PKHTB(op1_u32, op2_u32, 4);
684 ASSERT_TRUE(res_u32 == 0x11100022);
689 \brief Test case: TC_CoreSimd_MulAcc32
691 - Check Signed Most Significant Word Multiply Accumulate:
694 void TC_CoreSimd_MulAcc32 (void) {
695 #if ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
696 (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)) )
697 volatile int32_t op1_s32, op2_s32, op3_s32;
698 volatile int32_t res_s32;
700 /* --- __SMMLA Test ---------------------------------------------- */
701 op1_s32 = 0x00000200;
702 op2_s32 = 0x00000004;
703 op3_s32 = 0x00000100;
704 res_s32 = __SMMLA(op1_s32, op2_s32, op3_s32);
705 ASSERT_TRUE(res_s32 == 0x00000100);
707 op1_s32 = 0x40000000;
708 op2_s32 = 0x00000010;
709 op3_s32 = 0x00000300;
710 res_s32 = __SMMLA(op1_s32, op2_s32, op3_s32);
711 ASSERT_TRUE(res_s32 == 0x00000304);