Index: branches/RWT/modules/vci_mem_cache/caba/source/src/vci_mem_cache.cpp
===================================================================
--- branches/RWT/modules/vci_mem_cache/caba/source/src/vci_mem_cache.cpp	(revision 780)
+++ branches/RWT/modules/vci_mem_cache/caba/source/src/vci_mem_cache.cpp	(revision 783)
@@ -616,5 +616,5 @@
     /////////////////////////////////////////////////////
     tmpl(void) ::cache_monitor(addr_t addr)
-        /////////////////////////////////////////////////////
+    /////////////////////////////////////////////////////
     {
         size_t way = 0;
@@ -678,5 +678,5 @@
     /////////////////////////////////////////////////////
     tmpl(uint32_t)::min_value(uint32_t old_value, uint32_t new_value)
-        /////////////////////////////////////////////////////
+    /////////////////////////////////////////////////////
     {
         if (old_value < new_value)
@@ -688,5 +688,5 @@
     /////////////////////////////////////////////////////
     tmpl(uint32_t)::req_distance(uint32_t req_srcid)
-        /////////////////////////////////////////////////////
+    /////////////////////////////////////////////////////
     {
         const uint32_t srcid_width = vci_param_int::S;
@@ -701,5 +701,5 @@
     /////////////////////////////////////////////////////
     tmpl(bool)::is_local_req(uint32_t req_srcid)
-        /////////////////////////////////////////////////////
+    /////////////////////////////////////////////////////
     {
         return req_distance(req_srcid) == 0;
@@ -845,44 +845,48 @@
     /////////////////////////////////////////
     {
-        m_cpt_reset_count        = m_cpt_cycles;
-        m_cpt_read_local         = 0;
-        m_cpt_read_remote        = 0;
-        m_cpt_read_cost          = 0;
-        m_cpt_write_local        = 0;
-        m_cpt_write_remote       = 0;
-        m_cpt_write_flits_local  = 0;
-        m_cpt_write_flits_remote = 0;
-        m_cpt_write_cost         = 0;
-        m_cpt_ll_local           = 0;
-        m_cpt_ll_remote          = 0;
-        m_cpt_ll_cost            = 0;
-        m_cpt_sc_local           = 0;
-        m_cpt_sc_remote          = 0;
-        m_cpt_sc_cost            = 0;
-        m_cpt_cas_local          = 0;
-        m_cpt_cas_remote         = 0;
-        m_cpt_cas_cost           = 0;
-        m_cpt_update             = 0;
-        m_cpt_update_local       = 0;
-        m_cpt_update_remote      = 0;
-        m_cpt_update_cost        = 0;
-        m_cpt_minval             = 0;
-        m_cpt_minval_local       = 0;
-        m_cpt_minval_remote      = 0;
-        m_cpt_minval_cost        = 0;
-        m_cpt_binval             = 0;
-        m_cpt_cleanup_local      = 0;
-        m_cpt_cleanup_remote     = 0;
-        m_cpt_cleanup_cost       = 0;
-        m_cpt_read_miss          = 0;
-        m_cpt_write_miss         = 0;
-        m_cpt_write_dirty        = 0;
-        m_cpt_trt_rb             = 0;
-        m_cpt_trt_full           = 0;
-        m_cpt_get                = 0;
-        m_cpt_put                = 0;
-        m_cpt_ncc_to_cc_read     = 0;
-        m_cpt_ncc_to_cc_write    = 0;
-        m_cpt_write_ncc_miss     = 0;
+        m_cpt_reset_count         = m_cpt_cycles;
+        m_cpt_read_local          = 0;
+        m_cpt_read_remote         = 0;
+        m_cpt_read_cost           = 0;
+        m_cpt_write_local         = 0;
+        m_cpt_write_remote        = 0;
+        m_cpt_write_flits_local   = 0;
+        m_cpt_write_flits_remote  = 0;
+        m_cpt_write_cost          = 0;
+        m_cpt_write_ncc_miss      = 0;
+        m_cpt_ll_local            = 0;
+        m_cpt_ll_remote           = 0;
+        m_cpt_ll_cost             = 0;
+        m_cpt_sc_local            = 0;
+        m_cpt_sc_remote           = 0;
+        m_cpt_sc_cost             = 0;
+        m_cpt_cas_local           = 0;
+        m_cpt_cas_remote          = 0;
+        m_cpt_cas_cost            = 0;
+        m_cpt_update              = 0;
+        m_cpt_update_local        = 0;
+        m_cpt_update_remote       = 0;
+        m_cpt_update_cost         = 0;
+        m_cpt_minval              = 0;
+        m_cpt_minval_local        = 0;
+        m_cpt_minval_remote       = 0;
+        m_cpt_minval_cost         = 0;
+        m_cpt_binval              = 0;
+        m_cpt_write_broadcast     = 0;
+        m_cpt_cleanup_local       = 0;
+        m_cpt_cleanup_remote      = 0;
+        m_cpt_cleanup_cost        = 0;
+        m_cpt_read_miss           = 0;
+        m_cpt_write_miss          = 0;
+        m_cpt_write_dirty         = 0;
+        m_cpt_trt_rb              = 0;
+        m_cpt_trt_full            = 0;
+        m_cpt_get                 = 0;
+        m_cpt_put                 = 0;
+        m_cpt_ncc_to_cc_read      = 0;
+        m_cpt_ncc_to_cc_write     = 0;
+        m_cpt_cleanup_data_local  = 0;
+        m_cpt_cleanup_data_remote = 0;
+        m_cpt_cleanup_data_cost   = 0;
     }
 
@@ -941,5 +945,7 @@
                 << "[091] REMOTE CLEANUP            = " << m_cpt_cleanup_remote << std::endl
                 << "[092] CLNUP COST (FLITS * DIST) = " << m_cpt_cleanup_cost << std::endl
-                << "[093] CLEANUP DATA              = " << m_cpt_cleanup_data << std::endl
+                << "[093] LOCAL CLEANUP DATA        = " << m_cpt_cleanup_data_local << std::endl
+                << "[094] REMOTE CLEANUP DATA       = " << m_cpt_cleanup_data_remote << std::endl
+                << "[095] CLEANUP DATA COST         = " << m_cpt_cleanup_data_cost << std::endl
                 << std::endl
                 << "[100] READ MISS                 = " << m_cpt_read_miss << std::endl
@@ -1012,5 +1018,5 @@
     /////////////////////////////////
     tmpl(/**/) ::~VciMemCache()
-        /////////////////////////////////
+    /////////////////////////////////
     {
         delete [] m_seg;
@@ -1042,5 +1048,5 @@
     //////////////////////////////////
     tmpl(void) ::transition()
-        //////////////////////////////////
+    //////////////////////////////////
     {
         using soclib::common::uint32_log2;
@@ -1187,36 +1193,40 @@
 
             // Activity counters
-            m_cpt_reset_count        = 0;
-            m_cpt_cycles             = 0;
-            m_cpt_read_local         = 0;
-            m_cpt_read_remote        = 0;
-            m_cpt_read_cost          = 0;
-            m_cpt_write_local        = 0;
-            m_cpt_write_remote       = 0;
-            m_cpt_write_flits_local  = 0;
-            m_cpt_write_flits_remote = 0;
-            m_cpt_write_ncc_miss     = 0;
-            m_cpt_write_cost         = 0;
-            m_cpt_ll_local           = 0;
-            m_cpt_ll_remote          = 0;
-            m_cpt_ll_cost            = 0;
-            m_cpt_sc_local           = 0;
-            m_cpt_sc_remote          = 0;
-            m_cpt_sc_cost            = 0;
-            m_cpt_cas_local          = 0;
-            m_cpt_cas_remote         = 0;
-            m_cpt_cas_cost           = 0;
-            m_cpt_update             = 0;
-            m_cpt_update_local       = 0;
-            m_cpt_update_remote      = 0;
-            m_cpt_update_cost        = 0;
-            m_cpt_minval             = 0;
-            m_cpt_minval_local       = 0;
-            m_cpt_minval_remote      = 0;
-            m_cpt_minval_cost        = 0;
-            m_cpt_binval             = 0;
-            m_cpt_cleanup_local      = 0;
-            m_cpt_cleanup_remote     = 0;
-            m_cpt_cleanup_cost       = 0;
+            m_cpt_reset_count         = 0;
+            m_cpt_cycles              = 0;
+            m_cpt_read_local          = 0;
+            m_cpt_read_remote         = 0;
+            m_cpt_read_cost           = 0;
+            m_cpt_write_local         = 0;
+            m_cpt_write_remote        = 0;
+            m_cpt_write_flits_local   = 0;
+            m_cpt_write_flits_remote  = 0;
+            m_cpt_write_ncc_miss      = 0;
+            m_cpt_write_cost          = 0;
+            m_cpt_ll_local            = 0;
+            m_cpt_ll_remote           = 0;
+            m_cpt_ll_cost             = 0;
+            m_cpt_sc_local            = 0;
+            m_cpt_sc_remote           = 0;
+            m_cpt_sc_cost             = 0;
+            m_cpt_cas_local           = 0;
+            m_cpt_cas_remote          = 0;
+            m_cpt_cas_cost            = 0;
+            m_cpt_update              = 0;
+            m_cpt_update_local        = 0;
+            m_cpt_update_remote       = 0;
+            m_cpt_update_cost         = 0;
+            m_cpt_minval              = 0;
+            m_cpt_minval_local        = 0;
+            m_cpt_minval_remote       = 0;
+            m_cpt_minval_cost         = 0;
+            m_cpt_binval              = 0;
+            m_cpt_cleanup_local       = 0;
+            m_cpt_cleanup_remote      = 0;
+            m_cpt_cleanup_cost        = 0;
+            m_cpt_cleanup_data_local  = 0;
+            m_cpt_cleanup_data_remote = 0;
+            m_cpt_cleanup_data_cost   = 0;
+
 
             m_cpt_read_miss               = 0;
@@ -1270,6 +1280,4 @@
             m_cpt_read_data_miss_NCC      = 0;        
             m_cpt_read_ll_NCC             = 0;    
-            m_cpt_read_WTF                = 0;   
-            m_cpt_cleanup_data            = 0;      
             m_cpt_ncc_to_cc_read          = 0;      
             m_cpt_ncc_to_cc_write         = 0;       
@@ -5688,13 +5696,4 @@
                             "MEMC ERROR in CLEANUP_IDLE state : illegal SRCID value");
 
-                    // <Activity Counters>
-                    if (is_local_req(srcid)) {
-                        m_cpt_cleanup_local++;
-                    }
-                    else {
-                        m_cpt_cleanup_remote++;
-                        m_cpt_cleanup_cost += req_distance(srcid);
-                    }
-                    // </Activity Counters>
                     cc_receive_to_cleanup_fifo_get = true;
                     r_cleanup_fsm                  = CLEANUP_GET_NLINE;
@@ -5720,13 +5719,13 @@
             case CLEANUP_GET_NLINE:  // GET second DSPIN flit of the cleanup command
                 {
-                    if(not m_cc_receive_to_cleanup_fifo.rok()) break;
+                    if (not m_cc_receive_to_cleanup_fifo.rok()) break;
 
                     uint64_t flit = m_cc_receive_to_cleanup_fifo.read();
+                    uint32_t srcid = r_cleanup_srcid.read();
 
                     addr_t nline = r_cleanup_nline.read() |
                         DspinRwtParam::dspin_get(flit, DspinRwtParam::CLEANUP_NLINE_LSB);
 
-                    bool eop =
-                        DspinRwtParam::dspin_get(flit, DspinRwtParam::P2M_EOP) == 0x1;
+                    bool eop = DspinRwtParam::dspin_get(flit, DspinRwtParam::P2M_EOP) == 0x1;
 
                     if (! eop)
@@ -5735,8 +5734,29 @@
                         r_cleanup_data_index = 0;
                         r_cleanup_contains_data = true;
+                        // <Activity Counters>
+                        if (is_local_req(srcid)) {
+                            m_cpt_cleanup_local++;
+                            m_cpt_cleanup_data_local++;
+                        }
+                        else {
+                            m_cpt_cleanup_remote++;
+                            m_cpt_cleanup_data_remote++;
+                        }
+                        m_cpt_cleanup_cost += m_words * req_distance(srcid);
+                        m_cpt_cleanup_data_cost += m_words * req_distance(srcid);
+                        // </Activity Counters>
                     }
                     else
                     {
                         r_cleanup_fsm = CLEANUP_DIR_REQ;
+                        // <Activity Counters>
+                        if (is_local_req(srcid)) {
+                            m_cpt_cleanup_local++;
+                        }
+                        else {
+                            m_cpt_cleanup_remote++;
+                        }
+                        m_cpt_cleanup_cost += req_distance(srcid);
+                        // </Activity Counters>
                     }
                     cc_receive_to_cleanup_fifo_get = true;
@@ -5774,5 +5794,4 @@
                         {
                             r_cleanup_contains_data = true;
-                            m_cpt_cleanup_data ++;
                             r_cleanup_fsm = CLEANUP_DIR_REQ;
                         }
@@ -7782,6 +7801,6 @@
                         {
                             m_cpt_minval_remote++;
-                            m_cpt_minval_cost += req_distance(m_config_to_cc_send_srcid_fifo.read());
-                        }
+                        }
+                        m_cpt_minval_cost += req_distance(m_config_to_cc_send_srcid_fifo.read());
                         // </Activity Counters>
                         r_cc_send_fsm = CC_SEND_CONFIG_INVAL_NLINE;
@@ -7849,6 +7868,6 @@
                         {
                             m_cpt_minval_remote++;
-                            m_cpt_minval_cost += req_distance(m_xram_rsp_to_cc_send_srcid_fifo.read());
-                        }
+                        }
+                        m_cpt_minval_cost += req_distance(m_xram_rsp_to_cc_send_srcid_fifo.read());
                         // </Activity Counters>
                         r_cc_send_fsm = CC_SEND_XRAM_RSP_INVAL_NLINE;
@@ -8002,6 +8021,6 @@
                         {
                             m_cpt_update_remote++;
-                            m_cpt_update_cost += req_distance(m_write_to_cc_send_srcid_fifo.read());
-                        }
+                        }
+                        m_cpt_update_cost += req_distance(m_write_to_cc_send_srcid_fifo.read());
                         // </Activity Counters>
 
@@ -8091,6 +8110,6 @@
                         {
                             m_cpt_update_remote++;
-                            m_cpt_update_cost += req_distance(m_cas_to_cc_send_srcid_fifo.read());
-                        }
+                        }
+                        m_cpt_update_cost += req_distance(m_cas_to_cc_send_srcid_fifo.read());
                         // </Activity Counters>
                         r_cc_send_fsm = CC_SEND_CAS_UPDT_NLINE;
@@ -8566,5 +8585,5 @@
                             else
                             {
-                                m_cpt_read_WTF ++;
+                                assert(false);
                             }
                         }
@@ -8658,5 +8677,5 @@
                             else if (!r_cleanup_to_tgt_rsp_type.read())
                             {
-                                m_cpt_read_WTF ++;
+                                assert(false);
                             }
 
@@ -8754,5 +8773,5 @@
                             else
                             {
-                                m_cpt_read_WTF ++;
+                                assert(false);
                             }
 
