Index: branches/MESI/modules/vci_mem_cache/caba/source/src/vci_mem_cache.cpp
===================================================================
--- branches/MESI/modules/vci_mem_cache/caba/source/src/vci_mem_cache.cpp	(revision 674)
+++ branches/MESI/modules/vci_mem_cache/caba/source/src/vci_mem_cache.cpp	(revision 675)
@@ -3195,12 +3195,7 @@
                         bool last_multi_req     = multi_req and (r_read_count.read() == 1);
                         bool not_last_multi_req = multi_req and (r_read_count.read() != 1);
-                        bool match_send         = (r_read_copy.read() == m_cmd_read_srcid_fifo.read()) and
-                                                  (r_read_copy_inst.read() == 0);
-
-                        if(last_multi_req and match_send)
-                        {
-                            std::cout << "last_multi_req and match srcid are true" << std::endl;
-                            exit(0);
-                        }
+                        //bool match_send         = (r_read_copy.read() == m_cmd_read_srcid_fifo.read()) and
+                        //                          (r_read_copy_inst.read() == 0);
+
                         size_t ivt_send_count   = 0;
 
@@ -3240,4 +3235,6 @@
                             r_read_to_cc_send_nline         = nline;
                             r_read_to_cc_send_srcid         = m_cmd_read_srcid_fifo.read();
+                            r_read_to_cc_send_is_shared     = r_read_state.read() == ENTRY_SHARED;
+
                             if(r_read_need_block.read())
                             {
@@ -3248,18 +3245,19 @@
                                 r_read_to_cleanup_req           = true; 
                             }
-                            r_read_to_cc_send_type          = true;
-
-                            if(not match_send)
-                            {
-                                read_to_cc_send_fifo_srcid      = r_read_copy.read();
-                                read_to_cc_send_fifo_inst       = r_read_copy_inst.read();
-                                read_to_cc_send_fifo_put        = multi_req;
-                            }   
+                            r_read_to_cc_send_type              = true; //CC_INVAL
+
+                         //   if(not match_send)
+                         //   {
+                            read_to_cc_send_fifo_srcid      = r_read_copy.read();
+                            read_to_cc_send_fifo_inst       = r_read_copy_inst.read();
+                            read_to_cc_send_fifo_put        = multi_req;
+                         //   }   
                             r_read_next_ptr                 = r_read_ptr.read();
 
-                            if(((m_cmd_read_pktid_fifo.read() & 0x8) == 0x8) and (r_read_state.read() == ENTRY_SHARED))  
-                                ivt_send_count = r_read_count.read() - 1;
-                            else
-                                ivt_send_count = r_read_count.read();
+                          //  if(((m_cmd_read_pktid_fifo.read() & 0x8) == 0x8) and (r_read_state.read() == ENTRY_SHARED))  
+                          //      ivt_send_count = r_read_count.read() - 1;
+                          //  else
+                          //      ivt_send_count = r_read_count.read();
+                          
                             m_ivt.set(false,            // it's an inval transaction
                                       not multi_req,    // multi_inval or brdcast  
@@ -3270,5 +3268,5 @@
                                       m_cmd_read_pktid_fifo.read() & 0x7,
                                       nline,
-                                      ivt_send_count,
+                                      r_read_count.read(),
                                       index);
                                 
@@ -3318,12 +3316,12 @@
                         HeapEntry entry = m_heap.read(r_read_next_ptr.read());
 
-                        bool match_send         = ( entry.owner.srcid == m_cmd_read_srcid_fifo.read()) and
-                                                  ( entry.owner.inst  == 0);
-                        if(not match_send) 
-                        {
-                            read_to_cc_send_fifo_srcid    = entry.owner.srcid;
-                            read_to_cc_send_fifo_inst     = entry.owner.inst;
-                            read_to_cc_send_fifo_put      = true;
-                        }
+                       // bool match_send         = ( entry.owner.srcid == m_cmd_read_srcid_fifo.read()) and
+                       //                           ( entry.owner.inst  == 0);
+                       // if(not match_send) 
+                       // {
+                        read_to_cc_send_fifo_srcid    = entry.owner.srcid;
+                        read_to_cc_send_fifo_inst     = entry.owner.inst;
+                        read_to_cc_send_fifo_put      = true;
+                       // }
                      //   if(read_to_cc_send_inst_fifo.wok()) always not full
                         r_read_next_ptr = entry.next;
