debug.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /******************************************************************************
  2. * @file basic_math_functions.h
  3. * @brief Public header file for NMSIS DSP Library
  4. * @version V1.10.0
  5. * @date 08 July 2021
  6. * Target Processor: RISC-V Cores
  7. ******************************************************************************/
  8. /*
  9. * Copyright (c) 2010-2020 Arm Limited or its affiliates. All rights reserved.
  10. * Copyright (c) 2019 Nuclei Limited. All rights reserved.
  11. *
  12. * SPDX-License-Identifier: Apache-2.0
  13. *
  14. * Licensed under the Apache License, Version 2.0 (the License); you may
  15. * not use this file except in compliance with the License.
  16. * You may obtain a copy of the License at
  17. *
  18. * www.apache.org/licenses/LICENSE-2.0
  19. *
  20. * Unless required by applicable law or agreed to in writing, software
  21. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  22. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  23. * See the License for the specific language governing permissions and
  24. * limitations under the License.
  25. */
  26. #ifndef DEBUG_FUNCTIONS_H_
  27. #define DEBUG_FUNCTIONS_H_
  28. #include "riscv_math_types.h"
  29. #include "riscv_math_memory.h"
  30. #include "dsp/none.h"
  31. #include "dsp/utils.h"
  32. #include "dsp/matrix_functions.h"
  33. #include "dsp/matrix_functions_f16.h"
  34. #ifdef __cplusplus
  35. #include <cstdio>
  36. extern "C"
  37. {
  38. #else
  39. #include <stdio.h>
  40. #endif
  41. #if defined(RISCV_FLOAT16_SUPPORTED)
  42. #define PROW_f16(S,NB) \
  43. { \
  44. printf("{%f",(double)(S)[0]); \
  45. for(unsigned int i=1;i<(NB) ;i++) \
  46. { \
  47. printf(",%f",(double)(S)[i]);\
  48. } \
  49. printf("}"); \
  50. };
  51. #define PV_f16(S,V,NB)\
  52. { \
  53. printf("%s=",(S)); \
  54. PROW_f16((V),(NB)); \
  55. printf(";\n"); \
  56. };
  57. #define PM_f16(S,M) \
  58. { \
  59. printf("%s={",(S)); \
  60. for(unsigned int row=0;row<(M)->numRows;row++) \
  61. { \
  62. if (row != 0) \
  63. { \
  64. printf("\n,"); \
  65. } \
  66. PROW_f16((M)->pData + row * (M)->numCols, (M)->numCols);\
  67. } \
  68. printf("};\n"); \
  69. }
  70. #endif
  71. #define PROW_f32(S,NB) \
  72. { \
  73. printf("{%f",(double)(S)[0]); \
  74. for(unsigned int i=1;i<(NB) ;i++) \
  75. { \
  76. printf(",%f",(double)(S)[i]);\
  77. } \
  78. printf("}"); \
  79. };
  80. #define PV_f32(S,V,NB)\
  81. { \
  82. printf("%s=",(S)); \
  83. PROW_f32((V),(NB)); \
  84. printf(";\n"); \
  85. };
  86. #define PM_f32(S,M) \
  87. { \
  88. printf("%s={",(S)); \
  89. for(unsigned int row=0;row<(M)->numRows;row++) \
  90. { \
  91. if (row != 0) \
  92. { \
  93. printf("\n,"); \
  94. } \
  95. PROW_f32((M)->pData + row * (M)->numCols, (M)->numCols);\
  96. } \
  97. printf("};\n"); \
  98. }
  99. #define PROW_f64(S,NB) \
  100. { \
  101. printf("{%.20g",(double)(S)[0]); \
  102. for(unsigned int i=1;i<(NB) ;i++) \
  103. { \
  104. printf(",%.20g",(double)(S)[i]);\
  105. } \
  106. printf("}"); \
  107. };
  108. #define PV_f64(S,V,NB) \
  109. { \
  110. printf("%s=",(S)); \
  111. PROW_f64((V),(NB));\
  112. printf(";\n"); \
  113. };
  114. #define PM_f64(S,M) \
  115. { \
  116. printf("%s={",(S)); \
  117. for(unsigned int row=0;row<(M)->numRows;row++) \
  118. { \
  119. if (row != 0) \
  120. { \
  121. printf("\n,"); \
  122. } \
  123. PROW_f64((M)->pData + row * (M)->numCols, (M)->numCols);\
  124. } \
  125. printf("};\n"); \
  126. }
  127. #ifdef __cplusplus
  128. }
  129. #endif
  130. #endif /* ifndef _DEBUG_FUNCTIONS_H_ */