diff --git a/bin/config.xml b/bin/config.xml
index 67ca2185f14475a1dfd7a427873028ea4eb5d5d1..1dd7d29956f12c2696938a557393a1741450d2f7 100755
--- a/bin/config.xml
+++ b/bin/config.xml
@@ -61,11 +61,11 @@
 <ExternalCommand2Host data="localhost"/>
 <ExternalCommand2 data="/packages/uppaal(4.0.11/uppaal /home/enrici/TURTLE/uppaal/spec.xml"/>
 
-<LastOpenFile data="/home/hrua/stuxnet.xml"/>
+<LastOpenFile data="/home/enrici/embb/trunk/baseband/docs/andreae/Zigbee/models/MYZigbee_final.xml"/>
 
 
 
-<LastWindowAttributes x="-1" y="0" width="1368" height="769" max="true" />
+<LastWindowAttributes x="-1" y="27" width="1368" height="742" max="true" />
 
 
 </TURTLECONFIGURATION>
diff --git a/src/tmltranslator/HwMemory.java b/src/tmltranslator/HwMemory.java
index 4269d5481da8a92e27fd0a38952064202754dcb6..1e9276ebe87bc28c24a169498c995beedf2acd1b 100755
--- a/src/tmltranslator/HwMemory.java
+++ b/src/tmltranslator/HwMemory.java
@@ -46,17 +46,20 @@ knowledge of the CeCILL license and that you accept its terms.
 package tmltranslator;
 
 import java.util.*;
