Ignore:
Timestamp:
Dec 15, 2008, 12:04:03 PM (16 years ago)
Author:
rosiere
Message:

Update document on Vhdl generation.

Location:
trunk/IPs/systemC/processor/Morpheo/Behavioural/Core
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Dcache_Access/src/Dcache_Access_genMealy_rsp.cpp

    r88 r94  
    5656              throw ERRORMORPHEO(FUNCTION,_("invalid load_store_unit_id.\n"));
    5757
    58             if (context_id > _param->_nb_context[execute_loop_id][load_store_unit_id])
     58            if (context_id > _param->_nb_context[execute_loop_id])
    5959              throw ERRORMORPHEO(FUNCTION,_("invalid context_id.\n"));
    6060
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/SelfTest/config_mono_context.cfg

    r88 r94  
    221       1       +1      # nb_context             
    334       8       *2      # size_upt_queue         [0] [nb_context]
    4 1       4       *2      # size_ufpt_queue        [0] [nb_context]
     41       4       +1      # size_ufpt_queue        [0] [nb_context]
    5532      32      *2      # size_address           
    664       4       *4      # nb_inst_predict       
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/SelfTest/src/test.cpp

    r88 r94  
    116116//   ALLOC1_SC_SIGNAL(out_BRANCH_EVENT_MISS_PREDICTION,"out_BRANCH_EVENT_MISS_PREDICTION",Tcontrol_t         ,_param->_nb_context);
    117117  ALLOC1_SC_SIGNAL(out_BRANCH_EVENT_ADDRESS_SRC    ,"out_BRANCH_EVENT_ADDRESS_SRC    ",Taddress_t         ,_param->_nb_context);
     118  ALLOC1_SC_SIGNAL(out_BRANCH_EVENT_ADDRESS_DEST_VAL,"out_BRANCH_EVENT_ADDRESS_DEST_VAL",Tcontrol_t         ,_param->_nb_context);
    118119  ALLOC1_SC_SIGNAL(out_BRANCH_EVENT_ADDRESS_DEST   ,"out_BRANCH_EVENT_ADDRESS_DEST   ",Taddress_t         ,_param->_nb_context);
    119120
     
    130131  ALLOC1_SC_SIGNAL(out_UPDATE_DIR_HISTORY             ,"out_UPDATE_DIR_HISTORY             ",Thistory_t         ,_param->_nb_inst_update);
    131132  ALLOC1_SC_SIGNAL(out_UPDATE_RAS_VAL                 ,"out_UPDATE_RAS_VAL                 ",Tcontrol_t         ,_param->_nb_inst_update);
     133  ALLOC1_SC_SIGNAL(out_UPDATE_RAS_FLUSH               ,"out_UPDATE_RAS_FLUSH               ",Tcontrol_t         ,_param->_nb_inst_update);
    132134  ALLOC1_SC_SIGNAL(out_UPDATE_RAS_PUSH                ,"out_UPDATE_RAS_PUSH                ",Tcontrol_t         ,_param->_nb_inst_update);
    133135  ALLOC1_SC_SIGNAL(out_UPDATE_RAS_ADDRESS             ,"out_UPDATE_RAS_ADDRESS             ",Taddress_t         ,_param->_nb_inst_update);
     
    201203//   INSTANCE1_SC_SIGNAL(_Update_Prediction_Table,out_BRANCH_EVENT_MISS_PREDICTION,_param->_nb_context);
    202204  INSTANCE1_SC_SIGNAL(_Update_Prediction_Table,out_BRANCH_EVENT_ADDRESS_SRC    ,_param->_nb_context);
     205  INSTANCE1_SC_SIGNAL(_Update_Prediction_Table,out_BRANCH_EVENT_ADDRESS_DEST_VAL,_param->_nb_context);
    203206  INSTANCE1_SC_SIGNAL(_Update_Prediction_Table,out_BRANCH_EVENT_ADDRESS_DEST   ,_param->_nb_context);
    204207
     
    217220  INSTANCE1_SC_SIGNAL(_Update_Prediction_Table,out_UPDATE_DIR_HISTORY             ,_param->_nb_inst_update);
    218221  INSTANCE1_SC_SIGNAL(_Update_Prediction_Table,out_UPDATE_RAS_VAL                 ,_param->_nb_inst_update);
     222  INSTANCE1_SC_SIGNAL(_Update_Prediction_Table,out_UPDATE_RAS_FLUSH               ,_param->_nb_inst_update);
    219223  INSTANCE1_SC_SIGNAL(_Update_Prediction_Table,out_UPDATE_RAS_PUSH                ,_param->_nb_inst_update);
    220224  INSTANCE1_SC_SIGNAL(_Update_Prediction_Table,out_UPDATE_RAS_ADDRESS             ,_param->_nb_inst_update);
     
    247251  const  int32_t percent_transaction_branch_complete = 75;
    248252  const  int32_t percent_transaction_update          = 75;
    249 
    250 
     253  const  int32_t percent_transaction_branch_event    = 75;
     254
     255  const bool     test1 = false;
     256  const bool     test2 = false;
     257  const bool     test3 = false;
     258  const bool     test4 = true;
    251259
    252260  std::list<request_t> ufpt;
    253261  std::list<request_t> upt;
     262  request_t            event;
    254263
    255264  SC_START(0);
     
    302311      //---------------------------------------------------------------------
    303312      //---------------------------------------------------------------------
    304       if (1)
    305       {
     313      if (test1)
     314        {
    306315        uint32_t context = rand() % _param->_nb_context;
    307316
     
    508517          for (uint32_t i=0; i<upt.size(); i++)
    509518            {
    510               LABEL("Address_src (-1): %.8x (%d)",out_UPDATE_BTB_ADDRESS_SRC [i]->read(),upt.size());
    511 
    512519              bool have_transaction = false;
    513520
    514521              do
    515522                {
    516                   LABEL("Address_src (0) : %.8x",out_UPDATE_BTB_ADDRESS_SRC [i]->read());
    517 
    518523                  in_UPDATE_ACK [port]->write((rand()%100)<percent_transaction_update);
    519524
     
    522527//                   TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
    523528                 
    524                   LABEL("Address_src (1) : %.8x",out_UPDATE_BTB_ADDRESS_SRC [i]->read());
    525529                  SC_START(0);
    526                   LABEL("Address_src (2) : %.8x",out_UPDATE_BTB_ADDRESS_SRC [i]->read());
    527                  
     530
    528531                  LABEL("UPDATE [%d] %d - %d.",port,out_UPDATE_VAL [port]->read(),in_UPDATE_ACK [port]->read());
    529532                 
     
    534537                 
    535538                      if (_param->_have_port_context_id)
    536                       TEST(Tcontext_t         ,out_UPDATE_CONTEXT_ID            [i]->read(),it_upt->context);
    537                       TEST(Tcontrol_t         ,out_UPDATE_MISS_PREDICTION       [i]->read(),it_upt->miss_commit);
    538                       TEST(Tcontrol_t         ,out_UPDATE_DIRECTION_GOOD        [i]->read(),it_upt->flag);
    539                       TEST(Tcontrol_t         ,out_UPDATE_BTB_VAL               [i]->read(),update_btb(it_upt->condition));
     539                      TEST(Tcontext_t         ,out_UPDATE_CONTEXT_ID            [port]->read(),it_upt->context);
     540                      TEST(Tcontrol_t         ,out_UPDATE_MISS_PREDICTION       [port]->read(),it_upt->miss_commit);
     541                      TEST(Tcontrol_t         ,out_UPDATE_DIRECTION_GOOD        [port]->read(),it_upt->take_good);
     542                      TEST(Tcontrol_t         ,out_UPDATE_BTB_VAL               [port]->read(),update_btb(it_upt->condition));
    540543                      if (update_btb(it_upt->condition))
    541544                        {
    542                       TEST(Taddress_t         ,out_UPDATE_BTB_ADDRESS_SRC       [i]->read(),it_upt->address_src);
    543                       TEST(Taddress_t         ,out_UPDATE_BTB_ADDRESS_DEST      [i]->read(),it_upt->address_dest);
    544                       TEST(Tbranch_condition_t,out_UPDATE_BTB_CONDITION         [i]->read(),it_upt->condition);
     545                      TEST(Taddress_t         ,out_UPDATE_BTB_ADDRESS_SRC       [port]->read(),it_upt->address_src);
     546                      TEST(Taddress_t         ,out_UPDATE_BTB_ADDRESS_DEST      [port]->read(),it_upt->address_dest);
     547                      TEST(Tbranch_condition_t,out_UPDATE_BTB_CONDITION         [port]->read(),it_upt->condition);
    545548                        }
    546                       TEST(Tcontrol_t         ,out_UPDATE_DIR_VAL               [i]->read(),update_dir(it_upt->condition));
     549                      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));
    547550                      if (update_dir(it_upt->condition))
    548551                      if (_param->_have_port_history)
    549                       TEST(Thistory_t         ,out_UPDATE_DIR_HISTORY           [i]->read(),it_upt->history);
    550                       TEST(Tcontrol_t         ,out_UPDATE_RAS_VAL               [i]->read(),update_ras(it_upt->condition));
     552                      TEST(Thistory_t         ,out_UPDATE_DIR_HISTORY           [port]->read(),it_upt->history);
     553                      TEST(Tcontrol_t         ,out_UPDATE_RAS_VAL               [port]->read(),update_ras(it_upt->condition));
    551554                      if (update_ras(it_upt->condition))
    552555                        {
    553                       TEST(Tcontrol_t         ,out_UPDATE_RAS_PUSH              [i]->read(),push_ras  (it_upt->condition));
    554                       TEST(Taddress_t         ,out_UPDATE_RAS_ADDRESS           [i]->read(),it_upt->ras_address);
    555                       TEST(Tptr_t             ,out_UPDATE_RAS_INDEX             [i]->read(),it_upt->ras_index);
    556                       TEST(Tcontrol_t         ,out_UPDATE_RAS_PREDICTION_IFETCH [i]->read(),not it_upt->miss_ifetch);
     556//                    TEST(Tcontrol_t         ,out_UPDATE_RAS_FLUSH             [port]->read(),0);
     557                      TEST(Tcontrol_t         ,out_UPDATE_RAS_PUSH              [port]->read(),push_ras  (it_upt->condition));
     558                      TEST(Taddress_t         ,out_UPDATE_RAS_ADDRESS           [port]->read(),it_upt->ras_address);
     559                      TEST(Tptr_t             ,out_UPDATE_RAS_INDEX             [port]->read(),it_upt->ras_index);
     560                      TEST(Tcontrol_t         ,out_UPDATE_RAS_PREDICTION_IFETCH [port]->read(),not it_upt->miss_ifetch);
    557561                        }
    558562                      ++ it_upt;
     
    560564
    561565                  SC_START(1);
    562                   LABEL("Address_src (3) : %.8x",out_UPDATE_BTB_ADDRESS_SRC [i]->read());
    563                  
    564566                } while (not have_transaction);
    565567
    566               LABEL("Address_src (4) : %.8x",out_UPDATE_BTB_ADDRESS_SRC [i]->read());
    567568              in_UPDATE_ACK [port]->write(0);
    568               LABEL("Address_src (5) : %.8x",out_UPDATE_BTB_ADDRESS_SRC [i]->read());
    569569//               if (_param->_have_port_depth)
    570570//               TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
     
    586586      }
    587587
     588      //---------------------------------------------------------------------
     589      //---------------------------------------------------------------------
     590      // DECOD MISS : no RAS in ifetch
     591      //---------------------------------------------------------------------
     592      //---------------------------------------------------------------------
     593      if (test2)
     594        {
     595        uint32_t context = rand() % _param->_nb_context;
     596
     597        {
     598          LABEL("PREDICT - fill the queue");
     599          uint32_t port = rand() % _param->_nb_inst_predict;
     600
     601          LABEL("  * context : %d",context);
     602          LABEL("  * port    : %d",port);
     603         
     604          for (uint32_t i=0; i<_param->_size_ufpt_queue[context]; i++)
     605            {
     606              request_t request;
     607              request.context          = context;
     608              request.address_src      = 0xdeadbeef+i;
     609              request.address_dest     = 0x21071981+i;                                   
     610              request.address_good     = request.address_dest;
     611              request.condition        = BRANCH_CONDITION_FLAG_SET;                     
     612              request.take             = 1;                                             
     613              request.take_good        = 1;                                             
     614              request.flag             = (request.condition == BRANCH_CONDITION_FLAG_SET)?request.take_good:(not request.take_good);
     615              request.is_accurate      = true;
     616              request.miss_ifetch      = false;
     617              request.miss_decod       = false;
     618              request.miss_commit      = false;
     619              request.history          = i;                                             
     620              request.ras_address      = 0xdeaddead+i;                                   
     621              request.ras_index        = (0x12345678+i)%_param->_size_ras_index[context];
     622              request.ufpt_ptr         = ufpt_top [context];
     623//            request.upt_ptr;
     624
     625              bool have_transaction = false;
     626              do
     627                {
     628                  in_PREDICT_VAL              [port]->write((rand()%100)<percent_transaction_predict);
     629                  in_PREDICT_CONTEXT_ID       [port]->write(request.context     );
     630                  in_PREDICT_BTB_ADDRESS_SRC  [port]->write(request.address_src );
     631                  in_PREDICT_BTB_ADDRESS_DEST [port]->write(request.address_dest);
     632                  in_PREDICT_BTB_CONDITION    [port]->write(request.condition   );
     633                  in_PREDICT_BTB_LAST_TAKE    [port]->write(request.take        );
     634                  in_PREDICT_BTB_IS_ACCURATE  [port]->write(request.is_accurate );
     635                  in_PREDICT_DIR_HISTORY      [port]->write(request.history     );
     636                  in_PREDICT_RAS_ADDRESS      [port]->write(request.ras_address );
     637                  in_PREDICT_RAS_INDEX        [port]->write(request.ras_index   );
     638                 
     639                  if (_param->_have_port_depth)
     640                  TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
     641                  TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
     642                     
     643                  SC_START(0); // fct melay
     644                 
     645                  LABEL("PREDICT         [%d] %d - %d (accurate : %d).",
     646                        port,
     647                         in_PREDICT_VAL [port]->read(),
     648                        out_PREDICT_ACK [port]->read(),
     649                         in_PREDICT_BTB_IS_ACCURATE [port]->read());
     650                 
     651                  if (in_PREDICT_VAL [port]->read() and out_PREDICT_ACK [port]->read())
     652                    {
     653                      LABEL("PREDICT         [%d] - Transaction accepted",port);
     654                      have_transaction = true;
     655
     656                      if (_param->_have_port_depth)
     657                      TEST(Tprediction_ptr_t,out_PREDICT_UPDATE_PREDICTION_ID [port]->read(),ufpt_top [context]);
     658                     
     659                      ufpt_top [context] = (ufpt_top [context]+1)%_param->_size_ufpt_queue[context];
     660                    }
     661                 
     662                  SC_START(1); // transition
     663                 
     664                } while (not have_transaction);
     665
     666//            ufpt.push_back(request);
     667
     668              in_PREDICT_VAL [port]->write(0);
     669           
     670              if (_param->_have_port_depth)
     671              TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
     672              TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
     673            }
     674        }
     675       
     676        {
     677          LABEL("DECOD - Miss");
     678          uint32_t port = rand() % _param->_nb_inst_decod;
     679
     680          LABEL("  * context : %d",context);
     681          LABEL("  * port    : %d",port);
     682         
     683          request_t request;
     684          request.context          = context;
     685          request.address_src      = 0x14011959;
     686          request.address_dest     = 0x25071959; // after = not take               
     687          request.address_good     = request.address_dest;
     688          request.condition        = BRANCH_CONDITION_FLAG_SET;
     689          request.take             = 0;                                             
     690          request.take_good        = 0;                                             
     691          request.flag             = (request.condition == BRANCH_CONDITION_FLAG_SET)?request.take_good:(not request.take_good);
     692          request.is_accurate      = true;
     693          request.miss_ifetch      = false;
     694          request.miss_decod       = true ;
     695          request.miss_commit      = false;
     696          request.history          = 1;
     697          request.ras_address      = 0xbabababa;                                   
     698          request.ras_index        = (0x87654321)%_param->_size_ras_index[context];
     699          request.ufpt_ptr         = ufpt_top [context];
     700       
     701          event = request;
     702
     703//           for (uint32_t i=0; i<upt.size(); i++)
     704          // just one
     705            {
     706              bool have_transaction = false;
     707              do
     708                {
     709                  in_DECOD_VAL                  [port]->write((rand()%100)<percent_transaction_decod);
     710                  in_DECOD_CONTEXT_ID           [port]->write(request.context     );
     711                  in_DECOD_BTB_ADDRESS_SRC      [port]->write(request.address_src );
     712                  in_DECOD_BTB_ADDRESS_DEST     [port]->write(request.address_dest);
     713                  in_DECOD_BTB_CONDITION        [port]->write(request.condition   );
     714                  in_DECOD_BTB_LAST_TAKE        [port]->write(request.take        );
     715                  in_DECOD_RAS_ADDRESS          [port]->write(request.ras_address );
     716                  in_DECOD_RAS_INDEX            [port]->write(request.ras_index   );
     717                  in_DECOD_UPDATE_PREDICTION_ID [port]->write(request.ufpt_ptr    );
     718                  in_DECOD_MISS_IFETCH          [port]->write(request.miss_ifetch );
     719                  in_DECOD_MISS_DECOD           [port]->write(request.miss_decod  );
     720                  in_DECOD_IS_ACCURATE          [port]->write(request.is_accurate );
     721
     722                  SC_START(0); // fct melay
     723                 
     724                  LABEL("DECOD           [%d] %d - %d",
     725                        port,
     726                         in_PREDICT_VAL [port]->read(),
     727                        out_PREDICT_ACK [port]->read());
     728                 
     729                  if (in_DECOD_VAL [port]->read() and out_DECOD_ACK [port]->read())
     730                    {
     731                      LABEL("DECOD          [%d] - Transaction accepted",port);
     732                      have_transaction = true;
     733
     734                      request.upt_ptr = upt_top [context];
     735                      upt.push_back(request);
     736//                    ufpt.pop_front();
     737
     738                      upt_top [context] = (upt_top [context]+1)%_param->_size_upt_queue[context];
     739                    }
     740
     741                  SC_START(1); // transition
     742
     743                } while (not have_transaction);
     744
     745              in_DECOD_VAL              [port]->write(0);
     746             
     747              if (_param->_have_port_depth)
     748              TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
     749              TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
     750            }
     751        }
     752
     753        {
     754          LABEL("BRANCH_COMPLETE - hit ifetch");
     755       
     756          uint32_t port = rand() % _param->_nb_inst_branch_complete;
     757       
     758          LABEL("  * port    : %d",port);
     759 
     760          std::list<request_t>::iterator it_upt = upt.begin();
     761
     762//        for (uint32_t i=0; i<_param->_size_ufpt_queue[context]; i++)
     763//        for (uint32_t i=0; i<upt.size(); i++)
     764          // just one
     765          {
     766              bool have_transaction = false;
     767
     768              do
     769                {
     770                  in_BRANCH_COMPLETE_VAL        [port]->write((rand()%100)<percent_transaction_branch_complete);
     771                  in_BRANCH_COMPLETE_CONTEXT_ID [port]->write(it_upt->context     );
     772                  in_BRANCH_COMPLETE_DEPTH      [port]->write(it_upt->upt_ptr     );
     773                  in_BRANCH_COMPLETE_ADDRESS    [port]->write(it_upt->address_good);
     774                  in_BRANCH_COMPLETE_FLAG       [port]->write(it_upt->flag        );
     775
     776                  if (_param->_have_port_depth)
     777                  TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
     778                  TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
     779                 
     780                  SC_START(0);
     781                 
     782                  LABEL("BRANCH_COMPLETE [%d] %d - %d.",port,in_BRANCH_COMPLETE_VAL [port]->read(),out_BRANCH_COMPLETE_ACK [port]->read());
     783                 
     784                  if (in_BRANCH_COMPLETE_VAL [port]->read() and out_BRANCH_COMPLETE_ACK [port]->read())
     785                    {
     786                      LABEL("BRANCH_COMPLETE [%d] - Transaction accepted",port);
     787                      have_transaction = true;
     788                     
     789                      TEST(Tcontrol_t,out_BRANCH_COMPLETE_MISS_PREDICTION[port]->read(),it_upt->miss_commit );
     790                      TEST(Tcontrol_t,out_BRANCH_COMPLETE_TAKE           [port]->read(),it_upt->take_good   );
     791                      TEST(Taddress_t,out_BRANCH_COMPLETE_ADDRESS_SRC    [port]->read(),it_upt->address_src );
     792                      TEST(Taddress_t,out_BRANCH_COMPLETE_ADDRESS_DEST   [port]->read(),it_upt->address_good);
     793
     794                      it_upt ++;
     795                    }
     796                 
     797                  SC_START(1);
     798                } while (not have_transaction);
     799
     800              in_BRANCH_COMPLETE_VAL [port]->write(0);
     801             
     802              if (_param->_have_port_depth)
     803              TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
     804              TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
     805            }
     806        }
     807
     808        {
     809          LABEL("UPDATE - hit ifetch");
     810       
     811          uint32_t port = 0;
     812       
     813          LABEL("  * port    : %d",port);
     814          std::list<request_t>::iterator it_upt = upt.begin();
     815 
     816//        for (uint32_t i=0; i<_param->_size_ufpt_queue[context]; i++)
     817//        for (uint32_t i=0; i<upt.size(); i++)
     818          // just one
     819            {
     820              bool have_transaction = false;
     821
     822              do
     823                {
     824                  in_UPDATE_ACK [port]->write((rand()%100)<percent_transaction_update);
     825
     826//                   if (_param->_have_port_depth)
     827//                   TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
     828//                   TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
     829                 
     830                  SC_START(0);
     831
     832                  LABEL("UPDATE [%d] %d - %d.",port,out_UPDATE_VAL [port]->read(),in_UPDATE_ACK [port]->read());
     833                 
     834                  if (out_UPDATE_VAL [port]->read() and in_UPDATE_ACK [port]->read())
     835                    {
     836                      LABEL("UPDATE [%d] - Transaction accepted",port);
     837                      have_transaction = true;
     838                 
     839                      if (_param->_have_port_context_id)
     840                      TEST(Tcontext_t         ,out_UPDATE_CONTEXT_ID            [port]->read(),it_upt->context);
     841                      TEST(Tcontrol_t         ,out_UPDATE_MISS_PREDICTION       [port]->read(),it_upt->miss_commit);
     842                      TEST(Tcontrol_t         ,out_UPDATE_DIRECTION_GOOD        [port]->read(),it_upt->take_good);
     843                      TEST(Tcontrol_t         ,out_UPDATE_BTB_VAL               [port]->read(),update_btb(it_upt->condition));
     844                      if (update_btb(it_upt->condition))
     845                        {
     846                      TEST(Taddress_t         ,out_UPDATE_BTB_ADDRESS_SRC       [port]->read(),it_upt->address_src);
     847                      TEST(Taddress_t         ,out_UPDATE_BTB_ADDRESS_DEST      [port]->read(),it_upt->address_dest);
     848                      TEST(Tbranch_condition_t,out_UPDATE_BTB_CONDITION         [port]->read(),it_upt->condition);
     849                        }
     850                      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));
     851
     852                      if (update_dir(it_upt->condition))
     853                      if (_param->_have_port_history)
     854                      TEST(Thistory_t         ,out_UPDATE_DIR_HISTORY           [port]->read(),it_upt->history);
     855                      TEST(Tcontrol_t         ,out_UPDATE_RAS_VAL               [port]->read(),update_ras(it_upt->condition));
     856                      if (update_ras(it_upt->condition))
     857                        {
     858//                    TEST(Tcontrol_t         ,out_UPDATE_RAS_FLUSH             [port]->read(),0);
     859                      TEST(Tcontrol_t         ,out_UPDATE_RAS_PUSH              [port]->read(),push_ras  (it_upt->condition));
     860                      TEST(Taddress_t         ,out_UPDATE_RAS_ADDRESS           [port]->read(),it_upt->ras_address);
     861                      TEST(Tptr_t             ,out_UPDATE_RAS_INDEX             [port]->read(),it_upt->ras_index);
     862                      TEST(Tcontrol_t         ,out_UPDATE_RAS_PREDICTION_IFETCH [port]->read(),not it_upt->miss_ifetch);
     863                        }
     864                      ++ it_upt;
     865                    }
     866
     867                  SC_START(1);
     868                } while (not have_transaction);
     869
     870              in_UPDATE_ACK [port]->write(0);
     871//               if (_param->_have_port_depth)
     872//               TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
     873//               TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
     874            }
     875          upt.clear();
     876        }
     877
     878        {
     879          LABEL("BRANCH_EVENT - have miss decod");
     880         
     881          uint32_t port = context;
     882
     883          {
     884            bool have_transaction = false;
     885           
     886            do
     887              {
     888                in_BRANCH_EVENT_ACK [port]->write((rand()%100)<percent_transaction_branch_event);
     889               
     890                SC_START(0);
     891               
     892                LABEL("BRANCH_EVENT [%d] %d - %d.",port,out_BRANCH_EVENT_VAL [port]->read(),in_BRANCH_EVENT_ACK [port]->read());
     893               
     894                if (out_BRANCH_EVENT_VAL [port]->read() and in_BRANCH_EVENT_ACK [port]->read())
     895                  {
     896                    LABEL("BRANCH_EVENT [%d] - Transaction accepted",port);
     897                    have_transaction = true;
     898             
     899                    TEST(Taddress_t,out_BRANCH_EVENT_ADDRESS_SRC      [port]->read(),event.address_src);
     900                    TEST(Tcontrol_t,out_BRANCH_EVENT_ADDRESS_DEST_VAL [port]->read(),event.take);
     901                    if (event.take)
     902                    TEST(Taddress_t,out_BRANCH_EVENT_ADDRESS_DEST     [port]->read(),event.address_good);
     903
     904                    event.address_src  = 0;
     905                    event.take         = 0;
     906                    event.address_dest = 0;
     907                  }
     908               
     909                SC_START(1);
     910              } while (not have_transaction);
     911
     912              in_BRANCH_EVENT_ACK [port]->write(0);
     913          }
     914        }
     915
     916
     917        // Wait Garbage Collector
     918        {
     919          upt_bottom [context] = (upt_bottom [context]+1)%_param->_size_upt_queue[context];
     920//        upt_top    [context] = (upt_top    [context]);
     921
     922          while ((upt_bottom [context] != out_DEPTH_MIN [context]->read()) or
     923                 (upt_top    [context] != out_DEPTH_MAX [context]->read()))
     924            SC_START(1);
     925
     926        }
     927        }
     928
     929      //---------------------------------------------------------------------
     930      //---------------------------------------------------------------------
     931      // DECOD MISS : with RAS in ifetch
     932      //---------------------------------------------------------------------
     933      //---------------------------------------------------------------------
     934      if (test3)
     935        {
     936        uint32_t context = rand() % _param->_nb_context;
     937        uint32_t have_ras = false;
     938        {
     939          LABEL("PREDICT - fill the queue");
     940          uint32_t port = rand() % _param->_nb_inst_predict;
     941
     942          LABEL("  * context : %d",context);
     943          LABEL("  * port    : %d",port);
     944         
     945          for (uint32_t i=0; i<_param->_size_ufpt_queue[context]; i++)
     946            {
     947              request_t request;
     948              request.context          = context;
     949              request.address_src      = 0xdeadbeef+i;
     950              request.address_dest     = 0x21071981+i;                                   
     951              request.address_good     = request.address_dest;
     952              request.condition        = (rand()%2)?BRANCH_CONDITION_NONE_WITH_WRITE_STACK:BRANCH_CONDITION_FLAG_SET;
     953
     954              have_ras |= (update_ras(request.condition));
     955
     956              request.take             = 1;                                             
     957              request.take_good        = 1;                                             
     958              request.flag             = (request.condition == BRANCH_CONDITION_FLAG_SET)?request.take_good:(not request.take_good);
     959              request.is_accurate      = true;
     960              request.miss_ifetch      = false;
     961              request.miss_decod       = true ;
     962              request.miss_commit      = false;
     963              request.history          = i;                                             
     964              request.ras_address      = 0x12344321+i;                                   
     965              request.ras_index        = (043211234+i)%_param->_size_ras_index[context];
     966              request.ufpt_ptr         = ufpt_top [context];
     967//            request.upt_ptr;
     968             
     969              bool have_transaction = false;
     970              do
     971                {
     972                  in_PREDICT_VAL              [port]->write((rand()%100)<percent_transaction_predict);
     973                  in_PREDICT_CONTEXT_ID       [port]->write(request.context     );
     974                  in_PREDICT_BTB_ADDRESS_SRC  [port]->write(request.address_src );
     975                  in_PREDICT_BTB_ADDRESS_DEST [port]->write(request.address_dest);
     976                  in_PREDICT_BTB_CONDITION    [port]->write(request.condition   );
     977                  in_PREDICT_BTB_LAST_TAKE    [port]->write(request.take        );
     978                  in_PREDICT_BTB_IS_ACCURATE  [port]->write(request.is_accurate );
     979                  in_PREDICT_DIR_HISTORY      [port]->write(request.history     );
     980                  in_PREDICT_RAS_ADDRESS      [port]->write(request.ras_address );
     981                  in_PREDICT_RAS_INDEX        [port]->write(request.ras_index   );
     982                 
     983                  if (_param->_have_port_depth)
     984                  TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
     985                  TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
     986                     
     987                  SC_START(0); // fct melay
     988                 
     989                  LABEL("PREDICT         [%d] %d - %d (accurate : %d).",
     990                        port,
     991                         in_PREDICT_VAL [port]->read(),
     992                        out_PREDICT_ACK [port]->read(),
     993                         in_PREDICT_BTB_IS_ACCURATE [port]->read());
     994                 
     995                  if (in_PREDICT_VAL [port]->read() and out_PREDICT_ACK [port]->read())
     996                    {
     997                      LABEL("PREDICT         [%d] - Transaction accepted",port);
     998                      have_transaction = true;
     999
     1000                      if (_param->_have_port_depth)
     1001                      TEST(Tprediction_ptr_t,out_PREDICT_UPDATE_PREDICTION_ID [port]->read(),ufpt_top [context]);
     1002                     
     1003                      ufpt_top [context] = (ufpt_top [context]+1)%_param->_size_ufpt_queue[context];
     1004                    }
     1005                 
     1006                  SC_START(1); // transition
     1007                 
     1008                } while (not have_transaction);
     1009
     1010              ufpt.push_back(request); // to update
     1011
     1012              in_PREDICT_VAL [port]->write(0);
     1013           
     1014              if (_param->_have_port_depth)
     1015              TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
     1016              TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
     1017            }
     1018        }
     1019       
     1020        {
     1021          LABEL("DECOD - Miss");
     1022          uint32_t port = rand() % _param->_nb_inst_decod;
     1023
     1024          LABEL("  * context : %d",context);
     1025          LABEL("  * port    : %d",port);
     1026         
     1027          request_t request;
     1028          request.context          = context;
     1029          request.address_src      = 0x14011959;
     1030          request.address_dest     = 0x25071959; // after = not take               
     1031          request.address_good     = request.address_dest;
     1032          request.condition        = BRANCH_CONDITION_FLAG_SET;
     1033          request.take             = 0;                                             
     1034          request.take_good        = 0;                                             
     1035          request.flag             = (request.condition == BRANCH_CONDITION_FLAG_SET)?request.take_good:(not request.take_good);
     1036          request.is_accurate      = true;
     1037          request.miss_ifetch      = false;
     1038          request.miss_decod       = true ;
     1039          request.miss_commit      = false;
     1040          request.history          = 1;
     1041          request.ras_address      = 0xbabababa;                                   
     1042          request.ras_index        = (0x87654321)%_param->_size_ras_index[context];
     1043          request.ufpt_ptr         = ufpt_top [context];
     1044
     1045          event = request;
     1046         
     1047//           for (uint32_t i=0; i<upt.size(); i++)
     1048          // just one
     1049            {
     1050              bool have_transaction = false;
     1051              do
     1052                {
     1053                  in_DECOD_VAL                  [port]->write((rand()%100)<percent_transaction_decod);
     1054                  in_DECOD_CONTEXT_ID           [port]->write(request.context     );
     1055                  in_DECOD_BTB_ADDRESS_SRC      [port]->write(request.address_src );
     1056                  in_DECOD_BTB_ADDRESS_DEST     [port]->write(request.address_dest);
     1057                  in_DECOD_BTB_CONDITION        [port]->write(request.condition   );
     1058                  in_DECOD_BTB_LAST_TAKE        [port]->write(request.take        );
     1059                  in_DECOD_RAS_ADDRESS          [port]->write(request.ras_address );
     1060                  in_DECOD_RAS_INDEX            [port]->write(request.ras_index   );
     1061                  in_DECOD_UPDATE_PREDICTION_ID [port]->write(request.ufpt_ptr    );
     1062                  in_DECOD_MISS_IFETCH          [port]->write(request.miss_ifetch );
     1063                  in_DECOD_MISS_DECOD           [port]->write(request.miss_decod  );
     1064                  in_DECOD_IS_ACCURATE          [port]->write(request.is_accurate );
     1065
     1066                  SC_START(0); // fct melay
     1067                 
     1068                  LABEL("DECOD           [%d] %d - %d",
     1069                        port,
     1070                         in_PREDICT_VAL [port]->read(),
     1071                        out_PREDICT_ACK [port]->read());
     1072                 
     1073                  if (in_DECOD_VAL [port]->read() and out_DECOD_ACK [port]->read())
     1074                    {
     1075                      LABEL("DECOD          [%d] - Transaction accepted",port);
     1076                      have_transaction = true;
     1077
     1078                      request.upt_ptr = upt_top [context];
     1079                      upt.push_back(request);
     1080//                    ufpt.pop_front();
     1081
     1082                      upt_top [context] = (upt_top [context]+1)%_param->_size_upt_queue[context];
     1083                    }
     1084
     1085                  SC_START(1); // transition
     1086
     1087                } while (not have_transaction);
     1088
     1089              in_DECOD_VAL              [port]->write(0);
     1090             
     1091              if (_param->_have_port_depth)
     1092              TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
     1093              TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
     1094            }
     1095        }
     1096
     1097        {
     1098          LABEL("BRANCH_COMPLETE - hit ifetch");
     1099       
     1100          uint32_t port = rand() % _param->_nb_inst_branch_complete;
     1101       
     1102          LABEL("  * port    : %d",port);
     1103 
     1104          std::list<request_t>::iterator it_upt = upt.begin();
     1105
     1106//        for (uint32_t i=0; i<_param->_size_ufpt_queue[context]; i++)
     1107//        for (uint32_t i=0; i<upt.size(); i++)
     1108          // just one
     1109          {
     1110              bool have_transaction = false;
     1111
     1112              do
     1113                {
     1114                  in_BRANCH_COMPLETE_VAL        [port]->write((rand()%100)<percent_transaction_branch_complete);
     1115                  in_BRANCH_COMPLETE_CONTEXT_ID [port]->write(it_upt->context     );
     1116                  in_BRANCH_COMPLETE_DEPTH      [port]->write(it_upt->upt_ptr     );
     1117                  in_BRANCH_COMPLETE_ADDRESS    [port]->write(it_upt->address_good);
     1118                  in_BRANCH_COMPLETE_FLAG       [port]->write(it_upt->flag        );
     1119
     1120                  if (_param->_have_port_depth)
     1121                  TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
     1122                  TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
     1123                 
     1124                  SC_START(0);
     1125                 
     1126                  LABEL("BRANCH_COMPLETE [%d] %d - %d.",port,in_BRANCH_COMPLETE_VAL [port]->read(),out_BRANCH_COMPLETE_ACK [port]->read());
     1127                 
     1128                  if (in_BRANCH_COMPLETE_VAL [port]->read() and out_BRANCH_COMPLETE_ACK [port]->read())
     1129                    {
     1130                      LABEL("BRANCH_COMPLETE [%d] - Transaction accepted",port);
     1131                      have_transaction = true;
     1132                     
     1133                      TEST(Tcontrol_t,out_BRANCH_COMPLETE_MISS_PREDICTION[port]->read(),it_upt->miss_commit );
     1134                      TEST(Tcontrol_t,out_BRANCH_COMPLETE_TAKE           [port]->read(),it_upt->take_good   );
     1135                      TEST(Taddress_t,out_BRANCH_COMPLETE_ADDRESS_SRC    [port]->read(),it_upt->address_src );
     1136                      TEST(Taddress_t,out_BRANCH_COMPLETE_ADDRESS_DEST   [port]->read(),it_upt->address_good);
     1137
     1138                      it_upt ++;
     1139                    }
     1140                 
     1141                  SC_START(1);
     1142                } while (not have_transaction);
     1143
     1144              in_BRANCH_COMPLETE_VAL [port]->write(0);
     1145             
     1146              if (_param->_have_port_depth)
     1147              TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
     1148              TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
     1149            }
     1150        }
     1151
     1152        if (have_ras)
     1153        {
     1154          LABEL("UPDATE - Update UPFT");
     1155       
     1156          uint32_t port = 0;
     1157       
     1158          LABEL("  * port    : %d",port);
     1159          std::list<request_t>::iterator it_ufpt = ufpt.end();
     1160          -- it_ufpt;
     1161 
     1162          for (uint32_t i=0; i<_param->_size_ufpt_queue[context]; i++)
     1163            {
     1164              bool have_transaction = false;
     1165
     1166              do
     1167                {
     1168                  in_UPDATE_ACK [port]->write((rand()%100)<percent_transaction_update);
     1169
     1170//                   if (_param->_have_port_depth)
     1171//                   TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), ufpt_bottom [context]);
     1172//                   TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), ufpt_top [context]);
     1173                 
     1174                  SC_START(0);
     1175
     1176                  LABEL("UPDATE [%d] %d - %d.",port,out_UPDATE_VAL [port]->read(),in_UPDATE_ACK [port]->read());
     1177                 
     1178                  if (out_UPDATE_VAL [port]->read() and in_UPDATE_ACK [port]->read())
     1179                    {
     1180                      LABEL("UPDATE [%d] - Transaction accepted",port);
     1181                      have_transaction = true;
     1182                 
     1183                      if (_param->_have_port_context_id)
     1184                      TEST(Tcontext_t         ,out_UPDATE_CONTEXT_ID            [port]->read(),it_ufpt->context);
     1185                      TEST(Tcontrol_t         ,out_UPDATE_MISS_PREDICTION       [port]->read(),(it_ufpt->miss_ifetch or
     1186                                                                                                it_ufpt->miss_decod  or
     1187                                                                                                it_ufpt->miss_commit ));
     1188//                       if (update_btb(it_ufpt->condition) or
     1189//                           update_dir(it_ufpt->condition))
     1190//                       TEST(Tcontrol_t         ,out_UPDATE_DIRECTION_GOOD        [port]->read(),it_ufpt->take_good);
     1191                      TEST(Tcontrol_t         ,out_UPDATE_BTB_VAL               [port]->read(),0);
     1192//                       if (update_btb(it_ufpt->condition))
     1193//                         {
     1194//                       TEST(Taddress_t         ,out_UPDATE_BTB_ADDRESS_SRC       [port]->read(),it_ufpt->address_src);
     1195//                       TEST(Taddress_t         ,out_UPDATE_BTB_ADDRESS_DEST      [port]->read(),it_ufpt->address_dest);
     1196//                       TEST(Tbranch_condition_t,out_UPDATE_BTB_CONDITION         [port]->read(),it_ufpt->condition);
     1197//                         }
     1198                      TEST(Tcontrol_t         ,out_UPDATE_DIR_VAL               [port]->read(),0);
     1199
     1200//                       if (update_dir(it_ufpt->condition))
     1201//                       if (_param->_have_port_history)
     1202//                       TEST(Thistory_t         ,out_UPDATE_DIR_HISTORY           [port]->read(),it_ufpt->history);
     1203//                       TEST(Tcontrol_t         ,out_UPDATE_RAS_VAL               [port]->read(),update_ras(it_ufpt->condition));
     1204                      if (update_ras(it_ufpt->condition))
     1205                        {
     1206//                    TEST(Tcontrol_t         ,out_UPDATE_RAS_FLUSH             [port]->read(),0);
     1207                      TEST(Tcontrol_t         ,out_UPDATE_RAS_PUSH              [port]->read(),push_ras  (it_ufpt->condition));
     1208                      LABEL("KANE : out_UPDATE_RAS_ADDRESS [port]->read() : %.8x",out_UPDATE_RAS_ADDRESS [port]->read());
     1209                      LABEL("KANE : it_ufpt->ras_address                  : %.8x",it_ufpt->ras_address);
     1210
     1211                      TEST(Taddress_t         ,out_UPDATE_RAS_ADDRESS           [port]->read(),it_ufpt->ras_address);
     1212                      TEST(Tptr_t             ,out_UPDATE_RAS_INDEX             [port]->read(),it_ufpt->ras_index);
     1213                      TEST(Tcontrol_t         ,out_UPDATE_RAS_PREDICTION_IFETCH [port]->read(),not it_ufpt->miss_ifetch);
     1214                        }
     1215                    }
     1216
     1217                  SC_START(1);
     1218                } while (not have_transaction);
     1219
     1220              -- it_ufpt;
     1221               
     1222
     1223              in_UPDATE_ACK [port]->write(0);
     1224//               if (_param->_have_port_depth)
     1225//               TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), ufpt_bottom [context]);
     1226//               TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), ufpt_top [context]);
     1227            }
     1228        }
     1229        ufpt.clear();
     1230
     1231        {
     1232          LABEL("UPDATE - hit ifetch");
     1233       
     1234          uint32_t port = 0;
     1235       
     1236          LABEL("  * port    : %d",port);
     1237          std::list<request_t>::iterator it_upt = upt.begin();
     1238 
     1239//        for (uint32_t i=0; i<_param->_size_ufpt_queue[context]; i++)
     1240//        for (uint32_t i=0; i<upt.size(); i++)
     1241          // just one
     1242            {
     1243              bool have_transaction = false;
     1244
     1245              do
     1246                {
     1247                  in_UPDATE_ACK [port]->write((rand()%100)<percent_transaction_update);
     1248
     1249//                   if (_param->_have_port_depth)
     1250//                   TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
     1251//                   TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
     1252                 
     1253                  SC_START(0);
     1254
     1255                  LABEL("UPDATE [%d] %d - %d.",port,out_UPDATE_VAL [port]->read(),in_UPDATE_ACK [port]->read());
     1256                 
     1257                  if (out_UPDATE_VAL [port]->read() and in_UPDATE_ACK [port]->read())
     1258                    {
     1259                      LABEL("UPDATE [%d] - Transaction accepted",port);
     1260                      have_transaction = true;
     1261                 
     1262                      if (_param->_have_port_context_id)
     1263                      TEST(Tcontext_t         ,out_UPDATE_CONTEXT_ID            [port]->read(),it_upt->context);
     1264                      TEST(Tcontrol_t         ,out_UPDATE_MISS_PREDICTION       [port]->read(),it_upt->miss_commit);
     1265                      TEST(Tcontrol_t         ,out_UPDATE_DIRECTION_GOOD        [port]->read(),it_upt->take_good);
     1266                      TEST(Tcontrol_t         ,out_UPDATE_BTB_VAL               [port]->read(),update_btb(it_upt->condition));
     1267                      if (update_btb(it_upt->condition))
     1268                        {
     1269                      TEST(Taddress_t         ,out_UPDATE_BTB_ADDRESS_SRC       [port]->read(),it_upt->address_src);
     1270                      TEST(Taddress_t         ,out_UPDATE_BTB_ADDRESS_DEST      [port]->read(),it_upt->address_dest);
     1271                      TEST(Tbranch_condition_t,out_UPDATE_BTB_CONDITION         [port]->read(),it_upt->condition);
     1272                        }
     1273                      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));
     1274
     1275                      if (update_dir(it_upt->condition))
     1276                      if (_param->_have_port_history)
     1277                      TEST(Thistory_t         ,out_UPDATE_DIR_HISTORY           [port]->read(),it_upt->history);
     1278                      TEST(Tcontrol_t         ,out_UPDATE_RAS_VAL               [port]->read(),update_ras(it_upt->condition));
     1279                      if (update_ras(it_upt->condition))
     1280                        {
     1281//                    TEST(Tcontrol_t         ,out_UPDATE_RAS_FLUSH             [port]->read(),0);
     1282                      TEST(Tcontrol_t         ,out_UPDATE_RAS_PUSH              [port]->read(),push_ras  (it_upt->condition));
     1283                      TEST(Taddress_t         ,out_UPDATE_RAS_ADDRESS           [port]->read(),it_upt->ras_address);
     1284                      TEST(Tptr_t             ,out_UPDATE_RAS_INDEX             [port]->read(),it_upt->ras_index);
     1285                      TEST(Tcontrol_t         ,out_UPDATE_RAS_PREDICTION_IFETCH [port]->read(),not it_upt->miss_ifetch);
     1286                        }
     1287                      ++ it_upt;
     1288                    }
     1289
     1290                  SC_START(1);
     1291                } while (not have_transaction);
     1292
     1293              in_UPDATE_ACK [port]->write(0);
     1294//               if (_param->_have_port_depth)
     1295//               TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
     1296//               TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
     1297            }
     1298        }
     1299        upt.clear();
     1300
     1301        {
     1302          LABEL("BRANCH_EVENT - have miss decod");
     1303         
     1304          uint32_t port = context;
     1305
     1306          {
     1307            bool have_transaction = false;
     1308           
     1309            do
     1310              {
     1311                in_BRANCH_EVENT_ACK [port]->write((rand()%100)<percent_transaction_branch_event);
     1312               
     1313                SC_START(0);
     1314               
     1315                LABEL("BRANCH_EVENT [%d] %d - %d.",port,out_BRANCH_EVENT_VAL [port]->read(),in_BRANCH_EVENT_ACK [port]->read());
     1316               
     1317                if (out_BRANCH_EVENT_VAL [port]->read() and in_BRANCH_EVENT_ACK [port]->read())
     1318                  {
     1319                    LABEL("BRANCH_EVENT [%d] - Transaction accepted",port);
     1320                    have_transaction = true;
     1321             
     1322                    TEST(Taddress_t,out_BRANCH_EVENT_ADDRESS_SRC      [port]->read(),event.address_src);
     1323                    TEST(Tcontrol_t,out_BRANCH_EVENT_ADDRESS_DEST_VAL [port]->read(),event.take);
     1324                    if (event.take)
     1325                    TEST(Taddress_t,out_BRANCH_EVENT_ADDRESS_DEST     [port]->read(),event.address_good);
     1326
     1327                    event.address_src  = 0;
     1328                    event.take         = 0;
     1329                    event.address_dest = 0;
     1330                  }
     1331               
     1332                SC_START(1);
     1333              } while (not have_transaction);
     1334
     1335              in_BRANCH_EVENT_ACK [port]->write(0);
     1336          }
     1337        }
     1338
     1339        // Wait Garbage Collector
     1340        {
     1341          upt_bottom [context] = (upt_bottom [context]+1)%_param->_size_upt_queue[context];
     1342//        upt_top    [context] = (upt_top    [context]);
     1343
     1344          while ((upt_bottom [context] != out_DEPTH_MIN [context]->read()) or
     1345                 (upt_top    [context] != out_DEPTH_MAX [context]->read()))
     1346            SC_START(1);
     1347
     1348        }
     1349      }
     1350     
     1351      //---------------------------------------------------------------------
     1352      //---------------------------------------------------------------------
     1353      // COMMIT MISS : with RAS in UPFT and UPT
     1354      //---------------------------------------------------------------------
     1355      //---------------------------------------------------------------------
     1356      if (test4)
     1357        {
     1358          uint32_t context = rand() % _param->_nb_context;
     1359          uint32_t have_ufpt_ras = false;
     1360          uint32_t have_upt_ras  = false;
     1361          {
     1362            LABEL("PREDICT - fill the queue");
     1363            uint32_t port = rand() % _param->_nb_inst_predict;
     1364           
     1365            LABEL("  * context : %d",context);
     1366            LABEL("  * port    : %d",port);
     1367           
     1368            for (uint32_t i=0; i<_param->_size_ufpt_queue[context]; i++)
     1369              {
     1370                request_t request;
     1371                request.context          = context;
     1372                request.address_src      = rand();
     1373                request.address_dest     = rand();                                   
     1374               
     1375                request.condition        = (rand()%2)?BRANCH_CONDITION_READ_STACK:BRANCH_CONDITION_FLAG_SET;
     1376
     1377                request.take             = 1;                                             
     1378                request.take_good        = 1;                                             
     1379                request.flag             = (request.condition == BRANCH_CONDITION_FLAG_SET)?request.take_good:(not request.take_good);
     1380                request.is_accurate      = false;
     1381                request.miss_ifetch      = false;
     1382                request.miss_decod       = false;
     1383                request.miss_commit      = false;
     1384                request.history          = i;                                             
     1385                request.ras_address      = rand();                                   
     1386                request.ras_index        = rand()%_param->_size_ras_index[context];
     1387                request.ufpt_ptr         = ufpt_top [context];
     1388//              request.upt_ptr;
     1389               
     1390                bool have_transaction = false;
     1391                do
     1392                  {
     1393                    in_PREDICT_VAL              [port]->write((rand()%100)<percent_transaction_predict);
     1394                    in_PREDICT_CONTEXT_ID       [port]->write(request.context     );
     1395                    in_PREDICT_BTB_ADDRESS_SRC  [port]->write(request.address_src );
     1396                    in_PREDICT_BTB_ADDRESS_DEST [port]->write(request.address_dest);
     1397                    in_PREDICT_BTB_CONDITION    [port]->write(request.condition   );
     1398                    in_PREDICT_BTB_LAST_TAKE    [port]->write(request.take        );
     1399                    in_PREDICT_BTB_IS_ACCURATE  [port]->write(request.is_accurate );
     1400                    in_PREDICT_DIR_HISTORY      [port]->write(request.history     );
     1401                    in_PREDICT_RAS_ADDRESS      [port]->write(request.ras_address );
     1402                    in_PREDICT_RAS_INDEX        [port]->write(request.ras_index   );
     1403                   
     1404                    if (_param->_have_port_depth)
     1405                    TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
     1406                    TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
     1407                   
     1408                    SC_START(0); // fct melay
     1409                   
     1410                    LABEL("PREDICT         [%d] %d - %d (accurate : %d).",
     1411                          port,
     1412                          in_PREDICT_VAL [port]->read(),
     1413                          out_PREDICT_ACK [port]->read(),
     1414                          in_PREDICT_BTB_IS_ACCURATE [port]->read());
     1415                   
     1416                    if (in_PREDICT_VAL [port]->read() and out_PREDICT_ACK [port]->read())
     1417                      {
     1418                        LABEL("PREDICT         [%d] - Transaction accepted",port);
     1419                        have_transaction = true;
     1420                       
     1421                        if (_param->_have_port_depth)
     1422                          TEST(Tprediction_ptr_t,out_PREDICT_UPDATE_PREDICTION_ID [port]->read(),ufpt_top [context]);
     1423                       
     1424                        ufpt_top [context] = (ufpt_top [context]+1)%_param->_size_ufpt_queue[context];
     1425                      }
     1426                   
     1427                    SC_START(1); // transition
     1428                   
     1429                  } while (not have_transaction);
     1430               
     1431                ufpt.push_back(request); // to update
     1432               
     1433                in_PREDICT_VAL [port]->write(0);
     1434               
     1435                if (_param->_have_port_depth)
     1436                  TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
     1437                TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
     1438              }
     1439          }
     1440       
     1441          {
     1442            LABEL("DECOD");
     1443            uint32_t port = rand() % _param->_nb_inst_decod;
     1444           
     1445            LABEL("  * context : %d",context);
     1446            LABEL("  * port    : %d",port);
     1447           
     1448            for (uint32_t i=0; i<_param->_size_ufpt_queue[context]; i++)
     1449              {
     1450                request_t request = ufpt.front();
     1451               
     1452                bool have_transaction = false;
     1453                do
     1454                  {
     1455                    in_DECOD_VAL                  [port]->write((rand()%100)<percent_transaction_decod);
     1456                    in_DECOD_CONTEXT_ID           [port]->write(request.context     );
     1457                    in_DECOD_BTB_ADDRESS_SRC      [port]->write(request.address_src );
     1458                    in_DECOD_BTB_ADDRESS_DEST     [port]->write(request.address_dest);
     1459                    in_DECOD_BTB_CONDITION        [port]->write(request.condition   );
     1460                    in_DECOD_BTB_LAST_TAKE        [port]->write(request.take        );
     1461                    in_DECOD_RAS_ADDRESS          [port]->write(request.ras_address );
     1462                    in_DECOD_RAS_INDEX            [port]->write(request.ras_index   );
     1463                    in_DECOD_UPDATE_PREDICTION_ID [port]->write(request.ufpt_ptr    );
     1464                    in_DECOD_MISS_IFETCH          [port]->write(request.miss_ifetch );
     1465                    in_DECOD_MISS_DECOD           [port]->write(request.miss_decod  );
     1466                    in_DECOD_IS_ACCURATE          [port]->write(request.is_accurate );
     1467         
     1468                    have_upt_ras |= (update_ras(request.condition));
     1469         
     1470                    SC_START(0); // fct melay
     1471                   
     1472                    LABEL("DECOD           [%d] %d - %d",
     1473                          port,
     1474                          in_PREDICT_VAL [port]->read(),
     1475                          out_PREDICT_ACK [port]->read());
     1476                   
     1477                    if (in_DECOD_VAL [port]->read() and out_DECOD_ACK [port]->read())
     1478                      {
     1479                        LABEL("DECOD          [%d] - Transaction accepted",port);
     1480                        have_transaction = true;
     1481                       
     1482                        request.upt_ptr = upt_top [context];
     1483                        upt.push_back(request);
     1484                        ufpt.pop_front();
     1485                       
     1486                        upt_top [context] = (upt_top [context]+1)%_param->_size_upt_queue[context];
     1487                      }
     1488                   
     1489                    SC_START(1); // transition
     1490                   
     1491                  } while (not have_transaction);
     1492               
     1493                in_DECOD_VAL              [port]->write(0);
     1494               
     1495                if (_param->_have_port_depth)
     1496                  TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
     1497                TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
     1498              }
     1499          }
     1500
     1501          {
     1502            LABEL("PREDICT - fill the queue");
     1503            uint32_t port = rand() % _param->_nb_inst_predict;
     1504           
     1505            LABEL("  * context : %d",context);
     1506            LABEL("  * port    : %d",port);
     1507           
     1508            for (uint32_t i=0; i<_param->_size_ufpt_queue[context]; i++)
     1509              {
     1510                request_t request;
     1511                request.context          = context;
     1512                request.address_src      = rand();
     1513                request.address_dest     = rand();                                   
     1514                request.address_good     = request.address_dest;
     1515                request.condition        = (rand()%2)?BRANCH_CONDITION_NONE_WITH_WRITE_STACK:BRANCH_CONDITION_FLAG_SET;
     1516               
     1517                have_ufpt_ras |= (update_ras(request.condition));
     1518               
     1519                request.take             = 1;                                             
     1520                request.take_good        = 1;                                             
     1521                request.flag             = (request.condition == BRANCH_CONDITION_FLAG_SET)?request.take_good:(not request.take_good);
     1522                request.is_accurate      = false;
     1523                request.miss_ifetch      = false;
     1524                request.miss_decod       = false;
     1525                request.miss_commit      = true;
     1526                request.history          = i;                                             
     1527                request.ras_address      = rand();                                   
     1528                request.ras_index        = rand()%_param->_size_ras_index[context];
     1529                request.ufpt_ptr         = ufpt_top [context];
     1530//              request.upt_ptr;
     1531               
     1532                bool have_transaction = false;
     1533                do
     1534                  {
     1535                    in_PREDICT_VAL              [port]->write((rand()%100)<percent_transaction_predict);
     1536                    in_PREDICT_CONTEXT_ID       [port]->write(request.context     );
     1537                    in_PREDICT_BTB_ADDRESS_SRC  [port]->write(request.address_src );
     1538                    in_PREDICT_BTB_ADDRESS_DEST [port]->write(request.address_dest);
     1539                    in_PREDICT_BTB_CONDITION    [port]->write(request.condition   );
     1540                    in_PREDICT_BTB_LAST_TAKE    [port]->write(request.take        );
     1541                    in_PREDICT_BTB_IS_ACCURATE  [port]->write(request.is_accurate );
     1542                    in_PREDICT_DIR_HISTORY      [port]->write(request.history     );
     1543                    in_PREDICT_RAS_ADDRESS      [port]->write(request.ras_address );
     1544                    in_PREDICT_RAS_INDEX        [port]->write(request.ras_index   );
     1545                   
     1546                    if (_param->_have_port_depth)
     1547                    TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
     1548                    TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
     1549                   
     1550                    SC_START(0); // fct melay
     1551                   
     1552                    LABEL("PREDICT         [%d] %d - %d (accurate : %d).",
     1553                          port,
     1554                          in_PREDICT_VAL [port]->read(),
     1555                          out_PREDICT_ACK [port]->read(),
     1556                          in_PREDICT_BTB_IS_ACCURATE [port]->read());
     1557                   
     1558                    if (in_PREDICT_VAL [port]->read() and out_PREDICT_ACK [port]->read())
     1559                      {
     1560                        LABEL("PREDICT         [%d] - Transaction accepted",port);
     1561                        have_transaction = true;
     1562                       
     1563                        if (_param->_have_port_depth)
     1564                          TEST(Tprediction_ptr_t,out_PREDICT_UPDATE_PREDICTION_ID [port]->read(),ufpt_top [context]);
     1565                       
     1566                        ufpt_top [context] = (ufpt_top [context]+1)%_param->_size_ufpt_queue[context];
     1567                      }
     1568                   
     1569                    SC_START(1); // transition
     1570                   
     1571                  } while (not have_transaction);
     1572               
     1573                ufpt.push_back(request); // to update
     1574               
     1575                in_PREDICT_VAL [port]->write(0);
     1576               
     1577                if (_param->_have_port_depth)
     1578                  TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
     1579                TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
     1580              }
     1581          }
     1582
     1583          std::list<request_t>::iterator it_event;
     1584          {
     1585            LABEL("BRANCH_COMPLETE - hit ifetch");
     1586           
     1587            uint32_t port = rand() % _param->_nb_inst_branch_complete;
     1588           
     1589            LABEL("  * port    : %d",port);
     1590           
     1591            // middle
     1592            it_event = upt.begin();
     1593            for (uint32_t i=0; i < (upt.size()>>1); ++i)
     1594              it_event ++;
     1595
     1596            for (std::list<request_t>::iterator it_upt = it_event;
     1597                 it_upt != upt.end();
     1598                 ++it_upt)
     1599              it_upt->miss_commit = true;
     1600
     1601            if (update_ras(it_event->condition))
     1602              it_event->address_good = ~(it_event->address_dest);
     1603            else
     1604              {
     1605                it_event->address_good = it_event->address_dest;
     1606                it_event->flag         = not it_event->flag;
     1607                it_event->take_good    = not it_event->take_good;
     1608              }
     1609
     1610            event = *it_event;
     1611
     1612           
     1613//        for (uint32_t i=0; i<_param->_size_ufpt_queue[context]; i++)
     1614//        for (uint32_t i=0; i<upt.size(); i++)
     1615            // just one
     1616            {
     1617              bool have_transaction = false;
     1618             
     1619              do
     1620                {
     1621                  in_BRANCH_COMPLETE_VAL        [port]->write((rand()%100)<percent_transaction_branch_complete);
     1622                  in_BRANCH_COMPLETE_CONTEXT_ID [port]->write(it_event->context     );
     1623                  in_BRANCH_COMPLETE_DEPTH      [port]->write(it_event->upt_ptr     );
     1624                  in_BRANCH_COMPLETE_ADDRESS    [port]->write(it_event->address_good);
     1625                  in_BRANCH_COMPLETE_FLAG       [port]->write(it_event->flag        );
     1626
     1627                  if (_param->_have_port_depth)
     1628                  TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
     1629                  TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
     1630                 
     1631                  SC_START(0);
     1632                 
     1633                  LABEL("BRANCH_COMPLETE [%d] %d - %d.",port,in_BRANCH_COMPLETE_VAL [port]->read(),out_BRANCH_COMPLETE_ACK [port]->read());
     1634                 
     1635                  if (in_BRANCH_COMPLETE_VAL [port]->read() and out_BRANCH_COMPLETE_ACK [port]->read())
     1636                    {
     1637                      LABEL("BRANCH_COMPLETE [%d] - Transaction accepted",port);
     1638                      LABEL("  * CONTEXT_ID %d"  ,it_event->context     );
     1639                      LABEL("  * DEPTH      %d"  ,it_event->upt_ptr     );
     1640                      LABEL("  * CONDITION  %d"  ,it_event->condition   );
     1641                      LABEL("  * ADDRESS    %.8x",it_event->address_good);
     1642                      LABEL("  * FLAG       %d"  ,it_event->flag        );
     1643
     1644                      have_transaction = true;
     1645                     
     1646                      TEST(Tcontrol_t,out_BRANCH_COMPLETE_MISS_PREDICTION[port]->read(),it_event->miss_commit );
     1647                      TEST(Tcontrol_t,out_BRANCH_COMPLETE_TAKE           [port]->read(),it_event->take_good   );
     1648                      TEST(Taddress_t,out_BRANCH_COMPLETE_ADDRESS_SRC    [port]->read(),it_event->address_src );
     1649                      TEST(Taddress_t,out_BRANCH_COMPLETE_ADDRESS_DEST   [port]->read(),it_event->address_good);
     1650
     1651                      upt_top [it_event->context] = it_event->upt_ptr;
     1652                    }
     1653                 
     1654                  SC_START(1);
     1655                } while (not have_transaction);
     1656             
     1657              in_BRANCH_COMPLETE_VAL [port]->write(0);
     1658             
     1659              if (_param->_have_port_depth)
     1660              TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
     1661              TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
     1662            }
     1663          }
     1664         
     1665          if (have_ufpt_ras)
     1666            {
     1667              LABEL("UPDATE - Update UPFT");
     1668             
     1669              uint32_t port = 0;
     1670             
     1671              LABEL("  * port    : %d",port);
     1672              std::list<request_t>::iterator it_ufpt = ufpt.end();
     1673              -- it_ufpt;
     1674             
     1675              for (uint32_t i=0; i<_param->_size_ufpt_queue[context]; i++)
     1676                {
     1677                  bool have_transaction = false;
     1678                 
     1679                  do
     1680                    {
     1681                      in_UPDATE_ACK [port]->write((rand()%100)<percent_transaction_update);
     1682                     
     1683//                    if (_param->_have_port_depth)
     1684//                    TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), ufpt_bottom [context]);
     1685//                    TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), ufpt_top [context]);
     1686                 
     1687                      SC_START(0);
     1688                     
     1689                      LABEL("UPDATE [%d] %d - %d.",port,out_UPDATE_VAL [port]->read(),in_UPDATE_ACK [port]->read());
     1690                     
     1691                      if (out_UPDATE_VAL [port]->read() and in_UPDATE_ACK [port]->read())
     1692                        {
     1693                          LABEL("UPDATE [%d] - Transaction accepted",port);
     1694                          have_transaction = true;
     1695                         
     1696                          if (_param->_have_port_context_id)
     1697                          TEST(Tcontext_t         ,out_UPDATE_CONTEXT_ID            [port]->read(),it_ufpt->context);
     1698                          TEST(Tcontrol_t         ,out_UPDATE_MISS_PREDICTION       [port]->read(),(it_ufpt->miss_ifetch or
     1699                                                                                                    it_ufpt->miss_decod  or
     1700                                                                                                    it_ufpt->miss_commit ));
     1701//                        if (update_btb(it_ufpt->condition) or
     1702//                            update_dir(it_ufpt->condition))
     1703//                        TEST(Tcontrol_t         ,out_UPDATE_DIRECTION_GOOD        [port]->read(),it_ufpt->take_good);
     1704                          TEST(Tcontrol_t         ,out_UPDATE_BTB_VAL               [port]->read(),0);
     1705//                        if (update_btb(it_ufpt->condition))
     1706//                          {
     1707//                        TEST(Taddress_t         ,out_UPDATE_BTB_ADDRESS_SRC       [port]->read(),it_ufpt->address_src);
     1708//                        TEST(Taddress_t         ,out_UPDATE_BTB_ADDRESS_DEST      [port]->read(),it_ufpt->address_dest);
     1709//                        TEST(Tbranch_condition_t,out_UPDATE_BTB_CONDITION         [port]->read(),it_ufpt->condition);
     1710//                          }
     1711                          TEST(Tcontrol_t         ,out_UPDATE_DIR_VAL               [port]->read(),0);
     1712
     1713//                        if (update_dir(it_ufpt->condition))
     1714//                        if (_param->_have_port_history)
     1715//                        TEST(Thistory_t         ,out_UPDATE_DIR_HISTORY           [port]->read(),it_ufpt->history);
     1716//                        TEST(Tcontrol_t         ,out_UPDATE_RAS_VAL               [port]->read(),update_ras(it_ufpt->condition));
     1717                          if (update_ras(it_ufpt->condition))
     1718                            {
     1719//                            TEST(Tcontrol_t         ,out_UPDATE_RAS_FLUSH             [port]->read(),0);
     1720                              TEST(Tcontrol_t         ,out_UPDATE_RAS_PUSH              [port]->read(),push_ras  (it_ufpt->condition));
     1721                              TEST(Taddress_t         ,out_UPDATE_RAS_ADDRESS           [port]->read(),it_ufpt->ras_address);
     1722                              TEST(Tptr_t             ,out_UPDATE_RAS_INDEX             [port]->read(),it_ufpt->ras_index);
     1723                              TEST(Tcontrol_t         ,out_UPDATE_RAS_PREDICTION_IFETCH [port]->read(),not it_ufpt->miss_ifetch);
     1724                            }
     1725                        }
     1726                     
     1727                      SC_START(1);
     1728                    } while (not have_transaction);
     1729                 
     1730                  -- it_ufpt;
     1731                 
     1732                 
     1733                  in_UPDATE_ACK [port]->write(0);
     1734//                if (_param->_have_port_depth)
     1735//                TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), ufpt_bottom [context]);
     1736//                TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), ufpt_top [context]);
     1737                }
     1738            }
     1739          ufpt.clear();
     1740
     1741          {
     1742            LABEL("UPDATE - upt");
     1743           
     1744            uint32_t port = 0;
     1745           
     1746            LABEL("  * port    : %d",port);
     1747            std::list<request_t>::iterator it_upt = upt.end();
     1748            --it_upt;
     1749
     1750//             for (uint32_t i=0; i<upt.size(); i++)
     1751            while (it_upt != it_event)
     1752              {
     1753                bool have_transaction = false;
     1754               
     1755                do
     1756                  {
     1757                    in_UPDATE_ACK [port]->write((rand()%100)<percent_transaction_update);
     1758
     1759//                   if (_param->_have_port_depth)
     1760//                   TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
     1761//                   TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
     1762                 
     1763                    SC_START(0);
     1764                   
     1765                    LABEL("UPDATE [%d] %d - %d.",port,out_UPDATE_VAL [port]->read(),in_UPDATE_ACK [port]->read());
     1766                   
     1767                    if (out_UPDATE_VAL [port]->read() and in_UPDATE_ACK [port]->read())
     1768                      {
     1769                        LABEL("UPDATE [%d] - Transaction accepted",port);
     1770                        have_transaction = true;
     1771                       
     1772                        if (_param->_have_port_context_id)
     1773                        TEST(Tcontext_t         ,out_UPDATE_CONTEXT_ID            [port]->read(),it_upt->context);
     1774                        TEST(Tcontrol_t         ,out_UPDATE_MISS_PREDICTION       [port]->read(),it_upt->miss_commit);
     1775                        TEST(Tcontrol_t         ,out_UPDATE_DIRECTION_GOOD        [port]->read(),it_upt->take_good);
     1776                        TEST(Tcontrol_t         ,out_UPDATE_BTB_VAL               [port]->read(),update_btb(it_upt->condition));
     1777                        if (update_btb(it_upt->condition))
     1778                          {
     1779                        TEST(Taddress_t         ,out_UPDATE_BTB_ADDRESS_SRC       [port]->read(),it_upt->address_src);
     1780                        TEST(Taddress_t         ,out_UPDATE_BTB_ADDRESS_DEST      [port]->read(),it_upt->address_dest);
     1781                        TEST(Tbranch_condition_t,out_UPDATE_BTB_CONDITION         [port]->read(),it_upt->condition);
     1782                          }
     1783                        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));
     1784                       
     1785                        if (update_dir(it_upt->condition))
     1786                        if (_param->_have_port_history)
     1787                        TEST(Thistory_t         ,out_UPDATE_DIR_HISTORY           [port]->read(),it_upt->history);
     1788                        TEST(Tcontrol_t         ,out_UPDATE_RAS_VAL               [port]->read(),update_ras(it_upt->condition));
     1789                        if (update_ras(it_upt->condition))
     1790                          {
     1791//                      TEST(Tcontrol_t         ,out_UPDATE_RAS_FLUSH             [port]->read(),0);
     1792                        TEST(Tcontrol_t         ,out_UPDATE_RAS_PUSH              [port]->read(),push_ras  (it_upt->condition));
     1793                        TEST(Taddress_t         ,out_UPDATE_RAS_ADDRESS           [port]->read(),it_upt->ras_address);
     1794                        TEST(Tptr_t             ,out_UPDATE_RAS_INDEX             [port]->read(),it_upt->ras_index);
     1795                        TEST(Tcontrol_t         ,out_UPDATE_RAS_PREDICTION_IFETCH [port]->read(),not it_upt->miss_ifetch);
     1796                          }
     1797
     1798                        -- it_upt;
     1799                      }
     1800                   
     1801                    SC_START(1);
     1802                  } while (not have_transaction);
     1803             
     1804                upt.pop_back();
     1805                in_UPDATE_ACK [port]->write(0);
     1806//               if (_param->_have_port_depth)
     1807//               TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
     1808//               TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
     1809              }
     1810          }
     1811//           upt.clear(); // Not yet
     1812
     1813          {
     1814            LABEL("BRANCH_EVENT - have miss decod");
     1815           
     1816            uint32_t port = context;
     1817           
     1818            {
     1819              bool have_transaction = false;
     1820             
     1821              do
     1822                {
     1823                  in_BRANCH_EVENT_ACK [port]->write((rand()%100)<percent_transaction_branch_event);
     1824                 
     1825                  SC_START(0);
     1826                 
     1827                  LABEL("BRANCH_EVENT [%d] %d - %d.",port,out_BRANCH_EVENT_VAL [port]->read(),in_BRANCH_EVENT_ACK [port]->read());
     1828                 
     1829                  if (out_BRANCH_EVENT_VAL [port]->read() and in_BRANCH_EVENT_ACK [port]->read())
     1830                    {
     1831                      LABEL("BRANCH_EVENT [%d] - Transaction accepted",port);
     1832                      have_transaction = true;
     1833                     
     1834                      LABEL("  * event.address_src  : %.8x,",event.address_src );
     1835                      LABEL("  * event.address_good : %.8x,",event.address_good);
     1836                      LABEL("  * event.take         : %.8x,",event.take        );
     1837                     
     1838                      TEST(Taddress_t,out_BRANCH_EVENT_ADDRESS_SRC      [port]->read(),event.address_src);
     1839                      TEST(Tcontrol_t,out_BRANCH_EVENT_ADDRESS_DEST_VAL [port]->read(),event.take_good);
     1840                      if (event.take_good)
     1841                      TEST(Taddress_t,out_BRANCH_EVENT_ADDRESS_DEST     [port]->read(),event.address_good);
     1842                     
     1843                      event.address_src  = 0;
     1844                      event.take         = 0;
     1845                      event.address_dest = 0;
     1846                    }
     1847                 
     1848                  SC_START(1);
     1849                } while (not have_transaction);
     1850             
     1851              in_BRANCH_EVENT_ACK [port]->write(0);
     1852            }
     1853          }
     1854         
     1855          {
     1856            LABEL("UPDATE - upt");
     1857           
     1858            uint32_t port = 0;
     1859           
     1860            LABEL("  * port    : %d",port);
     1861            std::list<request_t>::iterator it_upt = upt.begin();
     1862
     1863            for (uint32_t i=0; i<upt.size(); i++)
     1864              {
     1865                bool have_transaction = false;
     1866               
     1867                do
     1868                  {
     1869                    in_UPDATE_ACK [port]->write((rand()%100)<percent_transaction_update);
     1870
     1871//                   if (_param->_have_port_depth)
     1872//                   TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
     1873//                   TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
     1874                 
     1875                    SC_START(0);
     1876                   
     1877                    LABEL("UPDATE [%d] %d - %d.",port,out_UPDATE_VAL [port]->read(),in_UPDATE_ACK [port]->read());
     1878                   
     1879                    if (out_UPDATE_VAL [port]->read() and in_UPDATE_ACK [port]->read())
     1880                      {
     1881                        LABEL("UPDATE [%d] - Transaction accepted",port);
     1882                        have_transaction = true;
     1883                       
     1884                        if (_param->_have_port_context_id)
     1885                        TEST(Tcontext_t         ,out_UPDATE_CONTEXT_ID            [port]->read(),it_upt->context);
     1886                        TEST(Tcontrol_t         ,out_UPDATE_MISS_PREDICTION       [port]->read(),it_upt->miss_commit);
     1887                        TEST(Tcontrol_t         ,out_UPDATE_DIRECTION_GOOD        [port]->read(),it_upt->take_good);
     1888                        TEST(Tcontrol_t         ,out_UPDATE_BTB_VAL               [port]->read(),update_btb(it_upt->condition));
     1889                        if (update_btb(it_upt->condition))
     1890                          {
     1891                        TEST(Taddress_t         ,out_UPDATE_BTB_ADDRESS_SRC       [port]->read(),it_upt->address_src);
     1892                        TEST(Taddress_t         ,out_UPDATE_BTB_ADDRESS_DEST      [port]->read(),it_upt->address_dest);
     1893                        TEST(Tbranch_condition_t,out_UPDATE_BTB_CONDITION         [port]->read(),it_upt->condition);
     1894                          }
     1895                        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));
     1896                       
     1897                        if (update_dir(it_upt->condition))
     1898                        if (_param->_have_port_history)
     1899                        TEST(Thistory_t         ,out_UPDATE_DIR_HISTORY           [port]->read(),it_upt->history);
     1900                        TEST(Tcontrol_t         ,out_UPDATE_RAS_VAL               [port]->read(),update_ras(it_upt->condition));
     1901                        if (update_ras(it_upt->condition))
     1902                          {
     1903//                      TEST(Tcontrol_t         ,out_UPDATE_RAS_FLUSH             [port]->read(),0);
     1904                        TEST(Tcontrol_t         ,out_UPDATE_RAS_PUSH              [port]->read(),push_ras  (it_upt->condition));
     1905                        TEST(Taddress_t         ,out_UPDATE_RAS_ADDRESS           [port]->read(),it_upt->ras_address);
     1906                        TEST(Tptr_t             ,out_UPDATE_RAS_INDEX             [port]->read(),it_upt->ras_index);
     1907                        TEST(Tcontrol_t         ,out_UPDATE_RAS_PREDICTION_IFETCH [port]->read(),not it_upt->miss_ifetch);
     1908                          }
     1909
     1910                        -- it_upt;
     1911                      }
     1912                   
     1913                    SC_START(1);
     1914                  } while (not have_transaction);
     1915               
     1916                in_UPDATE_ACK [port]->write(0);
     1917//               if (_param->_have_port_depth)
     1918//               TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
     1919//               TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
     1920              }
     1921          }
     1922          upt.clear(); // Not yet
     1923
     1924          // Wait Garbage Collector
     1925          {
     1926            upt_bottom [context] = (upt_bottom [context]+1)%_param->_size_upt_queue[context];
     1927//        upt_top    [context] = (upt_top    [context]);
     1928
     1929            while ((upt_bottom [context] != out_DEPTH_MIN [context]->read()) or
     1930                   (upt_top    [context] != out_DEPTH_MAX [context]->read()))
     1931              SC_START(1);
     1932           
     1933          }
     1934        }
     1935     
    5881936    }// ITERATION
    5891937
     
    6491997//   delete [] out_BRANCH_EVENT_MISS_PREDICTION;
    6501998  delete [] out_BRANCH_EVENT_ADDRESS_SRC    ;
     1999  delete [] out_BRANCH_EVENT_ADDRESS_DEST_VAL;
    6512000  delete [] out_BRANCH_EVENT_ADDRESS_DEST   ;
    6522001 
     
    6642013  delete [] out_UPDATE_DIR_HISTORY          ;
    6652014  delete [] out_UPDATE_RAS_VAL              ;
     2015  delete [] out_UPDATE_RAS_FLUSH            ;
    6662016  delete [] out_UPDATE_RAS_PUSH             ;
    6672017  delete [] out_UPDATE_RAS_ADDRESS          ;
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/include/Update_Prediction_Table.h

    r88 r94  
    120120//public    : SC_OUT(Tcontrol_t         )  ** out_BRANCH_EVENT_MISS_PREDICTION   ; //[nb_context] is always miss prediction
    121121  public    : SC_OUT(Taddress_t         )  ** out_BRANCH_EVENT_ADDRESS_SRC       ; //[nb_context]
     122  public    : SC_OUT(Tcontrol_t         )  ** out_BRANCH_EVENT_ADDRESS_DEST_VAL  ; //[nb_context]
    122123  public    : SC_OUT(Taddress_t         )  ** out_BRANCH_EVENT_ADDRESS_DEST      ; //[nb_context]
    123124
     
    135136  public    : SC_OUT(Thistory_t         )  ** out_UPDATE_DIR_HISTORY             ; //[nb_inst_update]
    136137  public    : SC_OUT(Tcontrol_t         )  ** out_UPDATE_RAS_VAL                 ; //[nb_inst_update]
     138  public    : SC_OUT(Tcontrol_t         )  ** out_UPDATE_RAS_FLUSH               ; //[nb_inst_update]
    137139  public    : SC_OUT(Tcontrol_t         )  ** out_UPDATE_RAS_PUSH                ; //[nb_inst_update]
    138140  public    : SC_OUT(Taddress_t         )  ** out_UPDATE_RAS_ADDRESS             ; //[nb_inst_update]
    139141  public    : SC_OUT(Tptr_t             )  ** out_UPDATE_RAS_INDEX               ; //[nb_inst_update]
    140142  public    : SC_OUT(Tcontrol_t         )  ** out_UPDATE_RAS_PREDICTION_IFETCH   ; //[nb_inst_update]
     143
     144    // ~~~~~[ Interface : "event" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     145  public    : SC_IN (Tevent_state_t     )  **  in_EVENT_STATE                    ; //[nb_context]
     146  public    : SC_IN (Tevent_type_t      )  **  in_EVENT_TYPE                     ; //[nb_context]
     147  public    : SC_IN (Tdepth_t           )  **  in_EVENT_DEPTH                    ; //[nb_context]
    141148
    142149    // ~~~~~[ Interface : "depth" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     
    164171  private   : uint32_t                      * reg_UPT_TOP                        ; //[nb_context]
    165172  private   : uint32_t                      * reg_UPT_UPDATE                     ; //[nb_context]
    166   private   : uint32_t                      * reg_UPT_NB_NEED_UPDATE             ; //[nb_context]
    167173                                                                                             
    168174  private   : bool                          * reg_IS_ACCURATE                    ; //[nb_context]
    169175
    170176  private   : event_state_t                 * reg_EVENT_STATE                    ; //[nb_context]
    171   private   : Tcontrol_t                    * reg_EVENT_RAS_CORRUPTED            ; //[nb_context] // RAS must be flush
    172177  private   : Taddress_t                    * reg_EVENT_ADDRESS_SRC              ; //[nb_context] // Address branch
    173   private   : Tcontrol_t                    * reg_EVENT_ADDRESS_SRC_VAL          ; //[nb_context] // if miss ifetch, decod issue branch, dest must be reload
     178  private   : Tcontrol_t                    * reg_EVENT_ADDRESS_DEST_VAL         ; //[nb_context] // if miss ifetch, decod issue branch, dest must be reload
    174179  private   : Taddress_t                    * reg_EVENT_ADDRESS_DEST             ; //[nb_context] // Address dest
    175180
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_allocation.cpp

    r88 r94  
    114114      ALLOC1_INTERFACE("branch_event", IN,SOUTH, "branch_event", _param->_nb_context);
    115115     
    116       ALLOC1_VALACK_OUT(out_BRANCH_EVENT_VAL            ,VAL);
    117       ALLOC1_VALACK_IN ( in_BRANCH_EVENT_ACK            ,ACK);
    118 //    ALLOC1_SIGNAL_OUT(out_BRANCH_EVENT_CONTEXT_ID     ,"context_id"     ,Tcontext_t,_param->_size_context_id);
    119 //    ALLOC1_SIGNAL_OUT(out_BRANCH_EVENT_DEPTH          ,"depth"          ,Tdepth_t  ,_param->_size_depth);
    120 //    ALLOC1_SIGNAL_OUT(out_BRANCH_EVENT_MISS_PREDICTION,"miss_prediction",Tcontrol_t,1);
    121       ALLOC1_SIGNAL_OUT(out_BRANCH_EVENT_ADDRESS_SRC    ,"address_src"    ,Taddress_t,_param->_size_instruction_address);
    122       ALLOC1_SIGNAL_OUT(out_BRANCH_EVENT_ADDRESS_DEST   ,"address_dest"   ,Taddress_t,_param->_size_instruction_address);
     116      ALLOC1_VALACK_OUT(out_BRANCH_EVENT_VAL              ,VAL);
     117      ALLOC1_VALACK_IN ( in_BRANCH_EVENT_ACK              ,ACK);
     118//    ALLOC1_SIGNAL_OUT(out_BRANCH_EVENT_CONTEXT_ID       ,"context_id"      ,Tcontext_t,_param->_size_context_id);
     119//    ALLOC1_SIGNAL_OUT(out_BRANCH_EVENT_DEPTH            ,"depth"           ,Tdepth_t  ,_param->_size_depth);
     120//    ALLOC1_SIGNAL_OUT(out_BRANCH_EVENT_MISS_PREDICTION  ,"miss_prediction" ,Tcontrol_t,1);
     121      ALLOC1_SIGNAL_OUT(out_BRANCH_EVENT_ADDRESS_SRC      ,"address_src"     ,Taddress_t,_param->_size_instruction_address);
     122      ALLOC1_SIGNAL_OUT(out_BRANCH_EVENT_ADDRESS_DEST_VAL ,"address_dest_val",Tcontrol_t,1);
     123      ALLOC1_SIGNAL_OUT(out_BRANCH_EVENT_ADDRESS_DEST     ,"address_dest"    ,Taddress_t,_param->_size_instruction_address);
    123124    }
    124125
     
    139140      ALLOC1_SIGNAL_OUT(out_UPDATE_DIR_HISTORY          ,"dir_history"          ,Thistory_t         ,_param->_size_history);
    140141      ALLOC1_SIGNAL_OUT(out_UPDATE_RAS_VAL              ,"ras_val"              ,Tcontrol_t         ,1);
     142      ALLOC1_SIGNAL_OUT(out_UPDATE_RAS_FLUSH            ,"ras_flush"            ,Tcontrol_t         ,1);
    141143      ALLOC1_SIGNAL_OUT(out_UPDATE_RAS_PUSH             ,"ras_push"             ,Tcontrol_t         ,1);
    142144      ALLOC1_SIGNAL_OUT(out_UPDATE_RAS_ADDRESS          ,"ras_address"          ,Taddress_t         ,_param->_size_instruction_address);
    143145      ALLOC1_SIGNAL_OUT(out_UPDATE_RAS_INDEX            ,"ras_index"            ,Tptr_t             ,_param->_max_size_ras_index);
    144146      ALLOC1_SIGNAL_OUT(out_UPDATE_RAS_PREDICTION_IFETCH,"ras_prediction_ifetch",Tcontrol_t         ,1);
     147    }
     148
     149    // ~~~~~[ Interface : "event" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     150    {
     151      ALLOC1_INTERFACE("event", IN,SOUTH,"event", _param->_nb_context);
     152
     153      ALLOC1_SIGNAL_IN ( in_EVENT_STATE  ,"state",Tevent_state_t,_param->_size_event_state);
     154      ALLOC1_SIGNAL_IN ( in_EVENT_TYPE   ,"type" ,Tevent_type_t ,_param->_size_event_type );
     155      ALLOC1_SIGNAL_IN ( in_EVENT_DEPTH  ,"depth",Tdepth_t      ,_param->_size_depth      );
    145156    }
    146157
     
    187198    ALLOC1(reg_UPT_TOP                      ,uint32_t     ,_param->_nb_context);
    188199    ALLOC1(reg_UPT_UPDATE                   ,uint32_t     ,_param->_nb_context);
    189     ALLOC1(reg_UPT_NB_NEED_UPDATE           ,uint32_t     ,_param->_nb_context);
    190200
    191201    ALLOC1(reg_EVENT_STATE                  ,event_state_t,_param->_nb_context);
    192     ALLOC1(reg_EVENT_RAS_CORRUPTED          ,Tcontrol_t   ,_param->_nb_context);
    193202    ALLOC1(reg_EVENT_ADDRESS_SRC            ,Taddress_t   ,_param->_nb_context);
    194     ALLOC1(reg_EVENT_ADDRESS_SRC_VAL        ,Tcontrol_t   ,_param->_nb_context);
     203    ALLOC1(reg_EVENT_ADDRESS_DEST_VAL       ,Tcontrol_t   ,_param->_nb_context);
    195204    ALLOC1(reg_EVENT_ADDRESS_DEST           ,Taddress_t   ,_param->_nb_context);
    196205      }
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_deallocation.cpp

    r88 r94  
    8888//      delete [] out_BRANCH_EVENT_MISS_PREDICTION;
    8989        delete [] out_BRANCH_EVENT_ADDRESS_SRC    ;
     90        delete [] out_BRANCH_EVENT_ADDRESS_DEST_VAL;
    9091        delete [] out_BRANCH_EVENT_ADDRESS_DEST   ;
    9192       
     
    105106        delete [] out_UPDATE_DIR_HISTORY          ;
    106107        delete [] out_UPDATE_RAS_VAL              ;
     108        delete [] out_UPDATE_RAS_FLUSH            ;
    107109        delete [] out_UPDATE_RAS_PUSH             ;
    108110        delete [] out_UPDATE_RAS_ADDRESS          ;
    109111        delete [] out_UPDATE_RAS_INDEX            ;
    110112        delete [] out_UPDATE_RAS_PREDICTION_IFETCH;
     113
     114        // ~~~~~[ Interface : "event" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     115        DELETE1_SIGNAL( in_EVENT_STATE  ,_param->_nb_context,_param->_size_event_state);
     116        DELETE1_SIGNAL( in_EVENT_TYPE   ,_param->_nb_context,_param->_size_event_type );
     117        DELETE1_SIGNAL( in_EVENT_DEPTH  ,_param->_nb_context,_param->_size_depth      );
    111118
    112119        // ~~~~~[ Interface : "depth" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     
    149156        DELETE1(reg_UPT_TOP                      ,_param->_nb_context);
    150157        DELETE1(reg_UPT_UPDATE                   ,_param->_nb_context);
    151         DELETE1(reg_UPT_NB_NEED_UPDATE           ,_param->_nb_context);
    152158       
    153159        DELETE1(reg_EVENT_STATE                  ,_param->_nb_context);
    154         DELETE1(reg_EVENT_RAS_CORRUPTED          ,_param->_nb_context);
    155160        DELETE1(reg_EVENT_ADDRESS_SRC            ,_param->_nb_context);
    156         DELETE1(reg_EVENT_ADDRESS_SRC_VAL        ,_param->_nb_context);
     161        DELETE1(reg_EVENT_ADDRESS_DEST_VAL       ,_param->_nb_context);
    157162        DELETE1(reg_EVENT_ADDRESS_DEST           ,_param->_nb_context);
    158163       }
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_genMealy_branch_complete.cpp

    r88 r94  
    6161              //miss      : always hit
    6262              //addr_dest : compute in decod stage
     63              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * BRANCH_CONDITION_NONE_WITHOUT_WRITE_STACK");
     64              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * BRANCH_CONDITION_NONE_WITH_WRITE_STACK   ");
    6365
    6466#ifdef DEBUG_TEST
     
    7577              //addr_dest : compute in decod stage
    7678              //miss if the direction is bad
     79              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * BRANCH_CONDITION_FLAG_UNSET");
     80
    7781              Tcontrol_t take_good = not flag; // flag set = not take
    7882
     
    9195              //addr_dest : compute in decod stage
    9296              //miss if the direction is bad
     97              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * BRANCH_CONDITION_FLAG_SET");
     98
    9399              Tcontrol_t take_good = flag; // flag set = take
    94100
     
    107113          case BRANCH_CONDITION_READ_STACK                        : // l.jr (rb==r9)
    108114            {
     115              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * BRANCH_CONDITION_READ_REGISTER_WITHOUT_WRITE_STACK");
     116              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * BRANCH_CONDITION_READ_REGISTER_WITH_WRITE_STACK   ");
     117              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * BRANCH_CONDITION_READ_STACK                       ");
     118
    109119              // miss if destination address is bad
    110120              miss      = (addr_dest != addr_good);
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_genMoore.cpp

    r88 r94  
    2424    log_begin(Update_Prediction_Table,FUNCTION);
    2525    log_function(Update_Prediction_Table,FUNCTION,_name.c_str());
    26     log_printf(NONE,Update_Prediction_Table,FUNCTION,FUNCTION);
    2726
    2827    if (PORT_READ(in_NRESET) == 1)
     
    8786        Thistory_t          dir_history          ;
    8887        Tcontrol_t          ras_val              ;
     88        Tcontrol_t          ras_flush            ;
    8989        Tcontrol_t          ras_push             ;
    9090        Taddress_t          ras_address          ;
     
    110110               
    111111                val                   = (state == UPDATE_FETCH_PREDICTION_STATE_EVENT);
     112//              val_without_ack       = not update_ras(condition);
     113
    112114                miss_prediction       = 1;
    113115//              direction_good        = ;
     
    119121//              dir_history           = ;
    120122                ras_val               = update_ras(condition); // repop/ repush data -> don't corrupt ras
     123                ras_flush             = 0;
    121124                ras_push              = push_ras(condition);
    122125                ras_address           = reg_UPDATE_FETCH_PREDICTION_TABLE [context][depth]._address_ras;
     
    132135                  ufpt_update [context] = false;
    133136               
    134                 tab_ufpt_depth[context] = (depth==0)?(_param->_size_ufpt_queue[context]-1):(depth-1);
     137                tab_ufpt_depth[context] = ((depth==0)?_param->_size_ufpt_queue[context]:depth)-1;
    135138              }
    136139          }
     
    177180                dir_history           = reg_UPDATE_PREDICTION_TABLE [context][depth]._history     ;
    178181                ras_val               = update_ras(condition); // repop/ repush data -> don't corrupt ras
     182                ras_flush             = (state == UPDATE_PREDICTION_STATE_KO); // miss prediction, RAS is corrupted
    179183                ras_push              = push_ras(condition);
    180184                ras_address           = reg_UPDATE_PREDICTION_TABLE [context][depth]._address_ras;
     
    224228        PORT_WRITE(out_UPDATE_BTB_VAL               [i],btb_val              );
    225229        PORT_WRITE(out_UPDATE_BTB_ADDRESS_SRC       [i],btb_address_src      );
    226 
    227         log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * address_src     : %.8x",btb_address_src);
    228 
    229230        PORT_WRITE(out_UPDATE_BTB_ADDRESS_DEST      [i],btb_address_dest     );
    230231        PORT_WRITE(out_UPDATE_BTB_CONDITION         [i],btb_condition        );
     
    233234        PORT_WRITE(out_UPDATE_DIR_HISTORY           [i],dir_history          );
    234235        PORT_WRITE(out_UPDATE_RAS_VAL               [i],ras_val              );
     236        PORT_WRITE(out_UPDATE_RAS_FLUSH             [i],ras_flush            );
    235237        PORT_WRITE(out_UPDATE_RAS_PUSH              [i],ras_push             );
    236238        PORT_WRITE(out_UPDATE_RAS_ADDRESS           [i],ras_address          );
     
    239241          }
    240242      }
    241 
    242 //     // ===================================================================
    243 //     // =====[ BRANCH_EVENT ]==============================================
    244 //     // ===================================================================
    245 //     for (uint32_t i=0; i<_param->_nb_context; i++)
    246 //       {
    247 //      Tdepth_t   depth   = (reg_BOTTOM [i] + reg_NB_ELT_UPDATE [i])%_param->_size_queue [i];
    248 //      state_t    state   = reg_UPDATE_PREDICTION_TABLE [i][depth]._state;
    249        
    250 //      Tcontrol_t val     = ((state == UPDATE_PREDICTION_STATE_EVENT) or
    251 //                               (state == UPDATE_PREDICTION_STATE_WAITEND_AND_EVENT));
    252 
    253 //      if (val)
    254 //        {
    255 // //          breakpoint ("UPT : have an branch_event (depth %d)",depth);
    256 //          PORT_WRITE(out_BRANCH_EVENT_ADDRESS_SRC  [i], reg_UPDATE_PREDICTION_TABLE [i][depth]._address_src );
    257 //          PORT_WRITE(out_BRANCH_EVENT_ADDRESS_DEST [i], reg_UPDATE_PREDICTION_TABLE [i][depth]._address_dest);
    258 //          internal_BRANCH_EVENT_DEPTH [i] = depth;
    259 //        }
    260 
    261 //      internal_BRANCH_EVENT_VAL   [i] = val;
    262 //      PORT_WRITE(out_BRANCH_EVENT_VAL [i], internal_BRANCH_EVENT_VAL [i]);
    263 //       }
    264 
    265       }
     243   
     244    // ===================================================================
     245    // =====[ BRANCH_EVENT ]==============================================
     246    // ===================================================================
     247    for (uint32_t i=0; i<_param->_nb_context; i++)
     248      {
     249        Tcontrol_t val = (reg_EVENT_STATE [i] == EVENT_STATE_UPDATE_CONTEXT);
     250
     251        PORT_WRITE(out_BRANCH_EVENT_VAL              [i],val);
     252        PORT_WRITE(out_BRANCH_EVENT_ADDRESS_SRC      [i],reg_EVENT_ADDRESS_SRC      [i]);
     253        PORT_WRITE(out_BRANCH_EVENT_ADDRESS_DEST_VAL [i],reg_EVENT_ADDRESS_DEST_VAL [i]);
     254        PORT_WRITE(out_BRANCH_EVENT_ADDRESS_DEST     [i],reg_EVENT_ADDRESS_DEST     [i]);
     255
     256        internal_BRANCH_EVENT_VAL [i] = val;
     257      }
     258      }
     259
    266260    log_end(Update_Prediction_Table,FUNCTION);
    267261  };
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_transition.cpp

    r88 r94  
    4545            reg_UPT_TOP              [i] = 0;
    4646            reg_UPT_UPDATE           [i] = 0;
    47             reg_UPT_NB_NEED_UPDATE   [i] = 0;
    4847                                                                                   
    4948            reg_IS_ACCURATE          [i] = true;
    50 
     49           
    5150            reg_EVENT_STATE          [i] = EVENT_STATE_OK;
    5251          }
     
    5453    else
    5554      {
     55        bool flush_UFPT [_param->_nb_context];
     56        for (uint32_t i=0; i<_param->_nb_context; i++)
     57          flush_UFPT [i] = false;
     58
    5659        // ===================================================================
    5760        // =====[ GARBAGE COLLECTOR ]=========================================
     
    166169              Tbranch_condition_t condition  ;
    167170              Tcontrol_t          is_accurate;
     171              Taddress_t          address_src   = PORT_READ(in_DECOD_BTB_ADDRESS_SRC  [i]);
     172              Taddress_t          address_dest  = PORT_READ(in_DECOD_BTB_ADDRESS_DEST [i]);
     173              Tcontrol_t          last_take     = PORT_READ(in_DECOD_BTB_LAST_TAKE    [i]);
    168174
    169175              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * DECOD[%d] - Accepted",i);
     
    176182                {
    177183                  // Have a miss !!!
     184#ifdef DEBUG_TEST
     185                  if (reg_EVENT_STATE [context] != EVENT_STATE_OK)
     186                    throw ERRORMORPHEO(FUNCTION,_("Decod : invalid event state."));
     187#endif
     188                 
     189                  if (reg_UFPT_NB_NEED_UPDATE [context] == 0)
     190                    {
     191                      // Change state
     192                      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_UPDATE_CONTEXT (decod - miss - no flush ufpt)",context);
     193                      reg_EVENT_STATE [context] = EVENT_STATE_UPDATE_CONTEXT;
     194                    }
     195                  else
     196                    {
     197                      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_FLUSH_UFPT (decod - miss - flush ufpt)",context);
     198                      reg_EVENT_STATE [context] = EVENT_STATE_FLUSH_UFPT;
     199                    }
    178200
    179201                  // Flush UPFT
    180 
    181                   // It's to accelerate miss speculation
    182                   if (reg_UFPT_NB_NEED_UPDATE [context] == 0)
    183                     {
    184                       // No entry need prediction, flush all entry -> Reset
    185                       for (uint32_t j=0; j<_param->_size_ufpt_queue[context]; ++j)
    186                         reg_UPDATE_FETCH_PREDICTION_TABLE [context][j]._state = UPDATE_FETCH_PREDICTION_STATE_EMPTY;
    187                       reg_UFPT_BOTTOM [context] = 0;
    188                       reg_UFPT_TOP    [context] = 0;
    189 //                    reg_UFPT_UPDATE [context] = 0;
    190                     }
    191                   else
    192                     {
    193                       reg_UFPT_UPDATE [context] = reg_UFPT_TOP [context];
    194 
    195 #ifdef DEBUG_TEST
    196                       if (reg_EVENT_STATE [context] == EVENT_STATE_OK)
    197                         throw ERRORMORPHEO(FUNCTION,_("Decod : invalid event state."));
    198 #endif
    199                      
    200                       // Change state
    201                       log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_FLUSH_UFPT (decod - miss)",context);
    202                      
    203                       reg_EVENT_STATE [context] = EVENT_STATE_FLUSH_UFPT;
    204                     }
     202                  flush_UFPT [context] = true;
     203
     204                  reg_EVENT_ADDRESS_SRC     [context] = address_src; // delay_slot is compute in Context_State
     205                  reg_EVENT_ADDRESS_DEST_VAL[context] = last_take;
     206                  reg_EVENT_ADDRESS_DEST    [context] = address_dest;
    205207
    206208                  // Push upt (from decod interface)
     
    209211
    210212                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._condition         = condition;
    211                   reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._address_src       = PORT_READ(in_DECOD_BTB_ADDRESS_SRC  [i]);
    212                   reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._address_dest      = PORT_READ(in_DECOD_BTB_ADDRESS_DEST [i]);
    213                   reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._last_take         = PORT_READ(in_DECOD_BTB_LAST_TAKE    [i]);
     213                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._address_src       = address_src ;
     214                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._address_dest      = address_dest;
     215                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._last_take         = last_take   ;
    214216//                reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._good_take;
    215217                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._is_accurate       = is_accurate;
     
    277279              reg_UPT_TOP     [context] = (upt_ptr_write+1)%_param->_size_upt_queue [context];
    278280//            reg_UPT_UPDATE  [context] = reg_UPT_TOP [context];
    279               if (need_update(condition))
    280                 {
    281                   reg_UPT_NB_NEED_UPDATE  [context] ++;
    282                 }
    283281            }
    284282
     
    296294              Tcontext_t context = (_param->_have_port_context_id)?PORT_READ(in_BRANCH_COMPLETE_CONTEXT_ID [i]):0;
    297295              Tdepth_t   depth   = (_param->_have_port_depth     )?PORT_READ(in_BRANCH_COMPLETE_DEPTH      [i]):0;
     296              Tcontrol_t miss      = internal_BRANCH_COMPLETE_MISS_PREDICTION [i];
     297              Tcontrol_t good_take = internal_BRANCH_COMPLETE_TAKE            [i];
     298              Taddress_t good_addr = internal_BRANCH_COMPLETE_ADDRESS_DEST    [i];
    298299
    299300              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * BRANCH_COMPLETE[%d] - Accepted",i);
    300301              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * context : %d",context);
    301302              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * depth   : %d",depth);
    302               log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * miss    : %d",internal_BRANCH_COMPLETE_MISS_PREDICTION [i]);
     303              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * miss    : %d",miss);
    303304             
    304               if (internal_BRANCH_COMPLETE_MISS_PREDICTION [i])
     305              if (miss)
    305306                {
    306                   // Miss case
    307 // //                breakpoint("Branch_complete and miss ...");
    308 
    309 //                   log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * state [%d][%d] <- UPDATE_PREDICTION_STATE_EVENT (branch_complete)",context,depth);
    310 //                reg_UPDATE_PREDICTION_TABLE [context][depth]._state = UPDATE_PREDICTION_STATE_EVENT;
    311 
    312 //                // Another prediction (prediction with depth higer)
    313 //                Tdepth_t top                = reg_TOP [context];
    314 //                uint32_t nb_elt_miss        = ((top> depth)?top:(top+_param->_size_queue[context]))-depth;
    315 //                uint32_t nb_elt_need_update = 1;
    316 //                for (uint32_t j=1; j<nb_elt_miss; j++)
    317 //                  {
    318 //                    uint32_t k=(depth+j)%_param->_size_queue[context];
    319                      
    320 //                    // Ifetch have make a prediction and it's a miss
    321 //                    // When ifetch predict :
    322 //                    //   * btb is not change       -> needn't update
    323 //                    //   * direction is not change -> needn't update
    324 //                    //   * ras have change         -> need    update
    325 
    326 //                    Tbranch_condition_t cond = reg_UPDATE_PREDICTION_TABLE [context][k]._condition;
    327 //                    if ((cond == BRANCH_CONDITION_NONE_WITH_WRITE_STACK) or
    328 //                        (cond == BRANCH_CONDITION_READ_REGISTER_WITH_WRITE_STACK) or
    329 //                        (cond == BRANCH_CONDITION_READ_STACK))
    330 //                      {
    331 //                           log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * state [%d][%d] <- UPDATE_PREDICTION_STATE_KO (branch_complete, ifetch miss, update ras)",context,k);
    332 
    333 //                        nb_elt_need_update ++;
    334 //                        reg_UPDATE_PREDICTION_TABLE [context][k]._state = UPDATE_PREDICTION_STATE_KO;
    335 //                      }
    336 //                    else
    337 //                      {
    338 //                           log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * state [%d][%d] <- UPDATE_PREDICTION_STATE_END (branch_complete, ifetch miss, don't update ras)",context,k);
    339 
    340 //                        reg_UPDATE_PREDICTION_TABLE [context][k]._state = UPDATE_PREDICTION_STATE_END;
    341 //                      }
    342 //                  }
    343 //                reg_NB_ELT_NEED_UPDATE [context] += nb_elt_need_update;
    344 
    345 //                // Update pointer :
    346 //                reg_TOP                [context]  = depth;
    347 //                reg_NB_ELT             [context] -= nb_elt_miss;
    348 //            reg_UPDATE_PREDICTION_TABLE [context][depth]._address_dest = internal_BRANCH_COMPLETE_ADDRESS_DEST [i];
    349 
     307                  // Have a miss !!!
     308                  // Flush UPFT
     309                  flush_UFPT [context] = true;
     310                 
     311                  // Flush UPT
     312                  uint32_t top        = reg_UPT_TOP [context];
     313                  uint32_t new_update = ((top==0)?_param->_size_upt_queue[context]:top)-1;
     314                  for (uint32_t j=(depth+1)%_param->_size_upt_queue[context];
     315                                j!=top;
     316                                j=(j+1)%_param->_size_upt_queue[context])
     317                    reg_UPDATE_PREDICTION_TABLE [context][j]._state = UPDATE_PREDICTION_STATE_EVENT;
     318                 
     319                  // TOP is next write slot : last slot is TOP-1
     320                  reg_UPT_UPDATE [context] = new_update;
     321                 
     322//                reg_UPT_BOTTOM [context];
     323                  reg_UPT_TOP    [context] = depth;
     324
     325#ifdef DEBUG_TEST
     326                  if (reg_UPDATE_PREDICTION_TABLE [context][depth]._state != UPDATE_PREDICTION_STATE_WAIT_END)
     327                    throw ERRORMORPHEO(FUNCTION,_("Branch complete : invalid upt state."));
     328#endif
     329                 
     330                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT  [%d][%d].state <- UPDATE_PREDICTION_STATE_KO (branch_complete, ifetch hit)",context,depth);
     331                  reg_UPDATE_PREDICTION_TABLE [context][depth]._state = UPDATE_PREDICTION_STATE_KO;
     332                 
     333
     334                  Taddress_t          address_src = reg_UPDATE_PREDICTION_TABLE [context][depth]._address_src;
     335
     336                  if (reg_UFPT_NB_NEED_UPDATE [context] > 0)
     337                    {
     338                      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_FLUSH_UFPT_AND_UPT (branch_complete - miss)",context);
     339                      reg_EVENT_STATE [context] = EVENT_STATE_FLUSH_UFPT_AND_UPT;
     340                    }
     341                  else
     342                    {
     343                      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_FLUSH_UFPT_RAS (branch_complete - miss)",context);
     344                      // have ras prediction ?
     345                      reg_EVENT_STATE [context] = (new_update!=depth)?EVENT_STATE_FLUSH_UPT_RAS:EVENT_STATE_UPDATE_CONTEXT;
     346                    }
     347
     348                  reg_EVENT_ADDRESS_SRC     [context] = address_src; // delay_slot is compute in Context_State
     349                  reg_EVENT_ADDRESS_DEST_VAL[context] = good_take;
     350                  reg_EVENT_ADDRESS_DEST    [context] = good_addr;
    350351                }
    351352              else
     
    363364
    364365              // In all case : update good_take
    365               reg_UPDATE_PREDICTION_TABLE [context][depth]._good_take = internal_BRANCH_COMPLETE_TAKE [i];
     366              reg_UPDATE_PREDICTION_TABLE [context][depth]._good_take = good_take;
    366367            }
    367368
     
    381382              if (internal_UPDATE_FROM_UFPT [i])
    382383                {
     384                // if free a slot, also all queue is updated
     385                // Last slot ?
     386                if (reg_UFPT_UPDATE [context] == reg_UFPT_BOTTOM [context])
     387                  switch (reg_EVENT_STATE [context])
     388                    {
     389                    case EVENT_STATE_FLUSH_UFPT         : reg_EVENT_STATE [context] = EVENT_STATE_UPDATE_CONTEXT; break;
     390                    case EVENT_STATE_FLUSH_UFPT_AND_UPT : reg_EVENT_STATE [context] = (reg_UPT_UPDATE[context]!=reg_UPT_TOP[context])?EVENT_STATE_FLUSH_UPT_RAS:EVENT_STATE_UPDATE_CONTEXT;  break;
     391                    default : break;
     392                    }
     393               
    383394                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * Update Fetch Prediction Table");
    384395                 
     
    393404                  reg_UPDATE_FETCH_PREDICTION_TABLE [context][depth]._state = UPDATE_FETCH_PREDICTION_STATE_END;
    394405
     406
    395407                  // Update pointer
    396                   reg_UFPT_UPDATE [context] = (depth==0)?(_param->_size_ufpt_queue[context]-1):(depth-1);
    397 
     408                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_UFPT_UPDATE (before) : %d",reg_UFPT_UPDATE [context]);
     409                  reg_UFPT_UPDATE [context] = ((depth==0)?_param->_size_ufpt_queue[context]:depth)-1;
     410                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_UFPT_UPDATE (after ) : %d",reg_UFPT_UPDATE [context]);
    398411                  // Free a register that need update ?
    399412                  if (need_update(reg_UPDATE_FETCH_PREDICTION_TABLE [context][depth]._condition))
     
    405418                 
    406419                  // Change state
    407 #ifdef DEBUG_TEST
    408                   if ((reg_UPDATE_PREDICTION_TABLE [context][depth]._state != UPDATE_PREDICTION_STATE_OK   ) and
    409                       (reg_UPDATE_PREDICTION_TABLE [context][depth]._state != UPDATE_PREDICTION_STATE_KO   ) and
    410                       (reg_UPDATE_PREDICTION_TABLE [context][depth]._state != UPDATE_PREDICTION_STATE_EVENT))
    411                     throw ERRORMORPHEO(FUNCTION,_("Update : invalid upt state."));
     420#ifdef DEBUG_TEST
     421                  if (internal_UPDATE_RAS [i])
     422                    {
     423                      if (reg_UPDATE_PREDICTION_TABLE [context][depth]._state != UPDATE_PREDICTION_STATE_EVENT)
     424                        throw ERRORMORPHEO(FUNCTION,_("Update : invalid upt state."));
     425                    }
     426                  else
     427                    {
     428                      if ((reg_UPDATE_PREDICTION_TABLE [context][depth]._state != UPDATE_PREDICTION_STATE_OK   ) and
     429                          (reg_UPDATE_PREDICTION_TABLE [context][depth]._state != UPDATE_PREDICTION_STATE_KO   ))
     430                        throw ERRORMORPHEO(FUNCTION,_("Update : invalid upt state."));
     431                    }
    412432#endif
    413433
     
    417437
    418438                  // Update pointer
     439                  bool end_event = (reg_UPT_UPDATE [context] == reg_UPT_TOP [context]);
     440
    419441                  if (internal_UPDATE_RAS [i])
    420                     reg_UPT_UPDATE [context] = (depth==0)?(_param->_size_upt_queue[context]-1):(depth-1);
     442                    {
     443                      reg_UPT_UPDATE [context] = (end_event)?reg_UPT_BOTTOM[context]:(((depth==0)?_param->_size_upt_queue[context]:depth)-1);
     444                    }
    421445                  else
    422                     reg_UPT_UPDATE [context] = (depth+1)%_param->_size_upt_queue[context];
    423 
    424                   // Free a register that need update ?
    425                   if (need_update(reg_UPDATE_PREDICTION_TABLE [context][depth]._condition))
    426                     reg_UPT_NB_NEED_UPDATE [context] --;
     446                    {
     447                      reg_UPT_UPDATE [context] = (depth+1)%_param->_size_upt_queue[context];
     448                    }
     449                 
     450                  // End and event ?
     451                  if (end_event and
     452                      (reg_EVENT_STATE [context] != EVENT_STATE_OK))
     453                    {
     454                      reg_EVENT_STATE [context] = EVENT_STATE_UPDATE_CONTEXT;
     455                    }
     456
    427457                  // Free the branch with no accurate ?
    428458                  if (reg_UPDATE_PREDICTION_TABLE [context][depth]._is_accurate == false)
    429                     reg_IS_ACCURATE [i] = true;
     459                    reg_IS_ACCURATE [context] = true;
    430460                }
    431461            }
     
    434464        reg_UPDATE_PRIORITY = (reg_UPDATE_PRIORITY+1)%_param->_nb_context;
    435465
    436 //      // ===================================================================
    437 //      // =====[ BRANCH_EVENT ]==============================================
    438 //      // ===================================================================
    439 //      for (uint32_t i=0; i<_param->_nb_context; i++)
    440 //        if (internal_BRANCH_EVENT_VAL [i] and PORT_READ(in_BRANCH_EVENT_ACK [i]))
    441 //             {
    442 //               Tdepth_t depth = internal_BRANCH_EVENT_DEPTH [i];
    443 
    444 //               if (reg_UPDATE_PREDICTION_TABLE [i][depth]._state == UPDATE_PREDICTION_STATE_EVENT)
    445 //                 {
    446 //                   log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * state [%d][%d] <- UPDATE_PREDICTION_STATE_KO (branch_event)",i,depth);
    447                  
    448 //                   reg_UPDATE_PREDICTION_TABLE [i][depth]._state = UPDATE_PREDICTION_STATE_KO;
    449 //                 }
    450 //               else
    451 //                 {
    452 // #ifdef DEBUG_TEST
    453 //                   if (reg_UPDATE_PREDICTION_TABLE [i][depth]._state == UPDATE_PREDICTION_STATE_WAITEND_AND_EVENT)
    454 //                     throw ERRORMORPHEO(FUNCTION,_("Branche event : invalid state"));
    455 // #endif
    456              
    457 //                   log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * state [%d][%d] <- UPDATE_PREDICTION_STATE_WAITEND (branch_event)",i,depth);
    458                  
    459 //                   reg_UPDATE_PREDICTION_TABLE [i][depth]._state = UPDATE_PREDICTION_STATE_WAITEND;
    460 //                 }
    461 //             }
     466        // ===================================================================
     467        // =====[ BRANCH_EVENT ]==============================================
     468        // ===================================================================
     469        for (uint32_t i=0; i<_param->_nb_context; i++)
     470          if (internal_BRANCH_EVENT_VAL [i] and PORT_READ(in_BRANCH_EVENT_ACK [i]))
     471            {
     472              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * UPDATE[%d] - Accepted",i);
     473
     474#ifdef DEBUG_TEST
     475              if (reg_EVENT_STATE [i] != EVENT_STATE_UPDATE_CONTEXT)
     476                throw ERRORMORPHEO(FUNCTION,_("Decod : invalid event state."));
     477#endif
     478             
     479              // Change state
     480              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_OK (branch_event)",i);
     481             
     482              reg_EVENT_STATE [i] = EVENT_STATE_OK;
     483            }
     484
     485        // ===================================================================
     486        // =====[ FLUSH ]=====================================================
     487        // ===================================================================
     488
     489        for (uint32_t i=0; i<_param->_nb_context; ++i)
     490          {
     491            if (flush_UFPT [i])
     492              {
     493                log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * Flush Update Fetch Prediction Table");
     494                log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * context                          : %d",i);
     495                log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_UFPT_NB_NEED_UPDATE          : %d",reg_UFPT_NB_NEED_UPDATE [i]);
     496
     497              // It's to accelerate miss speculation
     498              if (reg_UFPT_NB_NEED_UPDATE [i] == 0)
     499                {
     500
     501                  // No entry need prediction, flush all entry -> Reset
     502                  for (uint32_t j=0; j<_param->_size_ufpt_queue[i]; ++j)
     503                    reg_UPDATE_FETCH_PREDICTION_TABLE [i][j]._state = UPDATE_FETCH_PREDICTION_STATE_EMPTY;
     504                  reg_UFPT_BOTTOM [i] = 0;
     505                  reg_UFPT_TOP    [i] = 0;
     506//                reg_UFPT_UPDATE [i];
     507                }
     508              else
     509                {
     510                  for (uint32_t j=0; j<_param->_size_ufpt_queue[i]; ++j)
     511                    reg_UPDATE_FETCH_PREDICTION_TABLE [i][j]._state = UPDATE_FETCH_PREDICTION_STATE_EVENT;
     512                 
     513                  // TOP is next write slot : last slot is TOP-1
     514                  uint32_t top = reg_UFPT_TOP [i];
     515                  reg_UFPT_UPDATE [i] = ((top==0)?_param->_size_ufpt_queue[i]:top)-1;
     516                 
     517//                reg_UFPT_BOTTOM [i];
     518//                reg_UFPT_TOP    [i];
     519                }
     520
     521              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_UFPT_UPDATE         (after ) : %d",reg_UFPT_UPDATE [i]);
     522
     523              }
     524          }
     525
     526        // ===================================================================
     527        // =====[ PRINT ]=====================================================
     528        // ===================================================================
    462529
    463530#if (DEBUG >= DEBUG_TRACE)
     
    468535        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_IS_ACCURATE           : %d",reg_IS_ACCURATE        [i]);
    469536        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_EVENT_STATE           : %s"  ,toString(reg_EVENT_STATE [i]).c_str());
    470         log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_EVENT_RAS_CORRUPTED   : %d"  ,reg_EVENT_RAS_CORRUPTED   [i]);
    471537        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_EVENT_ADDRESS_SRC     : %.8x",reg_EVENT_ADDRESS_SRC     [i]);
    472         log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_EVENT_ADDRESS_SRC_VAL : %d"  ,reg_EVENT_ADDRESS_SRC_VAL [i]);
     538        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_EVENT_ADDRESS_DEST_VAL: %d"  ,reg_EVENT_ADDRESS_DEST_VAL[i]);
    473539        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_EVENT_ADDRESS_DEST    : %.8x",reg_EVENT_ADDRESS_DEST    [i]);
    474540
     
    476542        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * reg_UFPT_BOTTOM         : %d",reg_UFPT_BOTTOM         [i]);
    477543        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * reg_UFPT_TOP            : %d",reg_UFPT_TOP            [i]);
     544        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * reg_UFPT_UPDATE         : %d",reg_UFPT_UPDATE         [i]);
    478545        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * reg_UFPT_NB_NEED_UPDATE : %d",reg_UFPT_NB_NEED_UPDATE [i]);
    479546        for (uint32_t j=0; j<_param->_size_ufpt_queue[i]; j++)
     
    495562        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * reg_UPT_TOP             : %d",reg_UPT_TOP            [i]);
    496563        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * reg_UPT_UPDATE          : %d",reg_UPT_UPDATE         [i]);
    497         log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * reg_UPT_NB_NEED_UPDATE  : %d",reg_UPT_NB_NEED_UPDATE [i]);
    498564        for (uint32_t j=0; j<_param->_size_upt_queue[i]; j++)
    499565          log_printf(TRACE,Update_Prediction_Table,FUNCTION,"        [%d] %.4d, %.8x %.8x, %.1d %.1d %.1d, %.8d %.8x %.4d - %s",
Note: See TracChangeset for help on using the changeset viewer.