Index: trunk/modules/vci_mem_cache/caba/source/include/vci_mem_cache.h
===================================================================
--- trunk/modules/vci_mem_cache/caba/source/include/vci_mem_cache.h	(revision 1036)
+++ trunk/modules/vci_mem_cache/caba/source/include/vci_mem_cache.h	(revision 1037)
@@ -189,5 +189,6 @@
         READ_TRT_LOCK,
         READ_TRT_SET,
-        READ_TRT_REQ
+        READ_TRT_REQ,
+        READ_WAIT
       };
 
Index: trunk/modules/vci_mem_cache/caba/source/src/vci_mem_cache.cpp
===================================================================
--- trunk/modules/vci_mem_cache/caba/source/src/vci_mem_cache.cpp	(revision 1036)
+++ trunk/modules/vci_mem_cache/caba/source/src/vci_mem_cache.cpp	(revision 1037)
@@ -160,5 +160,6 @@
         "READ_TRT_LOCK",
         "READ_TRT_SET",
-        "READ_TRT_REQ"
+        "READ_TRT_REQ",
+        "READ_WAIT"
     };
     const char *write_fsm_str[] =
@@ -2984,5 +2985,5 @@
                         if (!wok)                  m_cpt_trt_full++;
                         if (hit_read or hit_write) m_cpt_trt_rb++;
-                        r_read_fsm = READ_IDLE;
+                        r_read_fsm = READ_WAIT;
                     }
                     else // missing line is requested to the XRAM
@@ -3037,5 +3038,5 @@
 
             //////////////////
-            case READ_TRT_REQ:   // consume the read request in FIFO and send it to IXR_CMD_FSM
+            case READ_TRT_REQ:   // consume read request in FIFO / send it to IXR_CMD_FSM
             {
                 if (not r_read_to_ixr_cmd_req)
@@ -3057,4 +3058,20 @@
                 break;
             }
+
+            ///////////////
+            case READ_WAIT:  // release the locks protecting the shared ressources
+            {
+
+#if DEBUG_MEMC_READ
+                if (m_debug)
+                {
+                    std::cout << "  <MEMC " << name() 
+                              << " READ_WAIT> Releases the locks before retry" << std::endl;
+                }
+#endif
+                r_read_fsm = READ_DIR_REQ;
+                break;
+            }
+
         } // end switch read_fsm
 
@@ -7896,6 +7913,8 @@
         // compute dir_allocate, that is actually a release condition:
         // allocation can be done if the owner FSM doest not use the cache
+        // The oner FSM get the lowest priority (registerd in dir_last)
+        // only if the DIR access is a success.
         bool dir_allocate = false;
-        int  dir_last;
+        int  dir_last     = r_alloc_dir_last.read();
         switch(r_alloc_dir_fsm.read())
         {
@@ -7921,6 +7940,6 @@
                      (r_alloc_trt_fsm.read() == ALLOC_TRT_READ)))
                 {
-                    dir_last     = ALLOC_DIR_READ;
                     dir_allocate = true;
+                    if ( r_read_fsm.read() != READ_WAIT ) dir_last = ALLOC_DIR_READ;
                 }
                 break;
@@ -7944,6 +7963,6 @@
                      (r_alloc_trt_fsm.read()  == ALLOC_TRT_WRITE)))
                 {
-                    dir_last     = ALLOC_DIR_WRITE;
                     dir_allocate = true;
+                    if ( r_write_fsm.read() != WRITE_WAIT ) dir_last = ALLOC_DIR_WRITE;
                 }
                 break;
@@ -7968,6 +7987,6 @@
                       (r_alloc_trt_fsm.read() == ALLOC_TRT_CAS)))
                 {
-                    dir_last     = ALLOC_DIR_CAS;
                     dir_allocate = true;
+                    if ( r_cas_fsm.read() != CAS_WAIT ) dir_last = ALLOC_DIR_CAS;
                 }
                 break;
@@ -7981,6 +8000,6 @@
                     (r_config_fsm.read() != CONFIG_IVT_LOCK))
                 {
+                    dir_allocate = true;
                     dir_last     = ALLOC_DIR_CONFIG;
-                    dir_allocate = true;
                 }
                 break;
@@ -7993,6 +8012,6 @@
                     (r_cleanup_fsm.read() != CLEANUP_HEAP_LOCK))
                 {
+                    dir_allocate = true;
                     dir_last     = ALLOC_DIR_CLEANUP;
-                    dir_allocate = true;
                 }
   
@@ -8005,5 +8024,4 @@
                     (r_xram_rsp_fsm.read() != XRAM_RSP_IVT_LOCK))
                 {
-                    dir_last     = r_alloc_dir_last.read();
                     dir_allocate = true;
                 }
@@ -8096,7 +8114,9 @@
 
         // Compute trt_allocate, that is actually a release condition:
-        // allocation can be done if owner FSM does not use the TRT
+        // allocation can be done if owner FSM release the TRT
+        // The owner FSM get the lowest priority (registered in trt_last)
+        // but only if the access to TRT is successful
         bool trt_allocate = false;
-        int  trt_last;
+        int  trt_last     = r_alloc_trt_last.read();
         switch(r_alloc_trt_fsm.read())
         {
@@ -8105,6 +8125,6 @@
                 (r_read_fsm.read() != READ_TRT_SET))
             {
-                trt_last     = ALLOC_TRT_READ;
                 trt_allocate = true;
+                if ( r_read_fsm.read() != READ_WAIT ) trt_last = ALLOC_TRT_READ;
             }
             break;
@@ -8117,6 +8137,6 @@
                 (r_write_fsm.read() != WRITE_BC_DIR_INVAL))
             {
-                trt_last     = ALLOC_TRT_WRITE;
                 trt_allocate = true;
+                if ( r_write_fsm.read() != WRITE_WAIT ) trt_last = ALLOC_TRT_WRITE;
             }
             break;
@@ -8128,6 +8148,6 @@
                 (r_cas_fsm.read() != CAS_BC_DIR_INVAL))
             {
-                trt_last     = ALLOC_TRT_CAS;
                 trt_allocate = true;
+                if ( r_cas_fsm.read() != CAS_WAIT ) trt_last = ALLOC_TRT_CAS;
             }
             break;
@@ -8136,6 +8156,6 @@
                 (r_config_fsm.read() != CONFIG_TRT_SET))
             {
+                trt_allocate = true;
                 trt_last     = ALLOC_TRT_CONFIG;
-                trt_allocate = true;
             }
             break;
@@ -8147,5 +8167,4 @@
                 (r_ixr_cmd_fsm.read() != IXR_CMD_CONFIG_TRT))
             {
-                trt_last     = r_alloc_trt_last.read();
                 trt_allocate = true;
             }
@@ -8157,5 +8176,4 @@
                 (r_xram_rsp_fsm.read() != XRAM_RSP_TRT_DIRTY))
             {
-                trt_last     = r_alloc_trt_last.read();
                 trt_allocate = true;
             }
@@ -8165,5 +8183,4 @@
                 (r_ixr_rsp_fsm.read() != IXR_RSP_TRT_READ))
             {
-                trt_last     = r_alloc_trt_last.read();
                 trt_allocate = true;
             }
