Index: branches/reconfiguration/modules/vci_mem_cache/caba/source/src/vci_mem_cache.cpp
===================================================================
--- branches/reconfiguration/modules/vci_mem_cache/caba/source/src/vci_mem_cache.cpp	(revision 868)
+++ branches/reconfiguration/modules/vci_mem_cache/caba/source/src/vci_mem_cache.cpp	(revision 869)
@@ -281,5 +281,7 @@
         "CLEANUP_IVT_CLEAR",
         "CLEANUP_WRITE_RSP",
-        "CLEANUP_SEND_CLACK"
+        "CLEANUP_SEND_CLACK",
+        "CLEANUP_TEST_HEADER",
+        "CLEANUP_TEST_SIGNATURE"
     };
     const char *alloc_dir_fsm_str[] =
@@ -5307,4 +5309,10 @@
             case CLEANUP_IDLE: // Get first DSPIN flit of the CLEANUP command
             {
+                if (r_cc_test_to_cleanup_req.read())
+                {
+                    r_cleanup_fsm = CLEANUP_TEST_HEADER;
+                    break;
+                }
+
                 if (not m_cc_receive_to_cleanup_fifo.rok()) break;
 
@@ -5341,4 +5349,19 @@
                 }
 #endif
+                break;
+            }
+            ///////////////////////
+            case CLEANUP_TEST_HEADER:
+            {
+                if (not p_dspin_clack.read) break;
+                r_cleanup_fsm = CLEANUP_TEST_SIGNATURE;
+                break;
+            }
+            ///////////////////////
+            case CLEANUP_TEST_SIGNATURE:
+            {
+                if (not p_dspin_clack.read) break;
+                r_cc_test_to_cleanup_req = false;
+                r_cleanup_fsm = CLEANUP_IDLE;
                 break;
             }
@@ -6697,5 +6720,5 @@
                 uint32_t srcid = DspinDhccpParam::dspin_get(
                         m_cc_receive_to_cc_test_fifo.read(),
-                        DspinDhccpParam::CC_TEST_SRCID);
+                        DspinDhccpParam::TEST_P2M_SRCID);
 
                 cc_receive_to_cc_test_fifo_get = true;
@@ -7436,7 +7459,9 @@
                     DspinDhccpParam::dspin_get(
                             p_dspin_p2m.data.read(),
-                            DspinDhccpParam::CC_TEST_TEST);
-
-                if ((type == DspinDhccpParam::TYPE_TEST) and (test == 1))
+                            DspinDhccpParam::TEST_P2M_TEST);
+
+                // TODO: verify DEST field
+
+                if ((type == DspinDhccpParam::TYPE_TEST) and test)
                 {
                     r_cc_receive_fsm = CC_RECEIVE_TEST;
@@ -9571,9 +9596,9 @@
                 DspinDhccpParam::dspin_set(flit,
                         r_cc_test_srcid.read(),
-                        DspinDhccpParam::CC_TEST_DEST);
+                        DspinDhccpParam::TEST_M2P_DEST);
 
                 DspinDhccpParam::dspin_set(flit,
                         1ULL,
-                        DspinDhccpParam::CC_TEST_TEST);
+                        DspinDhccpParam::TEST_M2P_TEST);
 
                 // TODO: Send MemoryCache SRCID too ?
@@ -9586,11 +9611,14 @@
             case CC_SEND_TEST_SIGNATURE:
             {
+                uint64_t data =
+                    DspinDhccpParam::dspin_get(
+                            m_cc_receive_to_cc_test_fifo.read(),
+                            DspinDhccpParam::TEST_P2M_SIGNATURE);
+
+                uint64_t lsb = (uint64_t)data & ((1 << 7) - 1);
                 uint64_t flit = 0;
-                uint64_t data = (uint64_t)m_cc_receive_to_cc_test_fifo.read();
-                uint64_t lsb  = (uint64_t)m_cc_receive_to_cc_test_fifo.read() & ((1 << 7) - 1);
-
                 DspinDhccpParam::dspin_set(flit,
                         data | (lsb << 32),
-                        DspinDhccpParam::CC_TEST_SIGNATURE);
+                        DspinDhccpParam::TEST_M2P_SIGNATURE);
 
                 p_dspin_m2p.write = true;
@@ -9605,49 +9633,92 @@
         ////////////////////////////////////////////////////////////////////
 
