Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_allocation.cpp
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_allocation.cpp	(revision 105)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_allocation.cpp	(revision 106)
@@ -197,4 +197,5 @@
     ALLOC1(reg_UFPT_UPDATE                  ,uint32_t     ,_param->_nb_context);
     ALLOC1(reg_UFPT_NB_NEED_UPDATE          ,uint32_t     ,_param->_nb_context);
+    ALLOC1(reg_UFPT_NB_UPDATE               ,uint32_t     ,_param->_nb_context);
                                                           
     ALLOC2(reg_UPDATE_PREDICTION_TABLE      ,upt_entry_t  ,_param->_nb_context,_param->_size_upt_queue[it1]);
Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_deallocation.cpp
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_deallocation.cpp	(revision 105)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_deallocation.cpp	(revision 106)
@@ -150,4 +150,5 @@
         DELETE1(reg_UFPT_UPDATE                  ,_param->_nb_context);
         DELETE1(reg_UFPT_NB_NEED_UPDATE          ,_param->_nb_context);
+        DELETE1(reg_UFPT_NB_UPDATE               ,_param->_nb_context);
         
         DELETE2(reg_UPDATE_PREDICTION_TABLE      ,_param->_nb_context,_param->_size_upt_queue[it1]);
Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_genMoore.cpp
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_genMoore.cpp	(revision 105)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_genMoore.cpp	(revision 106)
@@ -61,5 +61,5 @@
     bool     retire_ras_from_ufpt [_param->_nb_context]; // event ufpt -> restore RAS, else update upt
     bool     retire_ras_from_upt  [_param->_nb_context]; // event upt  -> restore RAS, else restore others structure
-//     bool     have_event           [_param->_nb_context];
+//  bool     have_event           [_param->_nb_context];
     bool     ufpt_update          [_param->_nb_context];
     bool     upt_update           [_param->_nb_context];
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 105)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_transition.cpp	(revision 106)
@@ -39,4 +39,5 @@
             reg_UFPT_UPDATE          [i] = 0;
             reg_UFPT_NB_NEED_UPDATE  [i] = 0;
+            reg_UFPT_NB_UPDATE       [i] = 0;
                                                                 
             for (uint32_t j=0; j<_param->_size_upt_queue[i]; ++j)
@@ -92,17 +93,15 @@
             {
               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);
+              bool          end         = (reg_UPDATE_PREDICTION_TABLE [i][bottom]._state == UPDATE_PREDICTION_STATE_END);
+//               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)
+//               if (end_ok or end_ko)
+              if (end)
                 {
                   log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT [%d][%d]",i,bottom);
                   log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT [%d][%d]._state =  UPDATE_PREDICTION_STATE_EMPTY",i,bottom);
-
                   // Free slot
                   reg_UPDATE_PREDICTION_TABLE [i][bottom]._state = UPDATE_PREDICTION_STATE_EMPTY;
@@ -110,5 +109,5 @@
                   // 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
@@ -118,5 +117,4 @@
 
                   if (reg_EVENT_VAL [i] and (reg_EVENT_UPT_PTR [i] == bottom))
-//                   if (end_ko) // free
                     {
                       log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * END EVENT");
@@ -129,7 +127,9 @@
                         reg_UPT_EMPTY [i] = false;
                     }
+
                 }
             }
 	  }
+
         log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * GARBAGE COLLECTOR (END)");
 
@@ -450,5 +450,6 @@
                       // if free a slot, also all queue is updated
                       // Last slot ?
