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 1037)
+++ trunk/modules/vci_mem_cache/caba/source/src/vci_mem_cache.cpp	(revision 1038)
@@ -7894,11 +7894,11 @@
         ////////////////////////////////////////////////////////////////////////////////////
         // The ALLOC_DIR FSM allocates the access to the directory and
-        // the data cache with a higher priority for the XRAM_RSP FSM, 
-        // and a round robin priority between the five other FSMs :
-        // (the cyclic ordering is READ > WRITE > CAS > CONFIG > CLEANUP)
+        // the data cache with a higher priority for CLEANUP and XRAM_RSP FSMs, 
+        // and a round robin priority between the four other FSMs :
+        //    CLEANUP > XRAM_RSP > cyclic( READ > WRITE > CAS > CONFIG )
         // To maximize the throughput, the ressource is always allocated.
         // A new allocation is done when the owner FSM does not access the cache.
         // - The r_alloc_dir_fsm register define the current owner.
-        // - The r_alloc_dir_last register define the previous owner for round robin.
+        // - The r_alloc_dir_last register define the previous owner for cyclic priority.
         /////////////////////////////////////////////////////////////////////////////////////
 
@@ -7913,8 +7913,9 @@
         // 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.
+        // The owner FSM get the lowest priority (registerd in dir_last),
+        // but only if there is no retry.
+
         bool dir_allocate = false;
-        int  dir_last     = r_alloc_dir_last.read();
+        int  dir_last     = r_alloc_dir_last.read(); 
         switch(r_alloc_dir_fsm.read())
         {
@@ -7935,8 +7936,5 @@
                      (r_read_fsm.read() != READ_DIR_LOCK)  and
                      (r_read_fsm.read() != READ_TRT_LOCK)  and
-                     (r_read_fsm.read() != READ_HEAP_REQ))
-                    or
-                     ((r_read_fsm.read() == READ_TRT_LOCK) and
-                     (r_alloc_trt_fsm.read() == ALLOC_TRT_READ)))
+                     (r_read_fsm.read() != READ_HEAP_REQ)))
                 {
                     dir_allocate = true;
@@ -7955,11 +7953,5 @@
                      (r_write_fsm.read() != WRITE_BC_IVT_LOCK)   and
                      (r_write_fsm.read() != WRITE_MISS_TRT_LOCK) and
-                     (r_write_fsm.read() != WRITE_UPT_HEAP_LOCK))
-                    or
-                     ((r_write_fsm.read()     == WRITE_UPT_HEAP_LOCK) and
-                     (r_alloc_heap_fsm.read() == ALLOC_HEAP_WRITE))
-                    or
-                     ((r_write_fsm.read()     == WRITE_MISS_TRT_LOCK) and
-                     (r_alloc_trt_fsm.read()  == ALLOC_TRT_WRITE)))
+                     (r_write_fsm.read() != WRITE_UPT_HEAP_LOCK)))
                 {
                     dir_allocate = true;
@@ -7979,11 +7971,5 @@
                      (r_cas_fsm.read() != CAS_BC_IVT_LOCK)     and
                      (r_cas_fsm.read() != CAS_MISS_TRT_LOCK)   and
-                     (r_cas_fsm.read() != CAS_UPT_HEAP_LOCK))
-                    or
-                     ((r_cas_fsm.read()       == CAS_UPT_HEAP_LOCK) and
-                     (r_alloc_heap_fsm.read() == ALLOC_HEAP_CAS))
-                    or
-                     ((r_cas_fsm.read()       == CAS_MISS_TRT_LOCK) and
-                      (r_alloc_trt_fsm.read() == ALLOC_TRT_CAS)))
+                     (r_cas_fsm.read() != CAS_UPT_HEAP_LOCK)))
                 {
                     dir_allocate = true;
@@ -8013,5 +7999,4 @@
                 {
                     dir_allocate = true;
-                    dir_last     = ALLOC_DIR_CLEANUP;
                 }
   
@@ -8036,8 +8021,9 @@
             r_alloc_dir_last = dir_last;
 
-            // higher priority for XRAM_FSM
-            if ( dir_req_xram_rsp ) r_alloc_dir_fsm = ALLOC_DIR_XRAM_RSP;
-
-            // round-robin priority for READ > WRITE > CAS > CONFIG > CLEANUP
+            // higher priority for CLEANUP and XRAM_RSP
+            if      (dir_req_cleanup)      r_alloc_dir_fsm = ALLOC_DIR_CLEANUP;
+            if else (dir_req_xram_rsp)     r_alloc_dir_fsm = ALLOC_DIR_XRAM_RSP;
+
+            // round-robin priority for READ > WRITE > CAS > CONFIG 
             else if ( dir_last == ALLOC_DIR_READ )
             {
@@ -8045,5 +8031,4 @@
                 else if (dir_req_cas)      r_alloc_dir_fsm = ALLOC_DIR_CAS;
                 else if (dir_req_config)   r_alloc_dir_fsm = ALLOC_DIR_CONFIG;
-                else if (dir_req_cleanup)  r_alloc_dir_fsm = ALLOC_DIR_CLEANUP;
                 else if (dir_req_read)     r_alloc_dir_fsm = ALLOC_DIR_READ;
             }
@@ -8052,5 +8037,4 @@
                 if      (dir_req_cas)      r_alloc_dir_fsm = ALLOC_DIR_CAS;
                 else if (dir_req_config)   r_alloc_dir_fsm = ALLOC_DIR_CONFIG;
-                else if (dir_req_cleanup)  r_alloc_dir_fsm = ALLOC_DIR_CLEANUP;
                 else if (dir_req_read)     r_alloc_dir_fsm = ALLOC_DIR_READ;
                 else if (dir_req_write)    r_alloc_dir_fsm = ALLOC_DIR_WRITE;
@@ -8059,5 +8043,4 @@
             {
                 if      (dir_req_config)   r_alloc_dir_fsm = ALLOC_DIR_CONFIG;
-                else if (dir_req_cleanup)  r_alloc_dir_fsm = ALLOC_DIR_CLEANUP;
                 else if (dir_req_read)     r_alloc_dir_fsm = ALLOC_DIR_READ;
                 else if (dir_req_write)    r_alloc_dir_fsm = ALLOC_DIR_WRITE;
@@ -8065,12 +8048,4 @@
             }
             else if ( dir_last == ALLOC_DIR_CONFIG )
-            {
-                if      (dir_req_cleanup)  r_alloc_dir_fsm = ALLOC_DIR_CLEANUP;
-                else if (dir_req_read)     r_alloc_dir_fsm = ALLOC_DIR_READ;
-                else if (dir_req_write)    r_alloc_dir_fsm = ALLOC_DIR_WRITE;
-                else if (dir_req_cas)      r_alloc_dir_fsm = ALLOC_DIR_CAS;
-                else if (dir_req_config)   r_alloc_dir_fsm = ALLOC_DIR_CONFIG;
-            }
-            else if ( dir_last == ALLOC_DIR_CLEANUP )
             {
                 if      (dir_req_read)     r_alloc_dir_fsm = ALLOC_DIR_READ;
@@ -8078,5 +8053,4 @@
                 else if (dir_req_cas)      r_alloc_dir_fsm = ALLOC_DIR_CAS;
                 else if (dir_req_config)   r_alloc_dir_fsm = ALLOC_DIR_CONFIG;
-                else if (dir_req_cleanup)  r_alloc_dir_fsm = ALLOC_DIR_CLEANUP;
             }
         }  // end if dir_allocate
