Index: trunk/modules/vci_cc_vcache_wrapper_v4/caba/source/include/vci_cc_vcache_wrapper_v4.h
===================================================================
--- trunk/modules/vci_cc_vcache_wrapper_v4/caba/source/include/vci_cc_vcache_wrapper_v4.h	(revision 262)
+++ trunk/modules/vci_cc_vcache_wrapper_v4/caba/source/include/vci_cc_vcache_wrapper_v4.h	(revision 284)
@@ -118,5 +118,5 @@
         //handling dirty bit update
         DCACHE_DIRTY_GET_PTE,
-        DCACHE_DIRTY_SC_WAIT,           
+        DCACHE_DIRTY_WAIT,           
 	    // handling processor miss requests
         DCACHE_MISS_VICTIM,
@@ -142,5 +142,5 @@
         CMD_DATA_UNC,
         CMD_DATA_WRITE,
-        CMD_DATA_SC, 
+        CMD_DATA_CAS, 
     };
 
@@ -152,5 +152,4 @@
         RSP_DATA_UNC,
         RSP_DATA_WRITE,
-        RSP_DATA_SC,
     };
 
@@ -173,4 +172,39 @@
         TGT_RSP_DCACHE,
     };
+
+    /* transaction type, pktid field */
+    enum transaction_type_e
+    {
+        // b3 unused
+        // b2 READ / NOT READ
+        // Si READ
+        //  b1 DATA / INS
+        //  b0 UNC / MISS
+        // Si NOT READ
+        //  b1 accÃšs table llsc type SW / other
+        //  b2 WRITE/CAS/LL/SC
+        TYPE_READ_DATA_UNC          = 0x0,
+        TYPE_READ_DATA_MISS         = 0x1,
+        TYPE_READ_INS_UNC           = 0x2,
+        TYPE_READ_INS_MISS          = 0x3,
+        TYPE_WRITE                  = 0x4,
+        TYPE_CAS                    = 0x5,
+        TYPE_LL                     = 0x6,
+        TYPE_SC                     = 0x7
+    };
+    
+    /* SC return values */
+    enum sc_status_type_e
+    {
+        SC_SUCCESS  =   0x00000000,
+        SC_FAIL     =   0x00000001
+    };
+    /*
+    this is already in vci_param.h
+    enum {
+        STORE_COND_ATOMIC = 0,
+        STORE_COND_NOT_ATOMIC = 1,
+    };
+    */
 
     // TLB Mode : ITLB / DTLB / ICACHE / DCACHE
Index: trunk/modules/vci_cc_vcache_wrapper_v4/caba/source/src/vci_cc_vcache_wrapper_v4.cpp
===================================================================
--- trunk/modules/vci_cc_vcache_wrapper_v4/caba/source/src/vci_cc_vcache_wrapper_v4.cpp	(revision 262)
+++ trunk/modules/vci_cc_vcache_wrapper_v4/caba/source/src/vci_cc_vcache_wrapper_v4.cpp	(revision 284)
@@ -89,5 +89,5 @@
 
         "DCACHE_DIRTY_PTE_GET",
-        "DCACHE_DIRTY_SC_WAIT",  
+        "DCACHE_DIRTY_WAIT",  
 
         "DCACHE_MISS_VICTIM",
@@ -112,5 +112,5 @@
         "CMD_DATA_UNC",     
         "CMD_DATA_WRITE", 
-        "CMD_DATA_SC", 
+        "CMD_DATA_CAS", 
     };
 const char *rsp_fsm_state_str[] = {
@@ -3995,5 +3995,5 @@
         r_dcache_vci_sc_old = pte;
         r_dcache_vci_sc_new = pte | PTE_D_MASK;
-        r_dcache_fsm        = DCACHE_DIRTY_SC_WAIT;
+        r_dcache_fsm        = DCACHE_DIRTY_WAIT;
 
 #if DEBUG_DCACHE
@@ -4010,10 +4010,10 @@
     }
     //////////////////////////
-    case DCACHE_DIRTY_SC_WAIT:		// wait completion of SC for PTE Dirty bit,
+    case DCACHE_DIRTY_WAIT:         // wait completion of CAS for PTE Dirty bit,
                                     // and return to IDLE state when response is received.
-                                    // we don't care if the SC is a failure:
-                                    // - if the SC is a success, the coherence mechanism
+                                    // we don't care if the CAS is a failure:
+                                    // - if the CAS is a success, the coherence mechanism
                                     //   updates the local copy.
