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