Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/include/Allocation.h
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/include/Allocation.h	(revision 112)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/include/Allocation.h	(revision 113)
@@ -101,4 +101,5 @@
 #define PRINT_SIZE_NUL(component,interface,signal) log_printf(TRACE,Allocation,FUNCTION,_("<%s> %s.%s.%s : size is nul."),_name.c_str(),component->get_name().c_str(),interface->get_name().c_str(),signal);
 #define TEST_SIGNAL(name,address) PRINT_SIGNAL_ADDRESS(name,address); TEST_PTR(address)
+#define INSTANCE_FOREIGN_PRINT(name) log_printf(TRACE,Allocation,FUNCTION,"<%s> : %s (%s, %d)",_name.c_str(),name,__FILE__,__LINE__);
 
 // ----------------------------------------------------------------------
@@ -106,6 +107,5 @@
 // ----------------------------------------------------------------------
 
-
-#define __ALLOC0_SIGNAL(sig, name, type)         \
+#define __ALLOC0_SIGNAL(sig, name, type)        \
   {                                             \
     sig = new type (name);                      \
@@ -113,9 +113,9 @@
 
 #ifdef POSITION
-#define ALLOC0_INTERFACE_BEGIN( name, direction, localisation, str)            \
+#define ALLOC0_INTERFACE_BEGIN( name, direction, localisation, str)     \
   INTERFACE_PRINT(name);                                                \
   morpheo::behavioural::Interface_fifo * interface = _interfaces->set_interface( name, direction, localisation, str);
 #else
-#define ALLOC0_INTERFACE_BEGIN( name, direction, localisation, str)            \
+#define ALLOC0_INTERFACE_BEGIN( name, direction, localisation, str)     \
   INTERFACE_PRINT(name);                                                \
   morpheo::behavioural::Interface_fifo * interface = _interfaces->set_interface( name);
@@ -124,13 +124,13 @@
 #define ALLOC0_INTERFACE_END()
 
-#define ALLOC0_VAL_ACK_IN(  sig, name, type)                             \
+#define ALLOC0_VAL_ACK_IN(  sig, name, type)                            \
   {                                                                     \
     sig = interface->set_signal_valack_in (name, type);                 \
   }                                                                     
-#define ALLOC0_VAL_ACK_OUT( sig, name, type)                             \
+#define ALLOC0_VAL_ACK_OUT( sig, name, type)                            \
   {                                                                     \
     sig = interface->set_signal_valack_out(name, type);                 \
   }                                                                     
-#define ALLOC0_VALACK_IN(     sig, type)                                 \
+#define ALLOC0_VALACK_IN(     sig, type)                                \
   {                                                                     \
     sig = interface->set_signal_valack_in (type);                       \
@@ -160,5 +160,5 @@
     }
 
-#define DELETE0_SIGNAL( sig, size)                                       \
+#define DELETE0_SIGNAL( sig, size)                                      \
   if (size > 0)                                                         \
     {                                                                   \
@@ -166,9 +166,35 @@
     }
 
-#define ALLOC0_SC_SIGNAL(  sig, name, type)                              \
-  sc_signal<type> * sig = new sc_signal<type> (name);                   \
+#define ALLOC0_FOREIGN_SIGNAL_IN(  sig, interface, name, type, size)    \
+  if (size > 0)                                                         \
+    {                                                                   \
+      std::string str = (toString("in")+"_"+((interface!="")?(toString(interface)+"_"):toString(""))+toString(name)); \
+      sig = new SC_IN    (type) (str.c_str());                          \
+    }
+
+#define ALLOC0_FOREIGN_SIGNAL_OUT( sig, interface, name, type, size)    \
+  if (size > 0)                                                         \
+    {                                                                   \
+      std::string str = (toString("out")+"_"+((interface!="")?(toString(interface)+"_"):toString(""))+toString(name)); \
+      sig = new SC_OUT   (type) (str.c_str());                          \
+    }
+
+#define DELETE0_FOREIGN_SIGNAL( sig, size) \
+  {                                        \
+    DELETE0_SIGNAL(sig,size);              \
+  }
+
+#define INSTANCE0_FOREIGN_SIGNAL(component, sig, type, name, size)      \
+  if (size > 0)                                                         \
+    {                                                                   \
+      INSTANCE_FOREIGN_PRINT(name);                                     \
+      _component->set_sc_signal<type>(_name,name,static_cast<void*>(component->sig)); \
+    }
+
+#define ALLOC0_SC_SIGNAL(  sig, name, type)                             \
+  sig = new sc_signal<type> (name);                                     \
   PRINT_SIGNAL_ADDRESS(name,sig);
 
-#define INSTANCE0_SC_SIGNAL(component, sig)                     \
+#define INSTANCE0_SC_SIGNAL(component, sig)                    \
   {                                                            \
     TEST_SIGNAL(component->sig->name(),component->sig);        \
@@ -177,5 +203,5 @@
   }
 
-#define _INSTANCE0_SC_SIGNAL(component, sig1,sig2)                       \
+#define _INSTANCE0_SC_SIGNAL(component, sig1,sig2)                      \
   {                                                                     \
     TEST_SIGNAL(component->sig1->name(),component->sig1);               \
@@ -185,6 +211,7 @@
 
 #define DELETE0_SC_SIGNAL( sig)                  \
-  {                                             \
-    delete sig;                                 \
+  {                                              \
+    PRINT_SIGNAL_ADDRESS("",sig);                \
+    delete sig;                                  \
   }
 
@@ -326,6 +353,33 @@
   }
 
+#define ALLOC1_FOREIGN_SIGNAL_IN(sig, interface, name, type, size,x1)   \
+  {                                                                     \
+    sig = new SC_IN (type) * [x1];                                   \
+    for (uint32_t it1=0; it1<x1; it1++)                                 \
+      if (size > 0)                                                     \
+        {                                                               \
+          std::string str = (toString("in")+"_"+((interface!="")?(toString(interface)+"_"):toString(""))+toString(it1)+"_"+toString(name)); \
+          sig [it1] = new SC_IN (type) (str.c_str());                   \
+        }                                                               \
+  }
+
+#define ALLOC1_FOREIGN_SIGNAL_OUT(sig, interface, name, type, size,x1)  \
+  {                                                                     \
+    sig = new SC_OUT (type) * [x1];                                     \
+    for (uint32_t it1=0; it1<x1; it1++)                                 \
+      if (size > 0)                                                     \
+        {                                                               \
+          std::string str = (toString("out")+"_"+((interface!="")?(toString(interface)+"_"):toString(""))+toString(it1)+"_"+toString(name)); \
+          sig [it1] = new SC_OUT (type) (str.c_str());                  \
+        }                                                               \
+  }
+
+#define DELETE1_FOREIGN_SIGNAL( sig, size,x1)            \
+  {                                                      \
+    DELETE1_SIGNAL(sig,x1,size);                         \
+  }
+
 #define ALLOC1_SC_SIGNAL( sig, name, type, x1)                          \
-  sc_signal<type> ** sig = new sc_signal<type> * [x1];                  \
+  sig = new sc_signal<type> * [x1];                                     \
   {                                                                     \
     std::string separator="_";                                          \
@@ -359,4 +413,5 @@
     for (uint32_t it1=0; it1<x1; it1++)                                 \
       {                                                                 \
+        PRINT_SIGNAL_ADDRESS("",sig[it1]);                         \
         delete sig[it1];                                                \
       }                                                                 \
@@ -530,6 +585,42 @@
   }
 
+
+#define ALLOC2_FOREIGN_SIGNAL_IN( sig, interface, name, type, size, x1, x2) \
+  {                                                                     \
+    sig = new SC_IN (type) ** [x1];                                     \
+    for (uint32_t it1=0; it1<x1; it1++)                                 \
+      {                                                                 \
+        sig [it1] = new SC_IN (type) * [x2];                            \
+        for (uint32_t it2=0; it2<x2; it2++)                             \
+          if (size > 0)                                                 \
+            {                                                           \
+              std::string str = (toString("in")+"_"+((interface!="")?(toString(interface)+"_"):toString(""))+toString(it1)+"_"+toString(it2)+"_"+toString(name)); \
+              sig [it1][it2] = new SC_IN    (type) (str.c_str()); \
+            }                                                           \
+      }                                                                 \
+  }
+
+#define ALLOC2_FOREIGN_SIGNAL_OUT( sig, interface, name, type, size, x1, x2) \
+  {                                                                     \
+    sig = new SC_OUT (type) ** [x1];                                    \
+    for (uint32_t it1=0; it1<x1; it1++)                                 \
+      {                                                                 \
+        sig [it1] = new SC_OUT (type) * [x2];                           \
+        for (uint32_t it2=0; it2<x2; it2++)                             \
+          if (size > 0)                                                 \
+            {                                                           \
+              std::string str = (toString("out")+"_"+((interface!="")?(toString(interface)+"_"):toString(""))+toString(it1)+"_"+toString(it2)+"_"+toString(name)); \
+              sig [it1][it2] = new SC_IN    (type) (str.c_str());       \
+            }                                                           \
+      }                                                                 \
+  }
+
+#define DELETE2_FOREIGN_SIGNAL( sig, size,x1,x2)            \
+  {                                                         \
+    DELETE2_SIGNAL(sig,x1,x2,size);                         \
+  }
+
 #define ALLOC2_SC_SIGNAL( sig, name, type, x1, x2)                      \
-  sc_signal<type> *** sig = new sc_signal<type> ** [x1];                \
+  sig = new sc_signal<type> ** [x1];                                    \
   {                                                                     \
     std::string separator="_";                                          \
@@ -571,4 +662,5 @@
         for (uint32_t it2=0; it2<x2; it2++)                             \
           {                                                             \
+            PRINT_SIGNAL_ADDRESS("",sig[it1][it2]);                     \
             delete sig[it1][it2];                                       \
           }                                                             \
@@ -758,6 +850,49 @@
   }
 
+#define ALLOC3_FOREIGN_SIGNAL_IN( sig, interface, name, type, size, x1, x2,x3)     \
+  {                                                                     \
+    sig = new SC_IN (type) *** [x1];                                    \
+    for (uint32_t it1=0; it1<x1; it1++)                                 \
+      {                                                                 \
+        sig [it1] = new SC_IN (type) ** [x2];                           \
+        for (uint32_t it2=0; it2<x2; it2++)                             \
+          {                                                             \
+            sig [it1][it2] = new SC_IN (type) * [x3];                   \
+            for (uint32_t it3=0; it3<x3; it3++)                         \
+              if (size > 0)                                             \
+                {                                                       \
+                  std::string str = (toString("in")+"_"+((interface!="")?(toString(interface)+"_"):toString(""))+toString(it1)+"_"+toString(it2)+"_"+toString(it3)+"_"+toString(name)); \
+                  sig [it1][it2][it3] = new SC_IN (type) (str.c_str()); \
+                }                                                       \
+          }                                                             \
+      }                                                                 \
+  }
+
+#define ALLOC3_FOREIGN_SIGNAL_OUT( sig, interface, name, type, size, x1, x2,x3)    \
+  {                                                                     \
+    sig = new SC_OUT (type) *** [x1];                                   \
+    for (uint32_t it1=0; it1<x1; it1++)                                 \
+      {                                                                 \
+        sig [it1] = new SC_OUT (type) ** [x2];                          \
+        for (uint32_t it2=0; it2<x2; it2++)                             \
+          {                                                             \
+            sig [it1][it2] = new SC_OUT (type) * [x3];                  \
+            for (uint32_t it3=0; it3<x3; it3++)                         \
+              if (size > 0)                                             \
+                {                                                       \
+                  std::string str = (toString("out")+"_"+((interface!="")?(toString(interface)+"_"):toString(""))+toString(it1)+"_"+toString(it2)+"_"+toString(it3)+"_"+toString(name)); \
+                  sig [it1][it2][it3] = new SC_OUT(type) (str.c_str()); \
+                }                                                       \
+          }                                                             \
+      }                                                                 \
+  }
+
+#define DELETE3_FOREIGN_SIGNAL( sig, size,x1,x2,x3)            \
+  {                                                            \
+    DELETE3_SIGNAL(sig,x1,x2,x3,size);                         \
+  }
+
 #define ALLOC3_SC_SIGNAL( sig, name, type, x1, x2, x3)                  \
-  sc_signal<type> **** sig = new sc_signal<type> *** [x1];              \
+  sig = new sc_signal<type> *** [x1];                                   \
   {                                                                     \
     std::string separator="_";                                          \
@@ -807,4 +942,5 @@
             for (uint32_t it3=0; it3<x3; it3++)                         \
               {                                                         \
+                PRINT_SIGNAL_ADDRESS("",sig[it1][it2][it3]);            \
                 delete sig[it1][it2][it3];                              \
               }                                                         \
