Index: trunk/IPs/systemC/processor/Morpheo/Common/include/Debug.h
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Common/include/Debug.h	(revision 94)
+++ trunk/IPs/systemC/processor/Morpheo/Common/include/Debug.h	(revision 97)
@@ -9,5 +9,4 @@
  * function to help the debugging :
  *
- *  - debug_tab
  *  - log_printf
  *  - log_begin
@@ -26,4 +25,6 @@
 
 #include "Common/include/Message.h"
+#include "Common/include/FromString.h"
+#include "Common/include/ChangeCase.h"
 #include "Behavioural/include/Debug_component.h"
 #include <systemc.h>
@@ -36,5 +37,5 @@
 namespace morpheo {
 
-enum _debug_verbosity 
+typedef enum 
   {
     DEBUG_NONE ,
@@ -43,17 +44,20 @@
     DEBUG_FUNC ,
     DEBUG_ALL
-  };
-
-std::string debug_tab     (void);
-void        debug_tab_inc (void);
-void        debug_tab_dec (void);
-
+  } debug_verbosity_t;
+
+  extern debug_verbosity_t debug;
+
+void        debug_init    (void);
+void        debug_init    (debug_verbosity_t level);
 #ifdef DEBUG
+
 # define log_printf(level, component, func, str... )			\
   do									\
     {									\
-      if ((DEBUG == DEBUG_ALL ) or					\
+      debug_init();                                                     \
+                                                                        \
+      if ((debug == DEBUG_ALL ) or					\
 	  (DEBUG_ ## level == DEBUG_NONE) or				\
-	  (( DEBUG_ ## level     <= DEBUG) and				\
+	  (( DEBUG_ ## level     <= debug) and				\
 	   ( DEBUG_ ## component == true )) )				\
 	{								\
@@ -67,9 +71,5 @@
 	    }								\
                                                                         \
-	  if (DEBUG >= DEBUG_FUNC)					\
-	    {								\
-	      msg("%s",debug_tab().c_str());		                \
-	    }								\
-	  if (DEBUG >= DEBUG_ALL )					\
+	  if (debug >= DEBUG_ALL )					\
 	    {								\
 	      switch (DEBUG_ ## level)					\
@@ -83,5 +83,5 @@
 		}							\
 	    }								\
-	  if (DEBUG >= DEBUG_FUNC)					\
+	  if (debug >= DEBUG_FUNC)					\
 	    {								\
 	      msg(  "<%s> " ,func);			        	\
@@ -98,5 +98,4 @@
   do									\
     {									\
-      debug_tab_inc ();							\
       log_printf(FUNC,component,func,_("Begin"));                       \
     } while(0)
@@ -106,5 +105,4 @@
     {									\
       log_printf(FUNC,component,func,_("End"));				\
-      debug_tab_dec ();							\
     } while(0)
 
@@ -172,4 +170,33 @@
 #endif
 
+
+  template<> inline debug_verbosity_t fromString<debug_verbosity_t> (const std::string& x)
+  {
+    std::string y=x;
+    LowerCase(y);
+
+    if ( (y.compare("0")     == 0) or
+         (y.compare("none")  == 0))
+      return DEBUG_NONE ;
+    if ( (y.compare("1")     == 0) or
+         (y.compare("info")  == 0))
+      return DEBUG_INFO ;
+    if ( (y.compare("2")     == 0) or
+         (y.compare("trace") == 0))
+      return DEBUG_TRACE;
+    if ( (y.compare("3")     == 0) or
+         (y.compare("func")  == 0))
+      return DEBUG_FUNC ;
+    if ( (y.compare("4")     == 0) or
+         (y.compare("all")   == 0))
+      return DEBUG_ALL  ;
+
+#ifdef DEBUG
+    return DEBUG;
+#else
+    return DEBUG_NONE ;
+#endif
+  }
+
 }; // end namespace morpheo
 #endif // !DEBUG_H
Index: trunk/IPs/systemC/processor/Morpheo/Common/include/Message.h
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Common/include/Message.h	(revision 94)
+++ trunk/IPs/systemC/processor/Morpheo/Common/include/Message.h	(revision 97)
@@ -41,26 +41,17 @@
 #endif
 
-#ifdef LOG_FILE
 extern FILE * log_stream;
-void log_init (void);
+FILE * log      (FILE * stream);
+void   log_init (bool        have_file,
+                 std::string directory,
+                 std::string file="");
 
 #define fmsg(stream,arg...)			\
   do						\
     {						\
-      log_init();                               \
-      fprintf(log_stream,arg);			\
-      fflush(log_stream);                       \
+      FILE * _stream = log(stream);             \
+      fprintf(_stream,arg);			\
+      fflush(_stream);                          \
     } while (0)
-
-#else
-
-#define fmsg(stream,arg...)			\
-  do						\
-    {						\
-      fprintf(stream,arg);			\
-      fflush(stream);                           \
-    } while (0) 
-
-#endif
 
 #define fmsgDebug(stream,arg...)		\
Index: trunk/IPs/systemC/processor/Morpheo/Common/include/Time.h
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Common/include/Time.h	(revision 94)
+++ trunk/IPs/systemC/processor/Morpheo/Common/include/Time.h	(revision 97)
@@ -15,10 +15,15 @@
 {
 #ifdef SYSTEMC
-private : double   nb_cycles_begin;
+private : const bool systemc;
+private : double     nb_cycles_begin;
 #endif
-private : timeval  time_begin;
+private : timeval    time_begin;
 // private : timeval time_end;
   
-public  : Time ()
+public  : Time (bool systemc=true)
+#ifdef SYSTEMC
+  :
+  systemc (systemc)
+#endif
   { 
 #ifdef SYSTEMC
@@ -41,14 +46,19 @@
     
 #ifdef SYSTEMC
-    double nb_cycles_end = sc_simulation_time();
-    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);
-    
-    output << "Timing : " << nb_cycles_end << " cycles \t(" << average << " cycles/s)" << std::endl;
-#else
-    double average       = static_cast<double>(time_end.tv_sec-x.time_begin.tv_sec+1);
-    
-    output << "Timing : " average << " s" << std::endl;
+    if (x.systemc)
+      {
+        double nb_cycles_end = sc_simulation_time();
+        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);
+        
+        output << "Timing : " << nb_cycles_end << " cycles \t(" << average << " cycles/s)" << std::endl;
+      }
+    else
 #endif
-    
+      {
+        double average       = static_cast<double>(time_end.tv_sec-x.time_begin.tv_sec+1);
+        
+        output << "Timing : " << average << " s" << std::endl;
+      }
+
     return output;
   }
Index: trunk/IPs/systemC/processor/Morpheo/Common/src/Debug.cpp
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Common/src/Debug.cpp	(revision 94)
+++ trunk/IPs/systemC/processor/Morpheo/Common/src/Debug.cpp	(revision 97)
@@ -11,25 +11,36 @@
 namespace morpheo {
 
-static uint32_t _debug_depth = 0;
+#ifdef DEBUG
+static bool       debug_initialized;
+#endif
+debug_verbosity_t debug;
 
 #undef  FUNCTION
-#define FUNCTION "debug_tab"
-std::string debug_tab (void)
+#define FUNCTION "debug_init"
+void debug_init (void)
 {
-  return std::string(_debug_depth,'\t');
+#ifdef DEBUG
+  if (not debug_initialized)
+    {
+      debug = DEBUG;
+
+//       debug_initialized = true;
+    }
+#endif
 }
 
 #undef  FUNCTION
-#define FUNCTION "debug_tab_inc"
-void debug_tab_inc (void)
+#define FUNCTION "debug_init"
+void debug_init (debug_verbosity_t level)
 {
-//   _debug_depth ++;
-}
-
-#undef  FUNCTION
-#define FUNCTION "debug_tab_dec"
-void debug_tab_dec (void)
-{
-//   _debug_depth --;
+#ifdef DEBUG
+  if (not debug_initialized)
+    {
+      // Take min
+      debug = (level < DEBUG)?level:DEBUG;
+      
+      debug_initialized = true;
+    }
+#endif
 }
 
Index: trunk/IPs/systemC/processor/Morpheo/Common/src/Environment.cpp
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Common/src/Environment.cpp	(revision 94)
+++ trunk/IPs/systemC/processor/Morpheo/Common/src/Environment.cpp	(revision 97)
@@ -9,4 +9,5 @@
 #include "Common/include/ErrorMorpheo.h"
 #include "Common/include/Debug.h"
+#include "Common/include/Message.h"
 #include <sys/stat.h>
 
Index: trunk/IPs/systemC/processor/Morpheo/Common/src/Message.cpp
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Common/src/Message.cpp	(revision 94)
+++ trunk/IPs/systemC/processor/Morpheo/Common/src/Message.cpp	(revision 97)
@@ -1,3 +1,2 @@
-#ifdef LOG_FILE
 /*
  * $Id$
@@ -16,33 +15,48 @@
 namespace morpheo {
 
-static bool log_initialized;
-FILE * log_stream;
-
+  static bool log_initialized;
+  FILE * log_stream;
+  
+#undef  FUNCTION
+#define FUNCTION "log"
+  FILE * log (FILE * stream)
+  {
+    // if log stream is initialized, take this, else return the default stream.
+    return (log_initialized and (log_stream!=NULL))?log_stream:stream;
+  };
+  
 #undef  FUNCTION
 #define FUNCTION "log_init"
-void log_init (void)
-{
-  if (not log_initialized)
-    {
-      log_initialized = true;
-
-      directory();
-      
-      std::string filename = MORPHEO_LOG+"/Morpheo_"+toString<pid_t>(getpid())+".log";
-
-      log_stream = fopen (filename.c_str(), "w");
-
-      if (log_stream==NULL)
-        {
-          fprintf(stderr,_("%s Error create log file \"%s\", take the standard output.\n"),MSG_ERROR,filename.c_str());
-          log_stream = stdout;
-        }
-      else
-        {
-          fprintf(stdout,_("%s Create log file \"%s\".\n"),MSG_INFORMATION,filename.c_str());
-        }
-    }
-}
-
+  void log_init (bool        have_file,
+                 std::string directory,
+                 std::string file)
+  {
+    if (not log_initialized)
+      {
+        log_initialized = true;
+        
+        if (have_file)
+          {
+            // if the file is not define, take pid.
+            std::string filename = directory+"/Morpheo_"+((file!="")?file:toString<pid_t>(getpid()))+".log";
+            
+            log_stream = fopen (filename.c_str(), "w");
+            
+            if (log_stream==NULL)
+              {
+                fprintf(stderr,_("%s Error create log file \"%s\", take the standard output.\n"),MSG_ERROR,filename.c_str());
+                log_stream = stdout;
+              }
+            else
+              {
+                fprintf(stdout,_("%s Create log file \"%s\".\n"),MSG_INFORMATION,filename.c_str());
+              }
+          }
+        else
+          {
+            log_stream = NULL;
+          }
+      }
+  }
+  
 }; // end namespace morpheo
-#endif