@@ -3435,5 +3433,5 @@
                             r_read_to_cc_send_brdcast_req   = false;
                             r_read_to_cc_send_nline         = nline;
-                            r_read_to_cc_send_type          = false;
+                            r_read_to_cc_send_type          = false;  //CC_UPDT
            
                             read_to_cc_send_fifo_srcid      = r_read_copy.read();
@@ -6781,4 +6779,5 @@
                     r_cleanup_to_tgt_rsp_srcid   = r_cleanup_locked_srcid.read();
                     r_cleanup_to_tgt_rsp_trdid   = r_cleanup_locked_trdid.read();
+                    r_cleanup_to_tgt_rsp_nline   = r_cleanup_nline.read();
                     
                     r_cleanup_to_tgt_rsp_pktid   = 0x8 + r_cleanup_locked_pktid.read(); // there is not a brdcast for cas operation. in cache L1, the line can be in M state
@@ -8279,4 +8278,7 @@
             case CC_SEND_CONFIG_IDLE:    // XRAM_RSP FSM has highest priority
                 {
+                    bool cc_send_updt_delay = not r_read_to_cc_send_type.read() and r_tgt_rsp_fsm.read() == TGT_RSP_CLEANUP and
+                                              r_read_to_cc_send_nline.read() == r_cleanup_to_tgt_rsp_nline.read() and
+                                              m_read_to_cc_send_srcid_fifo.read() == r_cleanup_to_tgt_rsp_srcid.read();
                     // XRAM_RSP
                     if(m_xram_rsp_to_cc_send_inst_fifo.rok() or
@@ -8305,6 +8307,6 @@
 
                     // READ
-                    if(m_read_to_cc_send_inst_fifo.rok() or 
-                            r_read_to_cc_send_multi_req.read())
+                    if((m_read_to_cc_send_inst_fifo.rok() or 
+                            r_read_to_cc_send_multi_req.read()) and not cc_send_updt_delay)
                     {
                         r_cc_send_fsm = CC_SEND_READ_MULTI_HEADER;
@@ -8351,4 +8353,7 @@
             case CC_SEND_WRITE_IDLE:     // CONFIG FSM has highest priority
                 {
+                    bool cc_send_updt_delay = not r_read_to_cc_send_type.read() and r_tgt_rsp_fsm.read() == TGT_RSP_CLEANUP and
+                                              r_read_to_cc_send_nline.read() == r_cleanup_to_tgt_rsp_nline.read() and
+                                              m_read_to_cc_send_srcid_fifo.read() == r_cleanup_to_tgt_rsp_srcid.read();
                     // CONFIG
                     if(r_config_to_cc_send_multi_req.read())
@@ -8387,6 +8392,6 @@
                     }
                     // READ
-                    if(m_read_to_cc_send_inst_fifo.rok() or 
-                            r_read_to_cc_send_multi_req.read())
+                    if((m_read_to_cc_send_inst_fifo.rok() or 
+                            r_read_to_cc_send_multi_req.read()) and not cc_send_updt_delay)
                     {
                         r_cc_send_fsm = CC_SEND_READ_MULTI_HEADER;
@@ -8420,4 +8425,7 @@
             case CC_SEND_XRAM_RSP_IDLE:   // CAS FSM has highest priority
                 {
+                    bool cc_send_updt_delay = not r_read_to_cc_send_type.read() and r_tgt_rsp_fsm.read() == TGT_RSP_CLEANUP and
+                                              r_read_to_cc_send_nline.read() == r_cleanup_to_tgt_rsp_nline.read() and
+                                              m_read_to_cc_send_srcid_fifo.read() == r_cleanup_to_tgt_rsp_srcid.read();
                     // CAS
                     if(m_cas_to_cc_send_inst_fifo.rok() or
@@ -8433,6 +8441,6 @@
                     }
                     // READ
-                    if(m_read_to_cc_send_inst_fifo.rok() or 
-                            r_read_to_cc_send_multi_req.read())
+                    if((m_read_to_cc_send_inst_fifo.rok() or 
+                            r_read_to_cc_send_multi_req.read()) and not cc_send_updt_delay)
                     {
                         r_cc_send_fsm = CC_SEND_READ_MULTI_HEADER;
@@ -8484,7 +8492,10 @@
             case CC_SEND_CAS_IDLE:   // CLEANUP FSM has highest priority
                 {
+                    bool cc_send_updt_delay = not r_read_to_cc_send_type.read() and r_tgt_rsp_fsm.read() == TGT_RSP_CLEANUP and
+                                              r_read_to_cc_send_nline.read() == r_cleanup_to_tgt_rsp_nline.read() and
+                                              m_read_to_cc_send_srcid_fifo.read() == r_cleanup_to_tgt_rsp_srcid.read();
                     // READ
-                    if(m_read_to_cc_send_inst_fifo.rok() or 
-                            r_read_to_cc_send_multi_req.read())
+                    if((m_read_to_cc_send_inst_fifo.rok() or 
+                            r_read_to_cc_send_multi_req.read()) and not cc_send_updt_delay)
                     {
                         r_cc_send_fsm = CC_SEND_READ_MULTI_HEADER;
@@ -8548,4 +8559,7 @@
             case CC_SEND_READ_IDLE:    // WRITE FSM has highest priority  
                 {
+                    bool cc_send_updt_delay = not r_read_to_cc_send_type.read() and r_tgt_rsp_fsm.read() == TGT_RSP_CLEANUP and
+                                              r_read_to_cc_send_nline.read() == r_cleanup_to_tgt_rsp_nline.read() and
+                                              m_read_to_cc_send_srcid_fifo.read() == r_cleanup_to_tgt_rsp_srcid.read();
                     //WRITE
                     if(m_write_to_cc_send_inst_fifo.rok() or
@@ -8596,6 +8610,6 @@
                     }
                     // READ
-                    if(m_read_to_cc_send_inst_fifo.rok() or 
-                            r_read_to_cc_send_multi_req.read())
+                    if((m_read_to_cc_send_inst_fifo.rok() or 
+                            r_read_to_cc_send_multi_req.read()) and not cc_send_updt_delay)
                     {
                         r_cc_send_fsm = CC_SEND_READ_MULTI_HEADER;
@@ -8613,4 +8627,5 @@
             case CC_SEND_CONFIG_INVAL_HEADER:   // send first flit multi-inval (from CONFIG FSM)
                 {
+
                     if(m_config_to_cc_send_inst_fifo.rok())
                     {
@@ -11499,5 +11514,5 @@
                     DspinDhccpParam::dspin_set( flit,
                             1,
-                            DspinDhccpParam::MULTI_INVAL_IS_CONFIG);
+                            DspinDhccpParam::BRDCAST_IS_CONFIG);
 
                     DspinDhccpParam::dspin_set( flit,
@@ -11546,4 +11561,8 @@
                             r_read_to_cc_send_srcid.read(),    // send the srcid itself which demands the request getM
                             DspinDhccpParam::BROADCAST_SRCID);
+
+                    DspinDhccpParam::dspin_set( flit,
+                            r_read_to_cc_send_is_shared.read(),    // send the actuel line state in memcache
+                            DspinDhccpParam::BRDCAST_IS_SHARED);
 
                     DspinDhccpParam::dspin_set( flit,
@@ -11618,6 +11637,6 @@
                     DspinDhccpParam::dspin_set(
                             flit,
-                            r_read_to_cc_send_srcid.read(),
-                            DspinDhccpParam::MULTI_INVAL_SRCID);
+                            r_read_to_cc_send_is_shared.read(),
+                            DspinDhccpParam::MULTI_INVAL_IS_SHARED);
 
                     if(r_read_to_cc_send_type.read())
