debug.h 4.9 KB

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