Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/SelfTest/src/test.cpp
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/SelfTest/src/test.cpp	(revision 101)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/SelfTest/src/test.cpp	(revision 105)
@@ -266,4 +266,5 @@
   const  int32_t percent_transaction_update          = 75;
   const  int32_t percent_transaction_branch_event    = 75;
+  const  int32_t percent_transaction_event           = 75;
 
   const bool     test1 = true;
@@ -271,4 +272,5 @@
   const bool     test3 = true;
   const bool     test4 = true;
+  const bool     test5 = true;
 
   std::list<request_t> ufpt;
@@ -961,5 +963,5 @@
           SC_START(1);
           in_EVENT_VAL   [context]->write(1);
-          in_EVENT_TYPE  [context]->write(EVENT_TYPE_MISS_SPECULATION);
+          in_EVENT_TYPE  [context]->write(EVENT_TYPE_BRANCH_MISS_SPECULATION);
 
           SC_START(1);
@@ -1407,5 +1409,5 @@
           SC_START(1);
           in_EVENT_VAL   [context]->write(1);
-          in_EVENT_TYPE  [context]->write(EVENT_TYPE_MISS_SPECULATION);
+          in_EVENT_TYPE  [context]->write(EVENT_TYPE_BRANCH_MISS_SPECULATION);
 
           SC_START(1);
@@ -2036,5 +2038,5 @@
             SC_START(1);
             in_EVENT_VAL   [context]->write(1);
-            in_EVENT_TYPE  [context]->write(EVENT_TYPE_MISS_SPECULATION);
+            in_EVENT_TYPE  [context]->write(EVENT_TYPE_BRANCH_MISS_SPECULATION);
             
             SC_START(1);
@@ -2128,4 +2130,662 @@
               }
             