-                                    // - if the SC is a failure, we just retry the write.
+                                    // - if the CAS is a failure, we just retry the write.
     {
         // external coherence request
@@ -4419,5 +4419,5 @@
             else if ( r_dcache_vci_sc_req.read() )
             {
-                r_vci_cmd_fsm       = CMD_DATA_SC;
+                r_vci_cmd_fsm       = CMD_DATA_CAS;
                 r_dcache_vci_sc_req = false;
                 r_vci_cmd_cpt       = 0;
@@ -4442,5 +4442,5 @@
         }
         /////////////////
-        case CMD_DATA_SC:
+        case CMD_DATA_CAS:
         {
             // The SC VCI command contains two flits
@@ -4475,5 +4475,5 @@
     //
     // As the VCI_RSP and VCI_CMD are fully desynchronized to support several
-    // simultaneous VCI transactions, this FSM uses the VCI TRDID field 
+    // simultaneous VCI transactions, this FSM uses the VCI RPKTID field 
     // to identify the transactions.
     //
@@ -4500,23 +4500,37 @@
             r_vci_rsp_cpt = 0;
 
-            if ( (p_vci_ini_d.rtrdid.read() >> (vci_param::T-1)) != 0 ) // Write transaction
-            {
-                r_vci_rsp_fsm = RSP_DATA_WRITE;
-            }
-            else if ( p_vci_ini_d.rtrdid.read() == TYPE_INS_MISS )
+            if      ( (p_vci_ini_d.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 ) 
+            {
+                r_vci_rsp_fsm = RSP_DATA_MISS;
+            }
+            else if ( (p_vci_ini_d.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  ) 
             {
                 r_vci_rsp_fsm = RSP_INS_MISS;
             }
-            else if ( p_vci_ini_d.rtrdid.read() == TYPE_INS_UNC )
-            {
-                r_vci_rsp_fsm = RSP_INS_UNC;
-            }
-            else if ( p_vci_ini_d.rtrdid.read() == TYPE_DATA_MISS )
-            {
-                r_vci_rsp_fsm = RSP_DATA_MISS;
-            }
-            else if ( p_vci_ini_d.rtrdid.read() == TYPE_DATA_UNC )
+            else if ( (p_vci_ini_d.rpktid.read() & 0x7) ==  TYPE_WRITE          )
+            {
+                r_vci_rsp_fsm = RSP_DATA_WRITE; 
+            }
+            else if ( (p_vci_ini_d.rpktid.read() & 0x7) ==  TYPE_CAS            ) 
             {
                 r_vci_rsp_fsm = RSP_DATA_UNC;
+            }
+            else if ( (p_vci_ini_d.rpktid.read() & 0x7) ==  TYPE_LL             ) 
+            {
+                assert(false and "TODO ! LL NOT IMPLEMENTED YET"); //TODO
+                //r_vci_rsp_fsm = RSP_DATA_UNC;
+            }
+            else if ( (p_vci_ini_d.rpktid.read() & 0x7) == TYPE_SC             ) 
+            {
+                assert(false and "TODO ! SC NOT IMPLEMENTED YET"); //TODO
+                //r_vci_rsp_fsm = RSP_DATA_UNC;
             }
             else
@@ -4850,6 +4864,6 @@
     p_vci_ini_d.pktid  = 0;
     p_vci_ini_d.srcid  = m_srcid_d;
-    p_vci_ini_d.cons   = (r_vci_cmd_fsm.read() == CMD_DATA_SC);
-    p_vci_ini_d.contig = not (r_vci_cmd_fsm.read() == CMD_DATA_SC);
+    p_vci_ini_d.cons   = (r_vci_cmd_fsm.read() == CMD_DATA_CAS);
+    p_vci_ini_d.contig = not (r_vci_cmd_fsm.read() == CMD_DATA_CAS);
     p_vci_ini_d.wrap   = false;
     p_vci_ini_d.clen   = 0;
@@ -4864,4 +4878,5 @@
         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;
@@ -4874,5 +4889,6 @@
         p_vci_ini_d.wdata   = 0;
         p_vci_ini_d.be      = 0xF;
-        p_vci_ini_d.trdid   = TYPE_INS_MISS;
+        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;
@@ -4885,5 +4901,6 @@
         p_vci_ini_d.wdata   = 0;
         p_vci_ini_d.be      = 0xF;
-        p_vci_ini_d.trdid   = TYPE_INS_UNC;
+        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;
@@ -4896,5 +4913,6 @@
         p_vci_ini_d.wdata   = 0;
         p_vci_ini_d.be      = 0xF;
-        p_vci_ini_d.trdid   = TYPE_DATA_MISS;
+        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;
@@ -4907,5 +4925,6 @@
         p_vci_ini_d.wdata   = 0;
         p_vci_ini_d.be      = r_dcache_vci_unc_be.read();
-        p_vci_ini_d.trdid   = TYPE_DATA_UNC;
+        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;
@@ -4919,4 +4938,5 @@
         p_vci_ini_d.be      = r_wbuf.getBe(r_vci_cmd_cpt.read());
         p_vci_ini_d.trdid   = r_wbuf.getIndex() + (1<<(vci_param::T-1));
+        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;
@@ -4924,5 +4944,5 @@
         break;
 
-    case CMD_DATA_SC:
+    case CMD_DATA_CAS:
         p_vci_ini_d.cmdval  = true;
         p_vci_ini_d.address = r_dcache_vci_paddr.read() & ~0x3;
@@ -4930,7 +4950,8 @@
         else                             p_vci_ini_d.wdata = r_dcache_vci_sc_new.read();
         p_vci_ini_d.be      = 0xF;
-        p_vci_ini_d.trdid   = TYPE_DATA_UNC;  
+        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_STORE_COND;
+        p_vci_ini_d.cmd     = vci_param::CMD_NOP;
         p_vci_ini_d.eop     = (r_vci_cmd_cpt.read() == 1);
         break;      
