Index: branches/RWT/modules/vci_cc_vcache_wrapper/caba/source/include/vci_cc_vcache_wrapper.h
===================================================================
--- branches/RWT/modules/vci_cc_vcache_wrapper/caba/source/include/vci_cc_vcache_wrapper.h	(revision 645)
+++ branches/RWT/modules/vci_cc_vcache_wrapper/caba/source/include/vci_cc_vcache_wrapper.h	(revision 646)
@@ -152,5 +152,6 @@
         CMD_INS_UNC,
         CMD_DATA_MISS,
-        CMD_DATA_UNC,
+        CMD_DATA_UNC_READ,
+        CMD_DATA_UNC_WRITE,
         CMD_DATA_WRITE,
         CMD_DATA_LL,
@@ -207,5 +208,5 @@
         //  b1 accÃšs table llsc type SW / other
         //  b2 WRITE/CAS/LL/SC
-        TYPE_READ_DATA_UNC          = 0x0,
+        TYPE_DATA_UNC               = 0x0,
         TYPE_READ_DATA_MISS         = 0x1,
         TYPE_READ_INS_UNC           = 0x2,
@@ -279,13 +280,13 @@
     };
 
-    enum transaction_type_d_e
-    {
-        // b0 : 1 if cached
-        // b1 : 1 if instruction
-        TYPE_DATA_UNC     = 0x0,
-        TYPE_DATA_MISS    = 0x1,
-        TYPE_INS_UNC      = 0x2,
-        TYPE_INS_MISS     = 0x3,
-    };
+//    enum transaction_type_d_e
+//    {
+//        // b0 : 1 if cached
+//        // b1 : 1 if instruction
+//        TYPE_DATA_UNC     = 0x0,
+//        TYPE_DATA_MISS    = 0x1,
+//        TYPE_INS_UNC      = 0x2,
+//        TYPE_INS_MISS     = 0x3,
+//    };
 
     //////////////////MODIFIED////////////////
@@ -428,5 +429,4 @@
     sc_signal<uint32_t>     r_dcache_save_be;           // byte enable (from proc)
     sc_signal<paddr_t>      r_dcache_save_paddr;        // physical address
-    sc_signal<bool>         r_dcache_save_cacheable;	// address cacheable
     sc_signal<size_t>       r_dcache_save_cache_way;	// selected way (from dcache)
     sc_signal<size_t>       r_dcache_save_cache_set;	// selected set (from dcache)
@@ -439,7 +439,9 @@
     // communication between DCACHE FSM and VCI_CMD FSM
     sc_signal<paddr_t>      r_dcache_vci_paddr;		    // physical address for VCI command
+    sc_signal<uint32_t>     r_dcache_vci_wdata;		    // write unc data for VCI command
     sc_signal<bool>         r_dcache_vci_miss_req;      // read miss request
-    sc_signal<bool>         r_dcache_vci_unc_req;       // uncacheable read request
-    sc_signal<uint32_t>     r_dcache_vci_unc_be;        // uncacheable read byte enable
+    sc_signal<bool>         r_dcache_vci_unc_req;       // uncacheable request (read/write)
+    sc_signal<uint32_t>     r_dcache_vci_unc_be;        // uncacheable byte enable
+    sc_signal<uint32_t>     r_dcache_vci_unc_write;     // uncacheable data write request
     sc_signal<bool>         r_dcache_vci_cas_req;       // atomic write request CAS
     sc_signal<uint32_t>     r_dcache_vci_cas_old;       // previous data value for a CAS
@@ -458,7 +460,4 @@
     sc_signal<size_t>       r_dcache_xtn_way;		    // selected way (from dcache)
     sc_signal<size_t>       r_dcache_xtn_set;		    // selected set (from dcache)
-
-    // write buffer state extension
-    sc_signal<bool>         r_dcache_pending_unc_write; // pending uncacheable write in WBUF
 
     // handling dcache miss
