Index: branches/RWT/modules/vci_cc_vcache_wrapper/caba/source/src/vci_cc_vcache_wrapper.cpp
===================================================================
--- branches/RWT/modules/vci_cc_vcache_wrapper/caba/source/src/vci_cc_vcache_wrapper.cpp	(revision 495)
+++ branches/RWT/modules/vci_cc_vcache_wrapper/caba/source/src/vci_cc_vcache_wrapper.cpp	(revision 513)
@@ -2033,6 +2033,5 @@
 
         // Switch slot state to ZOMBI and send CLEANUP command 
-        r_icache.write_dir( 0,
-                            r_icache_cc_way.read(),
+        r_icache.write_dir( r_icache_cc_way.read(),
                             r_icache_cc_set.read(),
                             CACHE_SLOT_STATE_ZOMBI );
@@ -2913,4 +2912,14 @@
                             }
                         }
+#if DEBUG_DCACHE
+if ( m_debug_activated )
+std::cout << "  <PROC " << name() << " DCACHE_IDLE>"
+          << " WRITE REQ " 
+          << " / wbuf_request = " << wbuf_request
+          << " / updt_request = " << updt_request
+          << " / cache_state = " << cache_state
+          << " / PADDR = " << std::hex << paddr << std::endl;
+#endif
+
                     } // end WRITE
 
@@ -3940,6 +3949,6 @@
                 r_dcache_miss_set     = set;
                 r_dcache_cc_cleanup_line_ncc = true;
-                //if (r_dcache_content_state[m_dcache_sets*way+set] != LINE_CACHE_DATA_NOT_DIRTY)//Must send data in the cleanup
-                if (true)//Must send data in the cleanup
+                if (r_dcache_content_state[m_dcache_sets*way+set] != LINE_CACHE_DATA_NOT_DIRTY)//Must send data in the cleanup
+                //if (true)//Must send data in the cleanup
                 {
                     r_dcache_xtn_flush_addr_data = (tag * m_dcache_sets + set) * m_dcache_words * 4;
@@ -4189,6 +4198,6 @@
                 {
                     r_dcache_cc_cleanup_line_ncc = true;
-                    //if ((r_dcache_content_state[way*m_dcache_sets+set] != LINE_CACHE_DATA_NOT_DIRTY)) //must send data
-                    if (true) //must send data
+                    if ((r_dcache_content_state[way*m_dcache_sets+set] != LINE_CACHE_DATA_NOT_DIRTY)) //must send data
+                    //if (true) //must send data
                     {
                         r_dcache_cc_cleanup_updt_data = true;
@@ -4334,4 +4343,5 @@
             bool     s_cleanup_updt_data = false;
             bool     s_cleanup_line_ncc = false;
+            uint32_t mask = 0;
 
 #ifdef INSTRUMENTATION
@@ -4360,6 +4370,6 @@
                         s_cleanup_line_ncc = true;
                         r_dcache_miss_data_addr = (victim*m_dcache_words)*4;
-                        //if ((r_dcache_content_state[way*m_dcache_sets+set] != LINE_CACHE_DATA_NOT_DIRTY))//must send data
-                        if (true)//must send data
+                        if ((r_dcache_content_state[way*m_dcache_sets+set] != LINE_CACHE_DATA_NOT_DIRTY))//must send data
+                        //if (true)//must send data
                         {
                             s_cleanup_updt_data = true;
@@ -4368,4 +4378,6 @@
                                 m_cpt_cleanup_data_dirty_word += r_dcache_dirty_word[(m_dcache_sets*way+set)*m_dcache_words + w];
                             }
+                            mask = r_dcache.get_cache_mask(way, set);
+                           // std::cout << "found a vcitim ncc dirty mask = " << mask << std::endl;
                             r_dcache_fsm = DCACHE_MISS_DATA;
                         }
@@ -4373,4 +4385,6 @@
                         {
                             s_cleanup_updt_data = false;
+                            mask = r_dcache.get_cache_mask(way, set);
+                           // std::cout << "found a vcitim ncc non dirty mask = " << mask << std::endl;
                         }
 
@@ -4401,8 +4415,4 @@
                         r_dcache_cleanup_victim_updt_data = s_cleanup_updt_data;
                         r_dcache_cleanup_victim_line_ncc = s_cleanup_line_ncc;
-                        std::cout << "  <PROC " << name()
-                                  << "/ CYCLE = "
-                                  << m_cpt_total_cycles
-                                  << std :: endl;
                     }
                 }
@@ -4662,4 +4672,5 @@
             {
                 r_dcache_fsm = DCACHE_MISS_DIR_UPDT;
+                r_dcache.reset_cache_mask(r_dcache_miss_way.read(), r_dcache_miss_set.read());
             }
         }
@@ -5097,5 +5108,5 @@
 if ( m_debug_activated )
 {
-    std::cout << "  <PROC " << name()
+    std::cout << "  <PROC " << name() << std::hex
               << " DCACHE_CC_CHECK> paddr = " << paddr
               << " r_dcache_vci_paddr = " << r_dcache_vci_paddr.read()
@@ -5107,5 +5118,5 @@
               << " ((r_dcache_vci_paddr.read() & mask) == (paddr & mask)) = " 
               << ((r_dcache_vci_paddr.read() & mask) == (paddr & mask))
-              <<std::endl;
+              << std::dec <<std::endl;
 }
 #endif
@@ -5273,4 +5284,5 @@
         int      cache_state = r_dcache_cc_state.read();
         bool     dirty_save = false;
+        uint32_t mask = 0;
 
         if (r_dcache_cc_need_write.read())
@@ -5329,6 +5341,6 @@
                 {
                     r_dcache_cc_cleanup_line_ncc = true; 
-                    //if ((r_dcache_content_state[way*m_dcache_sets+set] != LINE_CACHE_DATA_NOT_DIRTY) or r_dcache_dirty_save.read() or dirty_save) //must send data
-                    if (true) //must send data
+                    if ((r_dcache_content_state[way*m_dcache_sets+set] != LINE_CACHE_DATA_NOT_DIRTY) or r_dcache_dirty_save.read() or dirty_save) //must send data
+                    //if (true) //must send data
                     {
                         r_dcache_cc_cleanup_updt_data = true;
@@ -5337,8 +5349,19 @@
                             m_cpt_cleanup_data_dirty_word += r_dcache_dirty_word[(m_dcache_sets*way+set)*m_dcache_words + w];
                         }
+
+                        mask = r_dcache.get_cache_mask(way, set);
+                      //  std::cout << "cc inval ncc dirty mask = " << mask << std::endl;
+
                         r_dcache_fsm          = DCACHE_CC_INVAL_DATA;
                     }
                     else
                     {
+                        r_dcache.write_dir( way,
+                                            set,
+                                            CACHE_SLOT_STATE_ZOMBI );
+ 
+                        mask = r_dcache.get_cache_mask(way, set);
+                      //  std::cout << "cc inval ncc non dirty mask = " << mask << std::endl;
+
                         r_dcache_cc_cleanup_updt_data = false;
                         r_dcache_fsm = r_dcache_fsm_cc_save.read();
