Index: trunk/modules/vci_mem_cache_v4/caba/source/src/vci_mem_cache_v4.cpp
===================================================================
--- trunk/modules/vci_mem_cache_v4/caba/source/src/vci_mem_cache_v4.cpp	(revision 138)
+++ trunk/modules/vci_mem_cache_v4/caba/source/src/vci_mem_cache_v4.cpp	(revision 140)
@@ -29,14 +29,20 @@
 #include "../include/vci_mem_cache_v4.h"
 
-//#define TDEBUG // Transaction tab debug
-//#define IDEBUG // Update tab debug
-//#define DDEBUG // Directory debug
-//#define LOCK_DEBUG // Lock debug
+// #define TDEBUG // Transaction tab debug
+// #define IDEBUG // Update tab debug
+// #define DDEBUG // Directory debug
+// #define LOCK_DEBUG // Lock debug
+
 #define DEBUG_VCI_MEM_CACHE 0
-#define DEBUG_START_CYCLE   200000
+#define DEBUG_START_CYCLE   949900
 #define RANDOMIZE_SC
 
+#define ASSERT_VERBOSE
+#define ASSERT_NCYCLES m_cpt_cycles
+
+#include "debug.h"
+
 #if DEBUG_VCI_MEM_CACHE
-# define PRINTF(msg...) do { if (m_cpt_cycles > DEBUG_START_CYCLE) printf(msg); } while (0); 
+# define PRINTF(msg...) PRINTF_COND(m_cpt_cycles > DEBUG_START_CYCLE,msg)
 #else
 # define PRINTF(msg...)
@@ -301,4 +307,7 @@
     m_write_to_init_cmd_inst_fifo("m_write_to_init_cmd_inst_fifo",8),
     m_write_to_init_cmd_srcid_fifo("m_write_to_init_cmd_srcid_fifo",8),
+#if L1_MULTI_CACHE
+    m_write_to_init_cmd_cache_id_fifo("m_write_to_init_cmd_cache_id_fifo",8),
+#endif
     r_init_rsp_fsm("r_init_rsp_fsm"),
     r_cleanup_fsm("r_cleanup_fsm"),
@@ -306,8 +315,14 @@
     m_llsc_to_init_cmd_inst_fifo("m_llsc_to_init_cmd_inst_fifo",8),
     m_llsc_to_init_cmd_srcid_fifo("m_llsc_to_init_cmd_srcid_fifo",8),
+#if L1_MULTI_CACHE
+    m_llsc_to_init_cmd_cache_id_fifo("m_llsc_to_init_cmd_cache_id_fifo",8),
+#endif
     r_ixr_rsp_fsm("r_ixr_rsp_fsm"),
     r_xram_rsp_fsm("r_xram_rsp_fsm"),
     m_xram_rsp_to_init_cmd_inst_fifo("m_xram_rsp_to_init_cmd_inst_fifo",8),
     m_xram_rsp_to_init_cmd_srcid_fifo("m_xram_rsp_to_init_cmd_srcid_fifo",8),
+#if L1_MULTI_CACHE
+    m_xram_rsp_to_init_cmd_cache_id_fifo("m_xram_rsp_to_init_cmd_cache_id_fifo",8),
+#endif
     r_ixr_cmd_fsm("r_ixr_cmd_fsm"),
     r_tgt_rsp_fsm("r_tgt_rsp_fsm"),
@@ -532,4 +547,7 @@
       m_write_to_init_cmd_inst_fifo.init();
       m_write_to_init_cmd_srcid_fifo.init();
+#if L1_MULTI_CACHE
+      m_write_to_init_cmd_cache_id_fifo.init();
+#endif
 
       r_cleanup_to_tgt_rsp_req	= false;
@@ -545,4 +563,7 @@
       m_llsc_to_init_cmd_inst_fifo.init();
       m_llsc_to_init_cmd_srcid_fifo.init();
