DSPLIB User Guide
DSPLIB_debugPrintVector.h
Go to the documentation of this file.
1 
2 /******************************************************************************/
6 /* Copyright (C) 2015 Texas Instruments Incorporated - https://www.ti.com/
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the
18  * distribution.
19  *
20  * Neither the name of Texas Instruments Incorporated nor the names of
21  * its contributors may be used to endorse or promote products derived
22  * from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35  *
36  ******************************************************************************/
37 
38 #ifndef COMMON_DSPLIB_UTIL_DEBUGPRINTVECTOR_H_
39 #define COMMON_DSPLIB_UTIL_DEBUGPRINTFECTOR_H_ 1
40 
41 /*******************************************************************************
42  *
43  * INCLUDES
44  *
45  ******************************************************************************/
46 
47 #include "../DSPLIB_types.h"
48 
49 //----------------------------------------------------------------------------------
50 #ifdef __cplusplus
51 #include <c7x_scalable.h> // for device scalability
52 
53 #pragma FUNC_ALWAYS_INLINE
54 static inline void DSPLIB_debugPrintVector(c7x::uchar_vec vector)
55 {
56 #if DSPLIB_DEBUGPRINT
57  for (uint i = 0; i < c7x::element_count_of<c7x::uchar_vec>::value; i++) {
58  DSPLIB_PRINTF("%04u", *((uchar *) (&vector) + i));
59  }
60 
61  DSPLIB_PRINTF("%s", "\n");
62 #endif
63 }
64 
65 #pragma FUNC_ALWAYS_INLINE
66 static inline void DSPLIB_debugPrintVector(c7x::char_vec vector)
67 {
68 #if DSPLIB_DEBUGPRINT
69  for (uint i = 0; i < c7x::element_count_of<c7x::char_vec>::value; i++) {
70  DSPLIB_PRINTF("%04d", *((int8_t *) (&vector) + i));
71  }
72 
73  DSPLIB_PRINTF("%s", "\n");
74 #endif
75 }
76 
77 #pragma FUNC_ALWAYS_INLINE
78 static inline void DSPLIB_debugPrintVector(c7x::ushort_vec vector)
79 {
80 #if DSPLIB_DEBUGPRINT
81  for (uint i = 0; i < c7x::element_count_of<c7x::ushort_vec>::value; i++) {
82  DSPLIB_PRINTF("%05u", *((ushort *) (&vector) + i));
83  }
84 
85  DSPLIB_PRINTF("%s", "\n");
86 #endif
87 }
88 
89 #pragma FUNC_ALWAYS_INLINE
90 static inline void DSPLIB_debugPrintVector(c7x::short_vec vector)
91 {
92 #if DSPLIB_DEBUGPRINT
93  for (uint i = 0; i < c7x::element_count_of<c7x::short_vec>::value; i++) {
94  DSPLIB_PRINTF("%05d", *((short *) (&vector) + i));
95  }
96 
97  DSPLIB_PRINTF("%s", "\n");
98 #endif
99 }
100 
101 #pragma FUNC_ALWAYS_INLINE
102 static inline void DSPLIB_debugPrintVector(c7x::uint_vec vector)
103 {
104 #if DSPLIB_DEBUGPRINT
105  for (uint i = 0; i < c7x::element_count_of<c7x::uint_vec>::value; i++) {
106  DSPLIB_PRINTF("%010u", *((uint *) (&vector) + i));
107  }
108 
109  DSPLIB_PRINTF("%s", "\n");
110 #endif
111 }
112 
113 #pragma FUNC_ALWAYS_INLINE
114 static inline void DSPLIB_debugPrintVector(c7x::float_vec vector)
115 {
116 #if DSPLIB_DEBUGPRINT
117  for (uint i = 0; i < c7x::element_count_of<c7x::float_vec>::value; i++) {
118  DSPLIB_PRINTF("%f ", *((float *) (&vector) + i));
119  }
120 
121  DSPLIB_PRINTF("%s", "\n");
122 #endif
123 }
124 
125 #pragma FUNC_ALWAYS_INLINE
126 static inline void DSPLIB_debugPrintVector(c7x::double_vec vector)
127 {
128 #if MATHLIB_DEBUGPRINT
129  for (uint i = 0; i < c7x::element_count_of<c7x::double_vec>::value; i++) {
130  MATHLIB_PRINTF("%lf", *((double *) (&vector) + i));
131  }
132 
133  MATHLIB_PRINTF("%s", "\n");
134 #endif
135 }
136 #pragma FUNC_ALWAYS_INLINE
137 static inline void DSPLIB_debugPrintVector(c7x::int_vec vector)
138 {
139 #if DSPLIB_DEBUGPRINT
140  for (uint i = 0; i < c7x::element_count_of<c7x::int_vec>::value; i++) {
141  DSPLIB_PRINTF("%010d", *((int *) (&vector) + i));
142  }
143 
144  DSPLIB_PRINTF("%s", "\n");
145 #endif
146 }
147 
148 #pragma FUNC_ALWAYS_INLINE
149 static inline void DSPLIB_debugPrintVectorInHex(c7x::long_vec vector)
150 {
151 #if DSPLIB_DEBUGPRINT
152  for (uint i = 0; i < c7x::element_count_of<c7x::long_vec>::value; i++) {
153  DSPLIB_PRINTF("%016lx", *((long *) (&vector) + i));
154  }
155 
156  DSPLIB_PRINTF("%s", "\n");
157 #endif
158 }
159 
160 #pragma FUNC_ALWAYS_INLINE
161 static inline void DSPLIB_debugPrintNonScalableVectorInHex(long8 vector)
162 {
163 #if DSPLIB_DEBUGPRINT
164  DSPLIB_PRINTF("%010lx ", vector.s[7]);
165  DSPLIB_PRINTF("%010lx ", vector.s[6]);
166  DSPLIB_PRINTF("%010lx ", vector.s[5]);
167  DSPLIB_PRINTF("%010lx ", vector.s[4]);
168  DSPLIB_PRINTF("%010lx ", vector.s[3]);
169  DSPLIB_PRINTF("%010lx ", vector.s[2]);
170  DSPLIB_PRINTF("%010lx ", vector.s[1]);
171  DSPLIB_PRINTF("%010lx ", vector.s[0]);
172 
173  DSPLIB_PRINTF("%s", "\n");
174 #endif
175  return;
176 }
177 
178 #endif //#ifdef __cplusplus
179 #endif /* COMMON_DSPLIB_UTIL_DEBUGPRINTVECTOR_H_ */
#define DSPLIB_PRINTF(fmt,...)
Definition: DSPLIB_types.h:84