Index: /trunk/modules/vci_cc_xcache_wrapper_v1/caba/source/include/vci_cc_xcache_wrapper_v1.h
===================================================================
--- /trunk/modules/vci_cc_xcache_wrapper_v1/caba/source/include/vci_cc_xcache_wrapper_v1.h	(revision 190)
+++ /trunk/modules/vci_cc_xcache_wrapper_v1/caba/source/include/vci_cc_xcache_wrapper_v1.h	(revision 191)
@@ -144,4 +144,9 @@
     const size_t        m_icache_yzmask;
 
+    const size_t	m_x_width;   
+    const size_t	m_y_width;   
+    const size_t	m_memc_id;   
+    addr_40		m_srcid_mask;
+
     // REGISTERS
     sc_signal<int>          r_dcache_fsm;
@@ -264,5 +269,8 @@
                        size_t dcache_ways,
                        size_t dcache_sets,
-                       size_t dcache_words );
+                       size_t dcache_words,
+		       size_t x_width,
+		       size_t y_width,
+		       size_t memc_id );
 
     ~VciCcXCacheWrapperV1();
Index: /trunk/modules/vci_cc_xcache_wrapper_v1/caba/source/src/vci_cc_xcache_wrapper_v1.cpp
===================================================================
--- /trunk/modules/vci_cc_xcache_wrapper_v1/caba/source/src/vci_cc_xcache_wrapper_v1.cpp	(revision 190)
+++ /trunk/modules/vci_cc_xcache_wrapper_v1/caba/source/src/vci_cc_xcache_wrapper_v1.cpp	(revision 191)
@@ -28,4 +28,5 @@
  *              nipo
  *              malek <abdelmalek.si-merabet@lip6.fr> 
+ *              cfuguet <c.sarfuguet@gmail.com>
  */
 
@@ -65,4 +66,5 @@
 
 //#define DEBUG_CC_XCACHE_WRAPPER 1
+//#define DEBUG_CLEANUP
 
 namespace soclib { 
@@ -150,5 +152,9 @@
             size_t dcache_ways,
             size_t dcache_sets,
-            size_t dcache_words )
+            size_t dcache_words,
+            // Parameters for the CLEANUP transaction
+            size_t x_width,
+            size_t y_width,
+            size_t memc_id )
         : 
             soclib::caba::BaseModule(name),
@@ -172,4 +178,11 @@
             m_icache_words(icache_words),
             m_icache_yzmask((~0)<<(uint32_log2(icache_words) + 2)),
+
+            m_x_width(x_width),
+            m_y_width(y_width),
+
+            m_memc_id(memc_id),
+
+            m_srcid_mask(~((0x1 << (vci_param::N - vci_param::S)) - 1)),
 
             r_dcache_fsm("r_dcache_fsm"),
@@ -1571,4 +1584,5 @@
         // VCI initiator command
 
