]> begriffs open source - cmsis/blob - CMSIS/CoreValidation/Source/CV_CoreSimd.c
Added SIMD tests for Cortex-M devices.
[cmsis] / CMSIS / CoreValidation / Source / CV_CoreSimd.c
1 /*-----------------------------------------------------------------------------
2  *      Name:         CV_CoreSimd.c
3  *      Purpose:      CMSIS CORE validation tests implementation
4  *-----------------------------------------------------------------------------
5  *      Copyright (c) 2018 Arm Limited. All rights reserved.
6  *----------------------------------------------------------------------------*/
7
8 #include "CV_Framework.h"
9 #include "cmsis_cv.h"
10
11 /*-----------------------------------------------------------------------------
12  *      Test implementation
13  *----------------------------------------------------------------------------*/
14
15 /*-----------------------------------------------------------------------------
16  *      Test cases
17  *----------------------------------------------------------------------------*/
18
19 /**
20 \brief Test case: TC_CoreSimd_SatAddSub
21 \details
22 - Check Saturating addition and subtraction:
23   __QADD
24   __QSUB
25 */
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;
31
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);
37
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);
42
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);
48
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);
53 #endif
54 }
55
56 /**
57 \brief Test case: TC_CoreSimd_ParSat16
58 \details
59 - Check Parallel 16-bit saturation:
60   __SSAT16
61   __USAT16
62 */
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;
68
69   /* --- __SSAT16 Test ---------------------------------------------- */
70   op1_s32 = (int32_t)0x80030168;
71   res_s32 = __SSAT16(op1_s32, 8);
72   ASSERT_TRUE(res_s32 == (int32_t)0xFF80007F);
73
74   /* --- __USAT16 Test ---------------------------------------------- */
75   op1_s32 = 0x0030168;
76   res_s32 = __USAT16(op1_s32, 8);
77   ASSERT_TRUE(res_s32 == 0x000300FF);
78 #endif
79 }
80
81 /**
82 \brief Test case: TC_CoreSimd_PackUnpack
83 \details
84 - Check Packing and unpacking:
85   __SXTB16
86   __SXTAB16
87   __UXTB16
88   __UXTAB16
89 */
90 void TC_CoreSimd_PackUnpack (void) {
91 #if ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__  == 1)) || \
92      (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1))     )
93   volatile int32_t op1_s32, op2_s32;
94   volatile int32_t res_s32;
95
96   /* --- __SXTB16 Test ---------------------------------------------- */
97   op1_s32 = (int32_t)0x80830168;
98   res_s32 = __SXTB16(op1_s32);
99   ASSERT_TRUE(res_s32 == (int32_t)0xFF830068);
100
101   /* --- __SXTAB16 Test ---------------------------------------------- */
102   op1_s32 = (int32_t)0x000D0008;
103   op2_s32 = (int32_t)0x80830168;
104   res_s32 = __SXTAB16(op1_s32, op2_s32);
105   ASSERT_TRUE(res_s32 == (int32_t)0xFF900070);
106
107   /* --- __UXTB16 Test ---------------------------------------------- */
108   op1_s32 = (int32_t)0x80830168;
109   res_s32 = __UXTB16(op1_s32);
110   ASSERT_TRUE(res_s32 == 0x00830068);
111
112   /* --- __UXTAB16 Test ---------------------------------------------- */
113   op1_s32 =          0x000D0008;
114   op2_s32 = (int32_t)0x80830168;
115   res_s32 = __UXTAB16(op1_s32, op2_s32);
116   ASSERT_TRUE(res_s32 == 0x00900070);
117 #endif
118 }
119
120 /**
121 \brief Test case: TC_CoreSimd_ParSel
122 \details
123 - Check Parallel selection:
124   __SEL
125 */
126 void TC_CoreSimd_ParSel (void) {
127 #if ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__  == 1)) || \
128      (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1))     )
129   volatile uint32_t res_u32;
130
131   volatile int32_t op1_s32, op2_s32;
132   volatile int32_t res_s32;
133
134   APSR_Type  apsr;
135   xPSR_Type  xpsr;
136
137   /* --- __SEL Test ---------------------------------------------- */
138   op1_s32 = 0x33221100;
139   op2_s32 = 0x77665544;
140
141   res_s32 = __SADD8(0x80808080, 0x00000000);            /* __sadd8   sets APSR.GE = 0x00 */
142   res_u32 = __get_APSR();
143   apsr.w = __get_APSR();
144   ASSERT_TRUE( (res_u32 == apsr.w) );
145   xpsr.w = __get_xPSR();
146   ASSERT_TRUE( (((res_u32 >> 16) & 0x0F) == xpsr.b.GE)  );
147   res_s32 = __SEL(op1_s32, op2_s32);                      /* __sel          APSR.GE = 0x00 */
148   ASSERT_TRUE( res_s32 == 0x77665544);
149
150   res_s32 = __SADD8(0x80808000, 0x00000000);            /* __sadd8   sets APSR.GE = 0x01 */
151   res_u32 = __get_APSR();
152   apsr.w = __get_APSR();
153   ASSERT_TRUE( (res_u32 == apsr.w)  );
154   xpsr.w = __get_xPSR();
155   ASSERT_TRUE( (((res_u32 >> 16) & 0x0F) == xpsr.b.GE)  );
156   res_s32 = __SEL(op1_s32, op2_s32);                      /* __sel          APSR.GE = 0x01 */
157   ASSERT_TRUE(res_s32 == 0x77665500);
158
159   res_s32 = __SADD8(0x80800080, 0x00000000);            /* __sadd8   sets APSR.GE = 0x02 */
160   res_u32 = __get_APSR();
161   apsr.w = __get_APSR();
162   ASSERT_TRUE( (res_u32 == apsr.w) );
163   xpsr.w = __get_xPSR();
164   ASSERT_TRUE( (((res_u32 >> 16) & 0x0F) == xpsr.b.GE)  );
165   res_s32 = __SEL(op1_s32, op2_s32);                      /* __sel          APSR.GE = 0x02 */
166   ASSERT_TRUE(res_s32 == 0x77661144);
167 #endif
168 }
169
170 /**
171 \brief Test case: TC_CoreSimd_ParAddSub8
172 \details
173 - Check Parallel 8-bit addition and subtraction:
174   __SADD8                                   S  Signed
175   __SSUB8                                   Q  Signed Saturating
176   __SHADD8                                  SH Signed Halving
177   __SHSUB8                                  U  Unsigned
178   __QADD8                                   UQ Unsigned Saturating
179   __QSUB8                                   UH Unsigned Halving
180   __UADD8
181   __USUB8
182   __UHADD8
183   __UHSUB8
184   __UQADD8
185   __UQSUB8
186 */
187 void TC_CoreSimd_ParAddSub8 (void) {
188 #if ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__  == 1)) || \
189      (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1))     )
190   volatile uint32_t op1_u32, op2_u32;
191   volatile uint32_t res_u32;
192
193   volatile int32_t op1_s32, op2_s32;
194   volatile int32_t res_s32;
195
196   /* --- __SADD8 Test ---------------------------------------------- */
197   op1_s32 = (int32_t)0x87858381;
198   op2_s32 = (int32_t)0x08060402;
199   res_s32 = __SADD8(op1_s32, op2_s32);
200   ASSERT_TRUE(res_s32 == (int32_t)0x8F8B8783);
201
202   /* --- __SSUB8 Test ---------------------------------------------- */
203   op1_s32 = (int32_t)0x8F8B8783;
204   op2_s32 = (int32_t)0x08060402;
205   res_s32 = __SSUB8(op1_s32, op2_s32);
206   ASSERT_TRUE(res_s32 == (int32_t)0x87858381);
207
208   /* --- __SHADD8 Test ---------------------------------------------- */
209   op1_s32 = 0x07050302;
210   op2_s32 = 0x08060402;
211   res_s32 = __SHADD8(op1_s32, op2_s32);
212   ASSERT_TRUE(res_s32 == 0x07050302);
213
214   /* --- __SHSUB8 Test ---------------------------------------------- */
215   op1_s32 = (int32_t)0x8F8B8783;
216   op2_s32 = 0x08060402;
217   res_s32 = __SHSUB8(op1_s32, op2_s32);
218   ASSERT_TRUE(res_s32 == (int32_t)0xC3C2C1C0);
219
220   /* --- __QADD8 Test ---------------------------------------------- */
221   op1_s32 = (int32_t)0x8085837F;
222   op2_s32 = (int32_t)0xFF060402;
223   res_s32 = __QADD8(op1_s32, op2_s32);
224   ASSERT_TRUE(res_s32 == (int32_t)0x808B877F);
225
226   /* --- __QSUB8 Test ---------------------------------------------- */
227   op1_s32 = (int32_t)0x808B8783;
228   op2_s32 = (int32_t)0x08060402;
229   res_s32 = __QSUB8(op1_s32, op2_s32);
230   ASSERT_TRUE(res_s32 == (int32_t)0x80858381);
231
232   /* --- __UADD8 Test ---------------------------------------------- */
233   op1_u32 = 0x07050301;
234   op2_u32 = 0x08060402;
235   res_u32 = __UADD8(op1_u32, op2_u32);
236   ASSERT_TRUE(res_u32 == 0x0F0B0703);
237
238   /* --- __USUB8 Test ---------------------------------------------- */
239   op1_u32 = 0x0F0B0703;
240   op2_u32 = 0x08060402;
241   res_u32 = __USUB8(op1_u32, op2_u32);
242   ASSERT_TRUE(res_u32 == 0x07050301);
243
244   /* --- __UHADD8 Test ---------------------------------------------- */
245   op1_u32 = 0x07050302;
246   op2_u32 = 0x08060402;
247   res_u32 = __UHADD8(op1_u32, op2_u32);
248   ASSERT_TRUE(res_u32 == 0x07050302);
249
250   /* --- __UHSUB8 Test ---------------------------------------------- */
251   op1_u32 = 0x0F0B0703;
252   op2_u32 = 0x08060402;
253   res_u32 = __UHSUB8(op1_u32, op2_u32);
254   ASSERT_TRUE(res_u32 == 0x03020100);
255
256   /* --- __UQADD8 Test ---------------------------------------------- */
257   op1_u32 = 0xFF050301;
258   op2_u32 = 0x08060402;
259   res_u32 = __UQADD8(op1_u32, op2_u32);
260   ASSERT_TRUE(res_u32 == 0xFF0B0703);
261
262   /* --- __UQSUB8 Test ---------------------------------------------- */
263   op1_u32 = 0x080B0702;
264   op2_u32 = 0x0F060408;
265   res_u32 = __UQSUB8(op1_u32, op2_u32);
266   ASSERT_TRUE(res_u32 == 0x00050300);
267 #endif
268 }
269
270 /**
271 \brief Test case: TC_CoreSimd_AbsDif8
272 \details
273 - Check Sum of 8-bit absolute differences:
274   __USAD8
275   __USADA8
276 */
277 void TC_CoreSimd_AbsDif8 (void) {
278 #if ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__  == 1)) || \
279      (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1))     )
280   volatile uint32_t op1_u32, op2_u32, op3_u32;
281   volatile uint32_t res_u32;
282
283   /* --- __USAD8 Test ---------------------------------------------- */
284   op1_u32 = 0x87858381;
285   op2_u32 = 0x08060402;
286   res_u32 = __USAD8(op1_u32, op2_u32);
287   ASSERT_TRUE(res_u32 == 0x000001FC);
288
289   /* --- __USADA8 Test ---------------------------------------------- */
290   op1_u32 = 0x87858381;
291   op2_u32 = 0x08060402;
292   op3_u32 = 0x00008000;
293   res_u32 = __USADA8(op1_u32, op2_u32, op3_u32);
294   ASSERT_TRUE(res_u32 == 0x000081FC);
295 #endif
296 }
297
298 /**
299 \brief Test case: TC_CoreSimd_ParAddSub16
300 \details
301 - Check Parallel 16-bit addition and subtraction:
302   __SADD16
303   __SSUB16
304   __SASX
305   __SSAX
306   __SHADD16
307   __SHSUB16
308   __SHASX
309   __SHSAX
310   __QADD16
311   __QSUB16
312   __QASX
313   __QSAX
314   __UADD16
315   __USUB16
316   __UASX
317   __USAX
318   __UHADD16
319   __UHSUB16
320   __UHASX
321   __UHSAX
322   __UQSUB16
323   __UQADD16
324   __UQASX
325   __UQSAX
326 */
327 void TC_CoreSimd_ParAddSub16 (void) {
328 #if ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__  == 1)) || \
329      (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1))     )
330   volatile uint32_t op1_u32, op2_u32;
331   volatile uint32_t res_u32;
332
333   volatile int32_t op1_s32, op2_s32;
334   volatile int32_t res_s32;
335
336   /* --- __SADD16 Test ---------------------------------------------- */
337   op1_s32 = (int32_t)0x80038001;
338   op2_s32 = (int32_t)0x00040002;
339   res_s32 = __SADD16(op1_s32, op2_s32);
340   ASSERT_TRUE(res_s32 == (int32_t)0x80078003);
341
342   /* --- __SSUB16 Test ---------------------------------------------- */
343   op1_s32 = (int32_t)0x80078003;
344   op2_s32 = (int32_t)0x00040002;
345   res_s32 = __SSUB16(op1_s32, op2_s32);
346   ASSERT_TRUE(res_s32 == (int32_t)0x80038001);
347
348   /* --- __SASX Test ---------------------------------------------- */
349   op1_s32 = (int32_t)0x80078003;
350   op2_s32 = (int32_t)0x00040002;
351   res_s32 = __SASX(op1_s32, op2_s32);
352   ASSERT_TRUE(res_s32 == (int32_t)0x80097FFF);
353
354   /* --- __SSAX Test ---------------------------------------------- */
355   op1_s32 = (int32_t)0x80038007;
356   op2_s32 = (int32_t)0x00020004;
357   res_s32 = __SSAX(op1_s32, op2_s32);
358   ASSERT_TRUE(res_s32 == (int32_t)0x7FFF8009);
359
360   /* --- __SHADD16 Test ---------------------------------------------- */
361   op1_s32 = (int32_t)0x80038001;
362   op2_s32 = (int32_t)0x00040002;
363   res_s32 = __SHADD16(op1_s32, op2_s32);
364   ASSERT_TRUE(res_s32 == (int32_t)0xC003C001);
365
366   /* --- __SHSUB16 Test ---------------------------------------------- */
367   op1_s32 = (int32_t)0x80078003;
368   op2_s32 = (int32_t)0x00040002;
369   res_s32 = __SHSUB16(op1_s32, op2_s32);
370   ASSERT_TRUE(res_s32 == (int32_t)0xC001C000);
371
372   /* --- __SHASX Test ---------------------------------------------- */
373   op1_s32 = (int32_t)0x80078003;
374   op2_s32 = (int32_t)0x00040002;
375   res_s32 = __SHASX(op1_s32, op2_s32);
376   ASSERT_TRUE(res_s32 == (int32_t)0xC004BFFF);
377
378   /* --- __SHSAX Test ---------------------------------------------- */
379   op1_s32 = (int32_t)0x80038007;
380   op2_s32 = (int32_t)0x00020004;
381   res_s32 = __SHSAX(op1_s32, op2_s32);
382   ASSERT_TRUE(res_s32 == (int32_t)0xBFFFC004);
383
384   /* --- __QADD16 Test ---------------------------------------------- */
385   op1_s32 = (int32_t)0x80038000;
386   op2_s32 = (int32_t)0x00048002;
387   res_s32 = __QADD16(op1_s32, op2_s32);
388   ASSERT_TRUE(res_s32 == (int32_t)0x80078000);
389
390   /* --- __QSUB16 Test ---------------------------------------------- */
391   op1_s32 = (int32_t)0x80038003;
392   op2_s32 = (int32_t)0x00040002;
393   res_s32 = __QSUB16(op1_s32, op2_s32);
394   ASSERT_TRUE(res_s32 == (int32_t)0x80008001);
395
396   /* --- __QASX Test ---------------------------------------------- */
397   op1_s32 = (int32_t)0x80078003;
398   op2_s32 = (int32_t)0x00040002;
399   res_s32 = __QASX(op1_s32, op2_s32);
400   ASSERT_TRUE(res_s32 == (int32_t)0x80098000);
401
402   /* --- __QSAX Test ---------------------------------------------- */
403   op1_s32 = (int32_t)0x80038007;
404   op2_s32 = (int32_t)0x00020004;
405   res_s32 = __QSAX(op1_s32, op2_s32);
406   ASSERT_TRUE(res_s32 == (int32_t)0x80008009);
407
408   /* --- __UADD16 Test ---------------------------------------------- */
409   op1_u32 = 0x00010002;
410   op2_u32 = 0x00020004;
411   res_u32 = __UADD16(op1_u32, op2_u32);
412   ASSERT_TRUE(res_u32 == 0x00030006);
413
414   /* --- __USUB16 Test ---------------------------------------------- */
415   op1_u32 = 0x00030006;
416   op2_u32 = 0x00020004;
417   res_u32 = __USUB16(op1_u32, op2_u32);
418   ASSERT_TRUE(res_u32 == 0x00010002);
419
420   /* --- __UASX Test ---------------------------------------------- */
421   op1_u32 = 0x80078003;
422   op2_u32 = 0x00040002;
423   res_u32 = __UASX(op1_u32, op2_u32);
424   ASSERT_TRUE(res_u32 == 0x80097FFF);
425
426   /* --- __USAX Test ---------------------------------------------- */
427   op1_u32 = 0x80038007;
428   op2_u32 = 0x00020004;
429   res_u32 = __USAX(op1_u32, op2_u32);
430   ASSERT_TRUE(res_u32 == 0x7FFF8009);
431
432   /* --- __UHADD16 Test ---------------------------------------------- */
433   op1_u32 = 0x00010002;
434   op2_u32 = 0x00020004;
435   res_u32 = __UHADD16(op1_u32, op2_u32);
436   ASSERT_TRUE(res_u32 == 0x00010003);
437
438   /* --- __UHSUB16 Test ---------------------------------------------- */
439   op1_u32 = 0x00030006;
440   op2_u32 = 0x00020004;
441   res_u32 = __UHSUB16(op1_u32, op2_u32);
442   ASSERT_TRUE(res_u32 == 0x00000001);
443
444   /* --- __UHASX Test ---------------------------------------------- */
445   op1_u32 = 0x80078003;
446   op2_u32 = 0x00040002;
447   res_u32 = __UHASX(op1_u32, op2_u32);
448   ASSERT_TRUE(res_u32 == 0x40043FFF);
449
450   /* --- __UHSAX Test ---------------------------------------------- */
451   op1_u32 = 0x80038007;
452   op2_u32 = 0x00020004;
453   res_u32 = __UHSAX(op1_u32, op2_u32);
454   ASSERT_TRUE(res_u32 == 0x3FFF4004);
455
456   /* --- __UQADD16 Test ---------------------------------------------- */
457   op1_u32 = 0xFFFE0002;
458   op2_u32 = 0x00020004;
459   res_u32 = __UQADD16(op1_u32, op2_u32);
460   ASSERT_TRUE(res_u32 == 0xFFFF0006);
461
462   /* --- __UQSUB16 Test ---------------------------------------------- */
463   op1_u32 = 0x00020006;
464   op2_u32 = 0x00030004;
465   res_u32 = __UQSUB16(op1_u32, op2_u32);
466   ASSERT_TRUE(res_u32 == 0x00000002);
467
468   /* --- __UQASX Test ---------------------------------------------- */
469   op1_u32 = 0xFFF80003;
470   op2_u32 = 0x00040009;
471   res_u32 = __UQASX(op1_u32, op2_u32);
472   ASSERT_TRUE(res_u32 == 0xFFFF0000);
473
474   /* --- __UQSAX Test ---------------------------------------------- */
475   op1_u32 = 0x0003FFF8;
476   op2_u32 = 0x00090004;
477   res_u32 = __UQSAX(op1_u32, op2_u32);
478   ASSERT_TRUE(res_u32 == 0x0000FFFF);
479 #endif
480 }
481
482 /**
483 \brief Test case: TC_CoreSimd_ParMul16
484 \details
485 - Check Parallel 16-bit multiplication:
486   __SMLAD
487   __SMLADX
488   __SMLALD
489   __SMLALDX
490   __SMLSD
491   __SMLSDX
492   __SMLSLD
493   __SMLSLDX
494   __SMUAD
495   __SMUADX
496   __SMUSD
497   __SMUSDX
498 */
499 void TC_CoreSimd_ParMul16 (void) {
500 #if ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__  == 1)) || \
501      (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1))     )
502   volatile int32_t op1_s32, op2_s32, op3_s32;
503   volatile int32_t res_s32;
504
505   volatile int64_t op1_s64;
506   volatile int64_t res_s64;
507
508   /* --- __SMLAD Test ---------------------------------------------- */
509   op1_s32 = 0x00030002;
510   op2_s32 = 0x00050004;
511   op3_s32 = 0x20000000;
512   res_s32 = __SMLAD(op1_s32, op2_s32, op3_s32);
513   ASSERT_TRUE(res_s32 == 0x20000017);
514
515   /* --- __SMLADX Test ---------------------------------------------- */
516   op1_s32 = 0x00030002;
517   op2_s32 = 0x00050004;
518   op3_s32 = 0x00000800;
519   res_s32 = __SMLADX(op1_s32, op2_s32, op3_s32);
520   ASSERT_TRUE(res_s32 == 0x00000816);
521
522   /* --- __SMLALD Test ---------------------------------------------- */
523   op1_s32 = 0x00030002;
524   op2_s32 = 0x00050004;
525   op1_s64 = 0x00000000200000000LL;
526   res_s64 = __SMLALD(op1_s32, op2_s32, op1_s64);
527   ASSERT_TRUE(res_s64 == 0x0000000200000017LL);
528
529   /* --- __SMLALDX Test ---------------------------------------------- */
530   op1_s32 = 0x00030002;
531   op2_s32 = 0x00050004;
532   op1_s64 = 0x00000000200000000LL;
533   res_s64 = __SMLALDX(op1_s32, op2_s32, op1_s64);
534   ASSERT_TRUE(res_s64 == 0x0000000200000016LL);
535
536   /* --- __SMLSD Test ---------------------------------------------- */
537   op1_s32 = 0x00030006;
538   op2_s32 = 0x00050004;
539   op3_s32 = 0x00000800;
540   res_s32 = __SMLSD(op1_s32, op2_s32, op3_s32);
541   ASSERT_TRUE(res_s32 == 0x00000809);
542
543   /* --- __SMLSDX Test ---------------------------------------------- */
544   op1_s32 = 0x00030002;
545   op2_s32 = 0x00050004;
546   op3_s32 = 0x00000800;
547   res_s32 = __SMLSDX(op1_s32, op2_s32, op3_s32);
548   ASSERT_TRUE(res_s32 == 0x000007FE);
549
550   /* --- __SMLSLD Test ---------------------------------------------- */
551   op1_s32 = 0x00030006;
552   op2_s32 = 0x00050004;
553   op1_s64 = 0x00000000200000000LL;
554   res_s64 = __SMLSLD(op1_s32, op2_s32, op1_s64);
555   ASSERT_TRUE(res_s64 == 0x0000000200000009LL);
556
557   /* --- __SMLSLDX Test ---------------------------------------------- */
558   op1_s32 = 0x00030006;
559   op2_s32 = 0x00050004;
560   op1_s64 = 0x00000000200000000LL;
561   res_s64 = __SMLSLDX(op1_s32, op2_s32, op1_s64);
562   ASSERT_TRUE(res_s64 == 0x0000000200000012LL);
563
564   /* --- __SMUAD Test ---------------------------------------------- */
565   op1_s32 = 0x00030001;
566   op2_s32 = 0x00040002;
567   res_s32 = __SMUAD(op1_s32,op2_s32);
568   ASSERT_TRUE(res_s32 == 0x0000000E);
569
570   op1_s32 = (int32_t)0xFFFDFFFF;
571   op2_s32 = (int32_t)0x00040002;
572   res_s32 = __SMUAD(op1_s32,op2_s32);
573   ASSERT_TRUE(res_s32 == (int32_t)0xFFFFFFF2);
574
575   /* --- __SMUADX Test ---------------------------------------------- */
576   op1_s32 = 0x00030001;
577   op2_s32 = 0x00040002;
578   res_s32 = __SMUADX(op1_s32,op2_s32);
579   ASSERT_TRUE(res_s32 == 0x0000000A);
580
581   op1_s32 = (int32_t)0xFFFDFFFF;
582   op2_s32 = (int32_t)0x00040002;
583   res_s32 = __SMUADX(op1_s32,op2_s32);
584   ASSERT_TRUE(res_s32 == (int32_t)0xFFFFFFF6);
585
586   /* --- __SMUSD Test ---------------------------------------------- */
587   op1_s32 = (int32_t)0x00030001;
588   op2_s32 = (int32_t)0x00040002;
589   res_s32 = __SMUSD(op1_s32,op2_s32);
590   ASSERT_TRUE(res_s32 == (int32_t)0xFFFFFFF6);
591
592   op1_s32 = (int32_t)0xFFFDFFFF;
593   op2_s32 = (int32_t)0x00040002;
594   res_s32 = __SMUSD(op1_s32,op2_s32);
595   ASSERT_TRUE(res_s32 == 0x0000000A);
596
597   /* --- __SMUSDX Test ---------------------------------------------- */
598   op1_s32 = 0x00030001;
599   op2_s32 = 0x00040002;
600   res_s32 = __SMUSDX(op1_s32,op2_s32);
601   ASSERT_TRUE(res_s32 == (int32_t)0xFFFFFFFE);
602
603   op1_s32 = (int32_t)0xFFFDFFFF;
604   op2_s32 = (int32_t)0x00040002;
605   res_s32 = __SMUSDX(op1_s32,op2_s32);
606   ASSERT_TRUE(res_s32 == (int32_t)0x00000002);
607 #endif
608 }
609
610 /**
611 \brief Test case: TC_CoreSimd_Part9
612 \details
613 - Check Packing Halfword:
614   __PKHBT
615   __PKHTB
616 */
617 void TC_CoreSimd_Pack16 (void) {
618 #if ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__  == 1)) || \
619      (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1))     )
620   volatile uint32_t op1_u32, op2_u32;
621   volatile uint32_t res_u32;
622
623   /* --- __PKHBT Test ---------------------------------------------- */
624   op1_u32 = 0x00000111;
625   op2_u32 = 0x22200000;
626   res_u32 = __PKHBT(op1_u32, op2_u32, 0);
627   ASSERT_TRUE(res_u32 == 0x22200111);
628
629   op1_u32 = 0x00000111;
630   op2_u32 = 0x22200000;
631   res_u32 = __PKHBT(op1_u32, op2_u32, 4);
632   ASSERT_TRUE(res_u32 == 0x22000111);
633
634   /* --- __PKHTB Test ---------------------------------------------- */
635   op1_u32 = 0x11100000;
636   op2_u32 = 0x00000222;
637   res_u32 = __PKHTB(op1_u32, op2_u32, 0);
638   ASSERT_TRUE(res_u32 == 0x11100222);
639
640   op1_u32 = 0x11100000;
641   op2_u32 = 0x00000222;
642   res_u32 = __PKHTB(op1_u32, op2_u32, 4);
643   ASSERT_TRUE(res_u32 == 0x11100022);
644 #endif
645 }
646
647 /**
648 \brief Test case: TC_CoreSimd_MulAcc32
649 \details
650 - Check Signed Most Significant Word Multiply Accumulate:
651   __SMMLA
652 */
653 void TC_CoreSimd_MulAcc32 (void) {
654 #if ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__  == 1)) || \
655      (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1))     )
656   volatile int32_t op1_s32, op2_s32, op3_s32;
657   volatile int32_t res_s32;
658
659   /* --- __SMMLA Test ---------------------------------------------- */
660   op1_s32 = 0x00000200;
661   op2_s32 = 0x00000004;
662   op3_s32 = 0x00000100;
663   res_s32 = __SMMLA((int64_t)op1_s32, (int64_t)op2_s32, op3_s32);
664   ASSERT_TRUE(res_s32 == 0x00000100);
665
666   op1_s32 = 0x40000000;
667   op2_s32 = 0x00000010;
668   op3_s32 = 0x00000300;
669   res_s32 = __SMMLA(op1_s32, op2_s32, op3_s32);
670   ASSERT_TRUE(res_s32 == 0x00000304);
671 #endif
672 }