Changeset 97 for trunk/IPs/systemC/processor/Morpheo/Common
- Timestamp:
- Dec 19, 2008, 4:34:00 PM (16 years ago)
- Location:
- trunk/IPs/systemC/processor/Morpheo/Common
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/IPs/systemC/processor/Morpheo/Common/include/Debug.h
r88 r97 9 9 * function to help the debugging : 10 10 * 11 * - debug_tab12 11 * - log_printf 13 12 * - log_begin … … 26 25 27 26 #include "Common/include/Message.h" 27 #include "Common/include/FromString.h" 28 #include "Common/include/ChangeCase.h" 28 29 #include "Behavioural/include/Debug_component.h" 29 30 #include <systemc.h> … … 36 37 namespace morpheo { 37 38 38 enum _debug_verbosity39 typedef enum 39 40 { 40 41 DEBUG_NONE , … … 43 44 DEBUG_FUNC , 44 45 DEBUG_ALL 45 } ;46 47 std::string debug_tab (void);48 void debug_tab_inc (void); 49 void debug_ tab_dec(void);50 46 } debug_verbosity_t; 47 48 extern debug_verbosity_t debug; 49 50 void debug_init (void); 51 void debug_init (debug_verbosity_t level); 51 52 #ifdef DEBUG 53 52 54 # define log_printf(level, component, func, str... ) \ 53 55 do \ 54 56 { \ 55 if ((DEBUG == DEBUG_ALL ) or \ 57 debug_init(); \ 58 \ 59 if ((debug == DEBUG_ALL ) or \ 56 60 (DEBUG_ ## level == DEBUG_NONE) or \ 57 (( DEBUG_ ## level <= DEBUG) and \61 (( DEBUG_ ## level <= debug) and \ 58 62 ( DEBUG_ ## component == true )) ) \ 59 63 { \ … … 67 71 } \ 68 72 \ 69 if (DEBUG >= DEBUG_FUNC) \ 70 { \ 71 msg("%s",debug_tab().c_str()); \ 72 } \ 73 if (DEBUG >= DEBUG_ALL ) \ 73 if (debug >= DEBUG_ALL ) \ 74 74 { \ 75 75 switch (DEBUG_ ## level) \ … … 83 83 } \ 84 84 } \ 85 if ( DEBUG>= DEBUG_FUNC) \85 if (debug >= DEBUG_FUNC) \ 86 86 { \ 87 87 msg( "<%s> " ,func); \ … … 98 98 do \ 99 99 { \ 100 debug_tab_inc (); \101 100 log_printf(FUNC,component,func,_("Begin")); \ 102 101 } while(0) … … 106 105 { \ 107 106 log_printf(FUNC,component,func,_("End")); \ 108 debug_tab_dec (); \109 107 } while(0) 110 108 … … 172 170 #endif 173 171 172 173 template<> inline debug_verbosity_t fromString<debug_verbosity_t> (const std::string& x) 174 { 175 std::string y=x; 176 LowerCase(y); 177 178 if ( (y.compare("0") == 0) or 179 (y.compare("none") == 0)) 180 return DEBUG_NONE ; 181 if ( (y.compare("1") == 0) or 182 (y.compare("info") == 0)) 183 return DEBUG_INFO ; 184 if ( (y.compare("2") == 0) or 185 (y.compare("trace") == 0)) 186 return DEBUG_TRACE; 187 if ( (y.compare("3") == 0) or 188 (y.compare("func") == 0)) 189 return DEBUG_FUNC ; 190 if ( (y.compare("4") == 0) or 191 (y.compare("all") == 0)) 192 return DEBUG_ALL ; 193 194 #ifdef DEBUG 195 return DEBUG; 196 #else 197 return DEBUG_NONE ; 198 #endif 199 } 200 174 201 }; // end namespace morpheo 175 202 #endif // !DEBUG_H -
trunk/IPs/systemC/processor/Morpheo/Common/include/Message.h
r88 r97 41 41 #endif 42 42 43 #ifdef LOG_FILE44 43 extern FILE * log_stream; 45 void log_init (void); 44 FILE * log (FILE * stream); 45 void log_init (bool have_file, 46 std::string directory, 47 std::string file=""); 46 48 47 49 #define fmsg(stream,arg...) \ 48 50 do \ 49 51 { \ 50 log_init();\51 fprintf( log_stream,arg); \52 fflush( log_stream);\52 FILE * _stream = log(stream); \ 53 fprintf(_stream,arg); \ 54 fflush(_stream); \ 53 55 } while (0) 54 55 #else56 57 #define fmsg(stream,arg...) \58 do \59 { \60 fprintf(stream,arg); \61 fflush(stream); \62 } while (0)63 64 #endif65 56 66 57 #define fmsgDebug(stream,arg...) \ -
trunk/IPs/systemC/processor/Morpheo/Common/include/Time.h
r88 r97 15 15 { 16 16 #ifdef SYSTEMC 17 private : double nb_cycles_begin; 17 private : const bool systemc; 18 private : double nb_cycles_begin; 18 19 #endif 19 private : timeval time_begin;20 private : timeval time_begin; 20 21 // private : timeval time_end; 21 22 22 public : Time () 23 public : Time (bool systemc=true) 24 #ifdef SYSTEMC 25 : 26 systemc (systemc) 27 #endif 23 28 { 24 29 #ifdef SYSTEMC … … 41 46 42 47 #ifdef SYSTEMC 43 double nb_cycles_end = sc_simulation_time();44 double average = static_cast<double>(nb_cycles_end-x.nb_cycles_begin+1) / static_cast<double>(time_end.tv_sec-x.time_begin.tv_sec+1);45 46 output << "Timing : " << nb_cycles_end << " cycles \t(" << average << " cycles/s)" << std::endl;47 #else 48 double average = static_cast<double>(time_end.tv_sec-x.time_begin.tv_sec+1);49 50 output << "Timing : " average << " s" << std::endl;48 if (x.systemc) 49 { 50 double nb_cycles_end = sc_simulation_time(); 51 double average = static_cast<double>(nb_cycles_end-x.nb_cycles_begin+1) / static_cast<double>(time_end.tv_sec-x.time_begin.tv_sec+1); 52 53 output << "Timing : " << nb_cycles_end << " cycles \t(" << average << " cycles/s)" << std::endl; 54 } 55 else 51 56 #endif 52 57 { 58 double average = static_cast<double>(time_end.tv_sec-x.time_begin.tv_sec+1); 59 60 output << "Timing : " << average << " s" << std::endl; 61 } 62 53 63 return output; 54 64 } -
trunk/IPs/systemC/processor/Morpheo/Common/src/Debug.cpp
r88 r97 11 11 namespace morpheo { 12 12 13 static uint32_t _debug_depth = 0; 13 #ifdef DEBUG 14 static bool debug_initialized; 15 #endif 16 debug_verbosity_t debug; 14 17 15 18 #undef FUNCTION 16 #define FUNCTION "debug_ tab"17 std::string debug_tab(void)19 #define FUNCTION "debug_init" 20 void debug_init (void) 18 21 { 19 return std::string(_debug_depth,'\t'); 22 #ifdef DEBUG 23 if (not debug_initialized) 24 { 25 debug = DEBUG; 26 27 // debug_initialized = true; 28 } 29 #endif 20 30 } 21 31 22 32 #undef FUNCTION 23 #define FUNCTION "debug_ tab_inc"24 void debug_ tab_inc (void)33 #define FUNCTION "debug_init" 34 void debug_init (debug_verbosity_t level) 25 35 { 26 // _debug_depth ++; 27 } 28 29 #undef FUNCTION 30 #define FUNCTION "debug_tab_dec" 31 void debug_tab_dec (void) 32 { 33 // _debug_depth --; 36 #ifdef DEBUG 37 if (not debug_initialized) 38 { 39 // Take min 40 debug = (level < DEBUG)?level:DEBUG; 41 42 debug_initialized = true; 43 } 44 #endif 34 45 } 35 46 -
trunk/IPs/systemC/processor/Morpheo/Common/src/Environment.cpp
r88 r97 9 9 #include "Common/include/ErrorMorpheo.h" 10 10 #include "Common/include/Debug.h" 11 #include "Common/include/Message.h" 11 12 #include <sys/stat.h> 12 13 -
trunk/IPs/systemC/processor/Morpheo/Common/src/Message.cpp
r88 r97 1 #ifdef LOG_FILE2 1 /* 3 2 * $Id$ … … 16 15 namespace morpheo { 17 16 18 static bool log_initialized; 19 FILE * log_stream; 20 17 static bool log_initialized; 18 FILE * log_stream; 19 20 #undef FUNCTION 21 #define FUNCTION "log" 22 FILE * log (FILE * stream) 23 { 24 // if log stream is initialized, take this, else return the default stream. 25 return (log_initialized and (log_stream!=NULL))?log_stream:stream; 26 }; 27 21 28 #undef FUNCTION 22 29 #define FUNCTION "log_init" 23 void log_init (void) 24 { 25 if (not log_initialized) 26 { 27 log_initialized = true; 28 29 directory(); 30 31 std::string filename = MORPHEO_LOG+"/Morpheo_"+toString<pid_t>(getpid())+".log"; 32 33 log_stream = fopen (filename.c_str(), "w"); 34 35 if (log_stream==NULL) 36 { 37 fprintf(stderr,_("%s Error create log file \"%s\", take the standard output.\n"),MSG_ERROR,filename.c_str()); 38 log_stream = stdout; 39 } 40 else 41 { 42 fprintf(stdout,_("%s Create log file \"%s\".\n"),MSG_INFORMATION,filename.c_str()); 43 } 44 } 45 } 46 30 void log_init (bool have_file, 31 std::string directory, 32 std::string file) 33 { 34 if (not log_initialized) 35 { 36 log_initialized = true; 37 38 if (have_file) 39 { 40 // if the file is not define, take pid. 41 std::string filename = directory+"/Morpheo_"+((file!="")?file:toString<pid_t>(getpid()))+".log"; 42 43 log_stream = fopen (filename.c_str(), "w"); 44 45 if (log_stream==NULL) 46 { 47 fprintf(stderr,_("%s Error create log file \"%s\", take the standard output.\n"),MSG_ERROR,filename.c_str()); 48 log_stream = stdout; 49 } 50 else 51 { 52 fprintf(stdout,_("%s Create log file \"%s\".\n"),MSG_INFORMATION,filename.c_str()); 53 } 54 } 55 else 56 { 57 log_stream = NULL; 58 } 59 } 60 } 61 47 62 }; // end namespace morpheo 48 #endif
Note: See TracChangeset
for help on using the changeset viewer.