Index: branches/v5/modules/vci_cc_vcache_wrapper_dspin_coherence/caba/source/include/vci_cc_vcache_wrapper_dspin_coherence.h
===================================================================
--- branches/v5/modules/vci_cc_vcache_wrapper_dspin_coherence/caba/source/include/vci_cc_vcache_wrapper_dspin_coherence.h	(revision 341)
+++ branches/v5/modules/vci_cc_vcache_wrapper_dspin_coherence/caba/source/include/vci_cc_vcache_wrapper_dspin_coherence.h	(revision 346)
@@ -1,3 +1,4 @@
 /* -*- c++ -*-
+ *
  * File : vci_cc_vcache_wrapper.h
  * Copyright (c) UPMC, Lip6, SoC
@@ -285,39 +286,35 @@
     sc_in<bool>                             p_resetn;
     sc_in<bool>                             p_irq[iss_t::n_irq];
-    soclib::caba::VciInitiator<vci_param>   p_vci_ini_d;
-    soclib::caba::DspinInput <40> p_dspin_in;
-    soclib::caba::DspinOutput<33> p_dspin_out;
+    soclib::caba::VciInitiator<vci_param>   p_vci;
+    soclib::caba::DspinInput <40>           p_dspin_in;
+    soclib::caba::DspinOutput<33>           p_dspin_out;
 
 private:
 
     // STRUCTURAL PARAMETERS
-    soclib::common::AddressDecodingTable<uint32_t, bool>    	m_cacheability_table;
-    const soclib::common::Segment                           	m_segment;
-    const vci_srcid_t                                       	m_srcid_d;
-    const vci_srcid_t                                       	m_srcid_c;
-
+    soclib::common::AddressDecodingTable<uint32_t, bool> m_cacheability_table;
+
+    const vci_srcid_t                   m_srcid;
+    const size_t                        m_cc_global_id;
+    const size_t                        m_nline_width;
     const size_t  						m_itlb_ways;
     const size_t  						m_itlb_sets;
-
     const size_t  						m_dtlb_ways;
     const size_t  						m_dtlb_sets;
-
     const size_t  						m_icache_ways;
     const size_t  						m_icache_sets;
     const paddr_t 						m_icache_yzmask;
     const size_t  						m_icache_words;
-
     const size_t  						m_dcache_ways;
     const size_t  						m_dcache_sets;
     const paddr_t 						m_dcache_yzmask;
     const size_t  						m_dcache_words;
-
     const size_t                        m_x_width;
     const size_t                        m_y_width;
-
-    const size_t                        m_memory_cache_local_id;
     const size_t                        m_proc_id;
     const uint32_t						m_max_frozen_cycles;
     const size_t  						m_paddr_nbits;
+    uint32_t                            m_debug_start_cycle;
+    bool                                m_debug_ok;
 
     ////////////////////////////////////////
@@ -332,6 +329,4 @@
     // debug variables (for each FSM)
     /////////////////////////////////////////////
-    uint32_t                            m_debug_start_cycle;
-    bool                                m_debug_ok;
     bool                                m_debug_previous_hit;
     bool                                m_idebug_previous_hit;
@@ -686,29 +681,26 @@
 public:
     VciCcVCacheWrapper(
-        sc_module_name insname,
-        int proc_id,
-        const soclib::common::MappingTable &mtp,
-        const soclib::common::MappingTable &mtc,
-        const soclib::common::IntTab &initiator_index_d,
-        const soclib::common::IntTab &initiator_index_c,
-        const soclib::common::IntTab &target_index_d,
-        size_t   itlb_ways,
-        size_t   itlb_sets,
-        size_t   dtlb_ways,
-        size_t   dtlb_sets,
-        size_t   icache_ways,
-        size_t   icache_sets,
-        size_t   icache_words,
-        size_t   dcache_ways,
-        size_t   dcache_sets,
-        size_t   dcache_words,
-        size_t   wbuf_nlines,
-        size_t   wbuf_nwords,
-        size_t   x_width,
-        size_t   y_width,
-        uint32_t memory_cache_local_id,
-        uint32_t max_frozen_cycles,
-        uint32_t debug_start_cycle,
-        bool     debug_ok);
+        sc_module_name                      name,
+        const int                           proc_id,
+        const soclib::common::MappingTable  &mtd,
+        const soclib::common::IntTab        &srcid,
+        const size_t                        cc_global_id,
+        const size_t                        itlb_ways,
+        const size_t                        itlb_sets,
+        const size_t                        dtlb_ways,
+        const size_t                        dtlb_sets,
+        const size_t                        icache_ways,
+        const size_t                        icache_sets,
+        const size_t                        icache_words,
+        const size_t                        dcache_ways,
+        const size_t                        dcache_sets,
+        const size_t                        dcache_words,
+        const size_t                        wbuf_nlines,
+        const size_t                        wbuf_nwords,
+        const size_t                        x_width,
+        const size_t                        y_width,
+        const uint32_t                      max_frozen_cycles,
+        const uint32_t                      debug_start_cycle,
+        const bool                          debug_ok );
 
     ~VciCcVCacheWrapper();
Index: branches/v5/modules/vci_cc_vcache_wrapper_dspin_coherence/caba/source/src/vci_cc_vcache_wrapper_dspin_coherence.cpp
===================================================================
--- branches/v5/modules/vci_cc_vcache_wrapper_dspin_coherence/caba/source/src/vci_cc_vcache_wrapper_dspin_coherence.cpp	(revision 341)
+++ branches/v5/modules/vci_cc_vcache_wrapper_dspin_coherence/caba/source/src/vci_cc_vcache_wrapper_dspin_coherence.cpp	(revision 346)
@@ -162,72 +162,61 @@
 #define tmpl(...)  template<typename vci_param, typename iss_t> __VA_ARGS__ VciCcVCacheWrapper<vci_param, iss_t>
 
-using soclib::common::uint32_log2;
+using namespace soclib::common;
 
 /////////////////////////////////
 tmpl(/**/)::VciCcVCacheWrapper(
     sc_module_name 			name,
-    int 				proc_id,
-    const soclib::common::MappingTable 	&mtd,
-    const soclib::common::MappingTable 	&mtc,
-    const soclib::common::IntTab 	&initiator_index_d,
-    const soclib::common::IntTab 	&initiator_index_c,
-    const soclib::common::IntTab 	&target_index_c,
-    size_t 				itlb_ways,
-    size_t 				itlb_sets,
-    size_t 				dtlb_ways,
-    size_t 				dtlb_sets,
-    size_t 				icache_ways,
-    size_t 				icache_sets,
-    size_t 				icache_words,
-    size_t 				dcache_ways,
-    size_t 				dcache_sets,
-    size_t 				dcache_words,
-    size_t 				wbuf_nlines,
-    size_t 				wbuf_nwords,
-    size_t				x_width,
-    size_t				y_width,
-    uint32_t			memory_cache_local_id,
-    uint32_t			max_frozen_cycles,
-    uint32_t			debug_start_cycle,
-    bool				debug_ok)
+    const int 				proc_id,
+    const MappingTable 	    &mtd,
+    const IntTab 	        &srcid,
+    const size_t 	        cc_global_id,
+    const size_t 			itlb_ways,
+    const size_t 			itlb_sets,
+    const size_t 			dtlb_ways,
+    const size_t 			dtlb_sets,
+    const size_t 			icache_ways,
+    const size_t 			icache_sets,
+    const size_t 			icache_words,
+    const size_t 			dcache_ways,
+    const size_t 			dcache_sets,
+    const size_t 			dcache_words,
+    const size_t 			wbuf_nlines,
+    const size_t 			wbuf_nwords,
+    const size_t			x_width,
+    const size_t			y_width,
+    const uint32_t			max_frozen_cycles,
+    const uint32_t			debug_start_cycle,
+    const bool				debug_ok )
     : soclib::caba::BaseModule(name),
 
