Changeset 88 for trunk/IPs/systemC/processor/Morpheo/Common
- Timestamp:
- Dec 10, 2008, 7:31:39 PM (16 years ago)
- Location:
- trunk/IPs/systemC/processor/Morpheo/Common
- Files:
-
- 3 added
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/IPs/systemC/processor/Morpheo/Common/include/Address.h
r81 r88 1 #ifndef morpheo_Address2 #define morpheo_Address1 #ifndef Morpheo_Address_h 2 #define Morpheo_Address_h 3 3 4 4 /* -
trunk/IPs/systemC/processor/Morpheo/Common/include/Average.h
r81 r88 1 #ifndef morpheo_Average2 #define morpheo_Average1 #ifndef Morpheo_Average_h 2 #define Morpheo_Average_h 3 3 4 4 /* -
trunk/IPs/systemC/processor/Morpheo/Common/include/BitManipulation.h
r81 r88 1 #ifndef morpheo_BitManipulation2 #define morpheo_BitManipulation1 #ifndef Morpheo_BitManipulation_h 2 #define Morpheo_BitManipulation_h 3 3 4 4 /* -
trunk/IPs/systemC/processor/Morpheo/Common/include/ChangeCase.h
r81 r88 1 #ifndef morpheo_changecase2 #define morpheo_changecase1 #ifndef Morpheo_ChangeCase_h 2 #define Morpheo_ChangeCase_h 3 3 4 4 /* -
trunk/IPs/systemC/processor/Morpheo/Common/include/Debug.h
r83 r88 1 #ifndef DEBUG_H2 #define DEBUG_H1 #ifndef Morpheo_Debug_h 2 #define Morpheo_Debug_h 3 3 4 4 /* … … 13 13 * - log_begin 14 14 * - log_end 15 * - log_function 16 * - msg_print 15 17 * - breakpoint 16 18 * … … 25 27 #include "Common/include/Message.h" 26 28 #include "Behavioural/include/Debug_component.h" 27 #include "Behavioural/include/Environment.h"29 #include <systemc.h> 28 30 #include <stdio.h> 29 31 #include <string.h> … … 31 33 #include <sstream> 32 34 #include <string> 35 36 namespace morpheo { 33 37 34 38 enum _debug_verbosity … … 54 58 ( DEBUG_ ## component == true )) ) \ 55 59 { \ 60 if (DEBUG_ ## level <= DEBUG_INFO) \ 61 { \ 62 msg("%s ",MSG_INFORMATION); \ 63 } \ 64 else \ 65 { \ 66 msg("%s ",MSG_DEBUG); \ 67 } \ 68 \ 56 69 if (DEBUG >= DEBUG_FUNC) \ 57 70 { \ 58 msg( _("%s"),debug_tab().c_str());\71 msg("%s",debug_tab().c_str()); \ 59 72 } \ 60 73 if (DEBUG >= DEBUG_ALL ) \ … … 72 85 if (DEBUG >= DEBUG_FUNC) \ 73 86 { \ 74 msg(_("<%s> "),func); \ 75 msg(_("In file %s, "),__FILE__); \ 76 msg(_("at line %d " ),__LINE__); \ 77 msg(_(": ")); \ 78 } \ 79 msg(str); \ 80 msg(_("\n")); \ 81 fflush (stdout); \ 87 msg( "<%s> " ,func); \ 88 msg(_("In file %s, "),__FILE__); \ 89 msg(_("at line %d " ),__LINE__); \ 90 msg( ": " ); \ 91 } \ 92 msg(str); \ 93 msg("\n"); \ 82 94 } \ 83 95 } while(0) … … 87 99 { \ 88 100 debug_tab_inc (); \ 89 log_printf(FUNC,component,func, "Begin");\101 log_printf(FUNC,component,func,_("Begin")); \ 90 102 } while(0) 91 103 … … 93 105 do \ 94 106 { \ 95 log_printf(FUNC,component,func, "End"); \107 log_printf(FUNC,component,func,_("End")); \ 96 108 debug_tab_dec (); \ 97 109 } while(0) … … 115 127 #endif // DEBUG 116 128 129 # define log_function(component,func,name) \ 130 do \ 131 { \ 132 log_printf(TRACE,component,func,_("[%d] %s.%s"),static_cast<uint32_t>(sc_simulation_time()),name,func); \ 133 } while(0) 134 135 136 #define msg_printf(type,str...) \ 137 do \ 138 { \ 139 msg("%s ",MSG_ ## type); \ 140 msg(str); \ 141 msg("\n"); \ 142 } while(0) 143 144 117 145 #define breakpoint(str...) \ 118 146 do \ 119 147 { \ 120 msg(_("Breakpoint : file %s, line %d. Enter Any key to continue\n"),__FILE__,__LINE__); \ 121 msg(str); \ 148 fprintf(stdout,_("%s "),MSG_BREAKPOINT); \ 149 fprintf(stdout,_("Breakpoint in file %s, line %d.\n"),__FILE__,__LINE__); \ 150 fprintf(stdout,_("%s "),MSG_NONE); \ 151 fprintf(stdout,str); \ 152 fprintf(stdout,_("\n")); \ 153 fprintf(stdout,_("%s "),MSG_NONE); \ 154 fprintf(stdout,_("Enter any key to continue\n")); \ 122 155 getchar(); \ 123 156 } while(0) … … 128 161 { \ 129 162 if (x == NULL) \ 130 err(_(" %s File %s, Line %d, this pointeur is null\n"),MSG_ERROR,__FILE__,__LINE__); \163 err(_("File %s, Line %d, this pointeur is null\n"),__FILE__,__LINE__); \ 131 164 } \ 132 165 while (0) … … 139 172 #endif 140 173 141 174 }; // end namespace morpheo 142 175 #endif // !DEBUG_H -
trunk/IPs/systemC/processor/Morpheo/Common/include/ErrorMorpheo.h
r82 r88 1 #ifndef morpheo_ErrorMorpheo2 #define morpheo_ErrorMorpheo1 #ifndef Morpheo_ErrorMorpheo_h 2 #define Morpheo_ErrorMorpheo_h 3 3 4 4 /* … … 9 9 */ 10 10 11 #include "ToString.h" 11 #include "Common/include/ToString.h" 12 #include "Common/include/Translation.h" 13 #include "Common/include/Message.h" 14 12 15 #include <iostream> 13 16 #include <exception> … … 23 26 24 27 // -----[ methods ]--------------------------------------------------- 25 public : ErrorMorpheo () throw() {_msg ="Exception detected ...";}26 public : ErrorMorpheo (std::string msg) throw() {_msg =msg;}28 public : ErrorMorpheo () throw() {_msg = toString("%s ",MSG_ERROR); _msg+="Exception detected ...";} 29 public : ErrorMorpheo (std::string msg) throw() {_msg = toString("%s ",MSG_ERROR); _msg+=msg;} 27 30 public : ErrorMorpheo (std::string funcname, 28 31 std::string msg , … … 30 33 std::string file ) throw() 31 34 { 32 _msg = toString("<%s> at line %d, in file %s : %s",funcname.c_str(),line,file.c_str(),msg.c_str()); 35 #ifdef DEBUG 36 _msg = toString(_("%s <%s> at line %d, in file %s : %s"),MSG_ERROR,funcname.c_str(),line,file.c_str(),msg.c_str()); 37 #else 38 _msg = toString(_("%s %s"),MSG_ERROR,msg.c_str()); 39 #endif 33 40 } 34 41 public : ~ErrorMorpheo (void) throw() {} … … 43 50 44 51 // -----[ methods ]--------------------------------------------------- 45 public : TestMorpheo () throw() {_msg= "Test error ...";}52 public : TestMorpheo () throw() {_msg=_("Test error ...");} 46 53 public : TestMorpheo (std::string msg) throw() {_msg=msg;} 47 54 public : ~TestMorpheo (void) throw() {} -
trunk/IPs/systemC/processor/Morpheo/Common/include/FromString.h
r81 r88 1 #ifndef morpheo_fromstring2 #define morpheo_fromstring1 #ifndef Morpheo_FromString_h 2 #define Morpheo_FromString_h 3 3 4 4 /* … … 27 27 } 28 28 29 template<> inline uint64_t fromString<uint64_t> (const std::string& x) 30 { 31 return static_cast<uint64_t>(atoll(x.c_str())); 32 } 33 34 template<> inline double fromString<double> (const std::string& x) 35 { 36 return static_cast<double>(atof(x.c_str())); 37 } 38 29 39 template<> inline bool fromString<bool> (const std::string& x) 30 40 { -
trunk/IPs/systemC/processor/Morpheo/Common/include/Log2.h
r81 r88 1 #ifndef morpheo_Log22 #define morpheo_Log21 #ifndef Morpheo_Log2_h 2 #define Morpheo_Log2_h 3 3 4 4 /* -
trunk/IPs/systemC/processor/Morpheo/Common/include/Max.h
r87 r88 1 #ifndef morpheo_max2 #define morpheo_max1 #ifndef Morpheo_Max_h 2 #define Morpheo_Max_h 3 3 4 4 /* … … 13 13 namespace morpheo { 14 14 15 template<typename T> inline T max ( constT * x, uint32_t size)15 template<typename T> inline T max (T * x, uint32_t size) 16 16 { 17 17 T res = x[0]; 18 18 19 19 for (uint32_t i=1; i<size; i++) 20 if (res<x[i]) 21 res = x[i]; 20 { 21 T tmp = x[i]; 22 if (res<tmp) 23 res = tmp; 24 } 22 25 23 26 return res; 24 27 } 25 28 26 template<typename T> inline T max (const T * x, uint32_t size, uint32_t n) 29 template<typename T> inline T max (T ** x, uint32_t size1, uint32_t size2) 30 { 31 T res = max(x[0],size2); 32 33 for (uint32_t i=1; i<size1; i++) 34 { 35 T tmp = max(x[i],size2); 36 if (res<tmp) 37 res = tmp; 38 } 39 40 return res; 41 } 42 43 template<typename T> inline T max (T ** x, uint32_t size1, uint32_t * size2) 44 { 45 T res = max(x[0],size2[0]); 46 47 for (uint32_t i=1; i<size1; i++) 48 { 49 T tmp = max(x[i],size2[i]); 50 if (res<tmp) 51 res = tmp; 52 } 53 54 return res; 55 } 56 57 58 template<typename T> inline T max (T * x, uint32_t size, uint32_t n) 27 59 { 28 60 if ((n==0) or (n>size)) -
trunk/IPs/systemC/processor/Morpheo/Common/include/Message.h
r83 r88 1 #ifndef M ESSAGE_H2 #define M ESSAGE_H1 #ifndef Morpheo_Message_h 2 #define Morpheo_Message_h 3 3 /* 4 4 * $Id$ … … 15 15 namespace morpheo { 16 16 17 #define MSG_ERROR _("[ ERROR ]") 18 #define MSG_WARNING _("[ WARNING ]") 19 #define MSG_INFORMATION _("[INFORMATION]") 17 // Color 18 // 31 : rouge 19 // 32 : vert 20 // 33 : jaune 21 // 34 : bleu 22 // 35 : rose 23 // 36 : cyan 24 // 37 : blanc 25 // 38 : noir souligne 26 // 39 : noir 20 27 21 #define msg(arg...) \ 28 # define MSG_NONE _(" ") 29 #ifdef PRINT_COLOR 30 # define MSG_DEBUG _("[1;34m[ DEBUG ][0m") 31 # define MSG_ERROR _("[1;31m[ ERROR ][0m") 32 # define MSG_WARNING _("[1;35m[ WARNING ][0m") 33 # define MSG_INFORMATION _("[1;32m[INFORMATION][0m") 34 # define MSG_BREAKPOINT _("[1;38m[ BREAK ][0m") 35 #else 36 # define MSG_DEBUG _("[ DEBUG ]") 37 # define MSG_ERROR _("[ ERROR ]") 38 # define MSG_WARNING _("[ WARNING ]") 39 # define MSG_INFORMATION _("[INFORMATION]") 40 # define MSG_BREAKPOINT _("[ BREAK ]") 41 #endif 42 43 #ifdef LOG_FILE 44 extern FILE * log_stream; 45 void log_init (void); 46 47 #define fmsg(stream,arg...) \ 22 48 do \ 23 49 { \ 24 fprintf(stdout,arg); \ 50 log_init(); \ 51 fprintf(log_stream,arg); \ 52 fflush(log_stream); \ 53 } while (0) 54 55 #else 56 57 #define fmsg(stream,arg...) \ 58 do \ 59 { \ 60 fprintf(stream,arg); \ 61 fflush(stream); \ 25 62 } while (0) 26 63 27 #define err(arg...) \ 64 #endif 65 66 #define fmsgDebug(stream,arg...) \ 28 67 do \ 29 68 { \ 30 fprintf(stderr,arg); \ 69 fmsg(stream,"%s ",MSG_DEBUG); \ 70 fmsg(stream,arg); \ 31 71 } while (0) 32 72 73 #define fmsgError(stream,arg...) \ 74 do \ 75 { \ 76 fmsg(stream,"%s ",MSG_ERROR); \ 77 fmsg(stream,arg); \ 78 } while (0) 79 80 #define fmsgWarning(stream,arg...) \ 81 do \ 82 { \ 83 fmsg(stream,"%s ",MSG_WARNING); \ 84 fmsg(stream,arg); \ 85 } while (0) 86 87 #define fmsgInformation(stream,arg...) \ 88 do \ 89 { \ 90 fmsg(stream,"%s ",MSG_INFORMATION); \ 91 fmsg(stream,arg); \ 92 } while (0) 93 94 #define msg(arg...) fmsg(stdout,arg) 95 #define msgDebug(arg...) fmsgDebug(stdout,arg) 96 #define msgError(arg...) fmsgError(stdout,arg) 97 #define msgWarning(arg...) fmsgWarning(stdout,arg) 98 #define msgInformation(arg...) fmsgInformation(stdout,arg) 99 #define err(arg...) fmsgError(stderr,arg) 33 100 34 101 }; // end namespace morpheo -
trunk/IPs/systemC/processor/Morpheo/Common/include/Percent.h
r81 r88 1 #ifndef morpheo_Percent2 #define morpheo_Percent1 #ifndef Morpheo_Percent_h 2 #define Morpheo_Percent_h 3 3 4 4 /* -
trunk/IPs/systemC/processor/Morpheo/Common/include/Test.h
r83 r88 1 #ifndef TEST_H 2 #define TEST_H 1 #ifndef Morpheo_Test_h 2 #define Morpheo_Test_h 3 4 /* 5 * $Id$ 6 * 7 * [ Description ] 8 * 9 * Macro / function to test 10 */ 3 11 4 12 #include <iostream> … … 11 19 namespace morpheo { 12 20 13 //-----[ Routine de test ]--------------------------------------- 21 #define STR_OK "Test OK" 22 #define STR_KO "Test KO" 14 23 15 24 static uint32_t num_test; … … 24 33 inline void test_ko (char * file, uint32_t line, T exp1, T exp2) 25 34 { 26 std::cerr << "[" << num_test << "] : Test KO" 35 fflush (stdout); 36 fflush (stderr); 37 38 std::cerr << "[" << num_test << "] : " << STR_KO 27 39 << "\tline " << line << std::endl 28 40 << " * Localisation" << std::endl … … 38 50 inline void test_ko (char * file, uint32_t line) 39 51 { 40 std::cerr << "[" << num_test << "] : Test KO" 52 fflush (stdout); 53 fflush (stderr); 54 55 std::cerr << "[" << num_test << "] : " << STR_KO 41 56 << "\tline " << line << std::endl 42 57 << " * Localisation" << std::endl … … 49 64 inline void test_ok () 50 65 { 51 msg (_("[%d] : Test OK\n"), num_test); 66 fflush (stdout); 67 fflush (stderr); 68 69 msg (_("[%d] : %s\n"), num_test,STR_OK); 52 70 53 71 num_test ++; … … 56 74 inline void test_ok (char * file, uint32_t line) 57 75 { 58 msg (_("[%d] : Test OK\n"), num_test); 76 fflush (stdout); 77 fflush (stderr); 78 79 msg (_("[%d] : %s\n"), num_test,STR_OK); 59 80 msg (_("\tline %d\n"), line); 60 81 … … 65 86 inline void test_ok (char * file, uint32_t line, T exp) 66 87 { 67 msg (_("[%d] : Test OK\n"), num_test); 88 fflush (stdout); 89 fflush (stderr); 90 91 msg (_("[%d] : %s\n"), num_test, STR_OK); 68 92 msg (_("\tline %d\n"), line); 69 93 msg (_("\tvalue %s\n"), (morpheo::toString(exp)).c_str()); … … 91 115 msg (str); \ 92 116 msg (_("\n")); \ 117 fflush (stdout); \ 93 118 } while(0) 94 95 119 96 120 #ifndef CYCLE_MAX … … 109 133 } \ 110 134 \ 111 if ( cycle_current > CYCLE_MAX)\135 if ((CYCLE_MAX != 0) and (cycle_current > CYCLE_MAX)) \ 112 136 { \ 113 137 TEST_KO("Maximal cycles Reached"); \ -
trunk/IPs/systemC/processor/Morpheo/Common/include/Time.h
r81 r88 1 #ifndef TIME_H2 #define TIME_H1 #ifndef Morpheo_Time_h 2 #define Morpheo_Time_h 3 3 4 4 #ifdef SYSTEMC … … 10 10 #include <sys/time.h> 11 11 12 namespace morpheo { 13 12 14 class Time 13 15 { 14 private : timeval time_begin; 16 #ifdef SYSTEMC 17 private : double nb_cycles_begin; 18 #endif 19 private : timeval time_begin; 15 20 // private : timeval time_end; 16 21 17 22 public : Time () 18 { 19 gettimeofday(&time_begin ,NULL); 23 { 24 #ifdef SYSTEMC 25 nb_cycles_begin = sc_simulation_time(); 26 #endif 27 gettimeofday(&time_begin,NULL); 20 28 }; 21 29 22 30 public : ~Time () 23 31 { … … 25 33 }; 26 34 27 public : friend std::ostream& operator<< (std::ostream& output _stream,35 public : friend std::ostream& operator<< (std::ostream& output, 28 36 const Time & x) 29 37 { 30 38 timeval time_end; 31 39 32 gettimeofday(&time_end 40 gettimeofday(&time_end,NULL); 33 41 34 uint32_t nb_cycles = static_cast<uint32_t>(sc_simulation_time()); 35 36 double average = static_cast<double>(nb_cycles) / static_cast<double>(time_end.tv_sec-x.time_begin.tv_sec+1);42 #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); 37 45 38 output_stream << "Timing : " << nb_cycles << " cycles \t(" << average << " cycles/s)" << std::endl; 39 40 return output_stream; 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; 51 #endif 52 53 return output; 41 54 } 42 55 }; 43 56 57 }; // end namespace morpheo 58 44 59 #endif -
trunk/IPs/systemC/processor/Morpheo/Common/include/ToBase2.h
r81 r88 1 #ifndef morpheo_ToBase22 #define morpheo_ToBase21 #ifndef Morpheo_ToBase2_h 2 #define Morpheo_ToBase2_h 3 3 4 4 /* -
trunk/IPs/systemC/processor/Morpheo/Common/include/ToString.h
r82 r88 1 #ifndef morpheo_tostring2 #define morpheo_tostring1 #ifndef Morpheo_ToString_h 2 #define Morpheo_ToString_h 3 3 4 4 /* -
trunk/IPs/systemC/processor/Morpheo/Common/include/Translation.h
r82 r88 1 #ifndef morpheo_Translation_H2 #define morpheo_Translation_H1 #ifndef Morpheo_Translation_h 2 #define Morpheo_Translation_h 3 3 /* 4 4 * $Id$ … … 16 16 #define MORPHEO_PACKAGE "morpheo" 17 17 18 #ifdef NO_TRANSLATION 18 #ifdef TRANSLATION 19 # define _(str) dgettext (MORPHEO_PACKAGE,str) 20 #else 19 21 # define _(str) (str) 20 #else21 # define _(str) dgettext (MORPHEO_PACKAGE,str)22 22 #endif 23 23 24 24 namespace morpheo 25 25 { 26 class Translation 27 { 28 public : Translation (void); 29 public : ~Translation (void); 30 }; 31 26 void translation (void); 32 27 }; // end namespace morpheo 33 28 #endif -
trunk/IPs/systemC/processor/Morpheo/Common/include/Types.h
r81 r88 1 #ifndef morpheo_Type2 #define morpheo_Type1 #ifndef Morpheo_Type_h 2 #define Morpheo_Type_h 3 3 4 4 /* … … 34 34 // #endif 35 35 36 # define SC_CLOCK sc_in_clk37 // 38 // 39 // 40 # define SC_IN(type) sc_in <type >41 # define SC_OUT(type) sc_out <type >36 # define SC_CLOCK sc_in_clk 37 //#define SC_INTERNAL(type) type 38 //#define SC_REGISTER(type) sc_signal<type > 39 //#define SC_SIGNAL(type) sc_signal<type > 40 # define SC_IN(type) sc_in <type > 41 # define SC_OUT(type) sc_out <type > 42 42 43 # define PORT_READ(sig) sig->read()44 # define PORT_WRITE(sig,val) sig->write(val)45 // 46 // 47 // 48 // 49 // 50 // 43 # define PORT_READ(sig) sig->read() 44 # define PORT_WRITE(sig,val) sig->write(val) 45 //#define INTERNAL_READ(sig) (*sig) 46 //#define INTERNAL_WRITE(sig,val) (*sig) = val 47 //#define SIGNAL_READ(sig) sig->read() 48 //#define SIGNAL_WRITE(sig,val) sig->write(val) 49 //#define REGISTER_READ(sig) sig->read() 50 //#define REGISTER_WRITE(sig,val) sig->write(val) 51 51 52 52 #endif -
trunk/IPs/systemC/processor/Morpheo/Common/src/Debug.cpp
r82 r88 7 7 8 8 #include "Common/include/Debug.h" 9 #include "Common/include/Environment.h" 10 11 namespace morpheo { 9 12 10 13 static uint32_t _debug_depth = 0; 11 14 15 #undef FUNCTION 16 #define FUNCTION "debug_tab" 12 17 std::string debug_tab (void) 13 18 { … … 15 20 } 16 21 22 #undef FUNCTION 23 #define FUNCTION "debug_tab_inc" 17 24 void debug_tab_inc (void) 18 25 { … … 20 27 } 21 28 29 #undef FUNCTION 30 #define FUNCTION "debug_tab_dec" 22 31 void debug_tab_dec (void) 23 32 { 24 33 // _debug_depth --; 25 34 } 35 36 }; // end namespace morpheo -
trunk/IPs/systemC/processor/Morpheo/Common/src/Translation.cpp
r82 r88 6 6 */ 7 7 8 #include "../include/Translation.h" 9 #include "../include/ErrorMorpheo.h" 8 #include "Common/include/Environment.h" 9 #include "Common/include/Translation.h" 10 #include "Common/include/ErrorMorpheo.h" 10 11 11 12 namespace morpheo { 12 13 13 Translation:: Translation (void) 14 static bool translation_initialized; 15 16 void translation (void) 14 17 { 15 #ifndef NO_TRANSLATION 16 char * top_level = getenv("MORPHEO_TOPLEVEL"); 17 18 if (top_level == NULL) 19 throw ERRORMORPHEO("Translation","Error morpheo environment is not positioned\n"); 20 21 std::string dirname = top_level; 22 dirname += "IPs/systemC/processor/Morpheo/locale"; 18 #ifdef TRANSLATION 19 if (not translation_initialized) 20 { 21 environment(); 22 23 std::string dirname = MORPHEO_TOPLEVEL; 24 dirname += "/IPs/systemC/processor/Morpheo/locale"; 23 25 24 bindtextdomain(MORPHEO_PACKAGE,dirname.c_str()); 26 if (bindtextdomain(MORPHEO_PACKAGE,dirname.c_str()) == NULL) 27 throw ERRORMORPHEO("Translation","Error in set directory containing message catalogs.\n"); 28 29 translation_initialized = true; 30 } 25 31 #endif 26 32 } 27 33 28 Translation::~Translation (void)29 {30 31 }32 33 34 }; // end namespace morpheo
Note: See TracChangeset
for help on using the changeset viewer.