+import tmltranslator.ctranslator.*;
 
 
 public class HwMemory extends HwCommunicationNode  {
 	
 	public static final int DEFAULT_BYTE_DATA_SIZE = 4;
-	
-    public int byteDataSize = DEFAULT_BYTE_DATA_SIZE; // In bytes. Should more than 0
+	public static final int DEFAULT_BUFFER_TYPE = 0;
+
+	public int BufferType = DEFAULT_BUFFER_TYPE;
+	public int byteDataSize = DEFAULT_BYTE_DATA_SIZE; // In bytes. Should more than 0
  
     public HwMemory(String _name) {
 		super(_name);
     }
 	
  
-}
\ No newline at end of file
+}
diff --git a/src/tmltranslator/TMLCPLib.java b/src/tmltranslator/TMLCPLib.java
index 6d4363cf5b61e5f5a068a8cc1f5cd02df446b348..e780680e1a099ad7ebd1db38b5db24fa81b4df3f 100755
--- a/src/tmltranslator/TMLCPLib.java
+++ b/src/tmltranslator/TMLCPLib.java
@@ -57,6 +57,7 @@ public class TMLCPLib extends TMLElement {
 		private CPMEC cpMEC;
     private String typeName;
 		private Vector<String> assignedAttributes;
+		private ArrayList<Integer> transferTypes;
 
 
     public TMLCPLib(String _name, String _typeName, Object _referenceObject, CPMEC _cpMEC ) {
@@ -128,4 +129,12 @@ public class TMLCPLib extends TMLElement {
 	public Vector<String> getAssignedAttributes()	{
 		return assignedAttributes;
 	}
+
+	public void setTransferTypes( ArrayList<Integer> _transferTypes )	{
+		transferTypes = _transferTypes;
+	}
+
+	public ArrayList<Integer> getTransferTypes()	{
+		return transferTypes;
+	}
 }       //End of the class
diff --git a/src/tmltranslator/ctranslator/CPMEC.java b/src/tmltranslator/ctranslator/CPMEC.java
index 75fd80a0d1fe5c3d4e10d56c65f46371a7c4b3ae..5e9dbec05664c1ef6f29b2db1b209bf4a7dbc175 100755
--- a/src/tmltranslator/ctranslator/CPMEC.java
+++ b/src/tmltranslator/ctranslator/CPMEC.java
@@ -67,9 +67,17 @@ public abstract class CPMEC	{
 	public String cleanup_code = new String();
 
 	public static final String[] cpTypes = { "Memory Copy", "Single DMA", "Double DMA" };
+	public static final String[] transferTypes = { "memory to IP core", "IP core to IP core", "IP core to memory" };
 	public static final String SingleDMA = "Single DMA";
 	public static final String DoubleDMA = "Double DMA";
 	public static final String MemoryCopy = "Memory Copy";
+	public static final int mem2IP = 0;
+	public static final int IP2IP = 1;
+	public static final int IP2mem = 2;
+
+	public static final String dmaController = "DMA_Controller";
+	public static final String sourceStorage = "Src_Storage_Instance";
+	public static final String destinationStorage = "Dst_Storage_Instance";
 
 	public CPMEC()	{
 		node_type = "1";
diff --git a/src/tmltranslator/ctranslator/CpuLoadMEC.java b/src/tmltranslator/ctranslator/CpuLoadMEC.java
deleted file mode 100644
index cbed78d035b2713ad9c6a42985540755e04a8e0e..0000000000000000000000000000000000000000
--- a/src/tmltranslator/ctranslator/CpuLoadMEC.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille, Andrea Enrici
-
-   ludovic.apvrille AT enst.fr
-   andrea.enrici AT enstr.fr
-
-   This software is a computer program whose purpose is to allow the
-   edition of TURTLE analysis, design and deployment diagrams, to
-   allow the generation of RT-LOTOS or Java code from this diagram,
-   and at last to allow the analysis of formal validation traces
-   obtained from external tools, e.g. RTL from LAAS-CNRS and CADP
-   from INRIA Rhone-Alpes.
-
-   This software is governed by the CeCILL  license under French law and
-   abiding by the rules of distribution of free software.  You can  use,
-   modify and/ or redistribute the software under the terms of the CeCILL
-   license as circulated by CEA, CNRS and INRIA at the following URL
-   "http://www.cecill.info".
-
-   As a counterpart to the access to the source code and  rights to copy,
-   modify and redistribute granted by the license, users are provided only
-   with a limited warranty  and the software's author,  the holder of the
-   economic rights,  and the successive licensors  have only  limited
-   liability.
-
-   In this respect, the user's attention is drawn to the risks associated
-   with loading,  using,  modifying and/or developing or reproducing the
-   software by the user in light of its specific status of free software,
-   that may mean  that it is complicated to manipulate,  and  that  also
-   therefore means  that it is reserved for developers  and  experienced
-   professionals having in-depth computer knowledge. Users are therefore
-   encouraged to load and test the software's suitability as regards their
-   requirements in conditions enabling the security of their systems and/or
-   data to be ensured and,  more generally, to use and operate it in the
-   same conditions as regards security.
-
-   The fact that you are presently reading this means that you have had
-   knowledge of the CeCILL license and that you accept its terms.
-
-   /**
-   * Class CpuLoadMEC, Model Extension Construct (MEC) class for Embb non-cachable CPU load operation
-   * Creation: 05/02/2014
-   * @version 1.0 05/02/2014
-   * @author Andrea ENRICI
-   * @see
-   */
-
-package tmltranslator.ctranslator;;
-
-import java.util.*;
-
-public class CpuLoadMEC extends CPMEC	{
-
-	protected String addr = "";
-
-	public CpuLoadMEC()	{
-		node_type = "CPU";
-		inst_type = "LOAD";
-		inst_decl = "VOID";
-		buff_type = "MM_BUFF_TYPE";
-		buff_init = "VOID";
-	}
-
-}	//End of class
diff --git a/src/tmltranslator/ctranslator/CpuMemoryCopyMEC.java b/src/tmltranslator/ctranslator/CpuMemoryCopyMEC.java
index 1b052409cb42a1e0ec7e69b700a82fc49a251816..86f7c3ad44581cd2e4eadd8f25fe320570f137c0 100644
--- a/src/tmltranslator/ctranslator/CpuMemoryCopyMEC.java
+++ b/src/tmltranslator/ctranslator/CpuMemoryCopyMEC.java
@@ -70,4 +70,21 @@ public class CpuMemoryCopyMEC extends CPMEC	{
 		cleanup_code = TAB + "embb_memcpy_ctx_cleanup(&" + ctxName + ");";
 	}
 
+	public CpuMemoryCopyMEC( String pssBaseAddress, String offset, String ddrAddress, String size )	{
+		node_type = "CpuMemoryCopy";
+		inst_type = "MEMORY_COPY";
+		inst_decl = "VOID";
+		buff_type = "MM_BUFFER_TYPE";
+		buff_init = "VOID";
+
+		exec_code = TAB + CR + TAB +
+								"int i = 0;" + CR + TAB +
+								"int k = 0;" + CR + TAB +
+								"for( i = 0 ;i < " + size + "; i += 4, k++ )\t{" + CR + TAB +
+								TAB + "cpu_mem_write_32( " + pssBaseAddress + " + " + offset + " + i, " + ddrAddress + "[k] );" + CR + TAB + "}" + CR;
+
+		//init_code = TAB + "embb_memcpy_ctx_init(&" + ctxName + ");" + CR;
+		//cleanup_code = TAB + "embb_memcpy_ctx_cleanup(&" + ctxName + ");";
+	}
+
 }	//End of class
diff --git a/src/tmltranslator/ctranslator/CpuStoreMEC.java b/src/tmltranslator/ctranslator/CpuStoreMEC.java
deleted file mode 100644
index e604749fe87d8f2e614025b7919b6048d3d5070a..0000000000000000000000000000000000000000
--- a/src/tmltranslator/ctranslator/CpuStoreMEC.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille, Andrea Enrici
-
-   ludovic.apvrille AT enst.fr
-   andrea.enrici AT enstr.fr
-
-   This software is a computer program whose purpose is to allow the
-   edition of TURTLE analysis, design and deployment diagrams, to
-   allow the generation of RT-LOTOS or Java code from this diagram,
-   and at last to allow the analysis of formal validation traces
-   obtained from external tools, e.g. RTL from LAAS-CNRS and CADP
-   from INRIA Rhone-Alpes.
-
-   This software is governed by the CeCILL  license under French law and
-   abiding by the rules of distribution of free software.  You can  use,
-   modify and/ or redistribute the software under the terms of the CeCILL
-   license as circulated by CEA, CNRS and INRIA at the following URL
-   "http://www.cecill.info".
-
-   As a counterpart to the access to the source code and  rights to copy,
-   modify and redistribute granted by the license, users are provided only
-   with a limited warranty  and the software's author,  the holder of the
-   economic rights,  and the successive licensors  have only  limited
-   liability.
-
-   In this respect, the user's attention is drawn to the risks associated
-   with loading,  using,  modifying and/or developing or reproducing the
-   software by the user in light of its specific status of free software,
-   that may mean  that it is complicated to manipulate,  and  that  also
-   therefore means  that it is reserved for developers  and  experienced
-   professionals having in-depth computer knowledge. Users are therefore
-   encouraged to load and test the software's suitability as regards their
-   requirements in conditions enabling the security of their systems and/or
-   data to be ensured and,  more generally, to use and operate it in the
-   same conditions as regards security.
-
-   The fact that you are presently reading this means that you have had
-   knowledge of the CeCILL license and that you accept its terms.
-
-   /**
-   * Class CpuStoreMEC, Model Extension Construct (MEC) class for Embb non-cachable CPU store operation
-   * Creation: 06/02/2014
-   * @version 1.0 06/02/2014
-   * @author Andrea ENRICI
-   * @see
-   */
-
-package tmltranslator.ctranslator;;
-
-import java.util.*;
-
-public class CpuStoreMEC extends CPMEC	{
-
-	/*protected String addr = "";
-	protected String word = "";*/
-
-	public CpuStoreMEC()	{
-		node_type = "CPU";
-		inst_type = "STORE";
-		inst_decl = "VOID";
-		buff_type = "MM_BUFF_TYPE";
-		buff_init = "VOID";
-	}
-}	//End of class
diff --git a/src/tmltranslator/ctranslator/DoubleDmaMEC.java b/src/tmltranslator/ctranslator/DoubleDmaMEC.java
index 3558ff79021d76f8b0b091cc0f4556ddaabe4a34..dc4b44979c0a2a03e9aa54c517f7492e1f2e120d 100755
--- a/src/tmltranslator/ctranslator/DoubleDmaMEC.java
+++ b/src/tmltranslator/ctranslator/DoubleDmaMEC.java
@@ -68,6 +68,8 @@ public class DoubleDmaMEC extends CPMEC	{
 	public static final String sourceAddress2 = "sourceAddress2";
 	public static final String counter2 = "counter2";
 
+	private String memoryBaseAddress = "0";
+
 	public DoubleDmaMEC( String ctxName )	{
 
 		node_type = "DoubleDmaMEC";
@@ -80,30 +82,68 @@ public class DoubleDmaMEC extends CPMEC	{
 		cleanup_code = TAB + "embb_dma_ctx_cleanup(&" + ctxName + ");";
 	}
 
-	public DoubleDmaMEC( String ctxName, ArchUnitMEC archMEC )	{
+	public DoubleDmaMEC( String ctxName, ArchUnitMEC archMEC, int srcMemoryType, int dstMemoryType, int transferType, String sizeString )	{
 
 		node_type = "DoubleDmaMEC";
 		inst_type = "VOID";
 		inst_decl = "EMBB_DMA_CONTEXT";
 		buff_type = "MM_BUFFER_TYPE";
 		buff_init = "VOID";
-		exec_code = TAB + "embb_dma_start(&" + ctxName + ", /*USER TO DO: SRC_ADDRESS*/, /*USER TO DO: DST_ADDRESS*/, /*USER TO DO: NUM_SAMPLES */ );" + CR;	
-		init_code = TAB + archMEC.getCtxInitCode() + "(&" + ctxName + ", " + "(uintptr_t) " + archMEC.getLocalMemoryPointer() + " );" + CR;
-		cleanup_code = TAB + archMEC.getCtxCleanupCode() + "(&" + ctxName + ");";
-	}
 
-	public DoubleDmaMEC( String ctxName, String destinationAddress1, String sourceAddress1, String size1, String destinationAddress2, String sourceAddress2, String size2 )	{
-
-		node_type = "DoubleDmaMEC";
-		inst_type = "VOID";
-		inst_decl = "EMBB_DMA_CONTEXT";
-		buff_type = "MM_BUFFER_TYPE";
-		buff_init = "VOID";
-		exec_code = TAB + "embb_dma_start(&" + ctxName + ", (uintptr_t) " + sourceAddress1 + ", (uintptr_t) " + destinationAddress1 + ", (size_t) " + size1 + " );" + CR;	
-		exec_code += TAB + "embb_dma_start(&" + ctxName + ", (uintptr_t) " + sourceAddress2 + ", (uintptr_t) " + destinationAddress2 + ", (size_t) " + size2 + " );" + CR;	
-		init_code = TAB + "embb_dma_ctx_init(&" + ctxName + ", /*USER TO DO: DMA_DEVICE*/, /*USER TO DO: DST_DEV*/, NULL );" + CR;
-		init_code += TAB + "embb_dma_ctx_init(&" + ctxName + ", /*USER TO DO: DMA_DEVICE*/, /*USER TO DO: DST_DEV*/, NULL );" + CR;
-		cleanup_code = TAB + "embb_dma_ctx_cleanup(&" + ctxName + ");";
+		switch( srcMemoryType )	{
+			case Buffer.FepBuffer:
+				memoryBaseAddress = "fep_mss";
+				break;
+			case Buffer.AdaifBuffer:
+				memoryBaseAddress = "adaif_mss";
+			break;
+			case Buffer.InterleaverBuffer:
+				memoryBaseAddress = "intl_mss";
+			break;
+			case Buffer.MapperBuffer:
+				memoryBaseAddress = "mapper_mss";
+			break;
+			case Buffer.MainMemoryBuffer:
+				memoryBaseAddress = "0";
+			break;
+			default:
+				memoryBaseAddress = "0";
+			break;
+		}
+
+		switch( transferType )	{
+			case CPMEC.mem2IP:
+				exec_code = TAB + "embb_mem2ip(&" + ctxName + ", (uintptr_t) " + memoryBaseAddress + ", /*USER TODO: *SRC */, " + sizeString + " );" + CR;	
+				init_code = TAB + archMEC.getCtxInitCode() + "(&" + ctxName + ", " + "(uintptr_t) " + memoryBaseAddress + " );" + CR;
+				cleanup_code = TAB + archMEC.getCtxCleanupCode() + "(&" + ctxName + ");";
+			break;
+			case CPMEC.IP2mem:
+				exec_code = TAB + "embb_ip2mem( /* USER TODO: *DST */, &" + ctxName + ", (uintptr_t) " + memoryBaseAddress + ", " + sizeString + " );" + CR;	
+				init_code = TAB + archMEC.getCtxInitCode() + "(&" + ctxName + ", " + "(uintptr_t) " + memoryBaseAddress + " );" + CR;
+				cleanup_code = TAB + archMEC.getCtxCleanupCode() + "(&" + ctxName + ");";
+			break;
+			case CPMEC.IP2IP:
+				exec_code = TAB + "embb_ip2ip(&" + ctxName + "_0, (uintptr_t) " + memoryBaseAddress + ", &" + ctxName + "_1, (uintptr_t) " + memoryBaseAddress + ", " + sizeString + " );" + CR;	
+				init_code = TAB + archMEC.getCtxInitCode() + "(&" + ctxName + "_0, " + "(uintptr_t) " + memoryBaseAddress + " );" + CR;
+				init_code += TAB + archMEC.getCtxInitCode() + "(&" + ctxName + "_1, " + "(uintptr_t) " + memoryBaseAddress + " );" + CR;
+				cleanup_code = TAB + archMEC.getCtxCleanupCode() + "(&" + ctxName + "_0);";
+				cleanup_code = TAB + archMEC.getCtxCleanupCode() + "(&" + ctxName + "_1);";
+			break;
+		}
 	}
 
+//	public DoubleDmaMEC( String ctxName, String destinationAddress1, String sourceAddress1, String size1, String destinationAddress2, String sourceAddress2, String size2 )	{
+//
+//		node_type = "DoubleDmaMEC";
+//		inst_type = "VOID";
+//		inst_decl = "EMBB_DMA_CONTEXT";
+//		buff_type = "MM_BUFFER_TYPE";
+//		buff_init = "VOID";
+//		exec_code = TAB + "embb_dma_start(&" + ctxName + ", (uintptr_t) " + sourceAddress1 + ", (uintptr_t) " + destinationAddress1 + ", (size_t) " + size1 + " );" + CR;	
+//		exec_code += TAB + "embb_dma_start(&" + ctxName + ", (uintptr_t) " + sourceAddress2 + ", (uintptr_t) " + destinationAddress2 + ", (size_t) " + size2 + " );" + CR;	
+//		init_code = TAB + "embb_dma_ctx_init(&" + ctxName + ", /*USER TO DO: DMA_DEVICE*/, /*USER TO DO: DST_DEV*/, NULL );" + CR;
+//		init_code += TAB + "embb_dma_ctx_init(&" + ctxName + ", /*USER TO DO: DMA_DEVICE*/, /*USER TO DO: DST_DEV*/, NULL );" + CR;
+//		cleanup_code = TAB + "embb_dma_ctx_cleanup(&" + ctxName + ");";
+//	}
+
 }	//End of class
diff --git a/src/tmltranslator/ctranslator/Signal.java b/src/tmltranslator/ctranslator/Signal.java
index 1ca0f66c1a83a7e026e0103a6a7463f94cfb4b63..04642b96772e472ed8ba99c7ce6d15bc13ff0f63 100755
--- a/src/tmltranslator/ctranslator/Signal.java
+++ b/src/tmltranslator/ctranslator/Signal.java
@@ -62,7 +62,7 @@ public class Signal	{
 	private String buffPointer_s = "void *pBuff" + SC + CR;
 	private Buffer buffPointer = null;
 	
-	public static final String DECLARATION = "struct SIG_TYPE	{\n\tbool f;\n\tvoid *pBuff;\n};\n\ntypedef struct SIG_TYPE SIG_TYPE;";
+	public static final String DECLARATION = "struct SIG_TYPE	{\n\tbool f;\n\tvoid *pBuff;\n};\n\ntypedef struct SIG_TYPE SIG_TYPE;\nextern SIG_TYPE sig[];\n\n";
 
 	private String name;
 	private TMLChannel channel;
diff --git a/src/tmltranslator/ctranslator/SingleDmaMEC.java b/src/tmltranslator/ctranslator/SingleDmaMEC.java
index 3d169a00e53cfd7fce106c2f5a32819958a3be4c..53bc09a6152a6aec448748d6a77e33561c82b9b8 100755
--- a/src/tmltranslator/ctranslator/SingleDmaMEC.java
+++ b/src/tmltranslator/ctranslator/SingleDmaMEC.java
@@ -47,12 +47,10 @@
 package tmltranslator.ctranslator;;
 
 import java.util.*;
+import myutil.*;
 
 public class SingleDmaMEC extends CPMEC	{
 
-	public static final String Context = "EMBB_CONTEXT";
-	public static final String Ctx_cleanup = "dma_ctx_cleanup";
-
 	public static final int MaxParameters = 3;
 	public static final int destinationAddressIndex = 0;
 	public static final int sourceAddressIndex = 1;
@@ -62,6 +60,8 @@ public class SingleDmaMEC extends CPMEC	{
 	public static final String sourceAddress = "sourceAddress";
 	public static final String counter = "counter";
 
+	private String memoryBaseAddress = "0";
+
 	public SingleDmaMEC( String ctxName )	{
 
 		node_type = "SingleDmaMEC";
@@ -71,32 +71,78 @@ public class SingleDmaMEC extends CPMEC	{
 		buff_init = "VOID";
 	}
 
-	public SingleDmaMEC( String ctxName, ArchUnitMEC archMEC )	{
+	public SingleDmaMEC( String ctxName, ArchUnitMEC archMEC, int srcMemoryType, int dstMemoryType, int transferType, String sizeString )	{
 
 		node_type = "SingleDmaMEC";
 		inst_type = "VOID";
 		inst_decl = "EMBB_DMA_CONTEXT";
 		buff_type = "MM_BUFFER_TYPE";
 		buff_init = "VOID";
-		exec_code = TAB + "embb_dma_start(&" + ctxName + ", (uintptr_t) /*USER TO DO: SRC_ADDRESS*/, (uintptr_t) /*USER TO DO: DST_ADDRESS*/, /*USER TO DO: NUM_SAMPLES */ );" + CR;	
-		init_code = TAB + archMEC.getCtxInitCode() + "(&" + ctxName + ", " + "(uintptr_t) " + archMEC.getLocalMemoryPointer() + " );" + CR;
-		cleanup_code = TAB + archMEC.getCtxCleanupCode() + "(&" + ctxName +");";
-	}
-	
-	public SingleDmaMEC( String ctxName, String destinationAddress, String sourceAddress, String size )	{
 
-		node_type = "SingleDmaMEC";
-		inst_type = "VOID";
-		inst_decl = "EMBB_DMA_CONTEXT";
-		buff_type = "MM_BUFFER_TYPE";
-		buff_init = "VOID";
-		exec_code = TAB + "embb_dma_start(&" + ctxName + ", (uintptr_t) " + sourceAddress + ", (uintptr_t) " + destinationAddress + ", (size_t) " + size + " );" + CR;	
-		init_code = TAB + "embb_dma_ctx_init(&" + ctxName + ", /*USER TO DO: DMA_DEVICE*/, /*USER TO DO: DST_DEV*/, NULL );" + CR;
-		cleanup_code = TAB + "embb_dma_ctx_cleanup(&" + ctxName +");";
+		switch( srcMemoryType )	{
+			case Buffer.FepBuffer:
+				memoryBaseAddress = "fep_mss";
+				break;
+			case Buffer.AdaifBuffer:
+				memoryBaseAddress = "adaif_mss";
+			break;
+			case Buffer.InterleaverBuffer:
+				memoryBaseAddress = "intl_mss";
+			break;
+			case Buffer.MapperBuffer:
+				memoryBaseAddress = "mapper_mss";
+			break;
+			case Buffer.MainMemoryBuffer:
+				memoryBaseAddress = "0";
+			break;
+			default:
+				memoryBaseAddress = "0";
+			break;
+		}
+
+		switch( transferType )	{
+			case CPMEC.mem2IP:
+				exec_code = TAB + "embb_mem2ip(&" + ctxName + ", (uintptr_t) " + memoryBaseAddress + ", /*USER TODO: *SRC */, " + sizeString + " );" + CR;
+				init_code = TAB + archMEC.getCtxInitCode() + "(&" + ctxName + ", " + "(uintptr_t) " + archMEC.getLocalMemoryPointer() + " );" + CR;
+				cleanup_code = TAB + archMEC.getCtxCleanupCode() + "(&" + ctxName +");";
+			break;
+			case CPMEC.IP2mem:
+				exec_code = TAB + "embb_ip2mem( /* USER TODO: *DST */, &" + ctxName + ", (uintptr_t) " + memoryBaseAddress + ", " + sizeString + " );" + CR;	
+				init_code = TAB + archMEC.getCtxInitCode() + "(&" + ctxName + ", " + "(uintptr_t) " + archMEC.getLocalMemoryPointer() + " );" + CR;
+				cleanup_code = TAB + archMEC.getCtxCleanupCode() + "(&" + ctxName +");";
+			break;
+			case CPMEC.IP2IP:
+				exec_code = TAB + "embb_ip2ip(&" + ctxName + "_0, (uintptr_t) " + memoryBaseAddress + ", &" + ctxName + "_1, (uintptr_t) " + memoryBaseAddress + ", " + sizeString + " );" + CR;	
+				init_code = TAB + archMEC.getCtxInitCode() + "(&" + ctxName + "_0, " + "(uintptr_t) " + archMEC.getLocalMemoryPointer() + " );" + CR;
+				init_code += TAB + archMEC.getCtxInitCode() + "(&" + ctxName + "_1, " + "(uintptr_t) " + archMEC.getLocalMemoryPointer() + " );" + CR;
+				cleanup_code = TAB + archMEC.getCtxCleanupCode() + "(&" + ctxName +"_0);";
+				cleanup_code += TAB + archMEC.getCtxCleanupCode() + "(&" + ctxName +"_1);";
+			break;
+			default:
+				exec_code = TAB + "embb_mem2ip(&" + ctxName + ", (uintptr_t) " + memoryBaseAddress + ", /*USER TODO: *SRC */, " + sizeString + " );" + CR;
+			break;
+		}
+
 	}
+	
+//	public SingleDmaMEC( String ctxName, String destinationAddress, String sourceAddress, String size )	{
+//
+//		node_type = "SingleDmaMEC";
+//		inst_type = "VOID";
+//		inst_decl = "EMBB_DMA_CONTEXT";
+//		buff_type = "MM_BUFFER_TYPE";
+//		buff_init = "VOID";
+//		exec_code = TAB + "embb_dma_start(&" + ctxName + ", (uintptr_t) " + sourceAddress + ", (uintptr_t) " + destinationAddress + ", (size_t) " + size + " );" + CR;	
+//		init_code = TAB + "embb_dma_ctx_init(&" + ctxName + ", /*USER TO DO: DMA_DEVICE*/, /*USER TO DO: DST_DEV*/, NULL );" + CR;
+//		cleanup_code = TAB + "embb_dma_ctx_cleanup(&" + ctxName +");";
+//	}
 
 	public String getInitCode()	{
 		return init_code;
 	}
 
+	public String getCleanupCode()	{
+		return cleanup_code;
+	}
+
 }	//End of class
diff --git a/src/tmltranslator/ctranslator/TMLCCodeGeneration.java b/src/tmltranslator/ctranslator/TMLCCodeGeneration.java
index fb269518afe4aeb05b0350e219e867bd90f540c0..ed85f085604bf9a4edee615ea5cf3f2ff5dc47e0 100755
--- a/src/tmltranslator/ctranslator/TMLCCodeGeneration.java
+++ b/src/tmltranslator/ctranslator/TMLCCodeGeneration.java
@@ -210,8 +210,6 @@ public class TMLCCodeGeneration	{
 				String xTaskName = xTask.getName().split( "__" )[1].split( "X_" )[1];
 				if( xTaskName.equals( fTaskName ) )	{
 					//Mind that signals are based on channels NOT on events!
-					TraceManager.addDev( "TASK " + xTask.getName() );
-					//TraceManager.addDev( xTask.getTMLChannels().toString() );
 					prexPostexList = getPrexPostex( xTask );
 					inSignals = getInSignals( xTask );	//is null for Source operation
 					outSignal = getOutSignal( xTask );	//is null for Sink operation
@@ -568,16 +566,15 @@ public class TMLCCodeGeneration	{
 		int counter = 0;
 		for( Operation op: operationsList )	{
 			Signal sig = op.getOutSignal();	//operations have one and only one outSignal
-			if( sig != null){
-			TraceManager.addDev( "Checking if signal " + sig.getName() + " is contained in " + outSignals.toString() );
-			if( outSignals.contains( sig ) )	{
-				counter++;
-			}
-			if( counter == outSignals.size() )	{
-				return op;
+			if( sig != null)	{
+				if( outSignals.contains( sig ) )	{
+					counter++;
+				}
+				if( counter == outSignals.size() )	{
+					return op;
+				}
+				counter = 0;
 			}
-			counter = 0;
-		}
 		}
 		return null;
 	}
@@ -773,43 +770,66 @@ public class TMLCCodeGeneration	{
 			}
 		}
 		instructionsString.append( CR2 + "/**** Data Transfers Instructions ****/" + CR );
-		ArchUnitMEC archMEC = new CpuMEC();
+		ArchUnitMEC dmaArchMEC = new CpuMEC();
 		for( DataTransfer dt: dataTransfersList )	{
 			TMLCPLib tmlcplib = dt.getTMLCPLib();
 			CPMEC cpMEC = tmlcplib.getCPMEC();
 			ctxName = dt.getContextName();
-			if( cpMEC instanceof CpuMemoryCopyMEC )	{
-				if( declaration )	{
-					instructionsString.append( "extern" + SP + archMEC.getContext() + SP + ctxName + SC + CR );
-				}
-				else	{	instructionsString.append( archMEC.getContext() + SP + ctxName + SC + CR );	}
-			}
 			if( cpMEC instanceof SingleDmaMEC )	{
-				for( String s: tmlcplib.getMappedUnits() )	{
-					if( s.contains( "DMA_Controller" ) )	{
+				int transferType = tmlcplib.getTransferTypes().get(0);
+			for( String s: tmlcplib.getMappedUnits() )	{
+					if( s.contains( CPMEC.dmaController ) )	{
 						String dmaUnit = s.split(":")[1].replaceAll("\\s+","");
-						archMEC = tmla.getHwCPUByName( dmaUnit ).MEC;
+						dmaArchMEC = tmla.getHwCPUByName( dmaUnit ).MEC;
 						break;
 					}
 				}
 				if( declaration )	{
-					instructionsString.append( "extern" + SP + archMEC.getContext() + SP + ctxName + SC + CR );
+					if( transferType == CPMEC.IP2IP )	{	//there are two contexts to declare
+						instructionsString.append( "extern" + SP + dmaArchMEC.getContext() + SP + ctxName + "_1" + SC + CR );
+						instructionsString.append( "extern" + SP + dmaArchMEC.getContext() + SP + ctxName + "_0" + SC + CR );
+					}
+					else	{
+						instructionsString.append( "extern" + SP + dmaArchMEC.getContext() + SP + ctxName + SC + CR );
+					}
 				}
 				else	{
-					instructionsString.append( archMEC.getContext() + SP + ctxName + SC + CR );
+					if( transferType == CPMEC.IP2IP )	{	//there are two contexts to declare
+						instructionsString.append( dmaArchMEC.getContext() + SP + ctxName + "_0" + SC + CR );
+						instructionsString.append( dmaArchMEC.getContext() + SP + ctxName + "_1" + SC + CR );
+					}
+					else	{
+						instructionsString.append( dmaArchMEC.getContext() + SP + ctxName + SC + CR );
+					}
 				}
 			}
 			if( cpMEC instanceof DoubleDmaMEC )	{
+				int suffix = 0;
 				for( String s: tmlcplib.getMappedUnits() )	{
-					if( s.contains( "DMA_Controller" ) )	{
+					ArrayList<Integer> transferTypes = tmlcplib.getTransferTypes();
+					if( s.contains( CPMEC.dmaController ) )	{
+						int transferType = tmlcplib.getTransferTypes().get(suffix);
 						String dmaUnit = s.split(":")[1].replaceAll("\\s+","");
-						archMEC = tmla.getHwCPUByName( dmaUnit ).MEC;
+						dmaArchMEC = tmla.getHwCPUByName( dmaUnit ).MEC;
 						if( declaration )	{
-							instructionsString.append( "extern" + SP + archMEC.getContext() + SP + ctxName + SC + CR );
+							if( transferType == CPMEC.IP2IP )	{	//there are two contexts to declare
+								instructionsString.append( "extern" + SP + dmaArchMEC.getContext() + SP + ctxName + "_" + String.valueOf(suffix) + "_0" + SC + CR );
+								instructionsString.append( "extern" + SP + dmaArchMEC.getContext() + SP + ctxName + "_" + String.valueOf(suffix) + "_1" + SC + CR );
+							}
+							else	{
+								instructionsString.append( "extern" + SP + dmaArchMEC.getContext() + SP + ctxName + "_" + String.valueOf(suffix) + SC + CR );
+							}
 						}
 						else	{
-							instructionsString.append( archMEC.getContext() + SP + ctxName + SC + CR );
+							if( transferType == CPMEC.IP2IP )	{	//there are two contexts to declare
+								instructionsString.append( dmaArchMEC.getContext() + SP + ctxName + "_" + String.valueOf(suffix) + "_0" + SC + CR );
+								instructionsString.append( dmaArchMEC.getContext() + SP + ctxName + "_" + String.valueOf(suffix) + "_1" + SC + CR );
+							}
+							else	{
+								instructionsString.append( dmaArchMEC.getContext() + SP + ctxName + "_" + String.valueOf(suffix) + SC + CR );
+							}
 						}
+						suffix++;
 					}
 				}
 			}
@@ -845,7 +865,7 @@ public class TMLCCodeGeneration	{
 		s.append( InterleaverBuffer.DECLARATION + CR2 );
 		s.append( MMBuffer.DECLARATION + CR2 );
 		s.append( AdaifBuffer.DECLARATION + CR );
-		s.append( "extern SIG_TYPE sig[];" + CR2 );
+
 		return s.toString();
 	}
 
@@ -896,11 +916,6 @@ public class TMLCCodeGeneration	{
 		for( TMLPort port: prexList )	{
 			s.append( TAB + "sig[ " + port.getName() +" ].f = false;" + CR );
 		}
-		/*for( Operation op: operationsList )	{
-			if( op.isPrex() )	{
-				s.append( TAB + "op_" + op.getName() + "()" + SC + CR );
-			}
-		}*/
 		return s.toString();
 	}
 
@@ -1042,7 +1057,6 @@ public class TMLCCodeGeneration	{
 			TMLWriteChannel ch = task.getWriteChannels().get(0);
 			String signalName = ch.toString().split("__")[1];
 			if( signalsList.contains( signalName + "_CPin" ) )	{
-				TraceManager.addDev( "Task " + task.getName() + ", OUT signal: " + signalName );
 				s = signalName;
 			}
 			else	{
@@ -1060,7 +1074,6 @@ public class TMLCCodeGeneration	{
 			TMLReadChannel ch = task.getReadChannels().get(0);
 			String signalName = ch.toString().split("__")[1];
 			if( signalsList.contains( signalName + "_CPin" ) )	{
-				TraceManager.addDev( "Task " + task.getName() + ", IN signal: " + signalName );
 				s = signalName;
 			}
 			else	{
@@ -1073,49 +1086,60 @@ public class TMLCCodeGeneration	{
 
 	private void generateCodeForCommunicationPatterns()	{
 		
-		String s;
+		int srcMemoryType = 0, dstMemoryType = 0;
 		String destinationAddress, sourceAddress, counter;
 		String destinationAddress1, sourceAddress1, counter1;
 		String destinationAddress2, sourceAddress2, counter2;
 		TMLCPLib tmlcplib;
-		String ctxName;
+		String s, ctxName;
 		Vector<String> attributes;
+		ArchUnitMEC dmaArchMEC = new CpuMEC();
 
 		for( DataTransfer dt: dataTransfersList )	{
 			tmlcplib = dt.getTMLCPLib();
 			ctxName = dt.getContextName();
 			attributes = tmlcplib.getAssignedAttributes();
 			String name = tmlcplib.getName().split("::")[0];
-			programString.append( "int op_" + name + "()\t{" + CR );
-			programString.append( TAB + "int status = 0;" + CR );
+			programString.append( "int op_" + name + "()\t{" + CR + TAB + "int status = 0;" + CR );
 			
 			for( Signal sig: dt.getInSignals() )	{
 				programString.append( TAB + "sig[ " + sig.getName() + " ].f = false;" + CR );
 			}
 			CPMEC cpMEC = tmlcplib.getCPMEC();
-			TraceManager.addDev( "CPMEC: " + cpMEC + "\n" + attributes.toString() );
 			if( cpMEC instanceof CpuMemoryCopyMEC )	{
-				CpuMemoryCopyMEC mec = new CpuMemoryCopyMEC( ctxName, "", "", "", "" );
-				programString.append( "/*" + mec.getExecCode() + "*/" );
+				CpuMemoryCopyMEC mec = new CpuMemoryCopyMEC( "", "", "", "" );
+				programString.append( mec.getExecCode() );
 			}
 			if( cpMEC instanceof SingleDmaMEC )	{
-				destinationAddress = attributes.get( SingleDmaMEC.destinationAddressIndex );
-				sourceAddress = attributes.get( SingleDmaMEC.sourceAddressIndex );
+				int transferType = tmlcplib.getTransferTypes().get(0);
+				for( String s1: tmlcplib.getMappedUnits() )	{
+					if( s1.contains( CPMEC.dmaController ) )	{
+						String dmaUnit = s1.split(":")[1].replaceAll("\\s+","");
+						dmaArchMEC = tmla.getHwCPUByName( dmaUnit ).MEC;
+					}
+					if( s1.contains( CPMEC.sourceStorage ) )	{
+						String memoryUnit = s1.split(":")[1].replaceAll("\\s+","");
+						srcMemoryType = tmla.getHwMemoryByName( memoryUnit ).BufferType;
+					}
+					if( s1.contains( CPMEC.destinationStorage ) )	{
+						String memoryUnit = s1.split(":")[1].replaceAll("\\s+","");
+						dstMemoryType = tmla.getHwMemoryByName( memoryUnit ).BufferType;
+					}
+				}
 				counter = attributes.get( SingleDmaMEC.counterIndex );
-				SingleDmaMEC mec = new SingleDmaMEC( ctxName, destinationAddress, sourceAddress, counter );
-				programString.append( "/*" + mec.getExecCode() + "*/" );
+				SingleDmaMEC mec = new SingleDmaMEC( ctxName, dmaArchMEC, srcMemoryType, dstMemoryType, transferType, counter );
+				programString.append( mec.getExecCode() );
 			}
 			if( cpMEC instanceof DoubleDmaMEC )	{
-				destinationAddress1 = attributes.get( DoubleDmaMEC.destinationAddress1Index );
-				sourceAddress1 = attributes.get( DoubleDmaMEC.sourceAddress1Index );
-				counter1 = attributes.get( DoubleDmaMEC.counter1Index );
-				destinationAddress2 = attributes.get( DoubleDmaMEC.destinationAddress2Index );
-				sourceAddress2 = attributes.get( DoubleDmaMEC.sourceAddress2Index );
-				counter2 = attributes.get( DoubleDmaMEC.counter2Index );
-				DoubleDmaMEC mec = new DoubleDmaMEC( ctxName, destinationAddress1, sourceAddress1, counter1, destinationAddress2, sourceAddress2, counter2 );
-				programString.append( "/*" + mec.getExecCode() + "*/" );
+				ArrayList<Integer> transferTypes = tmlcplib.getTransferTypes();
+				ArrayList<String> sizes = new ArrayList<String>();
+				sizes.add( attributes.get( DoubleDmaMEC.counter1Index ) );
+				sizes.add( attributes.get( DoubleDmaMEC.counter2Index ) );
+				for( int i = 0; i < 2; i++ )	{
+					DoubleDmaMEC mec = getDoubleDmaMEC( tmlcplib, i, ctxName, sizes, transferTypes );
+					programString.append( mec.getExecCode() );
+				}
 			}
-
 			for( Signal sig: dt.getOutSignals() )	{
 				programString.append( TAB + "sig[ " + sig.getName() + " ].f = true;" + CR );
 			}
@@ -1123,6 +1147,29 @@ public class TMLCCodeGeneration	{
 		}
 	}
 
+	private DoubleDmaMEC getDoubleDmaMEC( TMLCPLib tmlcplib, int iteration, String ctxName, ArrayList<String> sizes, ArrayList<Integer> transferTypes )	{
+
+		int srcMemoryType = 0, dstMemoryType = 0;
+		ArchUnitMEC dmaArchMEC = new CpuMEC();
+
+		for( String s1: tmlcplib.getMappedUnits() )	{	//there are two DMA_controllers
+			if( s1.contains( CPMEC.dmaController + "_" + String.valueOf(iteration) ) )	{
+				String dmaUnit = s1.split(":")[1].replaceAll("\\s+","");
+				dmaArchMEC = tmla.getHwCPUByName( dmaUnit ).MEC;
+			}
+			if( s1.contains( CPMEC.sourceStorage + "_" + String.valueOf(iteration) ) )	{
+				String memoryUnit = s1.split(":")[1].replaceAll("\\s+","");
+				srcMemoryType = tmla.getHwMemoryByName( memoryUnit ).BufferType;
+			}
+			if( s1.contains( CPMEC.destinationStorage + "_" + String.valueOf(iteration) ) )	{
+				String memoryUnit = s1.split(":")[1].replaceAll("\\s+","");
+				dstMemoryType = tmla.getHwMemoryByName( memoryUnit ).BufferType;
+			}
+		}
+		DoubleDmaMEC mec = new DoubleDmaMEC( ctxName + "_" + String.valueOf(iteration), dmaArchMEC, srcMemoryType, dstMemoryType, transferTypes.get(iteration), sizes.get(iteration) );
+		return mec;
+	}
+
 	private void generateCodeToRegisterOperations()	{
 
 		programString.append( "void register_operations( void )\t{" + CR );
@@ -1209,8 +1256,6 @@ public class TMLCCodeGeneration	{
 				OperationMEC xTaskOperation = xTask.getOperationMEC();
 				OperationMEC fTaskOperation = fTask.getOperationMEC();
 				ctxName = op.getContextName();
-				/*TraceManager.addDev( "OPERATION: " + op.getName() );
-				TraceManager.addDev( "\t\t\tContext name: " + ctxName );*/
 				if( op.getInSignals().size() > 0 )	{
 					inSignalName = op.getInSignals().get(0).getName();
 				}
@@ -1274,8 +1319,6 @@ public class TMLCCodeGeneration	{
 		for( Operation op: operationsList )	{
 			if( op.getType() == Operation.SDR )	{
 				TMLTask xTask = op.getSDRTasks().get( Operation.X_TASK );
-				//TMLTask fTask = op.getSDRTasks().get( Operation.X_TASK );
-				//OperationMEC xTaskOperation = xTask.getOperationMEC();
 				ArchUnitMEC xTaskArchMEC = tmap.getHwNodeOf( xTask ).getArchUnitMEC();
 				if( xTaskArchMEC instanceof FepMEC )	{
 					initFileString.append( TAB + "init_" + xTask.getTaskName() + "();" + CR );
@@ -1298,7 +1341,9 @@ public class TMLCCodeGeneration	{
 		for( DataTransfer dt: dataTransfersList )	{
 			TMLCPLib tmlcplib = dt.getTMLCPLib();
 			String name = tmlcplib.getName().split("::")[0];
-			initFileString.append( TAB + "init_" + name + "();" + CR );
+			if( !( tmlcplib.getCPMEC() instanceof CpuMemoryCopyMEC ) )	{	//No need to create init routine for memory copy transfers
+				initFileString.append( TAB + "init_" + name + "();" + CR );
+			}
 		}
 		initFileString.append( "}" + CR2 );
 
@@ -1325,60 +1370,95 @@ public class TMLCCodeGeneration	{
 			}
 		}
 		initFileString.append( "}" + CR2 );
-		initFileString.append( "void cleanup_CPs_context( void )\t{" + CR + "/*" );
+		initFileString.append( "void cleanup_CPs_context( void )\t{" + CR );
+		ArchUnitMEC dmaArchMEC = new CpuMEC();
 		for( DataTransfer dt: dataTransfersList )	{
 			TMLCPLib tmlcplib = dt.getTMLCPLib();
 			CPMEC cpMEC = tmlcplib.getCPMEC();
 			ctxName = dt.getContextName();
-			if( cpMEC instanceof CpuMemoryCopyMEC )	{
-				initFileString.append( TAB + CpuMemoryCopyMEC.Ctx_cleanup + "( &" + ctxName + " );" + CR );
-			}
 			if( cpMEC instanceof SingleDmaMEC )	{
-				initFileString.append( TAB + SingleDmaMEC.Ctx_cleanup + "( &" + ctxName + " );" + CR );
+				int transferType = tmlcplib.getTransferTypes().get(0);
+				for( String s: tmlcplib.getMappedUnits() )	{
+					if( s.contains( CPMEC.dmaController ) )	{
+						String dmaUnit = s.split(":")[1].replaceAll("\\s+","");
+						dmaArchMEC = tmla.getHwCPUByName( dmaUnit ).MEC;
+						break;
+					}
+				}
+				if( transferType == CPMEC.IP2IP )	{
+					initFileString.append( TAB + dmaArchMEC.getCtxCleanupCode() + "(&" + ctxName +"_0);" + CR );
+					initFileString.append( TAB + dmaArchMEC.getCtxCleanupCode() + "(&" + ctxName +"_1);" + CR );
+				}
+				else	{
+					initFileString.append( TAB2 + dmaArchMEC.getCtxCleanupCode() + "(&" + ctxName +");" + CR );
+				}
 			}
 			if( cpMEC instanceof DoubleDmaMEC )	{
-				initFileString.append( TAB + DoubleDmaMEC.Ctx_cleanup + "( &" + ctxName + " );" + CR );
+				int suffix = 0;
+				for( String s: tmlcplib.getMappedUnits() )	{	//there are two DMA_controllers
+					if( s.contains( CPMEC.dmaController ) )	{
+						int transferType = tmlcplib.getTransferTypes().get(suffix);
+						String dmaUnit = s.split(":")[1].replaceAll("\\s+","");
+						dmaArchMEC = tmla.getHwCPUByName( dmaUnit ).MEC;
+						if( transferType == CPMEC.IP2IP )	{
+							initFileString.append( TAB + dmaArchMEC.getCtxCleanupCode() + "(&" + ctxName + "_" + String.valueOf(suffix) + "_0);" + CR );
+							initFileString.append( TAB + dmaArchMEC.getCtxCleanupCode() + "(&" + ctxName + "_" + String.valueOf(suffix) + "_1);" + CR );
+						}
+						else	{
+							initFileString.append( TAB + dmaArchMEC.getCtxCleanupCode() + "(&" + ctxName + "_" + String.valueOf(suffix) + ");" + CR );
+						}
+						suffix++;
+					}
+				}
 			}
 		}
-		initFileString.append( "*/\n}" + CR );
+		initFileString.append( "}" + CR );
 	}
 
 	private void generateInitRoutinesForCPs()	{
 
-		ArchUnitMEC archMEC = new CpuMEC();
-		ArrayList<ArchUnitMEC> archMECList = new ArrayList<ArchUnitMEC>();
+		ArchUnitMEC dmaArchMEC = new CpuMEC();
+		ArrayList<ArchUnitMEC> dmaArchMECList = new ArrayList<ArchUnitMEC>();
 
 		for( DataTransfer dt: dataTransfersList )	{
 			TMLCPLib tmlcplib = dt.getTMLCPLib();
 			CPMEC cpMEC = tmlcplib.getCPMEC();
 			String ctxName = dt.getContextName();
 			String name = tmlcplib.getName().split("::")[0];
-			if( cpMEC instanceof CpuMemoryCopyMEC )	{
-				initFileString.append( "void init_" + name + "()\t{" + CR );
-				CpuMemoryCopyMEC mec = new CpuMemoryCopyMEC( ctxName, "", "", "", "" );
-				initFileString.append( "//" + TAB + mec.getInitCode() + "}" + CR2 );
-			}
 			if( cpMEC instanceof SingleDmaMEC )	{
+				int transferType = tmlcplib.getTransferTypes().get(0);
 				for( String s: tmlcplib.getMappedUnits() )	{
-					if( s.contains( "DMA_Controller" ) )	{
+					if( s.contains( CPMEC.dmaController ) )	{
 						String dmaUnit = s.split(":")[1].replaceAll("\\s+","");
-						archMEC = tmla.getHwCPUByName( dmaUnit ).MEC;
+						dmaArchMEC = tmla.getHwCPUByName( dmaUnit ).MEC;
 						break;
 					}
 				}
 				initFileString.append( "void init_" + name + "()\t{" + CR );
-				SingleDmaMEC mec = new SingleDmaMEC( ctxName, archMEC );
-				initFileString.append( TAB + mec.getInitCode() + "}" + CR2 );
+				if( transferType == CPMEC.IP2IP )	{
+					initFileString.append( TAB + dmaArchMEC.getCtxInitCode() + "(&" + ctxName + "_0, (uintptr_t) " + dmaArchMEC.getLocalMemoryPointer() + " );" + CR );
+					initFileString.append( TAB + dmaArchMEC.getCtxInitCode() + "(&" + ctxName + "_1, (uintptr_t) " + dmaArchMEC.getLocalMemoryPointer() + " );" + CR + "}" + CR2 );
+				}
+				else	{
+					initFileString.append( TAB + dmaArchMEC.getCtxInitCode() + "(&" + ctxName + ", (uintptr_t) " + dmaArchMEC.getLocalMemoryPointer() + " );" + CR + "}" + CR2 );
+				}
 			}
 			if( cpMEC instanceof DoubleDmaMEC )	{
 				initFileString.append( "void init_" + name + "()\t{" + CR );
+				int suffix = 0;
 				for( String s: tmlcplib.getMappedUnits() )	{	//there are two DMA_controllers
-					if( s.contains( "DMA_Controller" ) )	{
+					if( s.contains( CPMEC.dmaController ) )	{
+						int transferType = tmlcplib.getTransferTypes().get(suffix);
 						String dmaUnit = s.split(":")[1].replaceAll("\\s+","");
-						archMEC = tmla.getHwCPUByName( dmaUnit ).MEC ;
-						//TraceManager.addDev( "DoubleDmaTransfer, archMEC: " + archMEC );
-						DoubleDmaMEC mec = new DoubleDmaMEC( ctxName, archMEC );
-						initFileString.append( TAB + mec.getInitCode() );
+						dmaArchMEC = tmla.getHwCPUByName( dmaUnit ).MEC ;
+						if( transferType == CPMEC.IP2IP )	{
+							initFileString.append( TAB + dmaArchMEC.getCtxInitCode() + "(&" + ctxName + "_" + String.valueOf(suffix) + "_0, (uintptr_t) " + dmaArchMEC.getLocalMemoryPointer() + " );" + CR );
+							initFileString.append( TAB + dmaArchMEC.getCtxInitCode() + "(&" + ctxName + "_" + String.valueOf(suffix) + "_1, (uintptr_t) " + dmaArchMEC.getLocalMemoryPointer() + " );" + CR );
+						}
+						else	{
+							initFileString.append( TAB + dmaArchMEC.getCtxInitCode() + "(&" + ctxName + "_" + String.valueOf(suffix) + ", (uintptr_t) " + dmaArchMEC.getLocalMemoryPointer() + " );" + CR );
+						}
+						suffix++;
 					}
 				}
 				initFileString.append( "}" + CR2 );
@@ -1466,6 +1546,19 @@ public class TMLCCodeGeneration	{
 		return headerString.toString() + programString.toString();
 	}
 
+	private ArchUnitMEC getArchMEC( TMLCPLib tmlcplib, String sdInstanceName )	{
+
+		ArchUnitMEC dmaArchMEC = new CpuMEC();
+		for( String s: tmlcplib.getMappedUnits() )	{
+			if( s.contains( sdInstanceName ) )	{
+				String dmaUnit = s.split(":")[1].replaceAll("\\s+","");
+				dmaArchMEC = tmla.getHwCPUByName( dmaUnit ).MEC;
+				break;
+			}
+		}
+		return dmaArchMEC;
+	}
+
 	public void saveFile( String path, String filename ) throws FileException {
 		
 		TMLCCodeGenerationMakefile make = new TMLCCodeGenerationMakefile( applicationName );
diff --git a/src/ui/GTMLModeling.java b/src/ui/GTMLModeling.java
index ea8480b9d69696395fd87016fda1216425d26753..b7a62a8ddf11b24ee1ab620a8eb1379808ba97e3 100755
--- a/src/ui/GTMLModeling.java
+++ b/src/ui/GTMLModeling.java
@@ -2254,6 +2254,7 @@ public class GTMLModeling  {
                     memory = new HwMemory(memorynode.getName());
                     memory.byteDataSize = memorynode.getByteDataSize();
                     memory.clockRatio = memorynode.getClockRatio();
+										memory.BufferType = memorynode.getBufferType();
                     listE.addCor(memory, memorynode);
                     archi.addHwNode(memory);
                     TraceManager.addDev("Memory node added:" + memory.getName());
@@ -2935,6 +2936,7 @@ public class GTMLModeling  {
                 map.addTMLCPLib(tmlcplib);
                 tmlcplib.setMappedUnits(cp.getMappedUnits());
 								tmlcplib.setAssignedAttributes( cp.getAssignedAttributes() );
+								tmlcplib.setTransferTypes( cp.getTransferTypes() );
 
                 // Handling mapped artifacts
                 for (TMLArchiPortArtifact artifact: cp.getPortArtifactList()) {
diff --git a/src/ui/tmldd/TMLArchiCPNode.java b/src/ui/tmldd/TMLArchiCPNode.java
index 52e109889faa42493b9a98e61422d90aacb0576b..726bcf94690784389fd51ccc76a60c6a06add622 100755
--- a/src/ui/tmldd/TMLArchiCPNode.java
+++ b/src/ui/tmldd/TMLArchiCPNode.java
@@ -69,6 +69,8 @@ public class TMLArchiCPNode extends TMLArchiCommunicationNode implements Swallow
     private Vector<String> mappedUnits = new Vector<String>();
     private Vector<String> assignedAttributes = new Vector<String>();
 		private String cpMEC = "VOID";
+		private int transferType1 = -1;
+		private int transferType2 = -1;
 		private String completeName;
 
     public TMLArchiCPNode(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp)  {
@@ -198,7 +200,7 @@ public class TMLArchiCPNode extends TMLArchiCommunicationNode implements Swallow
         String errors = "";
         String tmpName;
 
-        JDialogReferenceCP dialog = new JDialogReferenceCP( frame, "Setting CP attributes", this, mappedUnits, name, cpMEC, assignedAttributes );
+        JDialogReferenceCP dialog = new JDialogReferenceCP( frame, "Setting CP attributes", this, mappedUnits, name, cpMEC, assignedAttributes, transferType1, transferType2 );
         dialog.setSize( 700, 550 );
         GraphicLib.centerOnParent( dialog );
         dialog.show(); // blocked until dialog has been closed
@@ -206,6 +208,8 @@ public class TMLArchiCPNode extends TMLArchiCommunicationNode implements Swallow
         name = dialog.getNodeName();
         mappedUnits = dialog.getMappedUnits();
 				cpMEC = dialog.getCPMEC();
+				transferType1 = dialog.getTransferTypes().get(0);
+				transferType2 = dialog.getTransferTypes().get(1);
 				assignedAttributes = dialog.getAssignedAttributes();
 
         if( !dialog.isRegularClose() )  {
@@ -244,7 +248,7 @@ public class TMLArchiCPNode extends TMLArchiCommunicationNode implements Swallow
 
     protected String translateExtraParam() {
         StringBuffer sb = new StringBuffer("<extraparam>\n");
-        sb.append("<info stereotype=\"" + stereotype + "\" nodeName=\"" + name + "\" cpMEC=\"" + cpMEC );
+        sb.append("<info stereotype=\"" + stereotype + "\" nodeName=\"" + name + "\" cpMEC=\"" + cpMEC + "\" transferType1=\"" + String.valueOf(transferType1) + "\" transferType2=\"" + String.valueOf(transferType2) );
         sb.append("\" />\n");
         sb.append("<attributes reference=\"" + reference + "\" ");
         sb.append("/>\n");
@@ -288,6 +292,8 @@ public class TMLArchiCPNode extends TMLArchiCommunicationNode implements Swallow
                                 sstereotype = elt.getAttribute("stereotype");
                                 snodeName = elt.getAttribute("nodeName");
 																cpMEC = elt.getAttribute( "cpMEC" );
+																transferType1 = Integer.parseInt(elt.getAttribute( "transferType1" ) );
+																transferType2 = Integer.parseInt(elt.getAttribute( "transferType2" ) );
                             }
                             if (sstereotype != null) {
                                 stereotype = sstereotype;
@@ -472,4 +478,11 @@ public class TMLArchiCPNode extends TMLArchiCommunicationNode implements Swallow
 		String s = assignement.split(" = ")[1];
 		return s.substring(0, s.length()-1);	//remove trailing semi-colon
 	}
+
+	public ArrayList<Integer> getTransferTypes()	{
+		ArrayList<Integer> transferTypes = new ArrayList<Integer>();
+		transferTypes.add( transferType1 );
+		transferTypes.add( transferType2 );
+		return transferTypes;
+	}
 }
diff --git a/src/ui/window/JDialogReferenceCP.java b/src/ui/window/JDialogReferenceCP.java
index d5d6d0fe92ae5fb5f7e4b532a630bc6d8652be52..39cfb088c175bd813fabf27b0570e529f161ef26 100644
--- a/src/ui/window/JDialogReferenceCP.java
+++ b/src/ui/window/JDialogReferenceCP.java
@@ -139,22 +139,25 @@ public class JDialogReferenceCP extends javax.swing.JDialog implements ActionLis
 
 	//Panel5, code generation
 	private JPanel panel5;
-	private JComboBox cpMECsCB;
+	private JComboBox cpMECsCB, transferTypeCB1, transferTypeCB2;
 	private JList cpMECsList;
 	private String cpMEC;
+	private int transferType1, transferType2;
 	
 	// Main Panel
 	private JButton closeButton;
 	private JButton cancelButton;
 	
 	/** Creates new form  */
-	public JDialogReferenceCP( JFrame _frame,  String _title, TMLArchiCPNode _cp, Vector<String> _mappedUnits, String _name, String _cpMEC, Vector<String> _assignedAttributes ) {
+	public JDialogReferenceCP( JFrame _frame,  String _title, TMLArchiCPNode _cp, Vector<String> _mappedUnits, String _name, String _cpMEC, Vector<String> _assignedAttributes, int _transferType1, int _transferType2 ) {
 	
 	super( _frame, _title, true );
 	frame = _frame;
 	cp = _cp;
 	name = _name;
 	cpMEC = _cpMEC;
+	transferType1 = _transferType1;
+	transferType2 = _transferType2;
 	
 	if( _mappedUnits.size() > 0 )	{	//the validity of _mappedUnits is checked when initializing components
 		mappedUnitsSL = new Vector<String>();	//take into account the elements already mapped
@@ -477,6 +480,47 @@ public class JDialogReferenceCP extends javax.swing.JDialog implements ActionLis
 			cpMECsCB.addActionListener( this );
 			cpMECsCB.setMinimumSize( new Dimension(150, 50) );
 			panel5.add( cpMECsCB, c5 );
+			//
+			c5.gridwidth = GridBagConstraints.REMAINDER; //end row
+			panel5.add(new JLabel(""), c5);
+			c5.gridwidth = 1;
+			c5.gridheight = 1;
+			c5.weighty = 1.0;
+			c5.weightx = 1.0;
+			c5.fill = GridBagConstraints.HORIZONTAL;
+			c5.anchor = GridBagConstraints.LINE_START;
+			panel5.add( new JLabel( "DMA Transfer Type 1:" ), c5 );
+			transferTypeCB1 = new JComboBox( new Vector<String>( Arrays.asList( CPMEC.transferTypes ) ) );
+			if( transferType1 == -1 )	{
+				transferTypeCB1.setSelectedIndex( 0 );
+			}
+			else	{
+				transferTypeCB1.setSelectedIndex( transferType1 );
+			}
+			transferTypeCB1.addActionListener( this );
+			transferTypeCB1.setMinimumSize( new Dimension(150, 50) );
+			panel5.add( transferTypeCB1, c5 );
+			//
+			c5.gridwidth = GridBagConstraints.REMAINDER; //end row
+			panel5.add(new JLabel(""), c5);
+			c5.gridwidth = 1;
+			c5.gridheight = 1;
+			c5.weighty = 1.0;
+			c5.weightx = 1.0;
+			c5.fill = GridBagConstraints.HORIZONTAL;
+			c5.anchor = GridBagConstraints.LINE_START;
+			panel5.add( new JLabel( "DMA Transfer Type 2:" ), c5 );
+			transferTypeCB2 = new JComboBox( new Vector<String>( Arrays.asList( CPMEC.transferTypes ) ) );
+			if( transferType2 == -1 )	{
+				transferTypeCB2.setSelectedIndex( 0 );
+			}
+			else	{
+				transferTypeCB2.setSelectedIndex( transferType2 );
+			}
+			transferTypeCB2.addActionListener( this );
+			transferTypeCB2.setMinimumSize( new Dimension(150, 50) );
+			panel5.add( transferTypeCB2, c5 );
+			enableDisableTransferTypeCBs();
 			
 			// main panel;
 			c0.gridwidth = 1;	//num columns
@@ -494,9 +538,7 @@ public class JDialogReferenceCP extends javax.swing.JDialog implements ActionLis
 			c0.weighty = 1.0;
 			c0.weightx = 1.0;
 			c0.fill = GridBagConstraints.BOTH;
-			//c.add(panel3, c0);
 			c0.gridwidth = GridBagConstraints.REMAINDER; //end row
-			//c.add(panel4, c0);
 			panel34.add( panel3, c0 );
 			panel34.add( panel4, c0 );
 
@@ -718,7 +760,32 @@ public class JDialogReferenceCP extends javax.swing.JDialog implements ActionLis
 			else if( evt.getSource() == scrollPane )	{
 				manageScrollPaneButtons();
 			}
+			else if( evt.getSource() == cpMECsCB )	{
+				enableDisableTransferTypeCBs();
+			}
 		}	//End of method
+
+		private void enableDisableTransferTypeCBs()	{
+
+			if( cpMECsCB.getSelectedIndex() == 0 )	{	//selected memoryCopy
+				transferTypeCB1.setEnabled(false);
+				transferTypeCB2.setEnabled(false);
+				transferType1 = 0;
+				transferType2 = 0;
+			}
+			else if( cpMECsCB.getSelectedIndex() == 1 )	{	//selected SingleDma
+				transferTypeCB1.setEnabled(true);
+				transferType1 = 0;
+				transferTypeCB2.setEnabled(false);
+				transferType2 = 0;
+			}
+			else if( cpMECsCB.getSelectedIndex() == 2 )	{	//selected DoubleDma
+				transferTypeCB1.setEnabled(true);
+				transferType1 = 0;
+				transferTypeCB2.setEnabled(true);
+				transferType2 = 0;
+			}
+		}
 		
 		private void mapInstance() {
 
@@ -1013,10 +1080,8 @@ public class JDialogReferenceCP extends javax.swing.JDialog implements ActionLis
 			cancelled = false;
 			name = nameOfCP.getText();
 			cpMEC = (String)cpMECsCB.getSelectedItem();
-			/*if( attributesVector.size() > 0 )	{	//there are still parameters which must be assigned a value
-				JOptionPane.showMessageDialog( frame, "Please assign a value to all attributes", "Error", JOptionPane.INFORMATION_MESSAGE );
-				return;
-			}*/
+			transferType1 = Arrays.asList( CPMEC.transferTypes ).indexOf( (String)transferTypeCB1.getSelectedItem() );
+			transferType2 = Arrays.asList( CPMEC.transferTypes ).indexOf( (String)transferTypeCB2.getSelectedItem() );
 			dispose();
 		}
 		
@@ -1295,5 +1360,11 @@ public class JDialogReferenceCP extends javax.swing.JDialog implements ActionLis
 		}
 	}
 
+	public ArrayList<Integer> getTransferTypes()	{
+		ArrayList<Integer> transferTypes = new ArrayList<Integer>();
+		transferTypes.add( transferType1 );
+		transferTypes.add( transferType2 );
+		return transferTypes;
+	}
 		
 }	//End of class