-      p_clk("clk"),
-      p_resetn("resetn"),
-      p_vci_ini_d("vci_ini_d"),
-      p_dspin_in("dspin_in"),
-      p_dspin_out("dspin_out"),
-
-      m_cacheability_table(mtd.getCacheabilityTable()),
-      m_segment(mtc.getSegment(target_index_c)),
-      m_srcid_d(mtd.indexForId(initiator_index_d)),
-      m_srcid_c(mtc.indexForId(initiator_index_c)),
-
-      m_itlb_ways(itlb_ways),
-      m_itlb_sets(itlb_sets),
-
-      m_dtlb_ways(dtlb_ways),
-      m_dtlb_sets(dtlb_sets),
-
-      m_icache_ways(icache_ways),
-      m_icache_sets(icache_sets),
-      m_icache_yzmask((~0)<<(uint32_log2(icache_words) + 2)),
-      m_icache_words(icache_words),
-
-      m_dcache_ways(dcache_ways),
-      m_dcache_sets(dcache_sets),
-      m_dcache_yzmask((~0)<<(uint32_log2(dcache_words) + 2)),
-      m_dcache_words(dcache_words),
-
-      m_x_width(x_width),
-      m_y_width(y_width),
-
-      m_memory_cache_local_id(memory_cache_local_id),
-      m_proc_id(proc_id),
-      m_max_frozen_cycles(max_frozen_cycles),
-      m_paddr_nbits(vci_param::N),
-
-      m_debug_start_cycle(debug_start_cycle),
-      m_debug_ok(debug_ok),
+      p_clk("p_clk"),
+      p_resetn("p_resetn"),
+      p_vci("p_vci"),
+      p_dspin_in("p_dspin_in"),
+      p_dspin_out("p_dspin_out"),
+
+      m_cacheability_table( mtd.getCacheabilityTable() ),
+      m_srcid( mtd.indexForId(srcid) ),
+      m_cc_global_id( cc_global_id ),
+      m_nline_width( vci_param::N - (uint32_log2(dcache_words)) - 2 ),
+      m_itlb_ways( itlb_ways ),
+      m_itlb_sets( itlb_sets ),
+      m_dtlb_ways( dtlb_ways ),
+      m_dtlb_sets( dtlb_sets ),
+      m_icache_ways( icache_ways ),
+      m_icache_sets( icache_sets ),
+      m_icache_yzmask( (~0)<<(uint32_log2(icache_words) + 2) ),
+      m_icache_words( icache_words ),
+      m_dcache_ways( dcache_ways ),
+      m_dcache_sets( dcache_sets ),
+      m_dcache_yzmask( (~0)<<(uint32_log2(dcache_words) + 2) ),
+      m_dcache_words( dcache_words ),
+      m_x_width( x_width ),
+      m_y_width( y_width ),
+      m_proc_id( proc_id ),
+      m_max_frozen_cycles( max_frozen_cycles ),
+      m_paddr_nbits( vci_param::N ),
+      m_debug_start_cycle( debug_start_cycle ),
+      m_debug_ok( debug_ok ),
 
       r_mmu_ptpr("r_mmu_ptpr"),
@@ -3050,5 +3039,5 @@
         // We should compute the access locality:
         // The PPN MSB bits define the destination cluster index.
-        // The m_srcid_d MSB bits define the source cluster index.
+        // The m_srcid MSB bits define the source cluster index.
         // The number of bits to compare depends on the number of clusters,
         // and can be obtained in the mapping table.
@@ -3305,5 +3294,5 @@
         // We should compute the access locality:
         // The PPN MSB bits define the destination cluster index.
-        // The m_srcid_d MSB bits define the source cluster index.
+        // The m_srcid MSB bits define the source cluster index.
         // The number of bits to compare depends on the number of clusters,
         // and can be obtained in the mapping table.