+#if L1_MULTI_CACHE
+      m_llsc_to_init_cmd_cache_id_fifo.init();
+#endif
 
       for(size_t i=0; i<TRANSACTION_TAB_LINES ; i++){
@@ -557,4 +578,7 @@
       m_xram_rsp_to_init_cmd_inst_fifo.init();
       m_xram_rsp_to_init_cmd_srcid_fifo.init();
+#if L1_MULTI_CACHE
+      m_xram_rsp_to_init_cmd_cache_id_fifo.init();
+#endif
 
       r_ixr_cmd_cpt         = 0;
@@ -591,18 +615,27 @@
     bool    cmd_llsc_fifo_get = false;
 
-    bool    write_to_init_cmd_fifo_put   = false;
-    bool    write_to_init_cmd_fifo_get   = false;
-    bool    write_to_init_cmd_fifo_inst  = false;
-    size_t  write_to_init_cmd_fifo_srcid = 0;
-
-    bool    xram_rsp_to_init_cmd_fifo_put   = false;
-    bool    xram_rsp_to_init_cmd_fifo_get   = false;
-    bool    xram_rsp_to_init_cmd_fifo_inst  = false;
-    size_t  xram_rsp_to_init_cmd_fifo_srcid = 0;
-
-    bool    llsc_to_init_cmd_fifo_put   = false;
-    bool    llsc_to_init_cmd_fifo_get   = false;
-    bool    llsc_to_init_cmd_fifo_inst  = false;
-    size_t  llsc_to_init_cmd_fifo_srcid = 0;
+    bool    write_to_init_cmd_fifo_put      = false;
+    bool    write_to_init_cmd_fifo_get      = false;
+    bool    write_to_init_cmd_fifo_inst     = false;
+    size_t  write_to_init_cmd_fifo_srcid    = 0;
+#if L1_MULTI_CACHE
+    size_t  write_to_init_cmd_fifo_cache_id = 0;
+#endif
+
+    bool    xram_rsp_to_init_cmd_fifo_put      = false;
+    bool    xram_rsp_to_init_cmd_fifo_get      = false;
+    bool    xram_rsp_to_init_cmd_fifo_inst     = false;
+    size_t  xram_rsp_to_init_cmd_fifo_srcid    = 0;
+#if L1_MULTI_CACHE
+    size_t  xram_rsp_to_init_cmd_fifo_cache_id = 0;
+#endif
+
+    bool    llsc_to_init_cmd_fifo_put      = false;
+    bool    llsc_to_init_cmd_fifo_get      = false;
+    bool    llsc_to_init_cmd_fifo_inst     = false;
+    size_t  llsc_to_init_cmd_fifo_srcid    = 0;
+#if L1_MULTI_CACHE
+    size_t  llsc_to_init_cmd_fifo_cache_id = 0;
+#endif
 
 #if DEBUG_VCI_MEM_CACHE 
@@ -628,4 +661,11 @@
 #endif
 
+#ifdef IDEBUG
+if(m_cpt_cycles > DEBUG_START_CYCLE){
+	std::cout << sc_time_stamp() << " " << name() << " INIT_RSP_UPT_LOCK update table : " << std::endl;
+	m_update_tab.print();
+}
+#endif
+
     ////////////////////////////////////////////////////////////////////////////////////
     //		TGT_CMD FSM
@@ -651,5 +691,5 @@
           if ( p_vci_tgt.cmdval ) {
 
-              PRINTF("  * <TGT> Request from %d at address %llx\n",(uint32_t)p_vci_tgt.srcid.read(),(uint64_t)p_vci_tgt.address.read());
+              PRINTF("  * <MEM_CACHE.TGT> Request from %d.%d (%d) at address %llx\n",(uint32_t)p_vci_tgt.srcid.read(),(uint32_t)p_vci_tgt.pktid.read(),(uint32_t)p_vci_tgt.trdid.read(),(uint64_t)p_vci_tgt.address.read());
 
             if ( p_vci_tgt.cmd.read() == vci_param::CMD_READ ) 
@@ -676,6 +716,6 @@
 
         {
-          assert(((m_x[(vci_addr_t)p_vci_tgt.address.read()]+(p_vci_tgt.plen.read()>>2))<=16)
-              && "VCI_MEM_CACHE All read request to the MemCache must stay within a cache line"); 
+            ASSERT(((m_x[(vci_addr_t)p_vci_tgt.address.read()]+(p_vci_tgt.plen.read()>>2))<=16),
+                   "VCI_MEM_CACHE All read request to the MemCache must stay within a cache line"); 
 
           if ( p_vci_tgt.cmdval && m_cmd_read_addr_fifo.wok() ) {
@@ -744,9 +784,10 @@
 
           if ( p_vci_ini.rspval ) {
-
-            assert ( ( p_vci_ini.rtrdid.read() < m_update_tab.size() )
-                && "VCI_MEM_CACHE UPT index too large in VCI response paquet received by memory cache" );
-            assert ( p_vci_ini.reop 
-                && "VCI_MEM_CACHE All response packets to update/invalidate requests must be one cell" );
+            PRINTF("  * <MEM_CACHE.INIT_RSP> rsp val - trdid %d\n",(uint32_t)p_vci_ini.rtrdid.read());
+
+            ASSERT (( p_vci_ini.rtrdid.read() < m_update_tab.size())
+                    ,"VCI_MEM_CACHE UPT index too large in VCI response paquet received by memory cache" );
+            ASSERT (p_vci_ini.reop 
+                    ,"VCI_MEM_CACHE All response packets to update/invalidate requests must be one cell") ;
             r_init_rsp_upt_index = p_vci_ini.rtrdid.read(); 
             r_init_rsp_fsm = INIT_RSP_UPT_LOCK;
@@ -772,6 +813,6 @@
 #endif
             while(!valid);
-            assert ( valid 
-                && "VCI_MEM_CACHE Invalid UPT entry in VCI response paquet received by memory cache" );
+            ASSERT ( valid 
+                     ,"VCI_MEM_CACHE Invalid UPT entry in VCI response paquet received by memory cache" );
 
             if ( count == 0 ) r_init_rsp_fsm = INIT_RSP_UPT_CLEAR;
@@ -830,5 +871,5 @@
     ////////////////////////////////////////////////////////////////////////////////////
 
-    PRINTF("  * TOP : Request from %d at address %llx\n",(uint32_t)m_cmd_read_srcid_fifo.read(),(uint64_t)m_cmd_read_addr_fifo.read());
+    PRINTF("  * <MEM_CACHE.TOP> Request from %d.%d at address %llx\n",(uint32_t)m_cmd_read_srcid_fifo.read(),(uint32_t)m_cmd_read_pktid_fifo.read(),(uint64_t)m_cmd_read_addr_fifo.read());
 
     switch ( r_read_fsm.read() ) {
@@ -838,5 +879,5 @@
         {
           if (m_cmd_read_addr_fifo.rok()) {
-            PRINTF("  * <READ> Request from %d at address %llx\n",(uint32_t)m_cmd_read_srcid_fifo.read(),(uint64_t)m_cmd_read_addr_fifo.read());
+            PRINTF("  * <MEM_CACHE.READ> Request from %d.%d at address %llx\n",(uint32_t)m_cmd_read_srcid_fifo.read(),(uint32_t)m_cmd_read_pktid_fifo.read(),(uint64_t)m_cmd_read_addr_fifo.read());
 
             m_cpt_read++;
@@ -858,13 +899,16 @@
 }
 #endif
-            r_read_is_cnt   = entry.is_cnt;
-            r_read_dirty    = entry.dirty;
-            r_read_lock	    = entry.lock;
-            r_read_tag	    = entry.tag;
-            r_read_way	    = way;
-            r_read_count    = entry.count;
-            r_read_copy     = entry.owner.srcid; 
-            r_read_copy_inst= entry.owner.inst;
-            r_read_ptr      = entry.ptr;
+            r_read_is_cnt     = entry.is_cnt;
+            r_read_dirty      = entry.dirty;
+            r_read_lock	      = entry.lock;
+            r_read_tag	      = entry.tag;
+            r_read_way	      = way;
+            r_read_count      = entry.count;
+            r_read_copy       = entry.owner.srcid; 
+#if L1_MULTI_CACHE
+            r_read_copy_cache = entry.owner.cache_id; 
+#endif
+            r_read_copy_inst  = entry.owner.inst;
+            r_read_ptr        = entry.ptr;
 
             bool cached_read = (m_cmd_read_trdid_fifo.read() & 0x1);
@@ -910,8 +954,15 @@
               if(!is_cnt){ // Not counter mode
                 entry.owner.srcid   = m_cmd_read_srcid_fifo.read();
+#if L1_MULTI_CACHE
+                entry.owner.cache_id= m_cmd_read_pktid_fifo.read();
+#endif
+
                 entry.owner.inst    = inst_read;
                 entry.count         = r_read_count.read() + 1;
               } else { // Counter mode
                 entry.owner.srcid   = 0;
+#if L1_MULTI_CACHE
+                entry.owner.cache_id= 0;
+#endif
                 entry.owner.inst    = false;
                 entry.count         = r_read_count.read() + 1;
@@ -919,4 +970,8 @@
             } else { // Uncached read
               entry.owner.srcid     = r_read_copy.read();
+#if L1_MULTI_CACHE
+              entry.owner.cache_id  = r_read_copy_cache.read();
+#endif
+
               entry.owner.inst      = r_read_copy_inst.read();
               entry.count           = r_read_count.read();
@@ -956,4 +1011,7 @@
             if(!is_cnt){ // Not counter mode
                 entry.owner.srcid   = r_read_copy.read();
+#if L1_MULTI_CACHE
+                entry.owner.cache_id= r_read_copy_cache.read();
+#endif
                 entry.owner.inst    = r_read_copy_inst.read();
                 entry.count         = r_read_count.read() + 1;
@@ -961,4 +1019,7 @@
             } else { // Counter mode
                 entry.owner.srcid   = 0;
+#if L1_MULTI_CACHE
+                entry.owner.cache_id= 0;
+#endif
                 entry.owner.inst    = false;
                 entry.count         = r_read_count.read() + 1;
@@ -1008,6 +1069,9 @@
             bool inst_read = (m_cmd_read_trdid_fifo.read() & 0x2);
             HeapEntry new_heap_entry;
-            new_heap_entry.owner.srcid  = m_cmd_read_srcid_fifo.read();
-            new_heap_entry.owner.inst   = inst_read;
+            new_heap_entry.owner.srcid    = m_cmd_read_srcid_fifo.read();
+#if L1_MULTI_CACHE
+            new_heap_entry.owner.cache_id = m_cmd_read_pktid_fifo.read();
+#endif
+            new_heap_entry.owner.inst     = inst_read;
             if(r_read_count.read() == 1){ // creation of a new list
               new_heap_entry.next         = m_heap_directory.next_free_ptr(); 
@@ -1023,5 +1087,5 @@
             r_read_fsm = READ_RSP;
           } else {
-            assert(false && "MEMCACHE Error : Bad HEAP allocation");
+              ASSERT(false,"MEMCACHE Error : Bad HEAP allocation");
           }
           break;
@@ -1039,5 +1103,5 @@
             }
           } else {
-            assert(false && "MEMCACHE Error : Bad HEAP allocation");
+              ASSERT(false,"MEMCACHE Error : Bad HEAP allocation");
           }
           break;
@@ -1048,6 +1112,9 @@
           if(r_alloc_heap_fsm.read() == ALLOC_HEAP_READ){
             HeapEntry last_entry;
-            last_entry.owner.srcid = 0;
-            last_entry.owner.inst  = false;
+            last_entry.owner.srcid    = 0;
+#if L1_MULTI_CACHE
+            last_entry.owner.cache_id = 0;
+#endif
+            last_entry.owner.inst     = false;
             if(m_heap_directory.is_full()){
               last_entry.next      = r_read_ptr.read();
@@ -1059,5 +1126,5 @@
             r_read_fsm = READ_RSP;
           } else {
-            assert(false && "MEMCACHE Error : Bad HEAP allocation");
+              ASSERT(false,"MEMCACHE Error : Bad HEAP allocation");
           }
           break;
@@ -1107,5 +1174,5 @@
         {
           if ( r_alloc_trt_fsm.read() == ALLOC_TRT_READ ) {
-            m_transaction_tab.set(r_read_trt_index.read(),
+              m_transaction_tab.set(r_read_trt_index.read(),
                 true,
                 m_nline[(vci_addr_t)(m_cmd_read_addr_fifo.read())],
@@ -1178,4 +1245,6 @@
         {
           if ( m_cmd_write_addr_fifo.rok()) {
+              PRINTF("  * <MEM_CACHE.WRITE> KANE Request from %d.%d (%d) at address %llx\n",(uint32_t)m_cmd_write_srcid_fifo.read(),(uint32_t)m_cmd_write_pktid_fifo.read(),(uint32_t) m_cmd_write_trdid_fifo.read(), (uint64_t)m_cmd_write_addr_fifo.read());
+
             m_cpt_write++;
             m_cpt_write_cells++;
@@ -1212,6 +1281,6 @@
 
             // check that the next word is in the same cache line
-            assert( (m_nline[(vci_addr_t)(r_write_address.read())] == m_nline[(vci_addr_t)(m_cmd_write_addr_fifo.read())])  
-                && "VCI_MEM_CACHE write error in vci_mem_cache : write burst over a line" );
+            ASSERT( (m_nline[(vci_addr_t)(r_write_address.read())] == m_nline[(vci_addr_t)(m_cmd_write_addr_fifo.read())])  
+                    ,"VCI_MEM_CACHE write error in vci_mem_cache : write burst over a line" );
             // consume a word in the FIFO & write it in the local buffer 
             cmd_write_fifo_get=true;
@@ -1239,4 +1308,7 @@
               r_write_tag       = entry.tag;
               r_write_copy      = entry.owner.srcid;
+#if L1_MULTI_CACHE
+              r_write_copy_cache= entry.owner.cache_id;
+#endif
               r_write_copy_inst = entry.owner.inst;
               r_write_count     = entry.count;
@@ -1287,18 +1359,26 @@
           // update directory with Dirty bit
           DirectoryEntry entry;
-          entry.valid	    = true;
-          entry.dirty	    = true;
-          entry.tag	        = r_write_tag.read();
-          entry.is_cnt      = r_write_is_cnt.read();
-          entry.lock	    = r_write_lock.read();
-          entry.owner.srcid = r_write_copy.read();
-          entry.owner.inst  = r_write_copy_inst.read();
-          entry.count       = r_write_count.read();
-          entry.ptr         = r_write_ptr.read();
-          size_t set	    = m_y[(vci_addr_t)(r_write_address.read())];
-          size_t way	    = r_write_way.read();
+          entry.valid	      = true;
+          entry.dirty	      = true;
+          entry.tag	          = r_write_tag.read();
+          entry.is_cnt        = r_write_is_cnt.read();
+          entry.lock	      = r_write_lock.read();
+          entry.owner.srcid   = r_write_copy.read();
+#if L1_MULTI_CACHE
+          entry.owner.cache_id= r_write_copy_cache.read();
+#endif
+          entry.owner.inst    = r_write_copy_inst.read();
+          entry.count         = r_write_count.read();
+          entry.ptr           = r_write_ptr.read();
+          size_t set	      = m_y[(vci_addr_t)(r_write_address.read())];
+          size_t way	      = r_write_way.read();
           m_cache_directory.write(set, way, entry);
 
-          bool owner = (r_write_copy.read()==r_write_srcid.read()) && !r_write_copy_inst.read();
+          bool owner = (((r_write_copy.read()==r_write_srcid.read())
+#if L1_MULTI_CACHE
+                         and (r_write_copy_cache.read()==r_write_pktid.read())
+#endif
+                         ) and not r_write_copy_inst.read());
+
           bool no_update = (r_write_count.read()==0) || ( owner && (r_write_count.read()==1));
 
@@ -1387,6 +1467,6 @@
       case WRITE_UPT_REQ:
         {
-          assert( (r_alloc_heap_fsm.read() == ALLOC_HEAP_WRITE) &&
-                    "MemCache ERROR : bad HEAP allocation");
+          ASSERT( (r_alloc_heap_fsm.read() == ALLOC_HEAP_WRITE)
+                  ,"MemCache ERROR : bad HEAP allocation");
           if( !r_write_to_init_cmd_multi_req.read() && 
               !r_write_to_init_cmd_brdcast_req.read()  ){
@@ -1407,9 +1487,16 @@
             }
             
-            if( (r_write_copy.read() != r_write_srcid.read()) || r_write_copy_inst.read() ) {
+            if((r_write_copy.read() != r_write_srcid.read()) or
+#if L1_MULTI_CACHE
+               (r_write_copy_cache.read() != r_write_pktid.read()) or
+#endif
+               r_write_copy_inst.read() ) {
               // We put the first copy in the fifo
               write_to_init_cmd_fifo_put     = true;
               write_to_init_cmd_fifo_inst    = r_write_copy_inst.read();
               write_to_init_cmd_fifo_srcid   = r_write_copy.read();
+#if L1_MULTI_CACHE
+              write_to_init_cmd_fifo_cache_id= r_write_copy_cache.read();
+#endif
               if(r_write_count.read() == 1){
                 r_write_fsm = WRITE_IDLE;
@@ -1427,11 +1514,19 @@
       case WRITE_UPDATE:	// send a multi-update request to INIT_CMD fsm
         {
-          assert( (r_alloc_heap_fsm.read() == ALLOC_HEAP_WRITE) &&
-                    "MemCache ERROR : bad HEAP allocation");
+          ASSERT( (r_alloc_heap_fsm.read() == ALLOC_HEAP_WRITE)
+                  ,"MemCache ERROR : bad HEAP allocation");
           HeapEntry entry = m_heap_directory.read(r_write_ptr.read());
-          write_to_init_cmd_fifo_inst  = entry.owner.inst;
-          write_to_init_cmd_fifo_srcid = entry.owner.srcid;
+          write_to_init_cmd_fifo_inst     = entry.owner.inst;
+          write_to_init_cmd_fifo_srcid    = entry.owner.srcid;
+#if L1_MULTI_CACHE
+          write_to_init_cmd_fifo_cache_id = entry.owner.cache_id;
+#endif
+          
           bool dec_upt_counter = r_write_to_dec.read();
-          if( (entry.owner.srcid != r_write_srcid.read()) || entry.owner.inst ){
+          if( (entry.owner.srcid != r_write_srcid.read()) or
+#if L1_MULTI_CACHE
+              (entry.owner.cache_id != r_write_pktid.read()) or
+#endif
+              entry.owner.inst){
             write_to_init_cmd_fifo_put = true;
           } else {
@@ -1471,4 +1566,7 @@
         {
           if ( !r_write_to_tgt_rsp_req.read() ) {
+
+            PRINTF("  * <MEM_CACHE.WRITE> YURI Request from %d.%d (%d)\n",(uint32_t)r_write_srcid.read(), (uint32_t)r_write_trdid.read(), (uint32_t)r_write_pktid.read());
+
             r_write_to_tgt_rsp_req	    = true;
             r_write_to_tgt_rsp_srcid	= r_write_srcid.read();
@@ -1644,8 +1742,8 @@
       case WRITE_DIR_INVAL:
         {
-            assert(((r_alloc_trt_fsm.read() == ALLOC_TRT_WRITE ) &&
+            ASSERT(((r_alloc_trt_fsm.read() == ALLOC_TRT_WRITE ) &&
                     (r_alloc_upt_fsm.read() == ALLOC_UPT_WRITE ) &&
-                    (r_alloc_dir_fsm.read() == ALLOC_DIR_WRITE ))&&
-                    "MemCache ERROR : bad TRT,DIR or UPT allocation error");
+                    (r_alloc_dir_fsm.read() == ALLOC_DIR_WRITE ))
+                   ,"MemCache ERROR : bad TRT,DIR or UPT allocation error");
             m_transaction_tab.set(r_write_trt_index.read(),
                 false,				// write request to XRAM
@@ -1675,4 +1773,7 @@
             entry.lock          = false;
             entry.owner.srcid   = 0;
+#if L1_MULTI_CACHE
+            entry.owner.cache_id= 0;
+#endif
             entry.owner.inst    = false;
             entry.ptr           = 0;
@@ -1890,7 +1991,7 @@
             data_t data 	= p_vci_ixr.rdata.read();
             size_t index        = r_ixr_rsp_trt_index.read();
-            assert( ((eop == (r_ixr_rsp_cpt.read() == (m_words-1))) ||
-                     p_vci_ixr.rerror.read())
-                && "Error in VCI_MEM_CACHE : invalid length for a response from XRAM");
+            ASSERT(((eop == (r_ixr_rsp_cpt.read() == (m_words-1))) ||
+                    p_vci_ixr.rerror.read())
+                   ,"Error in VCI_MEM_CACHE : invalid length for a response from XRAM");
             m_transaction_tab.write_rsp(index, r_ixr_rsp_cpt.read(), data, p_vci_ixr.rerror.read()&0x1);
             r_ixr_rsp_cpt = r_ixr_rsp_cpt.read() + 1;
@@ -1988,4 +2089,7 @@
 
             r_xram_rsp_victim_copy      = victim.owner.srcid;
+#if L1_MULTI_CACHE
+            r_xram_rsp_victim_copy_cache= victim.owner.cache_id;
+#endif
             r_xram_rsp_victim_copy_inst = victim.owner.inst;
             r_xram_rsp_victim_count     = victim.count;
@@ -2005,5 +2109,5 @@
 if(m_cpt_cycles > DEBUG_START_CYCLE){
 	std::cout << "XRAM_RSP FSM in XRAM_RSP_TRT_COPY state" << std::endl;
-	std::cout << "Victim way : " << std::hex << way << " set " << std::hex << set << std::endl;
+	std::cout << "Victim way : " << std::hex << way << " set " << set << std::dec << std::endl;
 	victim.print();
 }
@@ -2093,17 +2197,17 @@
           entry.ptr       = 0;
           if(cached_read) {
-            if(inst_read) {
-              entry.owner.srcid = r_xram_rsp_trt_buf.srcid;
-              entry.owner.inst  = true;
-              entry.count       = 1;
-            } else {
-              entry.owner.srcid = r_xram_rsp_trt_buf.srcid;
-              entry.owner.inst  = false;
-              entry.count       = 1;
-            }
+              entry.owner.srcid   = r_xram_rsp_trt_buf.srcid;
+#if L1_MULTI_CACHE
+              entry.owner.cache_id= r_xram_rsp_trt_buf.pktid;
+#endif
+              entry.owner.inst    = inst_read;
+              entry.count         = 1;
           } else {
-            entry.owner.srcid = 0;
-            entry.owner.inst  = 0;
-            entry.count       = 0;
+            entry.owner.srcid    = 0;
+#if L1_MULTI_CACHE
+            entry.owner.cache_id = 0;
+#endif
+            entry.owner.inst     = 0;
+            entry.count          = 0;
           }
           m_cache_directory.write(set, way, entry);
@@ -2125,14 +2229,15 @@
 
           if(r_xram_rsp_victim_inval.read()){
-            bool    brdcast = r_xram_rsp_victim_is_cnt.read();
-            size_t index;
+            bool   brdcast = r_xram_rsp_victim_is_cnt.read();
+            size_t index = 0;
             size_t count_copies = r_xram_rsp_victim_count.read();
-
+            
+            //@@
             bool	 wok = m_update_tab.set(false,	// it's an inval transaction
                 brdcast,                          // set brdcast bit
                 false,  // it does not need a response
-                0,
-                0,
-                0,
+                0,//srcid
+                0,//trdid
+                0,//pktid
                 r_xram_rsp_victim_nline.read(),
                 count_copies,
@@ -2147,5 +2252,5 @@
             r_xram_rsp_upt_index = index;
             if(!wok) {
-              assert(false && "mem_cache error : xram_rsp_dir_upt, an update_tab entry was free but write unsuccessful");
+                ASSERT(false,"mem_cache error : xram_rsp_dir_upt, an update_tab entry was free but write unsuccessful");
             }
           }
@@ -2234,4 +2339,7 @@
             xram_rsp_to_init_cmd_fifo_srcid     = r_xram_rsp_victim_copy.read();
             xram_rsp_to_init_cmd_fifo_inst      = r_xram_rsp_victim_copy_inst.read();
+#if L1_MULTI_CACHE
+            xram_rsp_to_init_cmd_fifo_cache_id  = r_xram_rsp_victim_copy_cache.read();
+#endif
             xram_rsp_to_init_cmd_fifo_put       = multi_req;
             
@@ -2277,5 +2385,8 @@
           if( r_alloc_heap_fsm.read() == ALLOC_HEAP_XRAM_RSP ) {
             HeapEntry entry = m_heap_directory.read(r_xram_rsp_next_ptr.read());
-            xram_rsp_to_init_cmd_fifo_srcid = entry.owner.srcid;
+            xram_rsp_to_init_cmd_fifo_srcid    = entry.owner.srcid;
+#if L1_MULTI_CACHE
+            xram_rsp_to_init_cmd_fifo_cache_id = entry.owner.cache_id;
+#endif
             xram_rsp_to_init_cmd_fifo_inst  = entry.owner.inst;
             xram_rsp_to_init_cmd_fifo_put   = true;
@@ -2297,11 +2408,14 @@
       case XRAM_RSP_HEAP_LAST:	// last member of the list
         {
-          assert((r_alloc_heap_fsm.read() == ALLOC_HEAP_XRAM_RSP) &&
-                  "MemCache ERROR : bad HEAP allocation");
+          ASSERT((r_alloc_heap_fsm.read() == ALLOC_HEAP_XRAM_RSP)
+                 ,"MemCache ERROR : bad HEAP allocation");
           size_t free_pointer = m_heap_directory.next_free_ptr();
 
           HeapEntry last_entry;
-          last_entry.owner.srcid = 0;
-          last_entry.owner.inst  = false;
+          last_entry.owner.srcid    = 0;
+#if L1_MULTI_CACHE
+          last_entry.owner.cache_id = 0;
+#endif
+          last_entry.owner.inst     = false;
           if(m_heap_directory.is_full()){
             last_entry.next     = r_xram_rsp_next_ptr.read();
@@ -2377,6 +2491,6 @@
         {
           if ( p_vci_tgt_cleanup.cmdval.read() ) {
-            assert( (p_vci_tgt_cleanup.srcid.read() < m_initiators) &&
-            "VCI_MEM_CACHE error in a cleanup request : received SRCID is larger than the number of initiators");
+            ASSERT((p_vci_tgt_cleanup.srcid.read() < m_initiators)
+                   ,"VCI_MEM_CACHE error in a cleanup request : received SRCID is larger than the number of initiators");
 
             bool reached = false;
@@ -2391,4 +2505,6 @@
                  reached) 
             {
+              PRINTF("  * <MEM_CACHE.CLEANUP> Request from %d.%d at address %llx\n",(uint32_t)p_vci_tgt_cleanup.srcid.read(),(uint32_t)p_vci_tgt_cleanup.pktid.read(),(uint64_t)p_vci_tgt_cleanup.address.read());
+
               m_cpt_cleanup++;
 
@@ -2425,8 +2541,10 @@
             r_cleanup_way	    = way;
             r_cleanup_copy      = entry.owner.srcid;
+#if L1_MULTI_CACHE
+            r_cleanup_copy_cache= entry.owner.cache_id;
+#endif
             r_cleanup_copy_inst = entry.owner.inst;
             r_cleanup_count     = entry.count;
             r_cleanup_ptr       = entry.ptr;
-
 
             // In case of hit, the copy must be cleaned in the copies bit-vector
@@ -2446,6 +2564,6 @@
       case CLEANUP_DIR_WRITE:
         {
-          assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_CLEANUP ) && 
-                "MemCache ERROR : Bad DIR allocation");
+          ASSERT((r_alloc_dir_fsm.read() == ALLOC_DIR_CLEANUP)
+                 ,"MemCache ERROR : Bad DIR allocation");
           size_t way      = r_cleanup_way.read();
 #define L2 soclib::common::uint32_log2
@@ -2453,5 +2571,9 @@
 #undef L2
           bool cleanup_inst  = r_cleanup_trdid.read() & 0x1; 
-          bool match_srcid   = (r_cleanup_copy.read() == r_cleanup_srcid.read());
+          bool match_srcid   = ((r_cleanup_copy.read() == r_cleanup_srcid.read())
+#if L1_MULTI_CACHE
+                                and (r_cleanup_copy_cache.read() == r_cleanup_pktid.read())
+#endif
+                                );
           bool match_inst    = (r_cleanup_copy_inst.read()  == cleanup_inst);
           bool match         = match_srcid && match_inst;
@@ -2467,6 +2589,9 @@
           if(r_cleanup_is_cnt.read()) { // Directory is a counter
             entry.count  = r_cleanup_count.read() -1;
-            entry.owner.srcid = 0;
-            entry.owner.inst  = 0;
+            entry.owner.srcid   = 0;
+#if L1_MULTI_CACHE
+            entry.owner.cache_id= 0;
+#endif
+            entry.owner.inst    = 0;
             // response to the cache 
             r_cleanup_fsm = CLEANUP_RSP;
@@ -2474,13 +2599,19 @@
           else{                         // Directory is a list
             if(match) { // hit
-              entry.count       = 0; // no more copy
-              entry.owner.srcid = 0;
-              entry.owner.inst  = 0;
-              r_cleanup_fsm     = CLEANUP_RSP; 
+              entry.count         = 0; // no more copy
+              entry.owner.srcid   = 0;
+#if L1_MULTI_CACHE
+              entry.owner.cache_id=0;
+#endif
+              entry.owner.inst    = 0;
+              r_cleanup_fsm       = CLEANUP_RSP; 
             } else { // miss
-              entry.count       = r_cleanup_count.read();
-              entry.owner.srcid = r_cleanup_copy.read();
-              entry.owner.inst  = r_cleanup_copy_inst.read();
-              r_cleanup_fsm     = CLEANUP_UPT_LOCK;
+              entry.count          = r_cleanup_count.read();
+              entry.owner.srcid    = r_cleanup_copy.read();
+#if L1_MULTI_CACHE
+              entry.owner.cache_id = r_cleanup_copy_cache.read();
+#endif
+              entry.owner.inst     = r_cleanup_copy_inst.read();
+              r_cleanup_fsm        = CLEANUP_UPT_LOCK;
             }
           }
@@ -2501,43 +2632,72 @@
             bool cleanup_inst       = r_cleanup_trdid.read() & 0x1; 
             bool match_dir_srcid    = (r_cleanup_copy.read() == r_cleanup_srcid.read());
+#if L1_MULTI_CACHE
+            bool match_dir_cache_id = (r_cleanup_copy_cache.read() == r_cleanup_pktid.read());
+#endif
             bool match_dir_inst     = (r_cleanup_copy_inst.read()  == cleanup_inst);
-            bool match_dir          = match_dir_srcid && match_dir_inst;
+            bool match_dir          = match_dir_srcid and match_dir_cache_id and match_dir_inst;
             bool match_heap_srcid   = (heap_entry.owner.srcid == r_cleanup_srcid.read());
+#if L1_MULTI_CACHE
+            bool match_heap_cache_id= (heap_entry.owner.cache_id == r_cleanup_pktid.read());
+#endif
             bool match_heap_inst    = (heap_entry.owner.inst  == cleanup_inst);
-            bool match_heap         = match_heap_srcid && match_heap_inst;
-
-            r_cleanup_prev_ptr = r_cleanup_ptr.read();
-            r_cleanup_prev_srcid = heap_entry.owner.srcid;
-            r_cleanup_prev_inst  = heap_entry.owner.inst;
+            bool match_heap         = match_heap_srcid and match_heap_cache_id and match_heap_inst;
+
+#if L1_MULTI_CACHE
+            PRINTF("  * <MEM_CACHE.CLEANUP> match_dir  %d (match_dir_srcid  %d, match_dir_cache_id  %d, match_dir_inst  %d)\n",
+                   match_dir , match_dir_srcid , match_dir_cache_id , match_dir_inst);
+            PRINTF("  * <MEM_CACHE.CLEANUP> match_heap %d (match_heap_srcid %d, match_heap_cache_id %d, match_heap_inst %d)\n",
+                   match_heap, match_heap_srcid, match_heap_cache_id, match_heap_inst);
+#else
+            PRINTF("  * <MEM_CACHE.CLEANUP> match_dir  %d (match_dir_srcid  %d, match_dir_inst  %d)\n",
+                   match_dir , match_dir_srcid , match_dir_inst);
+            PRINTF("  * <MEM_CACHE.CLEANUP> match_heap %d (match_heap_srcid %d, match_heap_inst %d)\n",
+                   match_heap, match_heap_srcid, match_heap_inst);
+#endif
+            PRINTF("  * <MEM_CACHE.CLEANUP> last %d\n",last);
+
+            r_cleanup_prev_ptr      = r_cleanup_ptr.read();
+            r_cleanup_prev_srcid    = heap_entry.owner.srcid;
+#if L1_MULTI_CACHE
+            r_cleanup_prev_cache_id = heap_entry.owner.cache_id;
+#endif
+
+            r_cleanup_prev_inst     = heap_entry.owner.inst;
 
             if(match_dir){
               DirectoryEntry dir_entry;
-              dir_entry.valid	    = true;
-              dir_entry.is_cnt      = r_cleanup_is_cnt.read();
-              dir_entry.dirty	    = r_cleanup_dirty.read();
-              dir_entry.tag	        = r_cleanup_tag.read();
-              dir_entry.lock	    = r_cleanup_lock.read();
-              dir_entry.ptr         = heap_entry.next;
-              dir_entry.count       = r_cleanup_count.read()-1;
-              dir_entry.owner.srcid = heap_entry.owner.srcid;
-              dir_entry.owner.inst  = heap_entry.owner.inst;
+              dir_entry.valid	       = true;
+              dir_entry.is_cnt         = r_cleanup_is_cnt.read();
+              dir_entry.dirty	       = r_cleanup_dirty.read();
+              dir_entry.tag	           = r_cleanup_tag.read();
+              dir_entry.lock	       = r_cleanup_lock.read();
+              dir_entry.ptr            = heap_entry.next;
+              dir_entry.count          = r_cleanup_count.read()-1;
+              dir_entry.owner.srcid    = heap_entry.owner.srcid;
+#if L1_MULTI_CACHE
+              dir_entry.owner.cache_id = heap_entry.owner.cache_id;
+#endif
+              dir_entry.owner.inst     = heap_entry.owner.inst;
               m_cache_directory.write(set,way,dir_entry);
-              r_cleanup_next_ptr    = r_cleanup_ptr.read();
-              r_cleanup_fsm         = CLEANUP_HEAP_FREE;
+              r_cleanup_next_ptr       = r_cleanup_ptr.read();
+              r_cleanup_fsm            = CLEANUP_HEAP_FREE;
             }
             else if(match_heap){
               DirectoryEntry dir_entry;
-              dir_entry.valid	    = true;
-              dir_entry.is_cnt      = r_cleanup_is_cnt.read();
-              dir_entry.dirty	    = r_cleanup_dirty.read();
-              dir_entry.tag	        = r_cleanup_tag.read();
-              dir_entry.lock	    = r_cleanup_lock.read();
-              dir_entry.ptr         = heap_entry.next;
-              dir_entry.count       = r_cleanup_count.read()-1;
-              dir_entry.owner.srcid = r_cleanup_copy.read();
-              dir_entry.owner.inst  = r_cleanup_copy_inst.read();
+              dir_entry.valid	       = true;
+              dir_entry.is_cnt         = r_cleanup_is_cnt.read();
+              dir_entry.dirty	       = r_cleanup_dirty.read();
+              dir_entry.tag	           = r_cleanup_tag.read();
+              dir_entry.lock	       = r_cleanup_lock.read();
+              dir_entry.ptr            = heap_entry.next;
+              dir_entry.count          = r_cleanup_count.read()-1;
+              dir_entry.owner.srcid    = r_cleanup_copy.read();
+#if L1_MULTI_CACHE
+              dir_entry.owner.cache_id = r_cleanup_copy_cache.read();
+#endif
+              dir_entry.owner.inst     = r_cleanup_copy_inst.read();
               m_cache_directory.write(set,way,dir_entry);
-              r_cleanup_next_ptr    = r_cleanup_ptr.read();
-              r_cleanup_fsm         = CLEANUP_HEAP_FREE; 
+              r_cleanup_next_ptr       = r_cleanup_ptr.read();
+              r_cleanup_fsm            = CLEANUP_HEAP_FREE; 
             }
             else{
@@ -2552,4 +2712,7 @@
                 dir_entry.count         = r_cleanup_count.read()-1;
                 dir_entry.owner.srcid   = r_cleanup_copy.read();
+#if L1_MULTI_CACHE
+                dir_entry.owner.cache_id= r_cleanup_copy_cache.read();
+#endif
                 dir_entry.owner.inst    = r_cleanup_copy_inst.read();
                 m_cache_directory.write(set,way,dir_entry);
@@ -2559,5 +2722,5 @@
 
               } else{
-                assert(false && "MemCache ERROR : CLEANUP hit but line not shared");
+                  ASSERT(false,"MemCache ERROR : CLEANUP hit but line not shared");
               }
             }
@@ -2568,10 +2731,14 @@
       case CLEANUP_HEAP_SEARCH:
         {
-          assert( (r_alloc_heap_fsm.read() == ALLOC_HEAP_CLEANUP) &&
-                    "MemCache ERROR : bad HEAP allocation");
+          ASSERT((r_alloc_heap_fsm.read() == ALLOC_HEAP_CLEANUP)
+                 ,"MemCache ERROR : bad HEAP allocation");
           HeapEntry heap_entry = m_heap_directory.read(r_cleanup_next_ptr.read());
           bool last = (heap_entry.next == r_cleanup_next_ptr.read());
           bool cleanup_inst       = r_cleanup_trdid.read() & 0x1; 
-          bool match_heap_srcid   = (heap_entry.owner.srcid == r_cleanup_srcid.read());
+          bool match_heap_srcid   = ((heap_entry.owner.srcid == r_cleanup_srcid.read())
+#if L1_MULTI_CACHE
+                                     and (heap_entry.owner.cache_id == r_cleanup_pktid.read())
+#endif
+                                     );
           bool match_heap_inst    = (heap_entry.owner.inst  == cleanup_inst);
           bool match_heap         = match_heap_srcid && match_heap_inst;
@@ -2583,9 +2750,12 @@
           else{
             if(last) {
-              assert(false && "MemCache ERROR : CLEANUP hit but line not shared");
+                ASSERT(false,"MemCache ERROR : CLEANUP hit but line not shared");
             } else {
-              r_cleanup_prev_ptr = r_cleanup_next_ptr.read();
-              r_cleanup_prev_srcid = heap_entry.owner.srcid;
-              r_cleanup_prev_inst  = heap_entry.owner.inst;
+              r_cleanup_prev_ptr      = r_cleanup_next_ptr.read();
+              r_cleanup_prev_srcid    = heap_entry.owner.srcid;
+#if L1_MULTI_CACHE
+              r_cleanup_prev_cache_id = heap_entry.owner.cache_id;
+#endif
+              r_cleanup_prev_inst     = heap_entry.owner.inst;
               r_cleanup_next_ptr = heap_entry.next;
               r_cleanup_fsm      = CLEANUP_HEAP_SEARCH;
@@ -2598,10 +2768,13 @@
       case CLEANUP_HEAP_CLEAN:
         {
-          assert( (r_alloc_heap_fsm.read() == ALLOC_HEAP_CLEANUP) &&
-                    "MemCache ERROR : bad HEAP allocation");
+            ASSERT((r_alloc_heap_fsm.read() == ALLOC_HEAP_CLEANUP)
+                   ,"MemCache ERROR : bad HEAP allocation");
           bool last = (r_cleanup_next_ptr.read() == r_cleanup_ptr.read());
           HeapEntry heap_entry; 
-          heap_entry.owner.srcid = r_cleanup_prev_srcid.read();
-          heap_entry.owner.inst  = r_cleanup_prev_inst.read();
+          heap_entry.owner.srcid    = r_cleanup_prev_srcid.read();
+#if L1_MULTI_CACHE
+          heap_entry.owner.cache_id = r_cleanup_prev_cache_id.read();
+#endif
+          heap_entry.owner.inst     = r_cleanup_prev_inst.read();
           if(last){ // this is the last entry of the list of copies
             heap_entry.next     = r_cleanup_prev_ptr.read();
@@ -2616,9 +2789,12 @@
       case CLEANUP_HEAP_FREE:
         {
-          assert( (r_alloc_heap_fsm.read() == ALLOC_HEAP_CLEANUP) &&
-                    "MemCache ERROR : bad HEAP allocation");
+          ASSERT((r_alloc_heap_fsm.read() == ALLOC_HEAP_CLEANUP)
+                 ,"MemCache ERROR : bad HEAP allocation");
           HeapEntry heap_entry;
-          heap_entry.owner.srcid = 0;
-          heap_entry.owner.inst  = false;
+          heap_entry.owner.srcid    = 0;
+#if L1_MULTI_CACHE
+          heap_entry.owner.cache_id = 0;
+#endif
+          heap_entry.owner.inst     = false;
           if(m_heap_directory.is_full()){
             heap_entry.next     = r_cleanup_next_ptr.read();
@@ -2760,5 +2936,5 @@
                 r_llsc_wdata = m_cmd_llsc_wdata_fifo.read();
             if(r_llsc_cpt.read()>3)
-                assert(false && "MEMCACHE error : SC too long");
+                ASSERT(false,"MEMCACHE error : SC too long");
             if(r_llsc_cpt.read()==2){
                 r_llsc_wdata = m_cmd_llsc_wdata_fifo.read();
@@ -2774,12 +2950,16 @@
             size_t way = 0;
             DirectoryEntry entry(m_cache_directory.read(m_cmd_llsc_addr_fifo.read(), way));
-            r_llsc_is_cnt   = entry.is_cnt;
-            r_llsc_dirty    = entry.dirty;
-            r_llsc_tag      = entry.tag;
-            r_llsc_way      = way;
-            r_llsc_copy     = entry.owner.srcid;
-            r_llsc_copy_inst= entry.owner.inst;
-            r_llsc_ptr      = entry.ptr;
-            r_llsc_count    = entry.count;
+            r_llsc_is_cnt     = entry.is_cnt;
+            r_llsc_dirty      = entry.dirty;
+            r_llsc_tag        = entry.tag;
+            r_llsc_way        = way;
+            r_llsc_copy       = entry.owner.srcid;
+#if L1_MULTI_CACHE
+            r_llsc_copy_cache = entry.owner.cache_id;
+#endif
+
+            r_llsc_copy_inst  = entry.owner.inst;
+            r_llsc_ptr        = entry.ptr;
+            r_llsc_count      = entry.count;
             if ( entry.valid ){
                 r_llsc_fsm = SC_DIR_HIT_READ;
@@ -2798,13 +2978,16 @@
           // update directory (lock & dirty bits
           DirectoryEntry entry;
-          entry.valid	    = true;
-          entry.is_cnt      = r_llsc_is_cnt.read();
-          entry.dirty	    = true;
-          entry.lock	    = true;
-          entry.tag	        = r_llsc_tag.read();
-          entry.owner.srcid = r_llsc_copy.read();
-          entry.owner.inst  = r_llsc_copy_inst.read();
-          entry.count       = r_llsc_count.read();
-          entry.ptr         = r_llsc_ptr.read();
+          entry.valid	       = true;
+          entry.is_cnt         = r_llsc_is_cnt.read();
+          entry.dirty	       = true;
+          entry.lock	       = true;
+          entry.tag	           = r_llsc_tag.read();
+          entry.owner.srcid    = r_llsc_copy.read();
+#if L1_MULTI_CACHE
+          entry.owner.cache_id = r_llsc_copy_cache.read();
+#endif
+          entry.owner.inst     = r_llsc_copy_inst.read();
+          entry.count          = r_llsc_count.read();
+          entry.ptr            = r_llsc_ptr.read();
           m_cache_directory.write(set, way, entry);
 
@@ -2938,6 +3121,6 @@
       case SC_UPT_REQ: 	// Request the update
         {
-          assert( (r_alloc_heap_fsm.read() == ALLOC_HEAP_LLSC) &&
-                    "MemCache ERROR : bad HEAP allocation");
+          ASSERT((r_alloc_heap_fsm.read() == ALLOC_HEAP_LLSC)
+                 ,"MemCache ERROR : bad HEAP allocation");
           if( !r_llsc_to_init_cmd_multi_req.read() && 
               !r_llsc_to_init_cmd_brdcast_req.read()  ){
@@ -2959,4 +3142,7 @@
             llsc_to_init_cmd_fifo_inst    = r_llsc_copy_inst.read();
             llsc_to_init_cmd_fifo_srcid   = r_llsc_copy.read();
+#if L1_MULTI_CACHE
+            llsc_to_init_cmd_fifo_cache_id= r_llsc_copy_cache.read();
+#endif
             if(r_llsc_count.read() == 1){
 #ifdef LOCK_DEBUG
@@ -2978,9 +3164,12 @@
       case SC_UPDATE:   	// send a multi-update request to INIT_CMD fsm
         {
-          assert( (r_alloc_heap_fsm.read() == ALLOC_HEAP_LLSC) &&
-                    "MemCache ERROR : bad HEAP allocation");
+          ASSERT((r_alloc_heap_fsm.read() == ALLOC_HEAP_LLSC)
+                 ,"MemCache ERROR : bad HEAP allocation");
           HeapEntry entry = m_heap_directory.read(r_llsc_ptr.read());
-          llsc_to_init_cmd_fifo_inst  = entry.owner.inst;
-          llsc_to_init_cmd_fifo_srcid = entry.owner.srcid;
+          llsc_to_init_cmd_fifo_srcid    = entry.owner.srcid;
+#if L1_MULTI_CACHE
+          llsc_to_init_cmd_fifo_cache_id = entry.owner.cache_id;
+#endif
+          llsc_to_init_cmd_fifo_inst     = entry.owner.inst;
           llsc_to_init_cmd_fifo_put = true;
 
@@ -3106,4 +3295,7 @@
             entry.count         = 0;
             entry.owner.srcid   = 0;
+#if L1_MULTI_CACHE
+            entry.owner.cache_id= 0;
+#endif
             entry.owner.inst    = false;
             entry.ptr           = 0;
@@ -3114,5 +3306,5 @@
             r_llsc_fsm = SC_INVAL;
           } else {
-            assert(false && "LOCK ERROR in LLSC_FSM, STATE = LLSC_DIR_INVAL");
+              ASSERT(false,"LOCK ERROR in LLSC_FSM, STATE = LLSC_DIR_INVAL");
           }
 
@@ -3150,5 +3342,5 @@
             r_llsc_cpt = 0;
           } else {
-            assert( false && "MEM_CACHE, LLSC FSM : SC_XRAM_SEND state : the request should not have been previously set");
+              ASSERT(false,"MEM_CACHE, LLSC FSM : SC_XRAM_SEND state : the request should not have been previously set");
           }
           break;
@@ -4109,7 +4301,13 @@
         m_write_to_init_cmd_inst_fifo.put_and_get(write_to_init_cmd_fifo_inst);
         m_write_to_init_cmd_srcid_fifo.put_and_get(write_to_init_cmd_fifo_srcid);
+#if L1_MULTI_CACHE
+        m_write_to_init_cmd_cache_id_fifo.put_and_get(write_to_init_cmd_fifo_cache_id);
+#endif
       } else {
         m_write_to_init_cmd_inst_fifo.simple_put(write_to_init_cmd_fifo_inst);
         m_write_to_init_cmd_srcid_fifo.simple_put(write_to_init_cmd_fifo_srcid);
+#if L1_MULTI_CACHE
+        m_write_to_init_cmd_cache_id_fifo.simple_put(write_to_init_cmd_fifo_cache_id);
+#endif
       }
     } else {
@@ -4117,4 +4315,7 @@
         m_write_to_init_cmd_inst_fifo.simple_get();
         m_write_to_init_cmd_srcid_fifo.simple_get();
+#if L1_MULTI_CACHE
+        m_write_to_init_cmd_cache_id_fifo.simple_get();
+#endif
       }
     }
@@ -4127,7 +4328,13 @@
         m_xram_rsp_to_init_cmd_inst_fifo.put_and_get(xram_rsp_to_init_cmd_fifo_inst);
         m_xram_rsp_to_init_cmd_srcid_fifo.put_and_get(xram_rsp_to_init_cmd_fifo_srcid);
+#if L1_MULTI_CACHE
+        m_xram_rsp_to_init_cmd_cache_id_fifo.put_and_get(xram_rsp_to_init_cmd_fifo_cache_id);
+#endif
       } else {
         m_xram_rsp_to_init_cmd_inst_fifo.simple_put(xram_rsp_to_init_cmd_fifo_inst);
         m_xram_rsp_to_init_cmd_srcid_fifo.simple_put(xram_rsp_to_init_cmd_fifo_srcid);
+#if L1_MULTI_CACHE
+        m_xram_rsp_to_init_cmd_cache_id_fifo.simple_put(xram_rsp_to_init_cmd_fifo_cache_id);
+#endif
       }
     } else {
@@ -4135,4 +4342,7 @@
         m_xram_rsp_to_init_cmd_inst_fifo.simple_get();
         m_xram_rsp_to_init_cmd_srcid_fifo.simple_get();
+#if L1_MULTI_CACHE
+        m_xram_rsp_to_init_cmd_cache_id_fifo.simple_get();
+#endif
       }
     }
@@ -4145,12 +4355,21 @@
         m_llsc_to_init_cmd_inst_fifo.put_and_get(llsc_to_init_cmd_fifo_inst);
         m_llsc_to_init_cmd_srcid_fifo.put_and_get(llsc_to_init_cmd_fifo_srcid);
+#if L1_MULTI_CACHE
+        m_llsc_to_init_cmd_cache_id_fifo.put_and_get(llsc_to_init_cmd_fifo_cache_id);
+#endif
       } else {
-        m_llsc_to_init_cmd_inst_fifo.simple_put(llsc_to_init_cmd_fifo_inst);
-        m_llsc_to_init_cmd_srcid_fifo.simple_put(llsc_to_init_cmd_fifo_srcid);
+          m_llsc_to_init_cmd_inst_fifo.simple_put(llsc_to_init_cmd_fifo_inst);
+          m_llsc_to_init_cmd_srcid_fifo.simple_put(llsc_to_init_cmd_fifo_srcid);
+#if L1_MULTI_CACHE
+          m_llsc_to_init_cmd_cache_id_fifo.simple_put(llsc_to_init_cmd_fifo_cache_id);
+#endif
       }
     } else {
-      if ( llsc_to_init_cmd_fifo_get ) {
-        m_llsc_to_init_cmd_inst_fifo.simple_get();
-        m_llsc_to_init_cmd_srcid_fifo.simple_get();
+        if ( llsc_to_init_cmd_fifo_get ) {
+            m_llsc_to_init_cmd_inst_fifo.simple_get();
+            m_llsc_to_init_cmd_srcid_fifo.simple_get();
+#if L1_MULTI_CACHE
+            m_llsc_to_init_cmd_cache_id_fifo.simple_get();
+#endif
       }
     }
@@ -4160,5 +4379,5 @@
     m_cpt_cycles++;
 
-  } // end transition()
+    } // end transition()
 
   /////////////////////////////
@@ -4297,4 +4516,10 @@
         break;
       case TGT_RSP_READ:
+          PRINTF("  * <MEM_CACHE.TGT> RSP_READ     : srcid %d, trdid %d, pktid %d\n"
+                 ,(uint32_t)r_read_to_tgt_rsp_srcid.read()
+                 ,(uint32_t)r_read_to_tgt_rsp_trdid.read()
+                 ,(uint32_t)r_read_to_tgt_rsp_pktid.read()
+                 );
+
         p_vci_tgt.rspval   = true;
         p_vci_tgt.rdata    = r_read_to_tgt_rsp_data[r_tgt_rsp_cpt.read()].read();
@@ -4306,4 +4531,10 @@
         break;
       case TGT_RSP_WRITE:
+          PRINTF("  * <MEM_CACHE.TGT> RSP_WRITE    : BURP srcid %d, trdid %d, pktid %d\n"
+                 ,(uint32_t)r_write_to_tgt_rsp_srcid.read()
+                 ,(uint32_t)r_write_to_tgt_rsp_trdid.read()
+                 ,(uint32_t)r_write_to_tgt_rsp_pktid.read()
+                 );
+
         p_vci_tgt.rspval   = true;
         p_vci_tgt.rdata    = 0;
@@ -4315,4 +4546,10 @@
         break;
       case TGT_RSP_CLEANUP:
+          PRINTF("  * <MEM_CACHE.TGT> RSP_CLEANUP  : srcid %d, trdid %d, pktid %d\n"
+                 ,(uint32_t)r_cleanup_to_tgt_rsp_srcid.read()
+                 ,(uint32_t)r_cleanup_to_tgt_rsp_trdid.read()
+                 ,(uint32_t)r_cleanup_to_tgt_rsp_pktid.read()
+                 );
+
         p_vci_tgt.rspval   = true;
         p_vci_tgt.rdata    = 0;
@@ -4324,4 +4561,10 @@
         break;
       case TGT_RSP_LLSC:
+          PRINTF("  * <MEM_CACHE.TGT> RSP_LLSC     : srcid %d, trdid %d, pktid %d\n"
+                 ,(uint32_t)r_llsc_to_tgt_rsp_srcid.read()
+                 ,(uint32_t)r_llsc_to_tgt_rsp_trdid.read()
+                 ,(uint32_t)r_llsc_to_tgt_rsp_pktid.read()
+                 );
+
         p_vci_tgt.rspval   = true;
         p_vci_tgt.rdata    = r_llsc_to_tgt_rsp_data.read();
@@ -4333,4 +4576,10 @@
         break;
       case TGT_RSP_XRAM:
+          PRINTF("  * <MEM_CACHE.TGT> RSP_XRAM     : srcid %d, trdid %d, pktid %d\n"
+                 ,(uint32_t)r_xram_rsp_to_tgt_rsp_srcid.read()
+                 ,(uint32_t)r_xram_rsp_to_tgt_rsp_trdid.read()
+                 ,(uint32_t)r_xram_rsp_to_tgt_rsp_pktid.read()
+                 );
+
         p_vci_tgt.rspval   = true;
         p_vci_tgt.rdata    = r_xram_rsp_to_tgt_rsp_data[r_tgt_rsp_cpt.read()].read();
@@ -4343,4 +4592,10 @@
         break;
       case TGT_RSP_INIT:
+          PRINTF("  * <MEM_CACHE.TGT> RSP_INIT     : srcid %d, trdid %d, pktid %d\n"
+                 ,(uint32_t)r_init_rsp_to_tgt_rsp_srcid.read()
+                 ,(uint32_t)r_init_rsp_to_tgt_rsp_trdid.read()
+                 ,(uint32_t)r_init_rsp_to_tgt_rsp_pktid.read()
+                 );
+
         p_vci_tgt.rspval   = true;
         p_vci_tgt.rdata    = 0;
@@ -4359,5 +4614,4 @@
     p_vci_ini.cmd     = vci_param::CMD_WRITE;
     p_vci_ini.srcid   = m_srcid_ini;
-    p_vci_ini.pktid   = 0;
     p_vci_ini.cons    = true;
     p_vci_ini.wrap    = false;
@@ -4377,7 +4631,14 @@
         p_vci_ini.plen    = 0;
         p_vci_ini.trdid   = 0;
+        p_vci_ini.pktid   = 0;
         p_vci_ini.eop     = false;
         break;
       case INIT_CMD_INVAL_NLINE:
+      {
+        PRINTF("  * <MEM_CACHE.INIT_CMD> INVAL_NLINE : trdid %d, pktid %d\n"
+               ,(uint32_t)r_xram_rsp_to_init_cmd_trdid.read()
+               ,(uint32_t)m_xram_rsp_to_init_cmd_cache_id_fifo.read()
+               );
+        
         p_vci_ini.cmdval  = m_xram_rsp_to_init_cmd_inst_fifo.rok();
         if(m_xram_rsp_to_init_cmd_inst_fifo.rok()){
@@ -4392,6 +4653,8 @@
         p_vci_ini.plen    = 4;
         p_vci_ini.trdid   = r_xram_rsp_to_init_cmd_trdid.read();
+        p_vci_ini.pktid   = m_xram_rsp_to_init_cmd_cache_id_fifo.read();
         p_vci_ini.eop     = true;
         break;
+      }
       case INIT_CMD_XRAM_BRDCAST:
         p_vci_ini.cmdval  = true;
@@ -4401,4 +4664,5 @@
         p_vci_ini.plen    = 4;
         p_vci_ini.trdid   = r_xram_rsp_to_init_cmd_trdid.read();
+        p_vci_ini.pktid   = 0;
         p_vci_ini.eop     = true;
         break;
@@ -4412,4 +4676,5 @@
         p_vci_ini.eop     = true;
         p_vci_ini.trdid   = r_write_to_init_cmd_trdid.read();
+        p_vci_ini.pktid   = 0;
         break;
       case INIT_CMD_UPDT_NLINE:
@@ -4429,4 +4694,5 @@
         p_vci_ini.eop     = false;
         p_vci_ini.trdid   = r_write_to_init_cmd_trdid.read();
+        p_vci_ini.pktid   = m_write_to_init_cmd_cache_id_fifo.read();
         break;
       case INIT_CMD_UPDT_INDEX:
@@ -4441,4 +4707,5 @@
         p_vci_ini.plen    = 4 * (r_write_to_init_cmd_count.read() + 2);
         p_vci_ini.trdid   = r_write_to_init_cmd_trdid.read();
+        p_vci_ini.pktid   = m_write_to_init_cmd_cache_id_fifo.read();
         p_vci_ini.eop     = false;
         break;
@@ -4456,4 +4723,5 @@
         p_vci_ini.plen    = 4 * (r_write_to_init_cmd_count.read() + 2);
         p_vci_ini.trdid   = r_write_to_init_cmd_trdid.read();
+        p_vci_ini.pktid   = m_write_to_init_cmd_cache_id_fifo.read();
         p_vci_ini.eop     = ( r_init_cmd_cpt.read() == (r_write_to_init_cmd_count.read()-1) );
         break;
@@ -4467,4 +4735,5 @@
         p_vci_ini.eop     = true;
         p_vci_ini.trdid   = r_llsc_to_init_cmd_trdid.read();
+        p_vci_ini.pktid   = 0;
         break;
       case INIT_CMD_SC_UPDT_NLINE:
@@ -4488,4 +4757,5 @@
         p_vci_ini.eop     = false;
         p_vci_ini.trdid   = r_llsc_to_init_cmd_trdid.read();
+        p_vci_ini.pktid   = m_llsc_to_init_cmd_cache_id_fifo.read();
         break;
       case INIT_CMD_SC_UPDT_INDEX:
@@ -4504,4 +4774,5 @@
         }
         p_vci_ini.trdid   = r_llsc_to_init_cmd_trdid.read();
+        p_vci_ini.pktid   = m_llsc_to_init_cmd_cache_id_fifo.read();
         p_vci_ini.eop     = false;
         break;
@@ -4516,4 +4787,5 @@
         p_vci_ini.be      = 0xF;
         p_vci_ini.trdid   = r_llsc_to_init_cmd_trdid.read();
+        p_vci_ini.pktid   = m_llsc_to_init_cmd_cache_id_fifo.read();
         if(r_llsc_to_init_cmd_is_long.read()){
             p_vci_ini.plen    = 4 * 4;
@@ -4535,4 +4807,5 @@
         p_vci_ini.plen    = 4 * 4;
         p_vci_ini.trdid   = r_llsc_to_init_cmd_trdid.read();
+        p_vci_ini.pktid   = m_llsc_to_init_cmd_cache_id_fifo.read();
         p_vci_ini.eop     = true;
         break;
@@ -4567,4 +4840,6 @@
       case CLEANUP_RSP:
         {
+            PRINTF("  * <MEM_CACHE.CLEANUP_RSP> Respons to %d.%d\n",(uint32_t)r_cleanup_srcid.read(),(uint32_t)r_cleanup_pktid.read());
+
           p_vci_tgt_cleanup.rspval = true;
           p_vci_tgt_cleanup.rdata  = 0;