Index: branches/RWT/modules/vci_cc_vcache_wrapper/caba/source/src/vci_cc_vcache_wrapper.cpp
===================================================================
--- branches/RWT/modules/vci_cc_vcache_wrapper/caba/source/src/vci_cc_vcache_wrapper.cpp	(revision 645)
+++ branches/RWT/modules/vci_cc_vcache_wrapper/caba/source/src/vci_cc_vcache_wrapper.cpp	(revision 646)
@@ -124,5 +124,6 @@
         "CMD_INS_UNC",
         "CMD_DATA_MISS",
-        "CMD_DATA_UNC",
+        "CMD_DATA_UNC_READ",
+        "CMD_DATA_UNC_WRITE",
         "CMD_DATA_WRITE",
         "CMD_DATA_LL",
@@ -132,5 +133,5 @@
 
 const char *vci_pktid_type_str[] = {
-        "TYPE_READ_DATA_UNC",
+        "TYPE_DATA_UNC",
         "TYPE_READ_DATA_MISS",            
         "TYPE_READ_INS_UNC",          
@@ -302,5 +303,4 @@
       r_dcache_save_be("r_dcache_save_be"),
       r_dcache_save_paddr("r_dcache_save_paddr"),
-      r_dcache_save_cacheable("r_dcache_save_cacheable"),
       r_dcache_save_cache_way("r_dcache_save_cache_way"),
       r_dcache_save_cache_set("r_dcache_save_cache_set"),
@@ -312,7 +312,9 @@
 
       r_dcache_vci_paddr("r_dcache_vci_paddr"),
+      r_dcache_vci_wdata("r_dcache_vci_wdata"),
       r_dcache_vci_miss_req("r_dcache_vci_miss_req"),
       r_dcache_vci_unc_req("r_dcache_vci_unc_req"),
       r_dcache_vci_unc_be("r_dcache_vci_unc_be"),
+      r_dcache_vci_unc_write("r_dcache_vci_unc_write"),
       r_dcache_vci_cas_req("r_dcache_vci_cas_req"),
       r_dcache_vci_cas_old("r_dcache_vci_cas_old"),
@@ -324,6 +326,4 @@
       r_dcache_xtn_way("r_dcache_xtn_way"),
       r_dcache_xtn_set("r_dcache_xtn_set"),
-
-      r_dcache_pending_unc_write("r_dcache_pending_unc_write"),
 
       r_dcache_miss_type("r_dcache_miss_type"),
@@ -822,7 +822,4 @@
         r_dcache_vci_ll_req        = false;
         r_dcache_vci_sc_req        = false;
-
-        // No uncacheable write pending
-        r_dcache_pending_unc_write = false;
 
         // No processor XTN request pending
@@ -2426,28 +2423,16 @@
         if ( r_dcache_wbuf_req.read() )
         {
-            // miss if write not cacheable, and previous non cacheable write registered
-            if ( not r_dcache_save_cacheable.read() and r_dcache_pending_unc_write.read() )
-            {
-                wbuf_write_miss = true;
-            }
-            else		// try a registration into write buffer
-            {
-                bool wok = r_wbuf.write( r_dcache_save_paddr.read(),
-                                         r_dcache_save_be.read(),
-                                         r_dcache_save_wdata.read(),
-                                         r_dcache_save_cacheable.read() );
+            bool wok = r_wbuf.write( r_dcache_save_paddr.read(),
+                                     r_dcache_save_be.read(),
+                                     r_dcache_save_wdata.read(),
+                                     true );
 /*#ifdef INSTRUMENTATION
 m_cpt_wbuf_write++;
 #endif*/
-                if ( not wok ) // miss if write buffer full
-                {
-                    wbuf_write_miss = true;
-                }
-                else          // update the write_buffer state extension
-                {
-                    if(not r_dcache_pending_unc_write.read())
-                        r_dcache_pending_unc_write = not r_dcache_save_cacheable.read();
-                }
-            }
+
+            if ( not wok ) // miss if write buffer full
+            {
+                wbuf_write_miss = true;
+             }
         } // end WBUF update
 
@@ -2803,6 +2788,4 @@
                 if ( valid_req ) 	// processor request is valid (after MMU check)
                 {
-                    r_dcache_save_cacheable  = cacheable;
-
                     // READ request
                     // The read requests are taken only if there is no cache update.
@@ -2871,8 +2854,9 @@
                         else					// uncacheable read
                         {
-                            r_dcache_vci_paddr    = paddr;
-                            r_dcache_vci_unc_be   = m_dreq.be;
-                            r_dcache_vci_unc_req  = true;
-                            r_dcache_fsm          = DCACHE_UNC_WAIT;
+                            r_dcache_vci_paddr      = paddr;
+                            r_dcache_vci_unc_be     = m_dreq.be;
+                            r_dcache_vci_unc_write  = false;
+                            r_dcache_vci_unc_req    = true;
+                            r_dcache_fsm            = DCACHE_UNC_WAIT;
 #if DEBUG_DCACHE
 if ( m_debug_activated )
@@ -2940,13 +2924,19 @@
                                 r_dcache_llsc_valid = false;
 
-                            // response to processor
-                            m_drsp.valid        = true;
-
-
+                            if (not cacheable) 
+                            {                            
+                                r_dcache_vci_paddr      = paddr;
+                                r_dcache_vci_wdata      = m_dreq.wdata;
+                                r_dcache_vci_unc_write  = true;
+                                r_dcache_vci_unc_be     = m_dreq.be;
+                                r_dcache_vci_unc_req    = true;
+                                r_dcache_fsm            = DCACHE_UNC_WAIT;
+                            }
                             // activating P1 stage
-                            if( (cache_state != CACHE_SLOT_STATE_ZOMBI) && (cache_state != CACHE_SLOT_STATE_EMPTY) && (cacheable) )
+                            else if( (cache_state != CACHE_SLOT_STATE_ZOMBI) && (cache_state != CACHE_SLOT_STATE_EMPTY) )
                             {
                                 wbuf_request = (cache_state == CACHE_SLOT_STATE_VALID_CC); //write to L2 only if CC
                                 updt_request = true;
+                                m_drsp.valid = true;
                                 if ( cache_state == CACHE_SLOT_STATE_VALID_NCC ) 
                                 {
@@ -2985,6 +2975,7 @@
                             else
                             {
-                               if ( cacheable ) m_cpt_data_write_miss++;
+                               m_cpt_data_write_miss++;
                                
+                               m_drsp.valid = true;
                                wbuf_request = true;
                                updt_request = false;
@@ -4920,5 +4911,8 @@
         if ( r_vci_rsp_data_error.read() ) 	// bus error
         {
-            r_mmu_detr           = MMU_READ_DATA_ILLEGAL_ACCESS;
+            if(r_dcache_vci_unc_write.read())
+                r_mmu_detr           = MMU_WRITE_DATA_ILLEGAL_ACCESS;
+            else
+                r_mmu_detr           = MMU_READ_DATA_ILLEGAL_ACCESS;
             r_mmu_dbvar          = m_dreq.addr;
             r_vci_rsp_data_error = false;
@@ -5746,7 +5740,4 @@
             size_t      wbuf_max;
 
-            bool dcache_unc_req = r_dcache_vci_unc_req.read() and
-                 ( not r_icache_miss_req.read() or not r_vci_cmd_imiss_prio.read() );
-
             bool dcache_miss_req = r_dcache_vci_miss_req.read() and
                  ( not r_icache_miss_req.read() or not r_vci_cmd_imiss_prio.read() );
@@ -5755,11 +5746,26 @@
                  ( not r_icache_miss_req.read() or not r_vci_cmd_imiss_prio.read() );
 
+            bool dcache_sc_req   = r_dcache_vci_sc_req.read() and
+                 ( not r_icache_miss_req.read() or not r_vci_cmd_imiss_prio.read() );
+
+            bool dcache_cas_req   = r_dcache_vci_cas_req.read() and
+                 ( not r_icache_miss_req.read() or not r_vci_cmd_imiss_prio.read() );
+
             bool icache_miss_req = r_icache_miss_req.read() and
                  ( not (r_dcache_vci_miss_req.read() or
-                        r_dcache_vci_ll_req.read() or
-                        r_dcache_vci_unc_req.read())
+                        r_dcache_vci_ll_req.read()   or
+                        r_dcache_vci_cas_req.read()  or
+                        r_dcache_vci_sc_req.read())
                      or r_vci_cmd_imiss_prio.read() );
-            // 1 - Data Read Miss
-            if ( dcache_miss_req and r_wbuf.miss(r_dcache_vci_paddr.read()) )
+
+            // 1 - Data unc write
+            if ( r_dcache_vci_unc_req.read() and r_dcache_vci_unc_write.read())
+            {
+                r_vci_cmd_fsm        = CMD_DATA_UNC_WRITE;
+                r_dcache_vci_unc_req = false;
+//                m_cpt_dunc_transaction++;
+            }
+            // 2 data read miss
+            else if ( dcache_miss_req and r_wbuf.miss(r_dcache_vci_paddr.read()) )
             {
                 r_vci_cmd_fsm         = CMD_DATA_MISS;
@@ -5768,19 +5774,20 @@
                 m_cpt_dmiss_transaction++;
             }
-            // 2 - Data Read Uncachable
-            else if ( dcache_unc_req and r_wbuf.miss(r_dcache_vci_paddr.read()))
-            {
-                r_vci_cmd_fsm        = CMD_DATA_UNC;
+            // 3 - Data Read Uncachable
+            else if ( r_dcache_vci_unc_req.read() and not r_dcache_vci_unc_write.read() )
+            {
+                r_vci_cmd_fsm        = CMD_DATA_UNC_READ;
                 r_dcache_vci_unc_req = false;
                 m_cpt_dunc_transaction++;
             }
-            // 3 - Data Linked Load
+            // 4 - Data Linked Load
             else if ( dcache_ll_req and r_wbuf.miss(r_dcache_vci_paddr.read()))
             {
-                r_dcache_vci_ll_req = false;
-                r_vci_cmd_fsm       = CMD_DATA_LL;
+                r_vci_cmd_fsm         = CMD_DATA_LL;
+                r_dcache_vci_ll_req   = false;
+                r_vci_cmd_imiss_prio  = true;
                 m_cpt_ll_transaction++;
             }
-            // 4 - Instruction Miss
+            // 5 - Instruction Miss
             else if ( icache_miss_req and r_wbuf.miss(r_icache_vci_paddr.read()) )
             {
@@ -5790,5 +5797,5 @@
                 m_cpt_imiss_transaction++;
             }
-            // 5 - Instruction Uncachable
+            // 6 - Instruction Uncachable
             else if ( r_icache_unc_req.read() )
             {
@@ -5797,5 +5804,5 @@
                 //m_cpt_iunc_transaction++;
             }
-            // 6 - Data Write
+            // 7 - Data Write
             else if ( r_wbuf.rok(&wbuf_min, &wbuf_max) )
             {
@@ -5807,18 +5814,20 @@
                 m_length_write_transaction += (wbuf_max-wbuf_min+1);
             }
-            // 7 - Data Store Conditionnal
-            else if ( r_dcache_vci_sc_req.read() )
-            {
-                r_dcache_vci_sc_req = false;
-                r_vci_cmd_cpt  = 0;
-                r_vci_cmd_fsm  = CMD_DATA_SC;
+            // 8 - Data Store Conditionnal
+            else if ( dcache_sc_req and r_wbuf.miss(r_dcache_vci_paddr.read()) )
+            {
+                r_vci_cmd_fsm           = CMD_DATA_SC;
+                r_dcache_vci_sc_req     = false;
+                r_vci_cmd_imiss_prio    = true;
+                r_vci_cmd_cpt           = 0;
                 //m_cpt_sc_transaction++;
             }
-            // 8 - Compare And Swap
-            else if ( r_dcache_vci_cas_req.read() )
-            {
-                r_vci_cmd_fsm        = CMD_DATA_CAS;
-                r_dcache_vci_cas_req = false;
-                r_vci_cmd_cpt        = 0;
+            // 9 - Compare And Swap
+            else if ( dcache_cas_req and r_wbuf.miss(r_dcache_vci_paddr.read()) )
+            {
+                r_vci_cmd_fsm           = CMD_DATA_CAS;
+                r_dcache_vci_cas_req    = false;
+                r_vci_cmd_imiss_prio    = true;
+                r_vci_cmd_cpt           = 0;
                 //m_cpt_cas_transaction++;
             }
@@ -5865,5 +5874,6 @@
         case CMD_INS_UNC:
         case CMD_DATA_MISS:
-        case CMD_DATA_UNC:
+        case CMD_DATA_UNC_READ:
+        case CMD_DATA_UNC_WRITE:
         case CMD_DATA_LL:
         {
@@ -5913,5 +5923,5 @@
             r_vci_rsp_cpt = 0;
             if (r_dcache_vci_paddr.read() == 0x1f624) std::cout << "Tansaction on barrier, pktid = " <<  p_vci.rpktid.read() << std::endl;
-            if      ( (p_vci.rpktid.read() & 0x7) ==  TYPE_READ_DATA_UNC  )
+            if      ( (p_vci.rpktid.read() & 0x7) ==  TYPE_DATA_UNC  )
             {
                 r_vci_rsp_fsm = RSP_DATA_UNC;
@@ -6135,6 +6145,5 @@
                 r_vci_rsp_fsm = RSP_IDLE;
                 uint32_t   wbuf_index = p_vci.rtrdid.read();
-                bool       cacheable  = r_wbuf.completed(wbuf_index);
-                if ( not cacheable ) r_dcache_pending_unc_write = false;
+                r_wbuf.completed(wbuf_index);
                 if ( (p_vci.rerror.read()&0x1) != 0 ) r_iss.setWriteBerr();
             }
@@ -6683,5 +6692,5 @@
         break;
 
-    case CMD_DATA_UNC:
+    case CMD_DATA_UNC_READ:
         p_vci.cmdval  = true;
         p_vci.address = r_dcache_vci_paddr.read() & ~0x3;
@@ -6689,7 +6698,19 @@
         p_vci.be      = r_dcache_vci_unc_be.read();
         p_vci.trdid   = 0;
-        p_vci.pktid   = TYPE_READ_DATA_UNC;
+        p_vci.pktid   = TYPE_DATA_UNC;
         p_vci.plen    = 4;
         p_vci.cmd     = vci_param::CMD_READ;
+        p_vci.eop     = true;
+        break;
+
+    case CMD_DATA_UNC_WRITE:
+        p_vci.cmdval  = true;
+        p_vci.address = r_dcache_vci_paddr.read() & ~0x3;
+        p_vci.wdata   = r_dcache_vci_wdata.read();
+        p_vci.be      = r_dcache_vci_unc_be.read();
+        p_vci.trdid   = 0;
+        p_vci.pktid   = TYPE_DATA_UNC;
+        p_vci.plen    = 4;
+        p_vci.cmd     = vci_param::CMD_WRITE;
         p_vci.eop     = true;
         break;
Index: branches/RWT/modules/vci_mem_cache/caba/source/src/vci_mem_cache.cpp
===================================================================
--- branches/RWT/modules/vci_mem_cache/caba/source/src/vci_mem_cache.cpp	(revision 645)
+++ branches/RWT/modules/vci_mem_cache/caba/source/src/vci_mem_cache.cpp	(revision 646)
@@ -1404,5 +1404,5 @@
                             // ==> TYPE_WRITE = X100 with the TSAR encoding
                             // ==> mask = 0b0111 = 0x7
-                            assert(((p_vci_tgt.pktid.read() & 0x7) == 0x4) and
+                            assert(((p_vci_tgt.pktid.read() & 0x7) == 0x4 or (p_vci_tgt.pktid.read() == 0x0)) and
                                     "The type specified in the pktid field is incompatible with the WRITE CMD");
                             r_tgt_cmd_fsm = TGT_CMD_WRITE;