@@ -5004,5 +4993,5 @@
         case CMD_DATA_WRITE:
         {
-            if ( p_vci_ini_d.cmdack.read() )
+            if ( p_vci.cmdack.read() )
             {
                 r_vci_cmd_cpt = r_vci_cmd_cpt + 1;
@@ -5020,5 +5009,5 @@
         {
             // The CAS and SC VCI commands contain two flits
-            if ( p_vci_ini_d.cmdack.read() )
+            if ( p_vci.cmdack.read() )
             {
                r_vci_cmd_cpt = r_vci_cmd_cpt + 1;
@@ -5035,5 +5024,5 @@
         {
             // all read VCI commands contain one single flit
-            if ( p_vci_ini_d.cmdack.read() )  r_vci_cmd_fsm = CMD_IDLE;
+            if ( p_vci.cmdack.read() )  r_vci_cmd_fsm = CMD_IDLE;
             break;
         }
@@ -5073,37 +5062,37 @@
     case RSP_IDLE:
     {
-        if ( p_vci_ini_d.rspval.read() )
+        if ( p_vci.rspval.read() )
         {
             r_vci_rsp_cpt = 0;
 
-            if      ( (p_vci_ini_d.rpktid.read() & 0x7) ==  TYPE_READ_DATA_UNC  )
+            if      ( (p_vci.rpktid.read() & 0x7) ==  TYPE_READ_DATA_UNC  )
             {
                 r_vci_rsp_fsm = RSP_DATA_UNC;
             }
-            else if ( (p_vci_ini_d.rpktid.read() & 0x7) ==  TYPE_READ_DATA_MISS )
+            else if ( (p_vci.rpktid.read() & 0x7) ==  TYPE_READ_DATA_MISS )
             {
                 r_vci_rsp_fsm = RSP_DATA_MISS;
             }
-            else if ( (p_vci_ini_d.rpktid.read() & 0x7) ==  TYPE_READ_INS_UNC   )
+            else if ( (p_vci.rpktid.read() & 0x7) ==  TYPE_READ_INS_UNC   )
             {
                 r_vci_rsp_fsm = RSP_INS_UNC;
             }
-            else if ( (p_vci_ini_d.rpktid.read() & 0x7) ==  TYPE_READ_INS_MISS  )
+            else if ( (p_vci.rpktid.read() & 0x7) ==  TYPE_READ_INS_MISS  )
             {
                 r_vci_rsp_fsm = RSP_INS_MISS;
             }
-            else if ( (p_vci_ini_d.rpktid.read() & 0x7) ==  TYPE_WRITE          )
+            else if ( (p_vci.rpktid.read() & 0x7) ==  TYPE_WRITE          )
             {
                 r_vci_rsp_fsm = RSP_DATA_WRITE;
             }
-            else if ( (p_vci_ini_d.rpktid.read() & 0x7) ==  TYPE_CAS            )
+            else if ( (p_vci.rpktid.read() & 0x7) ==  TYPE_CAS            )
             {
                 r_vci_rsp_fsm = RSP_DATA_UNC;
             }
-            else if ( (p_vci_ini_d.rpktid.read() & 0x7) ==  TYPE_LL             )
+            else if ( (p_vci.rpktid.read() & 0x7) ==  TYPE_LL             )
             {
                 r_vci_rsp_fsm = RSP_DATA_LL;
             }
-            else if ( (p_vci_ini_d.rpktid.read() & 0x7) == TYPE_SC             )
+            else if ( (p_vci.rpktid.read() & 0x7) == TYPE_SC             )
             {
                 r_vci_rsp_fsm = RSP_DATA_UNC;
@@ -5119,10 +5108,10 @@
         case RSP_INS_MISS:
         {
-            if ( p_vci_ini_d.rspval.read() )
-            {
-                if ( (p_vci_ini_d.rerror.read()&0x1) != 0 )  // error reported
+            if ( p_vci.rspval.read() )
+            {
+                if ( (p_vci.rerror.read()&0x1) != 0 )  // error reported
                 {
                     r_vci_rsp_ins_error = true;
-                    if ( p_vci_ini_d.reop.read() ) r_vci_rsp_fsm = RSP_IDLE;
+                    if ( p_vci.reop.read() ) r_vci_rsp_fsm = RSP_IDLE;
                 }
                 else                                        // no error reported
@@ -5135,6 +5124,6 @@
                         r_vci_rsp_cpt                 = r_vci_rsp_cpt.read() + 1;
                         vci_rsp_fifo_icache_put       = true,
-                        vci_rsp_fifo_icache_data      = p_vci_ini_d.rdata.read();
-                        if ( p_vci_ini_d.reop.read() )
+                        vci_rsp_fifo_icache_data      = p_vci.rdata.read();
+                        if ( p_vci.reop.read() )
                         {
                             assert( (r_vci_rsp_cpt.read() == m_icache_words - 1) and
@@ -5151,10 +5140,10 @@
         case RSP_INS_UNC:
         {
-            if (p_vci_ini_d.rspval.read() )
-            {
-                assert( p_vci_ini_d.reop.read() and
+            if (p_vci.rspval.read() )
+            {
+                assert( p_vci.reop.read() and
                 "illegal VCI response packet for uncachable instruction");
 
-                if ( (p_vci_ini_d.rerror.read()&0x1) != 0 )  // error reported
+                if ( (p_vci.rerror.read()&0x1) != 0 )  // error reported
                 {
                     r_vci_rsp_ins_error = true;
@@ -5166,5 +5155,5 @@
                     {
                         vci_rsp_fifo_icache_put       = true;
-                        vci_rsp_fifo_icache_data      = p_vci_ini_d.rdata.read();
+                        vci_rsp_fifo_icache_data      = p_vci.rdata.read();
                         r_vci_rsp_fsm = RSP_IDLE;
                     }
@@ -5176,10 +5165,10 @@
         case RSP_DATA_MISS:
         {
-            if ( p_vci_ini_d.rspval.read() )
-            {
-                if ( (p_vci_ini_d.rerror.read()&0x1) != 0 )  // error reported
+            if ( p_vci.rspval.read() )
+            {
+                if ( (p_vci.rerror.read()&0x1) != 0 )  // error reported
                 {
                     r_vci_rsp_data_error = true;
-                    if ( p_vci_ini_d.reop.read() ) r_vci_rsp_fsm = RSP_IDLE;
+                    if ( p_vci.reop.read() ) r_vci_rsp_fsm = RSP_IDLE;
                 }
                 else                                        // no error reported
@@ -5192,6 +5181,6 @@
                         r_vci_rsp_cpt                 = r_vci_rsp_cpt.read() + 1;
                         vci_rsp_fifo_dcache_put       = true,
-                        vci_rsp_fifo_dcache_data      = p_vci_ini_d.rdata.read();
-                        if ( p_vci_ini_d.reop.read() )
+                        vci_rsp_fifo_dcache_data      = p_vci.rdata.read();
+                        if ( p_vci.reop.read() )
                         {
                             assert( (r_vci_rsp_cpt.read() == m_dcache_words - 1) and
@@ -5208,10 +5197,10 @@
         case RSP_DATA_UNC:
         {
-            if (p_vci_ini_d.rspval.read() )
-            {
-                assert( p_vci_ini_d.reop.read() and
+            if (p_vci.rspval.read() )
+            {
+                assert( p_vci.reop.read() and
                 "illegal VCI response packet for uncachable read data");
 
-                if ( (p_vci_ini_d.rerror.read()&0x1) != 0 )  // error reported
+                if ( (p_vci.rerror.read()&0x1) != 0 )  // error reported
                 {
                     r_vci_rsp_data_error = true;
@@ -5223,5 +5212,5 @@
                     {
                         vci_rsp_fifo_dcache_put       = true;
-                        vci_rsp_fifo_dcache_data      = p_vci_ini_d.rdata.read();
+                        vci_rsp_fifo_dcache_data      = p_vci.rdata.read();
                         r_vci_rsp_fsm = RSP_IDLE;
                     }
@@ -5233,7 +5222,7 @@
         case RSP_DATA_LL:
         {
-            if ( p_vci_ini_d.rspval.read() )
-            {
-                if ( (p_vci_ini_d.rerror.read()&0x1) != 0 )  // error reported
+            if ( p_vci.rspval.read() )
+            {
+                if ( (p_vci.rerror.read()&0x1) != 0 )  // error reported
                 {
                     r_vci_rsp_data_error = true;
@@ -5244,8 +5233,8 @@
                     if(r_vci_rsp_fifo_dcache.wok())
                     {
-                        assert(!p_vci_ini_d.reop.read() &&
+                        assert(!p_vci.reop.read() &&
                             "illegal VCI response packet for LL");
                         vci_rsp_fifo_dcache_put  = true;
-                        vci_rsp_fifo_dcache_data = p_vci_ini_d.rdata.read();
+                        vci_rsp_fifo_dcache_data = p_vci.rdata.read();
                         r_vci_rsp_cpt            = r_vci_rsp_cpt.read() + 1;
                     }
@@ -5256,8 +5245,8 @@
                     if(r_vci_rsp_fifo_dcache.wok())
                     {
-                        assert(p_vci_ini_d.reop.read() &&
+                        assert(p_vci.reop.read() &&
                             "illegal VCI response packet for LL");
                         vci_rsp_fifo_dcache_put  = true;
-                        vci_rsp_fifo_dcache_data = p_vci_ini_d.rdata.read();
+                        vci_rsp_fifo_dcache_data = p_vci.rdata.read();
                         r_vci_rsp_fsm            = RSP_IDLE;
                     }
@@ -5270,14 +5259,14 @@
         case RSP_DATA_WRITE:
         {
-            if (p_vci_ini_d.rspval.read())
-            {
-                assert( p_vci_ini_d.reop.read() and
+            if (p_vci.rspval.read())
+            {
+                assert( p_vci.reop.read() and
                 "a VCI response packet must contain one flit for a write transaction");
 
                 r_vci_rsp_fsm = RSP_IDLE;
-                uint32_t   wbuf_index = p_vci_ini_d.rtrdid.read();
+                uint32_t   wbuf_index = p_vci.rtrdid.read();
                 bool       cacheable  = r_wbuf.completed(wbuf_index);
                 if ( not cacheable ) r_dcache_pending_unc_write = false;
-                if ( (p_vci_ini_d.rerror.read()&0x1) != 0 ) r_iss.setWriteBerr();
+                if ( (p_vci.rerror.read()&0x1) != 0 ) r_iss.setWriteBerr();
             }
             break;
@@ -5545,5 +5534,5 @@
         case CC_RECEIVE_INVAL_HEADER:
         {
-            // sample updt tab index in the HEADER, than skip to second flit
+            // sample updt tab index in the HEADER, then skip to second flit
             uint64_t receive_data = p_dspin_in.data.read();
             // for data INVAL, wait for dcache to take the request
@@ -5683,4 +5672,5 @@
                                  vci_rsp_fifo_dcache_put,
                                  vci_rsp_fifo_dcache_data);
+
     ///////////////// updt FIFO update  //////////////////////
     //TODO check this
@@ -5708,146 +5698,147 @@
                          (r_vci_cmd_fsm.read() == CMD_DATA_SC );
 
-    p_vci_ini_d.pktid  = 0;
-    p_vci_ini_d.srcid  = m_srcid_d;
-    p_vci_ini_d.cons   = is_sc_or_cas; 
-    p_vci_ini_d.contig = not is_sc_or_cas; 
-    p_vci_ini_d.wrap   = false;
-    p_vci_ini_d.clen   = 0;
-    p_vci_ini_d.cfixed = false;
+    p_vci.pktid  = 0;
+    p_vci.srcid  = m_srcid;
+    p_vci.cons   = is_sc_or_cas; 
+    p_vci.contig = not is_sc_or_cas; 
+    p_vci.wrap   = false;
+    p_vci.clen   = 0;
+    p_vci.cfixed = false;
 
     switch ( r_vci_cmd_fsm.read() ) {
 
     case CMD_IDLE:
-        p_vci_ini_d.cmdval  = false;
-        p_vci_ini_d.address = 0;
-        p_vci_ini_d.wdata   = 0;
-        p_vci_ini_d.be      = 0;
-        p_vci_ini_d.trdid   = 0;
-        p_vci_ini_d.pktid   = 0;
-        p_vci_ini_d.plen    = 0;
-        p_vci_ini_d.cmd     = vci_param::CMD_NOP;
-        p_vci_ini_d.eop     = false;
+        p_vci.cmdval  = false;
+        p_vci.address = 0;
+        p_vci.wdata   = 0;
+        p_vci.be      = 0;
+        p_vci.trdid   = 0;
+        p_vci.pktid   = 0;
+        p_vci.plen    = 0;
+        p_vci.cmd     = vci_param::CMD_NOP;
+        p_vci.eop     = false;
         break;
 
     case CMD_INS_MISS:
-        p_vci_ini_d.cmdval  = true;
-        p_vci_ini_d.address = r_icache_vci_paddr.read() & m_icache_yzmask;
-        p_vci_ini_d.wdata   = 0;
-        p_vci_ini_d.be      = 0xF;
-        p_vci_ini_d.trdid   = 0;
-        p_vci_ini_d.pktid   = TYPE_READ_INS_MISS;
-        p_vci_ini_d.plen    = m_icache_words<<2;
-        p_vci_ini_d.cmd     = vci_param::CMD_READ;
-        p_vci_ini_d.eop     = true;
+        p_vci.cmdval  = true;
+        p_vci.address = r_icache_vci_paddr.read() & m_icache_yzmask;
+        p_vci.wdata   = 0;
+        p_vci.be      = 0xF;
+        p_vci.trdid   = 0;
+        p_vci.pktid   = TYPE_READ_INS_MISS;
+        p_vci.plen    = m_icache_words<<2;
+        p_vci.cmd     = vci_param::CMD_READ;
+        p_vci.eop     = true;
         break;
 
     case CMD_INS_UNC:
-        p_vci_ini_d.cmdval  = true;
-        p_vci_ini_d.address = r_icache_vci_paddr.read() & ~0x3;
-        p_vci_ini_d.wdata   = 0;
-        p_vci_ini_d.be      = 0xF;
-        p_vci_ini_d.trdid   = 0;
-        p_vci_ini_d.pktid   = TYPE_READ_INS_UNC;
-        p_vci_ini_d.plen    = 4;
-        p_vci_ini_d.cmd     = vci_param::CMD_READ;
-        p_vci_ini_d.eop     = true;
+        p_vci.cmdval  = true;
+        p_vci.address = r_icache_vci_paddr.read() & ~0x3;
+        p_vci.wdata   = 0;
+        p_vci.be      = 0xF;
+        p_vci.trdid   = 0;
+        p_vci.pktid   = TYPE_READ_INS_UNC;
+        p_vci.plen    = 4;
+        p_vci.cmd     = vci_param::CMD_READ;
+        p_vci.eop     = true;
         break;
 
     case CMD_DATA_MISS:
-        p_vci_ini_d.cmdval  = true;
-        p_vci_ini_d.address = r_dcache_vci_paddr.read() & m_dcache_yzmask;
-        p_vci_ini_d.wdata   = 0;
-        p_vci_ini_d.be      = 0xF;
-        p_vci_ini_d.trdid   = 0;
-        p_vci_ini_d.pktid   = TYPE_READ_DATA_MISS;
-        p_vci_ini_d.plen    = m_dcache_words << 2;
-        p_vci_ini_d.cmd     = vci_param::CMD_READ;
-        p_vci_ini_d.eop     = true;
+        p_vci.cmdval  = true;
+        p_vci.address = r_dcache_vci_paddr.read() & m_dcache_yzmask;
+        p_vci.wdata   = 0;
+        p_vci.be      = 0xF;
+        p_vci.trdid   = 0;
+        p_vci.pktid   = TYPE_READ_DATA_MISS;
+        p_vci.plen    = m_dcache_words << 2;
+        p_vci.cmd     = vci_param::CMD_READ;
+        p_vci.eop     = true;
         break;
 
     case CMD_DATA_UNC:
-        p_vci_ini_d.cmdval  = true;
-        p_vci_ini_d.address = r_dcache_vci_paddr.read() & ~0x3;
-        p_vci_ini_d.wdata   = 0;
-        p_vci_ini_d.be      = r_dcache_vci_unc_be.read();
-        p_vci_ini_d.trdid   = 0;
-        p_vci_ini_d.pktid   = TYPE_READ_DATA_UNC;
-        p_vci_ini_d.plen    = 4;
-        p_vci_ini_d.cmd     = vci_param::CMD_READ;
-        p_vci_ini_d.eop     = true;
+        p_vci.cmdval  = true;
+        p_vci.address = r_dcache_vci_paddr.read() & ~0x3;
+        p_vci.wdata   = 0;
+        p_vci.be      = r_dcache_vci_unc_be.read();
+        p_vci.trdid   = 0;
+        p_vci.pktid   = TYPE_READ_DATA_UNC;
+        p_vci.plen    = 4;
+        p_vci.cmd     = vci_param::CMD_READ;
+        p_vci.eop     = true;
         break;
 
     case CMD_DATA_WRITE:
-        p_vci_ini_d.cmdval  = true;
-        p_vci_ini_d.address = r_wbuf.getAddress(r_vci_cmd_cpt.read()) & ~0x3;
-        p_vci_ini_d.wdata   = r_wbuf.getData(r_vci_cmd_cpt.read());
-        p_vci_ini_d.be      = r_wbuf.getBe(r_vci_cmd_cpt.read());
-        p_vci_ini_d.trdid   = r_wbuf.getIndex();
-        p_vci_ini_d.pktid   = TYPE_WRITE;
-        p_vci_ini_d.plen    = (r_vci_cmd_max.read() - r_vci_cmd_min.read() + 1) << 2;
-        p_vci_ini_d.cmd     = vci_param::CMD_WRITE;
-        p_vci_ini_d.eop     = (r_vci_cmd_cpt.read() == r_vci_cmd_max.read());
+        p_vci.cmdval  = true;
+        p_vci.address = r_wbuf.getAddress(r_vci_cmd_cpt.read()) & ~0x3;
+        p_vci.wdata   = r_wbuf.getData(r_vci_cmd_cpt.read());
+        p_vci.be      = r_wbuf.getBe(r_vci_cmd_cpt.read());
+        p_vci.trdid   = r_wbuf.getIndex();
+        p_vci.pktid   = TYPE_WRITE;
+        p_vci.plen    = (r_vci_cmd_max.read() - r_vci_cmd_min.read() + 1) << 2;
+        p_vci.cmd     = vci_param::CMD_WRITE;
+        p_vci.eop     = (r_vci_cmd_cpt.read() == r_vci_cmd_max.read());
         break;
 
     case CMD_DATA_LL:
-        p_vci_ini_d.cmdval  = true;
-        p_vci_ini_d.address = r_dcache_vci_paddr.read() & ~0x3;
-        p_vci_ini_d.wdata   = 0;
-        p_vci_ini_d.be      = 0xF;
-        p_vci_ini_d.trdid   = 0;
-        p_vci_ini_d.pktid   = TYPE_LL;
-        p_vci_ini_d.plen    = 8;
-        p_vci_ini_d.cmd     = vci_param::CMD_LOCKED_READ;
-        p_vci_ini_d.eop     = true;
+        p_vci.cmdval  = true;
+        p_vci.address = r_dcache_vci_paddr.read() & ~0x3;
+        p_vci.wdata   = 0;
+        p_vci.be      = 0xF;
+        p_vci.trdid   = 0;
+        p_vci.pktid   = TYPE_LL;
+        p_vci.plen    = 8;
+        p_vci.cmd     = vci_param::CMD_LOCKED_READ;
+        p_vci.eop     = true;
         break;
 
     case CMD_DATA_SC:
-        p_vci_ini_d.cmdval  = true;
-        p_vci_ini_d.address = r_dcache_vci_paddr.read() & ~0x3;
-        if ( r_vci_cmd_cpt.read() == 0 ) p_vci_ini_d.wdata = r_dcache_llsc_key.read();
-        else                             p_vci_ini_d.wdata = r_dcache_vci_sc_data.read();
-        p_vci_ini_d.be      = 0xF;
-        p_vci_ini_d.trdid   = 0;
-        p_vci_ini_d.pktid   = TYPE_SC;
-        p_vci_ini_d.plen    = 8;
-        p_vci_ini_d.cmd     = vci_param::CMD_NOP;
-        p_vci_ini_d.eop     = (r_vci_cmd_cpt.read() == 1);
+        p_vci.cmdval  = true;
+        p_vci.address = r_dcache_vci_paddr.read() & ~0x3;
+        if ( r_vci_cmd_cpt.read() == 0 ) p_vci.wdata = r_dcache_llsc_key.read();
+        else                             p_vci.wdata = r_dcache_vci_sc_data.read();
+        p_vci.be      = 0xF;
+        p_vci.trdid   = 0;
+        p_vci.pktid   = TYPE_SC;
+        p_vci.plen    = 8;
+        p_vci.cmd     = vci_param::CMD_NOP;
+        p_vci.eop     = (r_vci_cmd_cpt.read() == 1);
         break;
 
     case CMD_DATA_CAS:
-        p_vci_ini_d.cmdval  = true;
-        p_vci_ini_d.address = r_dcache_vci_paddr.read() & ~0x3;
-        if ( r_vci_cmd_cpt.read() == 0 ) p_vci_ini_d.wdata = r_dcache_vci_cas_old.read();
-        else                             p_vci_ini_d.wdata = r_dcache_vci_cas_new.read();
-        p_vci_ini_d.be      = 0xF;
-        p_vci_ini_d.trdid   = 0;
-        p_vci_ini_d.pktid   = TYPE_CAS;
-        p_vci_ini_d.plen    = 8;
-        p_vci_ini_d.cmd     = vci_param::CMD_NOP;
-        p_vci_ini_d.eop     = (r_vci_cmd_cpt.read() == 1);
+        p_vci.cmdval  = true;
+        p_vci.address = r_dcache_vci_paddr.read() & ~0x3;
+        if ( r_vci_cmd_cpt.read() == 0 ) p_vci.wdata = r_dcache_vci_cas_old.read();
+        else                             p_vci.wdata = r_dcache_vci_cas_new.read();
+        p_vci.be      = 0xF;
+        p_vci.trdid   = 0;
+        p_vci.pktid   = TYPE_CAS;
+        p_vci.plen    = 8;
+        p_vci.cmd     = vci_param::CMD_NOP;
+        p_vci.eop     = (r_vci_cmd_cpt.read() == 1);
         break;
     } // end switch r_vci_cmd_fsm
 
     // VCI initiator response on the direct network
-    // it depends on the VCI RSP state
+    // it depends on the VCI_RSP FSM
 
     switch (r_vci_rsp_fsm.read() )
     {
-        case RSP_DATA_WRITE : p_vci_ini_d.rspack = true; break;
-        case RSP_INS_MISS   : p_vci_ini_d.rspack = r_vci_rsp_fifo_icache.wok(); break;
-        case RSP_INS_UNC    : p_vci_ini_d.rspack = r_vci_rsp_fifo_icache.wok(); break;
-        case RSP_DATA_MISS  : p_vci_ini_d.rspack = r_vci_rsp_fifo_dcache.wok(); break;
-        case RSP_DATA_UNC   : p_vci_ini_d.rspack = r_vci_rsp_fifo_dcache.wok(); break;
-        case RSP_DATA_LL    : p_vci_ini_d.rspack = r_vci_rsp_fifo_dcache.wok(); break;
-        case RSP_IDLE       : p_vci_ini_d.rspack = false; break;
+        case RSP_DATA_WRITE : p_vci.rspack = true; break;
+        case RSP_INS_MISS   : p_vci.rspack = r_vci_rsp_fifo_icache.wok(); break;
+        case RSP_INS_UNC    : p_vci.rspack = r_vci_rsp_fifo_icache.wok(); break;
+        case RSP_DATA_MISS  : p_vci.rspack = r_vci_rsp_fifo_dcache.wok(); break;
+        case RSP_DATA_UNC   : p_vci.rspack = r_vci_rsp_fifo_dcache.wok(); break;
+        case RSP_DATA_LL    : p_vci.rspack = r_vci_rsp_fifo_dcache.wok(); break;
+        case RSP_IDLE       : p_vci.rspack = false; break;
     } // end switch r_vci_rsp_fsm
 
-    /////////////////
-    // CC_SEND FSM //
-    /////////////////
+    
+    // Send coherence packets on DSPIN L2M 
+    // it depends on the CC_SEND FSM 
+
     uint64_t dspin_send_data = 0;
     switch ( r_cc_send_fsm.read() )
     {
-        ///////////////////////////
+        //////////////////
         case CC_SEND_IDLE:
         {
@@ -5855,58 +5846,61 @@
             break;
         }
-        ///////////////////////////
+        ///////////////////////
         case CC_SEND_CLEANUP_1:
         {
             // initialize dspin send data
-            DspinDhccpParam::dspin_set(dspin_send_data,0,DspinDhccpParam::FROM_L1_EOP);
-            DspinDhccpParam::dspin_set(dspin_send_data,m_srcid_c,DspinDhccpParam::CLEANUP_SRCID);
-            DspinDhccpParam::dspin_set(dspin_send_data,0,DspinDhccpParam::FROM_L1_BC);
-            // dcache active request
-            if(r_cc_send_last_client.read() == 0)
-            {
-                // compute global id
-                uint32_t nline_size = vci_param::N - (uint32_log2(m_dcache_words)) - (uint32_log2(vci_param::B));
-                uint64_t global_id = (uint64_t) r_dcache_cc_send_nline.read();
-                global_id >>= (nline_size - m_x_width - m_y_width) << (DspinDhccpParam::GLOBALID_WIDTH - m_x_width - m_y_width);
-
+            DspinDhccpParam::dspin_set(dspin_send_data,
+                                       0,
+                                       DspinDhccpParam::FROM_L1_EOP);
+            DspinDhccpParam::dspin_set(dspin_send_data,
+                                       m_cc_global_id,
+                                       DspinDhccpParam::CLEANUP_SRCID);
+            DspinDhccpParam::dspin_set(dspin_send_data,
+                                       0,
+                                       DspinDhccpParam::FROM_L1_BC);
+
+            if(r_cc_send_last_client.read() == 0) // dcache active request
+            {
+                uint64_t dest = (uint64_t)r_dcache_cc_send_nline.read() 
+                                >> (m_nline_width - m_x_width - m_y_width) 
+                                << (DspinDhccpParam::GLOBALID_WIDTH - m_x_width - m_y_width);
+ 
                 DspinDhccpParam::dspin_set(dspin_send_data,
-                    global_id,
-                    DspinDhccpParam::CLEANUP_DEST);
+                                           dest,
+                                           DspinDhccpParam::CLEANUP_DEST);
 
                 DspinDhccpParam::dspin_set(dspin_send_data,
-                    r_dcache_cc_send_nline.read() & 0x300000000ULL,
-                    DspinDhccpParam::CLEANUP_NLINE_MSB);
+                                           r_dcache_cc_send_nline.read() & 0x300000000ULL,
+                                           DspinDhccpParam::CLEANUP_NLINE_MSB);
 
                 DspinDhccpParam::dspin_set(dspin_send_data,
-                    r_dcache_cc_send_way.read(),
-                    DspinDhccpParam::CLEANUP_WAY_INDEX);
+                                           r_dcache_cc_send_way.read(),
+                                           DspinDhccpParam::CLEANUP_WAY_INDEX);
 
                 DspinDhccpParam::dspin_set(dspin_send_data,
-                    DspinDhccpParam::TYPE_CLEANUP_DATA,
-                    DspinDhccpParam::FROM_L1_TYPE);
-            }
-            // icache active request
-            else
-            {
-                // compute global id
-                uint32_t nline_size = vci_param::N - (uint32_log2(m_icache_words)) - (uint32_log2(vci_param::B));
-                uint64_t global_id = (uint64_t) r_icache_cc_send_nline.read();
-                global_id >>= (nline_size - m_x_width - m_y_width) << (DspinDhccpParam::GLOBALID_WIDTH - m_x_width - m_y_width);
+                                           DspinDhccpParam::TYPE_CLEANUP_DATA,
+                                           DspinDhccpParam::FROM_L1_TYPE);
+            }
+            else                                // icache active request
+            {
+                uint64_t dest = (uint64_t)r_icache_cc_send_nline.read() 
+                                >> (m_nline_width - m_x_width - m_y_width) 
+                                << (DspinDhccpParam::GLOBALID_WIDTH - m_x_width - m_y_width);
 
                 DspinDhccpParam::dspin_set(dspin_send_data,
-                    global_id,
-                    DspinDhccpParam::CLEANUP_DEST);
+                                           dest,
+                                           DspinDhccpParam::CLEANUP_DEST);
 
                 DspinDhccpParam::dspin_set(dspin_send_data,
-                    r_icache_cc_send_nline.read() & 0x300000000ULL,
-                    DspinDhccpParam::CLEANUP_NLINE_MSB);
+                                           r_icache_cc_send_nline.read() & 0x300000000ULL,
+                                           DspinDhccpParam::CLEANUP_NLINE_MSB);
 
                 DspinDhccpParam::dspin_set(dspin_send_data,
-                    r_icache_cc_send_way.read(),
-                    DspinDhccpParam::CLEANUP_WAY_INDEX);
+                                           r_icache_cc_send_way.read(),
+                                           DspinDhccpParam::CLEANUP_WAY_INDEX);
 
                 DspinDhccpParam::dspin_set(dspin_send_data,
-                    DspinDhccpParam::TYPE_CLEANUP_INST,
-                    DspinDhccpParam::FROM_L1_TYPE);
+                                           DspinDhccpParam::TYPE_CLEANUP_INST,
+                                           DspinDhccpParam::FROM_L1_TYPE);
             }
             // send flit
@@ -5915,22 +5909,23 @@
             break;
         }
-        ///////////////////////////
+        ///////////////////////
         case CC_SEND_CLEANUP_2:
         {
             // initialize dspin send data
-            DspinDhccpParam::dspin_set(dspin_send_data,1,DspinDhccpParam::FROM_L1_EOP);
-            // dcache active request
-            if(r_cc_send_last_client.read() == 0)
+            DspinDhccpParam::dspin_set(dspin_send_data,
+                                       1,
+                                       DspinDhccpParam::FROM_L1_EOP);
+
+            if(r_cc_send_last_client.read() == 0) // dcache active request
             {
                 DspinDhccpParam::dspin_set(dspin_send_data,
-                    r_dcache_cc_send_nline.read() & 0xFFFFFFFFULL,
-                    DspinDhccpParam::CLEANUP_NLINE_LSB);
-            }
-            // icache active request
-            else
+                                           r_dcache_cc_send_nline.read() & 0xFFFFFFFFULL,
+                                           DspinDhccpParam::CLEANUP_NLINE_LSB);
+            }
+            else                                  // icache active request
             {
                 DspinDhccpParam::dspin_set(dspin_send_data,
-                    r_icache_cc_send_nline.read() & 0xFFFFFFFFULL,
-                    DspinDhccpParam::CLEANUP_NLINE_LSB);
+                                           r_icache_cc_send_nline.read() & 0xFFFFFFFFULL,
+                                           DspinDhccpParam::CLEANUP_NLINE_LSB);
             }
             // send flit
@@ -5939,44 +5934,46 @@
             break;
         }
-        ///////////////////////////
+        ///////////////////////
         case CC_SEND_MULTI_ACK:
         {
             // initialize dspin send data
-            DspinDhccpParam::dspin_set(dspin_send_data,1,DspinDhccpParam::FROM_L1_EOP);
-            DspinDhccpParam::dspin_set(dspin_send_data,0,DspinDhccpParam::FROM_L1_BC);
             DspinDhccpParam::dspin_set(dspin_send_data,
-                DspinDhccpParam::TYPE_MULTI_ACK,
-                DspinDhccpParam::FROM_L1_TYPE);
-            // dcache active request
-            if(r_cc_send_last_client.read() == 0)
-            {
-                // compute global id
-                uint32_t nline_size = vci_param::N - (uint32_log2(m_dcache_words)) - (uint32_log2(vci_param::B));
-                uint64_t global_id = (uint64_t) r_dcache_cc_send_nline.read();
-                global_id >>= (nline_size - m_x_width - m_y_width) << (DspinDhccpParam::GLOBALID_WIDTH - m_x_width - m_y_width);
-
+                                       1,
+                                       DspinDhccpParam::FROM_L1_EOP);
+            DspinDhccpParam::dspin_set(dspin_send_data,
+                                       0,
+                                       DspinDhccpParam::FROM_L1_BC);
+            DspinDhccpParam::dspin_set(dspin_send_data,
+                                       DspinDhccpParam::TYPE_MULTI_ACK,
+                                       DspinDhccpParam::FROM_L1_TYPE);
+
+            if(r_cc_send_last_client.read() == 0) // dcache active request
+            {
+                uint64_t dest = (uint64_t)r_dcache_cc_send_nline.read() 
+                                >> (m_nline_width - m_x_width - m_y_width) 
+                                << (DspinDhccpParam::GLOBALID_WIDTH - m_x_width - m_y_width);
+ 
                 DspinDhccpParam::dspin_set(dspin_send_data,
-                    global_id,
-                    DspinDhccpParam::MULTI_ACK_DEST);
+                                           dest,
+                                           DspinDhccpParam::MULTI_ACK_DEST);
 
                 DspinDhccpParam::dspin_set(dspin_send_data,
-                    r_dcache_cc_send_updt_tab_idx.read(),
-                    DspinDhccpParam::MULTI_ACK_UPDT_INDEX);
-            }
-            // icache active request
-            else
-            {
-                // compute global id
-                uint32_t nline_size = vci_param::N - (uint32_log2(m_icache_words)) - (uint32_log2(vci_param::B));
-                uint64_t global_id = (uint64_t) r_icache_cc_send_nline.read();
-                global_id >>= (nline_size - m_x_width - m_y_width) << (DspinDhccpParam::GLOBALID_WIDTH - m_x_width - m_y_width);
+                                           r_dcache_cc_send_updt_tab_idx.read(),
+                                           DspinDhccpParam::MULTI_ACK_UPDT_INDEX);
+            }
+            else                                    // icache active request
+            {
+                uint64_t dest = (uint64_t)r_icache_cc_send_nline.read() 
+                                >> (m_nline_width - m_x_width - m_y_width) 
+                                << (DspinDhccpParam::GLOBALID_WIDTH - m_x_width - m_y_width);
+ 
 
                 DspinDhccpParam::dspin_set(dspin_send_data,
-                    global_id,
-                    DspinDhccpParam::MULTI_ACK_DEST);
+                                           dest,
+                                           DspinDhccpParam::MULTI_ACK_DEST);
 
                 DspinDhccpParam::dspin_set(dspin_send_data,
-                    r_icache_cc_send_updt_tab_idx.read(),
-                    DspinDhccpParam::MULTI_ACK_UPDT_INDEX);
+                                           r_icache_cc_send_updt_tab_idx.read(),
+                                           DspinDhccpParam::MULTI_ACK_UPDT_INDEX);
             }
             // send flit
@@ -5987,7 +5984,7 @@
     } // end switch CC_SEND FSM
 
-    ////////////////////
-    // CC_RECEIVE FSM //
-    ////////////////////
+    // Receive coherence packets
+    // It depends on the CC_RECEIVE FSM 
+
     switch( r_cc_receive_fsm.read() )
     {
