Timing.h 1.7 KB

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