+          }
+        }
+
+      //---------------------------------------------------------------------
+      //---------------------------------------------------------------------
+      // COMMIT MISS : with RAS in UPFT and UPT
+      //---------------------------------------------------------------------
+      //---------------------------------------------------------------------
+      if (test5)
+        {
+          uint32_t context = rand() % _param->_nb_context;
+          uint32_t have_ufpt_ras = false;
+          uint32_t have_upt_ras  = false;
+          
+          {
+            LABEL("PREDICT - fill the queue");
+            uint32_t port = rand() % _param->_nb_inst_predict;
+            
+            LABEL("  * context : %d",context);
+            LABEL("  * port    : %d",port);
+            
+            for (uint32_t i=0; i<_param->_size_ufpt_queue[context]; i++)
+              {
+                request_t request;
+                request.context          = context;
+                request.address_src      = rand();
+                request.address_dest     = rand();                                   
+                
+                request.condition        = (rand()%2)?BRANCH_CONDITION_READ_STACK:BRANCH_CONDITION_FLAG_SET;
+
+                request.take             = 1;                                              
+                request.take_good        = 1;                                              
+                request.flag             = (request.condition == BRANCH_CONDITION_FLAG_SET)?request.take_good:(not request.take_good);
+                request.no_sequence      = (request.condition == BRANCH_CONDITION_FLAG_SET)?request.flag:not request.flag;
+                request.is_accurate      = true ;
+                request.miss_ifetch      = false;
+                request.miss_decod       = false;
+                request.miss_commit      = false;
+                request.history          = i;                                              
+                request.ras_address      = rand();                                   
+                request.ras_index        = rand()%_param->_size_ras_index[context];
+                request.ufpt_ptr         = ufpt_top [context];
+//              request.upt_ptr;
+                
+                bool have_transaction = false;
+                do
+                  {
+                    in_PREDICT_VAL              [port]->write((rand()%100)<percent_transaction_predict);
+                    in_PREDICT_CONTEXT_ID       [port]->write(request.context     );
+                    in_PREDICT_BTB_ADDRESS_SRC  [port]->write(request.address_src );
+                    in_PREDICT_BTB_ADDRESS_DEST [port]->write(request.address_dest);
+                    in_PREDICT_BTB_CONDITION    [port]->write(request.condition   );
+                    in_PREDICT_BTB_LAST_TAKE    [port]->write(request.take        );
+                    in_PREDICT_BTB_IS_ACCURATE  [port]->write(request.is_accurate );
+                    in_PREDICT_DIR_HISTORY      [port]->write(request.history     );
+                    in_PREDICT_RAS_ADDRESS      [port]->write(request.ras_address );
+                    in_PREDICT_RAS_INDEX        [port]->write(request.ras_index   );
+                    
+                    if (_param->_have_port_depth)
+                      {
+                    TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
+                    TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
+                      }
+                    SC_START(0); // fct melay
+                    
+                    LABEL("PREDICT         [%d] %d - %d (accurate : %d).",
+                          port,
+                          in_PREDICT_VAL [port]->read(),
+                          out_PREDICT_ACK [port]->read(),
+                          in_PREDICT_BTB_IS_ACCURATE [port]->read());
+                    
+                    if (in_PREDICT_VAL [port]->read() and out_PREDICT_ACK [port]->read())
+                      {
+                        LABEL("PREDICT         [%d] - Transaction accepted",port);
+                        have_transaction = true;
+                        
+                        if (_param->_have_port_depth)
+                          TEST(Tprediction_ptr_t,out_PREDICT_UPDATE_PREDICTION_ID [port]->read(),ufpt_top [context]);
+                        
+                        ufpt_top [context] = (ufpt_top [context]+1)%_param->_size_ufpt_queue[context];
+                      }
+                    
+                    SC_START(1); // transition
+                    
+                  } while (not have_transaction);
+                
+                ufpt.push_back(request); // to update
+                
+                in_PREDICT_VAL [port]->write(0);
+                
+                if (_param->_have_port_depth)
+                  {
+                TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
+                TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
+                  }
+              }
+          }
+	
+          {
+            LABEL("DECOD");
+            uint32_t port = rand() % _param->_nb_inst_decod;
+            
+            LABEL("  * context : %d",context);
+            LABEL("  * port    : %d",port);
+            
+            for (uint32_t i=0; i<_param->_size_ufpt_queue[context]; i++)
+              {
+                request_t request = ufpt.front();
+                
+                bool have_transaction = false;
+                do
+                  {
+                    in_DECOD_VAL                  [port]->write((rand()%100)<percent_transaction_decod);
+                    in_DECOD_CONTEXT_ID           [port]->write(request.context     );
+                    in_DECOD_BTB_ADDRESS_SRC      [port]->write(request.address_src );
+                    in_DECOD_BTB_ADDRESS_DEST     [port]->write(request.address_dest);
+                    in_DECOD_BTB_CONDITION        [port]->write(request.condition   );
+                    in_DECOD_BTB_LAST_TAKE        [port]->write(request.take        );
+                    in_DECOD_RAS_ADDRESS          [port]->write(request.ras_address );
+                    in_DECOD_RAS_INDEX            [port]->write(request.ras_index   );
+                    in_DECOD_UPDATE_PREDICTION_ID [port]->write(request.ufpt_ptr    );
+                    in_DECOD_MISS_IFETCH          [port]->write(request.miss_ifetch );
+                    in_DECOD_MISS_DECOD           [port]->write(request.miss_decod  );
+                    in_DECOD_IS_ACCURATE          [port]->write(request.is_accurate );
+          
+                    have_upt_ras |= (update_ras(request.condition));
+          
+                    SC_START(0); // fct melay
+                    
+                    LABEL("DECOD           [%d] %d - %d",
+                          port,
+                          in_DECOD_VAL [port]->read(),
+                          out_DECOD_ACK [port]->read());
+                    
+                    if (in_DECOD_VAL [port]->read() and out_DECOD_ACK [port]->read())
+                      {
+                        LABEL("DECOD          [%d] - Transaction accepted",port);
+                        have_transaction = true;
+                        
+                        request.upt_ptr = upt_top [context];
+                        upt.push_back(request);
+                        ufpt.pop_front();
+                        
+                        upt_top [context] = (upt_top [context]+1)%_param->_size_upt_queue[context];
+                      }
+                    
+                    SC_START(1); // transition
+                    
+                  } while (not have_transaction);
+                
+                in_DECOD_VAL              [port]->write(0);
+                
+                if (_param->_have_port_depth)
+                  {
+                TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
+                TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
+                  }
+              }
+          }
+
+          {
+            LABEL("PREDICT - fill the queue");
+            uint32_t port = rand() % _param->_nb_inst_predict;
+            
+            LABEL("  * context : %d",context);
+            LABEL("  * port    : %d",port);
+            
+            for (uint32_t i=0; i<_param->_size_ufpt_queue[context]; i++)
+              {
+                request_t request;
+                request.context          = context;
+                request.address_src      = rand();
+                request.address_dest     = rand();                                   
+                request.address_good     = request.address_dest;
+                request.condition        = (rand()%2)?BRANCH_CONDITION_NONE_WITH_WRITE_STACK:BRANCH_CONDITION_FLAG_SET;
+                
+                have_ufpt_ras |= (update_ras(request.condition));
+                
+                request.take             = 1;                                              
+                request.take_good        = 1;                                              
+                request.flag             = (request.condition == BRANCH_CONDITION_FLAG_SET)?request.take_good:(not request.take_good);
+                request.no_sequence      = (request.condition == BRANCH_CONDITION_FLAG_SET)?request.flag:not request.flag;
+                request.is_accurate      = true ;
+                request.miss_ifetch      = false;
+                request.miss_decod       = false;
+                request.miss_commit      = true;
+                request.history          = i;                                              
+                request.ras_address      = rand();                                   
+                request.ras_index        = rand()%_param->_size_ras_index[context];
+                request.ufpt_ptr         = ufpt_top [context];
+//              request.upt_ptr;
+                
+                bool have_transaction = false;
+                do
+                  {
+                    in_PREDICT_VAL              [port]->write((rand()%100)<percent_transaction_predict);
+                    in_PREDICT_CONTEXT_ID       [port]->write(request.context     );
+                    in_PREDICT_BTB_ADDRESS_SRC  [port]->write(request.address_src );
+                    in_PREDICT_BTB_ADDRESS_DEST [port]->write(request.address_dest);
+                    in_PREDICT_BTB_CONDITION    [port]->write(request.condition   );
+                    in_PREDICT_BTB_LAST_TAKE    [port]->write(request.take        );
+                    in_PREDICT_BTB_IS_ACCURATE  [port]->write(request.is_accurate );
+                    in_PREDICT_DIR_HISTORY      [port]->write(request.history     );
+                    in_PREDICT_RAS_ADDRESS      [port]->write(request.ras_address );
+                    in_PREDICT_RAS_INDEX        [port]->write(request.ras_index   );
+                    
+                    if (_param->_have_port_depth)
+                      {
+                    TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
+                    TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
+                      }
+                    SC_START(0); // fct melay
+                    
+                    LABEL("PREDICT         [%d] %d - %d (accurate : %d).",
+                          port,
+                          in_PREDICT_VAL [port]->read(),
+                          out_PREDICT_ACK [port]->read(),
+                          in_PREDICT_BTB_IS_ACCURATE [port]->read());
+                    
+                    if (in_PREDICT_VAL [port]->read() and out_PREDICT_ACK [port]->read())
+                      {
+                        LABEL("PREDICT         [%d] - Transaction accepted",port);
+                        have_transaction = true;
+                        
+                        if (_param->_have_port_depth)
+                          TEST(Tprediction_ptr_t,out_PREDICT_UPDATE_PREDICTION_ID [port]->read(),ufpt_top [context]);
+                        
+                        ufpt_top [context] = (ufpt_top [context]+1)%_param->_size_ufpt_queue[context];
+                      }
+                    
+                    SC_START(1); // transition
+                    
+                  } while (not have_transaction);
+                
+                ufpt.push_back(request); // to update
+                
+                in_PREDICT_VAL [port]->write(0);
+                
+                if (_param->_have_port_depth)
+                  {
+                TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
+                TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
+                  }
+              }
+          }
+
+          uint32_t nb_branch_before_event = 0;
+          {
+            // middle
+            std::list<request_t>::iterator it_event = upt.begin();
+            for (uint32_t i=0; i < (upt.size()>>1); ++i)
+              {
+                nb_branch_before_event ++;
+                it_event ++;
+              }
+            for (std::list<request_t>::iterator it = it_event; it != upt.end(); ++it)
+              it->miss_commit = true;
+
+            bool have_transaction = false;
+            
+            do
+              {
+                PORT_WRITE(in_EVENT_VAL   [context],(rand()%100)<percent_transaction_event);
+                PORT_WRITE(in_EVENT_TYPE  [context],EVENT_TYPE_LOAD_MISS_SPECULATION);
+                PORT_WRITE(in_EVENT_DEPTH [context],it_event->upt_ptr);
+                
+                SC_START(0);
+                
+                if (PORT_READ(in_EVENT_VAL [context]) and PORT_READ(out_EVENT_ACK [context]))
+                  {
+                    LABEL("EVENT [%d] - Transaction accepted",context);
+                    
+                    have_transaction = true;
+                  }
+                
+                SC_START(1);
+              }
+            while (not have_transaction);
+            PORT_WRITE(in_EVENT_VAL   [context],0);
+
+            upt_top_event [it_event->context] = upt_top [it_event->context];
+            upt_top       [it_event->context] = it_event->upt_ptr;
+          }
+          
+          {
+            LABEL("BRANCH_COMPLETE - Hit ifetch");
+            
+            uint32_t port = rand() % _param->_nb_inst_branch_complete;
+            
+            LABEL("  * port    : %d",port);
+            
+            std::list<request_t>::iterator it_upt = upt.begin();
+            
+            for (uint32_t i=0; i<nb_branch_before_event; ++i)
+              {
+	      bool have_transaction = false;
+              
+	      do
+		{
+		  in_BRANCH_COMPLETE_VAL        [port]->write((rand()%100)<percent_transaction_branch_complete);
+		  in_BRANCH_COMPLETE_CONTEXT_ID [port]->write(it_upt->context     );
+		  in_BRANCH_COMPLETE_DEPTH      [port]->write(it_upt->upt_ptr     );
+		  in_BRANCH_COMPLETE_ADDRESS    [port]->write(it_upt->address_dest);
+		  in_BRANCH_COMPLETE_NO_SEQUENCE[port]->write(it_upt->no_sequence );
+
+                  if (_param->_have_port_depth)
+                    {
+                  TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
+                  TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
+                    }
+		  SC_START(0);
+		  
+		  LABEL("BRANCH_COMPLETE [%d] %d - %d.",port,in_BRANCH_COMPLETE_VAL [port]->read(),out_BRANCH_COMPLETE_ACK [port]->read());
+		  
+		  if (in_BRANCH_COMPLETE_VAL [port]->read() and out_BRANCH_COMPLETE_ACK [port]->read())
+		    {
+		      LABEL("BRANCH_COMPLETE [%d] - Transaction accepted",port);
+                      LABEL("  * CONTEXT_ID  : %d"  ,it_upt->context     );
+                      LABEL("  * DEPTH       : %d"  ,it_upt->upt_ptr     );
+                      LABEL("  * CONDITION   : %d"  ,it_upt->condition   );
+                      LABEL("  * ADDRESS     : %.8x",it_upt->address_dest);
+                      LABEL("  * FLAG        : %d"  ,it_upt->flag        );
+                      LABEL("  * NO_SEQUENCE : %d"  ,it_upt->no_sequence );
+
+		      have_transaction = true;
+		      
+		      TEST(Tcontrol_t,out_BRANCH_COMPLETE_MISS_PREDICTION[port]->read(),it_upt->miss_commit );
+		      TEST(Tcontrol_t,out_BRANCH_COMPLETE_TAKE           [port]->read(),it_upt->take        );
+                      it_upt->take_good = it_upt->take;
+		      TEST(Taddress_t,out_BRANCH_COMPLETE_ADDRESS_SRC    [port]->read(),it_upt->address_src );
+		      TEST(Taddress_t,out_BRANCH_COMPLETE_ADDRESS_DEST   [port]->read(),it_upt->address_dest);
+
+                      it_upt++;
+		    }
+		  
+		  SC_START(1);
+                  
+		} while (not have_transaction);
+              
+	      in_BRANCH_COMPLETE_VAL [port]->write(0);
+	      
+              if (_param->_have_port_depth)
+                {
+              TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
+              TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
+                }
+            }
+          }
+          
+          if (have_ufpt_ras)
+            {
+              LABEL("UPDATE - Update UPFT");
+              
+              uint32_t port = 0;
+              
+              LABEL("  * port    : %d",port);
+              std::list<request_t>::iterator it_ufpt = ufpt.end();
+              -- it_ufpt;
+              
+              for (uint32_t i=0; i<_param->_size_ufpt_queue[context]; i++)
+                {
+                  bool have_transaction = false;
+                  
+                  do
+                    {
+                      in_UPDATE_ACK [port]->write((rand()%100)<percent_transaction_update);
+                      
+//                    if (_param->_have_port_depth)
+//                    TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), ufpt_bottom [context]);
+//                    TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), ufpt_top [context]);
+		  
+                      SC_START(0);
+                      
+                      LABEL("UPDATE [%d] %d - %d.",port,out_UPDATE_VAL [port]->read(),in_UPDATE_ACK [port]->read());
+                      
+                      if (out_UPDATE_VAL [port]->read() and in_UPDATE_ACK [port]->read())
+                        {
+                          LABEL("UPDATE [%d] - Transaction accepted",port);
+                          have_transaction = true;
+                          
+                          if (_param->_have_port_context_id)
+                          TEST(Tcontext_t         ,out_UPDATE_CONTEXT_ID            [port]->read(),it_ufpt->context);
+                          TEST(Tcontrol_t         ,out_UPDATE_MISS_PREDICTION       [port]->read(),(it_ufpt->miss_ifetch or
+                                                                                                    it_ufpt->miss_decod  or
+                                                                                                    it_ufpt->miss_commit ));
+//                        if (update_btb(it_ufpt->condition) or
+//                            update_dir(it_ufpt->condition))
+//                        TEST(Tcontrol_t         ,out_UPDATE_DIRECTION_GOOD        [port]->read(),it_ufpt->take_good);
+                          TEST(Tcontrol_t         ,out_UPDATE_BTB_VAL               [port]->read(),0);
+//                        if (update_btb(it_ufpt->condition))
+//                          {
+//                        TEST(Taddress_t         ,out_UPDATE_BTB_ADDRESS_SRC       [port]->read(),it_ufpt->address_src);
+//                        TEST(Taddress_t         ,out_UPDATE_BTB_ADDRESS_DEST      [port]->read(),it_ufpt->address_dest);
+//                        TEST(Tbranch_condition_t,out_UPDATE_BTB_CONDITION         [port]->read(),it_ufpt->condition);
+//                          }
+                          TEST(Tcontrol_t         ,out_UPDATE_DIR_VAL               [port]->read(),0);
+
+//                        if (update_dir(it_ufpt->condition))
+//                        if (_param->_have_port_history)
+//                        TEST(Thistory_t         ,out_UPDATE_DIR_HISTORY           [port]->read(),it_ufpt->history);
+//                        TEST(Tcontrol_t         ,out_UPDATE_RAS_VAL               [port]->read(),update_ras(it_ufpt->condition));
+                          if (update_ras(it_ufpt->condition))
+                            {
+//                            TEST(Tcontrol_t         ,out_UPDATE_RAS_FLUSH             [port]->read(),0);
+                              TEST(Tcontrol_t         ,out_UPDATE_RAS_PUSH              [port]->read(),push_ras  (it_ufpt->condition));
+                              TEST(Taddress_t         ,out_UPDATE_RAS_ADDRESS           [port]->read(),it_ufpt->ras_address);
+                              TEST(Tptr_t             ,out_UPDATE_RAS_INDEX             [port]->read(),it_ufpt->ras_index);
+                              TEST(Tcontrol_t         ,out_UPDATE_RAS_PREDICTION_IFETCH [port]->read(),not it_ufpt->miss_ifetch);
+                            }
+                        }
+                      
+                      SC_START(1);
+                    } while (not have_transaction);
+                  
+                  -- it_ufpt;
+                  
+                  
+                  in_UPDATE_ACK [port]->write(0);
+//                if (_param->_have_port_depth)
+//                TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), ufpt_bottom [context]);
+//                TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), ufpt_top [context]);
+                }
+            }
+          ufpt.clear();
+
+          {
+            LABEL("UPDATE - upt (after event)");
+            
+            uint32_t port = 0;
+            
+            LABEL("  * port                   : %d",port);
+
+            std::list<request_t>::iterator it_upt = upt.end();
+
+//             for (uint32_t i=0; i<upt.size(); i++)
+
+            uint32_t size = upt.size();
+
+            LABEL("  * size                   : %d",size);
+            LABEL("  * nb_branch_before_event : %d",nb_branch_before_event);
+
+            for (uint32_t i=nb_branch_before_event; i<size; ++i)
+              {
+                --it_upt;
+                
+                bool have_transaction = false;
+                
+                if (need_update(it_upt->condition))
+                do
+                  {
+                    in_UPDATE_ACK [port]->write((rand()%100)<percent_transaction_update);
+
+//                   if (_param->_have_port_depth)
+//                   TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
+//                   TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
+		  
+                    SC_START(0);
+                    
+                    LABEL("UPDATE [%d] %d - %d.",port,out_UPDATE_VAL [port]->read(),in_UPDATE_ACK [port]->read());
+                    
+                    if (out_UPDATE_VAL [port]->read() and in_UPDATE_ACK [port]->read())
+                      {
+                        LABEL("UPDATE [%d] - Transaction accepted",port);
+                        LABEL("  * address_src                : %.8x",it_upt->address_src);
+                        LABEL("  * out_UPDATE_BTB_ADDRESS_SRC : %.8x",out_UPDATE_BTB_ADDRESS_SRC[port]->read());
+
+                        have_transaction = true;
+
+                        bool btb_val = ((update_btb(it_upt->condition)));
+                        bool dir_val = (update_dir(it_upt->condition) and 
+                                        not (it_upt->miss_ifetch or it_upt->miss_decod));
+                        bool ras_val = update_ras(it_upt->condition);
+
+                        if (_param->_have_port_context_id)
+                        TEST(Tcontext_t         ,out_UPDATE_CONTEXT_ID            [port]->read(),it_upt->context);
+                        TEST(Tcontrol_t         ,out_UPDATE_MISS_PREDICTION       [port]->read(),it_upt->miss_commit);
+//                         TEST(Tcontrol_t         ,out_UPDATE_BTB_VAL               [port]->read(),btb_val);
+
+//                         if (btb_val)
+//                           {
+//                         TEST(Taddress_t         ,out_UPDATE_BTB_ADDRESS_SRC       [port]->read(),it_upt->address_src);
+//                         TEST(Taddress_t         ,out_UPDATE_BTB_ADDRESS_DEST      [port]->read(),it_upt->address_dest);
+//                         TEST(Tbranch_condition_t,out_UPDATE_BTB_CONDITION         [port]->read(),it_upt->condition);
+//                           }
+//                         TEST(Tcontrol_t         ,out_UPDATE_DIR_VAL               [port]->read(),dir_val);
+                        
+//                         if (dir_val)
+//                           {
+//                         TEST(Tcontrol_t         ,out_UPDATE_DIRECTION_GOOD        [port]->read(),it_upt->take_good);
+//                         if (_param->_have_port_history)
+//                         TEST(Thistory_t         ,out_UPDATE_DIR_HISTORY           [port]->read(),it_upt->history);
+//                           }
+                        TEST(Tcontrol_t         ,out_UPDATE_RAS_VAL               [port]->read(),ras_val);
+
+                        if (ras_val)
+                          {
+//                      TEST(Tcontrol_t         ,out_UPDATE_RAS_FLUSH             [port]->read(),0);
+                        TEST(Tcontrol_t         ,out_UPDATE_RAS_PUSH              [port]->read(),push_ras  (it_upt->condition));
+                        TEST(Taddress_t         ,out_UPDATE_RAS_ADDRESS           [port]->read(),it_upt->ras_address);
+                        TEST(Tptr_t             ,out_UPDATE_RAS_INDEX             [port]->read(),it_upt->ras_index);
+                        TEST(Tcontrol_t         ,out_UPDATE_RAS_PREDICTION_IFETCH [port]->read(),not it_upt->miss_ifetch);
+                          }
+//                         -- it_upt;
+                      }
+                    
+                    SC_START(1);
+                  } while (not have_transaction);
+              
+                upt.pop_back();
+                in_UPDATE_ACK [port]->write(0);
+//               if (_param->_have_port_depth)
+//               TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
+//               TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
+              }
+          }
+
+          /*
+          {
+            LABEL("BRANCH_EVENT - have miss decod");
+            
+            uint32_t port = context;
+            
+            {
+              bool have_transaction = false;
+              
+              do
+                {
+                  in_BRANCH_EVENT_ACK [port]->write((rand()%100)<percent_transaction_branch_event);
+                  
+                  SC_START(0);
+                  
+                  LABEL("BRANCH_EVENT [%d] %d - %d.",port,out_BRANCH_EVENT_VAL [port]->read(),in_BRANCH_EVENT_ACK [port]->read());
+                  
+                  if (out_BRANCH_EVENT_VAL [port]->read() and in_BRANCH_EVENT_ACK [port]->read())
+                    {
+                      LABEL("BRANCH_EVENT [%d] - Transaction accepted",port);
+                      have_transaction = true;
+                      
+                      LABEL("  * event.address_src  : %.8x,",event.address_src );
+                      LABEL("  * event.address_good : %.8x,",event.address_good);
+                      LABEL("  * event.take         : %.8x,",event.take        );
+                      
+                      TEST(Tdepth_t  ,out_BRANCH_EVENT_DEPTH            [port]->read(),event.upt_ptr);
+                      TEST(Taddress_t,out_BRANCH_EVENT_ADDRESS_SRC      [port]->read(),event.address_src);
+                      TEST(Tcontrol_t,out_BRANCH_EVENT_ADDRESS_DEST_VAL [port]->read(),event.take_good);
+                      if (event.take_good)
+                      TEST(Taddress_t,out_BRANCH_EVENT_ADDRESS_DEST     [port]->read(),event.address_good);
+                      
+                      event.address_src  = 0;
+                      event.take         = 0;
+                      event.address_dest = 0;
+                    }
+                  
+                  SC_START(1);
+                } while (not have_transaction);
+              
+	      in_BRANCH_EVENT_ACK [port]->write(0);
+            }
+          }
+
+          {
+            LABEL("EVENT_STATE");
+            
+            SC_START(1);
+            in_EVENT_VAL   [context]->write(1);
+            in_EVENT_TYPE  [context]->write(EVENT_TYPE_BRANCH_MISS_SPECULATION);
+            
+            SC_START(1);
+            in_EVENT_VAL   [context]->write(0);
+            in_EVENT_TYPE  [context]->write(EVENT_TYPE_NONE            );
+          }
+          */
+
+          {
+            LABEL("UPDATE - upt (before event)");
+            
+            uint32_t port = 0;
+            
+            LABEL("  * port    : %d",port);
+            LABEL("  * size    : %d",upt.size());
+            std::list<request_t>::iterator it_upt = upt.begin();
+
+            for (uint32_t i=0; i<upt.size(); i++)
+              {
+                bool have_transaction = false;
+
+                do
+                  {
+                    in_UPDATE_ACK [port]->write((rand()%100)<percent_transaction_update);
+
+//                   if (_param->_have_port_depth)
+//                   TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
+//                   TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
+		  
+                    SC_START(0);
+                    
+                    LABEL("UPDATE [%d] %d - %d.",port,out_UPDATE_VAL [port]->read(),in_UPDATE_ACK [port]->read());
+                    
+                    if (out_UPDATE_VAL [port]->read() and in_UPDATE_ACK [port]->read())
+                      {
+                        LABEL("UPDATE [%d] - Transaction accepted",port);
+                        have_transaction = true;
+                        
+                        if (_param->_have_port_context_id)
+                        TEST(Tcontext_t         ,out_UPDATE_CONTEXT_ID            [port]->read(),it_upt->context);
+                        TEST(Tcontrol_t         ,out_UPDATE_MISS_PREDICTION       [port]->read(),it_upt->miss_commit);
+                        TEST(Tcontrol_t         ,out_UPDATE_DIRECTION_GOOD        [port]->read(),it_upt->take_good);
+                        TEST(Tcontrol_t         ,out_UPDATE_BTB_VAL               [port]->read(),update_btb(it_upt->condition));
+                        if (update_btb(it_upt->condition))
+                          {
+                        TEST(Taddress_t         ,out_UPDATE_BTB_ADDRESS_SRC       [port]->read(),it_upt->address_src);
+                        TEST(Taddress_t         ,out_UPDATE_BTB_ADDRESS_DEST      [port]->read(),it_upt->address_dest);
+                        TEST(Tbranch_condition_t,out_UPDATE_BTB_CONDITION         [port]->read(),it_upt->condition);
+                          }
+                        TEST(Tcontrol_t         ,out_UPDATE_DIR_VAL               [port]->read(),update_dir(it_upt->condition) and not (it_upt->miss_ifetch or it_upt->miss_decod));
+                        
+                        if (update_dir(it_upt->condition))
+                        if (_param->_have_port_history)
+                        TEST(Thistory_t         ,out_UPDATE_DIR_HISTORY           [port]->read(),it_upt->history);
+                        TEST(Tcontrol_t         ,out_UPDATE_RAS_VAL               [port]->read(),update_ras(it_upt->condition));
+                        if (update_ras(it_upt->condition))
+                          {
+//                      TEST(Tcontrol_t         ,out_UPDATE_RAS_FLUSH             [port]->read(),0);
+                        TEST(Tcontrol_t         ,out_UPDATE_RAS_PUSH              [port]->read(),push_ras  (it_upt->condition));
+                        TEST(Taddress_t         ,out_UPDATE_RAS_ADDRESS           [port]->read(),it_upt->ras_address);
+                        TEST(Tptr_t             ,out_UPDATE_RAS_INDEX             [port]->read(),it_upt->ras_index);
+                        TEST(Tcontrol_t         ,out_UPDATE_RAS_PREDICTION_IFETCH [port]->read(),not it_upt->miss_ifetch);
+                          }
+
+                        ++ it_upt;
+                      }
+                    
+                    SC_START(1);
+                  } while (not have_transaction);
+                
+                in_UPDATE_ACK [port]->write(0);
+//               if (_param->_have_port_depth)
+//               TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
+//               TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
+              }
+          }
+
+          upt.clear();
+
+          // Wait Garbage Collector
+          {
+            LABEL("GARBAGE COLLECTOR");
+            LABEL(" * upt bottom : %d",upt_bottom [context]);
+            LABEL(" * upt top    : %d",upt_top    [context]);
+
+            upt_top    [context] = (upt_top_event [context]);
+            upt_bottom [context] = (upt_top       [context]);
+
+            while ((upt_bottom [context] != out_DEPTH_MIN [context]->read()) or
+                   (upt_top    [context] != out_DEPTH_MAX [context]->read()))
+              {
+                SC_START(1);
+              }
           }
         }