+        addr_40 memc_addr = 0;
         switch (r_vci_cmd_fsm.read() ) {
 
@@ -1798,4 +1812,5 @@
 
             case CMD_INS_CLEANUP:
+            {
                 p_vci_ini_rw.cmdval = false;
                 p_vci_ini_rw.address = 0;
@@ -1814,24 +1829,37 @@
                 p_vci_ini_rw.eop    = false;
 
+                memc_addr = r_icache_cleanup_line.read() * (m_icache_words<<2);
+                memc_addr.range(vci_param::N-1 - m_x_width - m_y_width, vci_param::N - vci_param::S) 
+                  = m_memc_id;
+
+                memc_addr &= m_srcid_mask;
+
                 p_vci_ini_c.cmdval  = true;
-                p_vci_ini_c.address = r_icache_cleanup_line.read() * (m_icache_words<<2);
-                p_vci_ini_c.wdata  = 0;
-                p_vci_ini_c.be     = 0;
-                p_vci_ini_c.plen   = 4;
-                p_vci_ini_c.cmd    = vci_param::CMD_WRITE;
-                p_vci_ini_c.trdid  = 1; // cleanup instruction
-                p_vci_ini_c.pktid  = 0;
-                p_vci_ini_c.srcid  = m_srcid_c;
-                p_vci_ini_c.cons   = false;
-                p_vci_ini_c.wrap   = false;
-                p_vci_ini_c.contig = false;
-                p_vci_ini_c.clen   = 0;
-                p_vci_ini_c.cfixed = false;
-                p_vci_ini_c.eop = true;
-
-                break;
-
+                p_vci_ini_c.address = memc_addr; 
+                p_vci_ini_c.wdata   = r_icache_cleanup_line.read().range(31, 0);
+                p_vci_ini_c.be      = r_icache_cleanup_line.read().range(33, 32);
+                p_vci_ini_c.plen    = 4;
+                p_vci_ini_c.cmd     = vci_param::CMD_WRITE;
+                p_vci_ini_c.trdid   = 1; // cleanup instruction
+                p_vci_ini_c.pktid   = 0;
+                p_vci_ini_c.srcid   = m_srcid_c;
+                p_vci_ini_c.cons    = false;
+                p_vci_ini_c.wrap    = false;
+                p_vci_ini_c.contig  = false;
+                p_vci_ini_c.clen    = 0;
+                p_vci_ini_c.cfixed  = false;
+                p_vci_ini_c.eop     = true;
+
+#ifdef DEBUG_CLEANUP
+                std::cout << "Initiating Instruction Cleanup Transaction..." << std::endl;
+                std::cout << "MemoryCache Address: " << std::hex << memc_addr << std::endl;
+                std::cout << "Cache Line Address to cleanup: " << std::hex << r_icache_cleanup_line.read()
+                          << std::endl;
+#endif
+            }
+                break;
 
             case CMD_DATA_CLEANUP:
+            {
                 p_vci_ini_rw.cmdval = false;
                 p_vci_ini_rw.address = 0;
@@ -1850,20 +1878,33 @@
                 p_vci_ini_rw.eop    = false;
 
+                memc_addr = r_dcache_cleanup_line.read() * (m_dcache_words<<2);
+                memc_addr.range(vci_param::N-1 - m_x_width - m_y_width, vci_param::N - vci_param::S) 
+                  = m_memc_id;
+
+                memc_addr &= m_srcid_mask;
+
                 p_vci_ini_c.cmdval  = true;
-                p_vci_ini_c.address = r_dcache_cleanup_line.read() * (m_dcache_words<<2);
-                p_vci_ini_c.wdata  = 0;
-                p_vci_ini_c.be     = 0;
-                p_vci_ini_c.plen   = 4;
-                p_vci_ini_c.cmd    = vci_param::CMD_WRITE;
-                p_vci_ini_c.trdid  = 0; // cleanup data
-                p_vci_ini_c.pktid  = 0;
-                p_vci_ini_c.srcid  = m_srcid_c;
-                p_vci_ini_c.cons   = false;
-                p_vci_ini_c.wrap   = false;
-                p_vci_ini_c.contig = false;
-                p_vci_ini_c.clen   = 0;
-                p_vci_ini_c.cfixed = false;
-                p_vci_ini_c.eop = true;
-
+                p_vci_ini_c.address = memc_addr; 
+                p_vci_ini_c.wdata   = r_dcache_cleanup_line.read().range(31, 0);
+                p_vci_ini_c.be      = r_dcache_cleanup_line.read().range(33, 32);
+                p_vci_ini_c.plen    = 4;
+                p_vci_ini_c.cmd     = vci_param::CMD_WRITE;
+                p_vci_ini_c.trdid   = 0; // cleanup data
+                p_vci_ini_c.pktid   = 0;
+                p_vci_ini_c.srcid   = m_srcid_c;
+                p_vci_ini_c.cons    = false;
+                p_vci_ini_c.wrap    = false;
+                p_vci_ini_c.contig  = false;
+                p_vci_ini_c.clen    = 0;
+                p_vci_ini_c.cfixed  = false;
+                p_vci_ini_c.eop     = true;
+
+#ifdef DEBUG_CLEANUP
+                std::cout << "Initiating Data Cleanup Transaction..." << std::endl;
+                std::cout << "MemoryCache Address: " << std::hex << memc_addr << std::endl; 
+                std::cout << "Cache Line Address to cleanup: " << std::hex << r_dcache_cleanup_line.read()
+                          << std::endl;
+#endif
+		    }
                 break;
 
