1 #ifndef _TIMING_H_
2 #define _TIMING_H_
3 
4 #include "RTE_Components.h"
5 #include  CMSIS_device_header
6 
7 #include "Test.h"
8 #include "arm_math_types.h"
9 #include "arm_math_types_f16.h"
10 
11 void initCycleMeasurement();
12 void cycleMeasurementStart();
13 void cycleMeasurementStop();
14 
15 Testing::cycles_t getCycles();
16 
17 #if defined(EXTBENCH)  || defined(CACHEANALYSIS)
18 extern unsigned long sectionCounter;
19 
20 #if   defined ( __CC_ARM )
21     #define dbgInst(imm) __asm volatile{ DBG (imm) }
22 #elif defined ( __GNUC__ ) || defined ( __llvm__ )
23     #define dbgInst(imm) __asm volatile("DBG %0\n\t" : :"Ir" ((imm)) )
24 #else
25     #error "Unsupported compiler"
26 #endif
27 #define startSectionNB(num) dbgInst(((num) & 0x7) | 0x8)
28 #define stopSectionNB(num)  dbgInst(((num) & 0x7) | 0x0)
29 
startSection()30 static inline void startSection() {
31     switch(sectionCounter & 0x7)
32     {
33       case 0:
34         startSectionNB(0);
35       break;
36       case 1:
37         startSectionNB(1);
38       break;
39       case 2:
40         startSectionNB(2);
41       break;
42       case 3:
43         startSectionNB(3);
44       break;
45       case 4:
46         startSectionNB(4);
47       break;
48       case 5:
49         startSectionNB(5);
50       break;
51       case 6:
52         startSectionNB(6);
53       break;
54       case 7:
55         startSectionNB(7);
56       break;
57       default:
58         startSectionNB(0);
59     }
60 }
61 
stopSection()62 static inline void stopSection() {
63     switch(sectionCounter & 0x7)
64      {
65       case 0:
66         stopSectionNB(0);
67       break;
68       case 1:
69         stopSectionNB(1);
70       break;
71       case 2:
72         stopSectionNB(2);
73       break;
74       case 3:
75         stopSectionNB(3);
76       break;
77       case 4:
78         stopSectionNB(4);
79       break;
80       case 5:
81         stopSectionNB(5);
82       break;
83       case 6:
84         stopSectionNB(6);
85       break;
86       case 7:
87         stopSectionNB(7);
88       break;
89       default:
90         stopSectionNB(0);
91      }
92 
93      sectionCounter++;
94 }
95 
96 #endif
97 
98 #endif
99