Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_transition.cpp
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_transition.cpp	(revision 98)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_transition.cpp	(revision 101)
@@ -46,4 +46,5 @@
             reg_UPT_TOP_EVENT        [i] = 0;
             reg_UPT_UPDATE           [i] = 0;
+            reg_UPT_EMPTY            [i] = true;
                                                                                     
             reg_IS_ACCURATE          [i] = true;
@@ -87,9 +88,13 @@
             // UPDATE_PREDICTION_TABLE
             {
-              uint32_t bottom = reg_UPT_BOTTOM [i];
-              bool     end_ok = (reg_UPDATE_PREDICTION_TABLE [i][bottom]._state == UPDATE_PREDICTION_STATE_END_OK);
-              bool     end_ko = (reg_UPDATE_PREDICTION_TABLE [i][bottom]._state == UPDATE_PREDICTION_STATE_END_KO);
+              uint32_t      bottom      = reg_UPT_BOTTOM [i];
+              bool          end_ok      = (reg_UPDATE_PREDICTION_TABLE [i][bottom]._state == UPDATE_PREDICTION_STATE_END_OK);
+              bool          end_ko      = (reg_UPDATE_PREDICTION_TABLE [i][bottom]._state == UPDATE_PREDICTION_STATE_END_KO);
+//               event_state_t event_state = reg_EVENT_STATE [i];
 
               // Test if state is end
+//               if ((end_ok or end_ko) and 
+//                   ((event_state != EVENT_STATE_UPDATE_CONTEXT) and
+//                    (event_state != EVENT_STATE_WAIT_END_EVENT)))
               if (end_ok or end_ko)
                 {
@@ -102,4 +107,8 @@
                   // Update pointer
                   reg_UPT_BOTTOM [i] = (bottom+1)%_param->_size_upt_queue[i];
+
+                  if (reg_UPT_BOTTOM [i] == reg_UPT_TOP [i])
+                    reg_UPT_EMPTY [i] = true; // free a slot
+
 //                   if (bottom = reg_UPT_UPDATE [i])
 //                     reg_UPT_UPDATE [i] = reg_UPT_BOTTOM [i];
@@ -108,4 +117,7 @@
                       reg_UPT_TOP    [i] = reg_UPT_TOP_EVENT [i];
                       reg_UPT_UPDATE [i] = reg_UPT_TOP_EVENT [i];
+
+                      if (reg_UPT_BOTTOM [i] != reg_UPT_TOP [i])
+                        reg_UPT_EMPTY [i] = false;
                     }
                 }
@@ -290,4 +302,5 @@
               // Update pointer
               reg_UPT_TOP     [context] = (upt_ptr_write+1)%_param->_size_upt_queue [context];
+              reg_UPT_EMPTY   [context] = false;
 //            reg_UPT_UPDATE  [context] = reg_UPT_TOP [context];
 	    }
@@ -338,4 +351,7 @@
                   reg_UPT_TOP_EVENT [context] = top;
 
+                  if (reg_UPT_BOTTOM [context] == reg_UPT_TOP [context])
+                    reg_UPT_EMPTY [i] = true;
+
 #ifdef DEBUG_TEST
                   if (reg_UPDATE_PREDICTION_TABLE [context][depth]._state != UPDATE_PREDICTION_STATE_WAIT_END)
@@ -483,4 +499,9 @@
                       if (ko)
                         {
+                          // Ko : wait end of all instruction
+//                           log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT  [%d][%d].state <- UPDATE_PREDICTION_STATE_END_KO_WAIT_END (update)",context,depth);
+                          
+//                           reg_UPDATE_PREDICTION_TABLE [context][depth]._state = UPDATE_PREDICTION_STATE_END_KO_WAIT_END;
+
                           log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT  [%d][%d].state <- UPDATE_PREDICTION_STATE_END_KO (update)",context,depth);
                           
@@ -535,5 +556,5 @@
                       
                       // Free the branch with no accurate ?
-                      if (reg_UPDATE_PREDICTION_TABLE [context][depth]._is_accurate == false)
+                      if ( (reg_UPDATE_PREDICTION_TABLE [context][depth]._is_accurate == false) and not ko)
                         reg_IS_ACCURATE [context] = true;
                     }
@@ -587,5 +608,6 @@
 //            Tdepth_t       depth       = PORT_READ(in_EVENT_DEPTH [i]);
             
-              // Test if end of miss
+              // Test if end of miss -> all previous branch is complete
+              //                     -> all next     branch is finish
               if (event_type  == EVENT_TYPE_MISS_SPECULATION)
                 {
@@ -602,4 +624,19 @@
                   
                   reg_EVENT_STATE [i] = EVENT_STATE_OK;
+                  reg_IS_ACCURATE [i] = true;
+
+//                   Tdepth_t depth = reg_UPT_TOP [i];
+
+#ifdef DEBUG_TEST
+//                   if (reg_UPDATE_PREDICTION_TABLE [i][depth]._state != UPDATE_PREDICTION_STATE_END_KO_WAIT_END)
+//                     throw ERRORMORPHEO(FUNCTION,_("Event : invalid upt event state."));
+//                   if (reg_UPDATE_PREDICTION_TABLE [i][depth]._state != UPDATE_PREDICTION_STATE_END_KO)
+//                     throw ERRORMORPHEO(FUNCTION,_("Event : invalid upt event state."));
+#endif
+                  
+//                   log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT  [%d][%d].state <- UPDATE_PREDICTION_STATE_END_KO (update)",i,depth);
+                          
+//                   reg_UPDATE_PREDICTION_TABLE [i][depth]._state = UPDATE_PREDICTION_STATE_END_KO;
+
                 }
             }
@@ -699,4 +736,5 @@
 	log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * reg_UPT_TOP_EVENT       : %d",reg_UPT_TOP_EVENT      [i]);
 	log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * reg_UPT_UPDATE          : %d",reg_UPT_UPDATE         [i]);
+	log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * reg_UPT_EMPTY           : %d",reg_UPT_EMPTY          [i]);
 	for (uint32_t j=0; j<_param->_size_upt_queue[i]; j++)
 	  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"        [%d] %.4d, %.8x %.8x, %.1d %.1d %.1d, %.8d %.8x %.4d - %s",