-        if (r_cleanup_fsm.read() == CLEANUP_SEND_CLACK)
+        switch(r_cleanup_fsm.read())
         {
-            uint8_t cleanup_ack_type;
-            if (r_cleanup_inst.read())
-            {
-                cleanup_ack_type = DspinDhccpParam::TYPE_CLACK_INST;
-            }
-            else
-            {
-                cleanup_ack_type = DspinDhccpParam::TYPE_CLACK_DATA;
-            }
-
-            uint64_t flit = 0;
-            uint64_t dest = r_cleanup_srcid.read() <<
-                (DspinDhccpParam::SRCID_WIDTH - vci_param_int::S);
-
-            DspinDhccpParam::dspin_set(
-                    flit,
-                    dest,
-                    DspinDhccpParam::CLACK_DEST);
-
-            DspinDhccpParam::dspin_set(
-                    flit,
-                    r_cleanup_nline.read(),
-                    DspinDhccpParam::CLACK_SET);
-
-            DspinDhccpParam::dspin_set(
-                    flit,
-                    r_cleanup_way_index.read(),
-                    DspinDhccpParam::CLACK_WAY);
-
-            DspinDhccpParam::dspin_set(
-                    flit,
-                    cleanup_ack_type,
-                    DspinDhccpParam::CLACK_TYPE);
-
-            p_dspin_clack.eop   = true;
-            p_dspin_clack.write = true;
-            p_dspin_clack.data  = flit;
-        }
-        else
-        {
-            p_dspin_clack.write = false;
-            p_dspin_clack.eop   = false;
-            p_dspin_clack.data  = 0;
+            case CLEANUP_SEND_CLACK:
+            {
+                uint8_t cleanup_ack_type;
+                if (r_cleanup_inst.read())
+                {
+                    cleanup_ack_type = DspinDhccpParam::TYPE_CLACK_INST;
+                }
+                else
+                {
+                    cleanup_ack_type = DspinDhccpParam::TYPE_CLACK_DATA;
+                }
+
+                uint64_t flit = 0;
+                uint64_t dest = r_cleanup_srcid.read() <<
+                    (DspinDhccpParam::SRCID_WIDTH - vci_param_int::S);
+
+                DspinDhccpParam::dspin_set(
+                        flit,
+                        dest,
+                        DspinDhccpParam::CLACK_DEST);
+
+                DspinDhccpParam::dspin_set(
+                        flit,
+                        r_cleanup_nline.read(),
+                        DspinDhccpParam::CLACK_SET);
+
+                DspinDhccpParam::dspin_set(
+                        flit,
+                        r_cleanup_way_index.read(),
+                        DspinDhccpParam::CLACK_WAY);
+
+                DspinDhccpParam::dspin_set(
+                        flit,
+                        cleanup_ack_type,
+                        DspinDhccpParam::CLACK_TYPE);
+
+                p_dspin_clack.eop   = true;
+                p_dspin_clack.write = true;
+                p_dspin_clack.data  = flit;
+                break;
+            }
+            /////////////////////////////////////
+            case CLEANUP_TEST_HEADER:
+            {
+                uint64_t flit = 0;
+
+                DspinDhccpParam::dspin_set(flit,
+                        r_cc_test_srcid.read(),
+                        DspinDhccpParam::TEST_CLACK_DEST);
+
+                DspinDhccpParam::dspin_set(flit,
+                        1ULL,
+                        DspinDhccpParam::TEST_CLACK_TEST);
+
+                // TODO: Send MemoryCache SRCID too ?
+
+                p_dspin_clack.write = true;
+                p_dspin_clack.eop   = false;
+                p_dspin_clack.data  = flit;
+                break;
+            }
+            ////////////////////////////////////
+            case CLEANUP_TEST_SIGNATURE:
+            {
+                uint64_t data =
+                    DspinDhccpParam::dspin_get(
+                            m_cc_receive_to_cc_test_fifo.read(),
+                            DspinDhccpParam::TEST_P2M_SIGNATURE);
+
+                uint64_t lsb = (uint64_t)data & ((1 << 7) - 1);
+                uint64_t flit = 0;
+                DspinDhccpParam::dspin_set(flit,
+                        data | (lsb << 32),
+                        DspinDhccpParam::TEST_CLACK_SIGNATURE);
+
+                p_dspin_clack.write = true;
+                p_dspin_clack.eop   = true;
+                p_dspin_clack.data  = flit;
+                break;
+            }
+            ////////////////////////////////////
+            default:
+                p_dspin_clack.write = false;
+                p_dspin_clack.eop   = false;
+                p_dspin_clack.data  = 0;
+                break;
         }
 