-                      if (reg_UFPT_UPDATE [context] == reg_UFPT_BOTTOM [context])
+//                       if (reg_UFPT_UPDATE [context] == reg_UFPT_BOTTOM [context])
+                      if ((--reg_UFPT_NB_UPDATE [context])==0)
                         switch (reg_EVENT_STATE [context])
                           {
@@ -472,6 +473,5 @@
                       
                       reg_UPDATE_FETCH_PREDICTION_TABLE [context][depth]._state = UPDATE_FETCH_PREDICTION_STATE_END;
-                      
-                      
+                                            
                       // Update pointer
                       log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_UFPT_UPDATE (before) : %d",reg_UFPT_UPDATE [context]);
@@ -531,8 +531,9 @@
                       else
                         {
-                          log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT  [%d][%d].state <- UPDATE_PREDICTION_STATE_END_OK (update)",context,depth);
-                          
-                          reg_UPDATE_PREDICTION_TABLE [context][depth]._state = UPDATE_PREDICTION_STATE_END_OK;
-
+//                           log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT  [%d][%d].state <- UPDATE_PREDICTION_STATE_END_OK (update)",context,depth);
+//                           reg_UPDATE_PREDICTION_TABLE [context][depth]._state = UPDATE_PREDICTION_STATE_END_OK;
+
+                          log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT  [%d][%d].state <- UPDATE_PREDICTION_STATE_END (update)",context,depth);
+                          reg_UPDATE_PREDICTION_TABLE [context][depth]._state = UPDATE_PREDICTION_STATE_END;
 
 #ifdef STATISTICS
@@ -650,18 +651,25 @@
                     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."));
+
+                    Tdepth_t depth = reg_EVENT_UPT_PTR [i];
+
+                    if (reg_UPDATE_PREDICTION_TABLE [i][depth]._state == UPDATE_PREDICTION_STATE_END_KO)
+                      {
+                        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT  [%d][%d].state <- UPDATE_PREDICTION_STATE_END (event)",i,depth);
+                        
+                        reg_UPDATE_PREDICTION_TABLE [i][depth]._state = UPDATE_PREDICTION_STATE_END;
+                      }
+
+#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;
-
+
+//                     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;
+                    
                     break;
                   }
@@ -685,19 +693,19 @@
                     log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * new_update : %d",new_update);
 
-                    
-#ifdef DEBUG_TEST
-                    if (reg_UPDATE_PREDICTION_TABLE [i][depth]._state != UPDATE_PREDICTION_STATE_WAIT_END)
-                      throw ERRORMORPHEO(FUNCTION,_("Branch complete : invalid upt state."));
-#endif
-
-                    // flush all slot after the event
-                    for (uint32_t j=depth;
-                         j!=top; 
-                         j=(j+1)%_param->_size_upt_queue[i])
-                      reg_UPDATE_PREDICTION_TABLE [i][j]._state = UPDATE_PREDICTION_STATE_EVENT;
-                      
-                    // test full :
-                    if (full)
-                      reg_UPDATE_PREDICTION_TABLE [i][depth]._state = UPDATE_PREDICTION_STATE_EVENT;
+                    // Test empty
+                    if (not reg_UPT_EMPTY [i])
+                      {
+#ifdef DEBUG_TEST
+                        if (reg_UPDATE_PREDICTION_TABLE [i][depth]._state != UPDATE_PREDICTION_STATE_WAIT_END)
+                          throw ERRORMORPHEO(FUNCTION,_("Branch complete : invalid upt state."));
+#endif
+                        reg_UPDATE_PREDICTION_TABLE [i][depth]._state = UPDATE_PREDICTION_STATE_EVENT;
+
+                        // flush all slot after the event
+                        for (uint32_t j=(depth+1)%_param->_size_upt_queue[i];
+                             j!=top; 
+                             j=(j+1)%_param->_size_upt_queue[i])
+                          reg_UPDATE_PREDICTION_TABLE [i][j]._state = UPDATE_PREDICTION_STATE_EVENT;
+                      }
               
 //                  reg_UPT_BOTTOM    [i];
@@ -802,12 +810,15 @@
                 {
                   for (uint32_t j=0; j<_param->_size_ufpt_queue[i]; ++j)
-                    reg_UPDATE_FETCH_PREDICTION_TABLE [i][j]._state = UPDATE_FETCH_PREDICTION_STATE_EVENT;
-                  
+                    {
+                      reg_UFPT_NB_UPDATE [i] ++;
+                      reg_UPDATE_FETCH_PREDICTION_TABLE [i][j]._state = UPDATE_FETCH_PREDICTION_STATE_EVENT;
+                    }
+
                   // TOP is next write slot : last slot is TOP-1
                   uint32_t top = reg_UFPT_TOP [i];
-                  reg_UFPT_UPDATE [i] = ((top==0)?_param->_size_ufpt_queue[i]:top)-1;
-                  
-//                reg_UFPT_BOTTOM [i];
-//                reg_UFPT_TOP    [i];
+                  reg_UFPT_UPDATE    [i] = ((top==0)?_param->_size_ufpt_queue[i]:top)-1;
+
+//                reg_UFPT_BOTTOM    [i];
+//                reg_UFPT_TOP       [i];
                 }
 
@@ -853,4 +864,5 @@
 	log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * reg_UFPT_UPDATE         : %d",reg_UFPT_UPDATE         [i]);
 	log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * reg_UFPT_NB_NEED_UPDATE : %d",reg_UFPT_NB_NEED_UPDATE [i]);
+	log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * reg_UFPT_NB_UPDATE      : %d",reg_UFPT_NB_UPDATE      [i]);
 	for (uint32_t j=0; j<_param->_size_ufpt_queue[i]; j++)
 	  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"        [%d] %.4d, %.8x %.8x, %.1d   %.1d, %.8d %.8x %.4d - %s",
