Ignore:
Timestamp:
Dec 10, 2008, 7:31:39 PM (16 years ago)
Author:
rosiere
Message:

Almost complete design
with Test and test platform

Location:
trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/SelfTest/Makefile

    r81 r88  
    2424library_clean                   : Update_Prediction_Table_library_clean
    2525
     26local_clean                     :
     27
    2628include                         $(DIR_COMPONENT)/Makefile.deps
    2729include                         $(DIR_MORPHEO)/Behavioural/Makefile.flags
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/SelfTest/config_min.cfg

    r82 r88  
    11Update_Prediction_Table
    221       1       +1      # nb_context             
    3 1       4       *4      # size_queue             [0] [nb_context]
     31       1       *4      # size_upt_queue         [0] [nb_context]
     41       1       *4      # size_ufpt_queue        [0] [nb_context]
    4532      32      *2      # size_address           
    561       1       *4      # nb_inst_predict       
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/SelfTest/config_mono_context.cfg

    r81 r88  
    11Update_Prediction_Table
    221       1       +1      # nb_context             
    3 1       4       *4      # size_queue             [0] [nb_context]
     34       8       *2      # size_upt_queue         [0] [nb_context]
     41       4       *2      # size_ufpt_queue        [0] [nb_context]
    4532      32      *2      # size_address           
    564       4       *4      # nb_inst_predict       
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/SelfTest/config_multi_context.cfg

    r81 r88  
    11Update_Prediction_Table
    224       4       +1      # nb_context             
    3 4       4       *4      # size_queue             [0] [nb_context]
    4 1       1       *4      # size_queue             [1] [nb_context]
    5 8       8       *4      # size_queue             [2] [nb_context]
    6 2       2       *4      # size_queue             [3] [nb_context]
     34       4       *4      # size_upt_queue         [0] [nb_context]
     42       2       *4      # size_upt_queue         [1] [nb_context]
     58       8       *4      # size_upt_queue         [2] [nb_context]
     61       1       *4      # size_upt_queue         [3] [nb_context]
     74       4       *4      # size_ufpt_queue        [0] [nb_context]
     81       1       *4      # size_ufpt_queue        [1] [nb_context]
     92       2       *4      # size_ufpt_queue        [2] [nb_context]
     101       1       *4      # size_ufpt_queue        [3] [nb_context]
    71132      32      *2      # size_address           
    8124       4       *4      # nb_inst_predict       
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/SelfTest/src/main.cpp

    r81 r88  
    1515  err (_("list_params is :\n"));
    1616  err (_(" * nb_context                           (uint32_t)\n"));
    17   err (_(" * size_queue              [nb_context] (uint32_t)\n"));
     17  err (_(" * size_upt_queue          [nb_context] (uint32_t)\n"));
     18  err (_(" * size_ufpt_queue         [nb_context] (uint32_t)\n"));
    1819  err (_(" * size_address                         (uint32_t)\n"));
    1920  err (_(" * nb_inst_predict                      (uint32_t)\n"));
     
    4243  uint32_t   _nb_context              = fromString<uint32_t>(argv[x++]);
    4344
    44   if (argc != static_cast<int>(2+NB_PARAMS+2*_nb_context))
     45  if (argc != static_cast<int>(2+NB_PARAMS+3*_nb_context))
    4546    usage (argc, argv);
    4647
    47   uint32_t * _size_queue              = new uint32_t [_nb_context];
     48  uint32_t * _size_upt_queue              = new uint32_t [_nb_context];
    4849  for (uint32_t i=0; i<_nb_context; i++)
    49     _size_queue [i] = fromString<uint32_t>(argv[x++]);
     50    _size_upt_queue  [i] = fromString<uint32_t>(argv[x++]);
     51  uint32_t * _size_ufpt_queue             = new uint32_t [_nb_context];
     52  for (uint32_t i=0; i<_nb_context; i++)
     53    _size_ufpt_queue [i] = fromString<uint32_t>(argv[x++]);
    5054  uint32_t   _size_address            = fromString<uint32_t>(argv[x++]);
    5155  uint32_t   _nb_inst_predict         = fromString<uint32_t>(argv[x++]);
     
    6367      morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::Parameters * param = new morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::Parameters
    6468        (_nb_context             ,
    65          _size_queue             ,
     69         _size_upt_queue         ,
     70         _size_ufpt_queue        ,
    6671         _size_address           ,
    6772         _nb_inst_predict        ,
     
    7075         _nb_inst_update         ,
    7176         _size_history           ,
    72          _size_ras_index         );
     77         _size_ras_index         ,
     78         true //is_toplevel
     79         );
    7380     
    7481      msg(_("%s"),param->print(1).c_str());
     
    8996
    9097  delete [] _size_ras_index;
    91   delete [] _size_queue;
     98  delete [] _size_ufpt_queue;
     99  delete [] _size_upt_queue;
    92100
    93101  return (_return);
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/SelfTest/src/test.cpp

    r82 r88  
    11/*
    2  * $Id$
     2 * $id: test.cpp 82 2008-05-01 16:48:45Z rosiere $
    33 *
    44 * [ Description ]
     
    1313#include "Common/include/Test.h"
    1414#include "Behavioural/include/Allocation.h"
     15
     16typedef struct
     17{
     18  uint32_t            ufpt_ptr    ;
     19  uint32_t            upt_ptr     ;
     20
     21  Tcontext_t          context     ;
     22  Taddress_t          address_src ;
     23  Taddress_t          address_dest;
     24  Taddress_t          address_good;
     25  Tbranch_condition_t condition   ;
     26  Tcontrol_t          take        ;
     27  Tcontrol_t          take_good   ;
     28  Tcontrol_t          flag        ;
     29  Tcontrol_t          is_accurate ;
     30  Thistory_t          history     ;
     31  Taddress_t          ras_address ;
     32  Tptr_t              ras_index   ;
     33  Tcontrol_t          miss_ifetch ;
     34  Tcontrol_t          miss_decod  ;
     35  Tcontrol_t          miss_commit ;
     36} request_t;
    1537
    1638void test (string name,
     
    6183  ALLOC1_SC_SIGNAL( in_PREDICT_RAS_ADDRESS            ," in_PREDICT_RAS_ADDRESS            ",Taddress_t         ,_param->_nb_inst_predict);
    6284  ALLOC1_SC_SIGNAL( in_PREDICT_RAS_INDEX              ," in_PREDICT_RAS_INDEX              ",Tptr_t             ,_param->_nb_inst_predict);
    63 //ALLOC1_SC_SIGNAL(out_PREDICT_UPDATE_PREDICTION_ID   ,"out_PREDICT_UPDATE_PREDICTION_ID   ",Tprediction_ptr_t  ,_param->_nb_inst_predict);
     85  ALLOC1_SC_SIGNAL(out_PREDICT_UPDATE_PREDICTION_ID   ,"out_PREDICT_UPDATE_PREDICTION_ID   ",Tprediction_ptr_t  ,_param->_nb_inst_predict);
    6486  ALLOC1_SC_SIGNAL( in_DECOD_VAL                      ," in_DECOD_VAL                      ",Tcontrol_t         ,_param->_nb_inst_decod);
    6587  ALLOC1_SC_SIGNAL(out_DECOD_ACK                      ,"out_DECOD_ACK                      ",Tcontrol_t         ,_param->_nb_inst_decod);
     
    7597  ALLOC1_SC_SIGNAL( in_DECOD_UPDATE_PREDICTION_ID     ," in_DECOD_UPDATE_PREDICTION_ID     ",Tprediction_ptr_t  ,_param->_nb_inst_decod);
    7698//ALLOC1_SC_SIGNAL(out_DECOD_DEPTH                    ,"out_DECOD_DEPTH                    ",Tdepth_t           ,_param->_nb_inst_decod);
     99  ALLOC1_SC_SIGNAL( in_DECOD_IS_ACCURATE              ," in_DECOD_IS_ACCURATE              ",Tcontrol_t         ,_param->_nb_inst_decod);
    77100
    78101  ALLOC1_SC_SIGNAL( in_BRANCH_COMPLETE_VAL            ," in_BRANCH_COMPLETE_VAL            ",Tcontrol_t         ,_param->_nb_inst_branch_complete);
     
    111134  ALLOC1_SC_SIGNAL(out_UPDATE_RAS_INDEX               ,"out_UPDATE_RAS_INDEX               ",Tptr_t             ,_param->_nb_inst_update);
    112135  ALLOC1_SC_SIGNAL(out_UPDATE_RAS_PREDICTION_IFETCH   ,"out_UPDATE_RAS_PREDICTION_IFETCH   ",Tcontrol_t         ,_param->_nb_inst_update);
    113   ALLOC1_SC_SIGNAL(out_DEPTH_NB_BRANCH                ,"out_DEPTH_NB_BRANCH                ",Tdepth_t           ,_param->_nb_context);
    114   ALLOC1_SC_SIGNAL(out_DEPTH_TAIL                     ,"out_DEPTH_TAIL                     ",Tdepth_t           ,_param->_nb_context);
     136  ALLOC1_SC_SIGNAL(out_DEPTH_CURRENT                  ,"out_DEPTH_CURRENT                  ",Tdepth_t           ,_param->_nb_context);
     137  ALLOC1_SC_SIGNAL(out_DEPTH_MIN                      ,"out_DEPTH_MIN                      ",Tdepth_t           ,_param->_nb_context);
     138  ALLOC1_SC_SIGNAL(out_DEPTH_MAX                      ,"out_DEPTH_MAX                      ",Tdepth_t           ,_param->_nb_context);
    115139 
    116140  /********************************************************
     
    136160  INSTANCE1_SC_SIGNAL(_Update_Prediction_Table, in_PREDICT_RAS_ADDRESS            ,_param->_nb_inst_predict);
    137161  INSTANCE1_SC_SIGNAL(_Update_Prediction_Table, in_PREDICT_RAS_INDEX              ,_param->_nb_inst_predict);
    138 //if (_param->_have_port_depth)
    139 //INSTANCE1_SC_SIGNAL(_Update_Prediction_Table,out_PREDICT_UPDATE_PREDICTION_ID   ,_param->_nb_inst_predict);
     162  if (_param->_have_port_depth)
     163  INSTANCE1_SC_SIGNAL(_Update_Prediction_Table,out_PREDICT_UPDATE_PREDICTION_ID   ,_param->_nb_inst_predict);
    140164  INSTANCE1_SC_SIGNAL(_Update_Prediction_Table, in_DECOD_VAL                      ,_param->_nb_inst_decod);
    141165  INSTANCE1_SC_SIGNAL(_Update_Prediction_Table,out_DECOD_ACK                      ,_param->_nb_inst_decod);
     
    150174  INSTANCE1_SC_SIGNAL(_Update_Prediction_Table, in_DECOD_MISS_IFETCH              ,_param->_nb_inst_decod);
    151175  INSTANCE1_SC_SIGNAL(_Update_Prediction_Table, in_DECOD_MISS_DECOD               ,_param->_nb_inst_decod);
    152   if (_param->_have_port_max_depth)
     176  if (_param->_have_port_depth)
    153177  INSTANCE1_SC_SIGNAL(_Update_Prediction_Table, in_DECOD_UPDATE_PREDICTION_ID     ,_param->_nb_inst_decod);
    154178//if (_param->_have_port_depth)
    155179//INSTANCE1_SC_SIGNAL(_Update_Prediction_Table,out_DECOD_DEPTH                    ,_param->_nb_inst_decod);
     180  INSTANCE1_SC_SIGNAL(_Update_Prediction_Table, in_DECOD_IS_ACCURATE              ,_param->_nb_inst_decod);
    156181  INSTANCE1_SC_SIGNAL(_Update_Prediction_Table, in_BRANCH_COMPLETE_VAL            ,_param->_nb_inst_branch_complete);
    157182  INSTANCE1_SC_SIGNAL(_Update_Prediction_Table,out_BRANCH_COMPLETE_ACK            ,_param->_nb_inst_branch_complete);
    158183  if (_param->_have_port_context_id)
    159184  INSTANCE1_SC_SIGNAL(_Update_Prediction_Table, in_BRANCH_COMPLETE_CONTEXT_ID     ,_param->_nb_inst_branch_complete);
    160   if (_param->_have_port_max_depth)
     185  if (_param->_have_port_depth)
    161186  INSTANCE1_SC_SIGNAL(_Update_Prediction_Table, in_BRANCH_COMPLETE_DEPTH          ,_param->_nb_inst_branch_complete);
    162187  INSTANCE1_SC_SIGNAL(_Update_Prediction_Table, in_BRANCH_COMPLETE_ADDRESS        ,_param->_nb_inst_branch_complete);
     
    171196//   if (_param->_have_port_context_id)
    172197//   INSTANCE1_SC_SIGNAL(_Update_Prediction_Table, in_BRANCH_EVENT_CONTEXT_ID     ,_param->_nb_context);
    173 //   if (_param->_have_port_max_depth)
     198//   if (_param->_have_port_depth)
    174199//   INSTANCE1_SC_SIGNAL(_Update_Prediction_Table, in_BRANCH_EVENT_DEPTH          ,_param->_nb_context);
    175200//   INSTANCE1_SC_SIGNAL(_Update_Prediction_Table, in_BRANCH_EVENT_ADDRESS        ,_param->_nb_context);
     
    196221  INSTANCE1_SC_SIGNAL(_Update_Prediction_Table,out_UPDATE_RAS_INDEX               ,_param->_nb_inst_update);
    197222  INSTANCE1_SC_SIGNAL(_Update_Prediction_Table,out_UPDATE_RAS_PREDICTION_IFETCH   ,_param->_nb_inst_update);
    198   for (uint32_t i=0; i<_param->_nb_context; i++)
     223  if (_param->_have_port_depth)
    199224    {
    200       if (_param->_have_port_depth[i])
    201         {
    202           INSTANCE_SC_SIGNAL(_Update_Prediction_Table,out_DEPTH_TAIL      [i]);
    203         }
    204       INSTANCE_SC_SIGNAL(_Update_Prediction_Table,out_DEPTH_NB_BRANCH [i]);
     225  INSTANCE1_SC_SIGNAL(_Update_Prediction_Table,out_DEPTH_CURRENT                  ,_param->_nb_context);
     226  INSTANCE1_SC_SIGNAL(_Update_Prediction_Table,out_DEPTH_MIN                      ,_param->_nb_context);
    205227    }
     228  INSTANCE1_SC_SIGNAL(_Update_Prediction_Table,out_DEPTH_MAX                      ,_param->_nb_context);
    206229
    207230  msg(_("<%s> : Start Simulation ............\n"),name.c_str());
     
    225248  const  int32_t percent_transaction_update          = 75;
    226249
     250
     251
     252  std::list<request_t> ufpt;
     253  std::list<request_t> upt;
     254
    227255  SC_START(0);
    228256  LABEL("Initialisation");
     
    233261  in_NRESET->write(1); 
    234262
    235   for (uint32_t i=0; i<_param->_nb_context; i++)
     263  Tdepth_t ufpt_bottom [_param->_nb_context];
     264  Tdepth_t ufpt_top    [_param->_nb_context];
     265
     266  Tdepth_t upt_bottom  [_param->_nb_context];
     267  Tdepth_t upt_top     [_param->_nb_context];
     268
     269  for (uint32_t i=0; i<_param->_nb_context; ++i)
    236270    {
    237       PORT_WRITE(in_BRANCH_EVENT_ACK [i],1);
     271      ufpt_bottom [i] = 0;
     272      ufpt_top    [i] = 0;
     273      upt_bottom  [i] = 0;
     274      upt_top     [i] = 0;
    238275    }
    239276
    240   LABEL("Loop of Test");
     277  for (uint32_t i=0; i<_param->_nb_context; ++i)
     278    {
     279      TEST(Tdepth_t,out_DEPTH_CURRENT [i]->read(),upt_top    [i]);
     280      TEST(Tdepth_t,out_DEPTH_MIN     [i]->read(),upt_bottom [i]);
     281      TEST(Tdepth_t,out_DEPTH_MAX     [i]->read(),upt_top    [i]);
     282    }
    241283
    242284  for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++)
    243285    {
    244286      LABEL("Iteration %d",iteration);
    245      
     287
     288      for (uint32_t i=0; i<_param->_nb_inst_predict; ++i)
     289        in_PREDICT_VAL         [i]->write(0);
     290      for (uint32_t i=0; i<_param->_nb_inst_decod; ++i)
     291        in_DECOD_VAL           [i]->write(0);
     292      for (uint32_t i=0; i<_param->_nb_inst_branch_complete; ++i)
     293        in_BRANCH_COMPLETE_VAL [i]->write(0);
     294      for (uint32_t i=0; i<_param->_nb_context; ++i)
     295        in_BRANCH_EVENT_ACK    [i]->write(0);
     296      for (uint32_t i=0; i<_param->_nb_inst_update; ++i)
     297        in_UPDATE_ACK          [i]->write(0);
     298
     299      //---------------------------------------------------------------------
     300      //---------------------------------------------------------------------
     301      // COMMON CASE
     302      //---------------------------------------------------------------------
     303      //---------------------------------------------------------------------
     304      if (1)
    246305      {
    247306        uint32_t context = rand() % _param->_nb_context;
    248        
    249 //      LABEL("KANE : %d",context);
    250 
    251         LABEL("PREDICT - fill the queue");
    252        
     307
    253308        {
     309          LABEL("PREDICT - fill the queue");
    254310          uint32_t port = rand() % _param->_nb_inst_predict;
     311
     312          LABEL("  * context : %d",context);
     313          LABEL("  * port    : %d",port);
    255314         
    256           for (uint32_t i=0; i<_param->_size_queue[context]; i++)
     315          for (uint32_t i=0; i<_param->_size_ufpt_queue[context]; i++)
    257316            {
    258              
    259               bool find = false;
     317              request_t request;
     318              request.context          = context;
     319              request.address_src      = 0xdeadbeef+i;
     320              request.address_dest     = 0x21071981+i;                                   
     321              request.address_good     = request.address_dest;
     322              request.condition        = BRANCH_CONDITION_FLAG_SET;                     
     323              request.take             = 1;                                             
     324              request.take_good        = 1;                                             
     325              request.flag             = (request.condition == BRANCH_CONDITION_FLAG_SET)?request.take_good:(not request.take_good);
     326              request.is_accurate      = true;
     327              request.miss_ifetch      = false;
     328              request.miss_decod       = false;
     329              request.miss_commit      = false;
     330              request.history          = i;                                             
     331              request.ras_address      = 0xdeaddead+i;                                   
     332              request.ras_index        = (0x12345678+i)%_param->_size_ras_index[context];
     333              request.ufpt_ptr         = ufpt_top [context];
     334//            request.upt_ptr;
     335
     336              bool have_transaction = false;
    260337              do
    261338                {
    262339                  in_PREDICT_VAL              [port]->write((rand()%100)<percent_transaction_predict);
    263                   in_PREDICT_CONTEXT_ID       [port]->write(context);
    264                   in_PREDICT_BTB_ADDRESS_SRC  [port]->write(0xdeadbeef+i);
    265                   in_PREDICT_BTB_ADDRESS_DEST [port]->write(0x21071981+i);
    266                   in_PREDICT_BTB_CONDITION    [port]->write(BRANCH_CONDITION_FLAG_SET);
    267                   in_PREDICT_BTB_LAST_TAKE    [port]->write(1);
    268                   in_PREDICT_BTB_IS_ACCURATE  [port]->write((rand()%100)<percent_transaction_predict);
    269                   in_PREDICT_DIR_HISTORY      [port]->write(i);
    270                   in_PREDICT_RAS_ADDRESS      [port]->write(0xdeaddead+i);
    271                   in_PREDICT_RAS_INDEX        [port]->write((0x12345678+i)%_param->_size_ras_index[context]);
    272                  
    273                   if (_param->_have_port_depth[context])
    274                     {
    275                       TEST(Tdepth_t,out_DEPTH_TAIL     [context]->read(), 0);
    276                     }
    277                       TEST(Tdepth_t,out_DEPTH_NB_BRANCH[context]->read(), i);
     340                  in_PREDICT_CONTEXT_ID       [port]->write(request.context     );
     341                  in_PREDICT_BTB_ADDRESS_SRC  [port]->write(request.address_src );
     342                  in_PREDICT_BTB_ADDRESS_DEST [port]->write(request.address_dest);
     343                  in_PREDICT_BTB_CONDITION    [port]->write(request.condition   );
     344                  in_PREDICT_BTB_LAST_TAKE    [port]->write(request.take        );
     345                  in_PREDICT_BTB_IS_ACCURATE  [port]->write(request.is_accurate );
     346                  in_PREDICT_DIR_HISTORY      [port]->write(request.history     );
     347                  in_PREDICT_RAS_ADDRESS      [port]->write(request.ras_address );
     348                  in_PREDICT_RAS_INDEX        [port]->write(request.ras_index   );
     349                 
     350                  if (_param->_have_port_depth)
     351                  TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
     352                  TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
    278353                     
    279                   SC_START(0);
    280                  
    281                   LABEL("PREDICT         [%d] %d - %d (accurate : %d).",port,in_PREDICT_VAL [port]->read(),out_PREDICT_ACK [port]->read(), in_PREDICT_BTB_IS_ACCURATE [port]->read());
     354                  SC_START(0); // fct melay
     355                 
     356                  LABEL("PREDICT         [%d] %d - %d (accurate : %d).",
     357                        port,
     358                         in_PREDICT_VAL [port]->read(),
     359                        out_PREDICT_ACK [port]->read(),
     360                         in_PREDICT_BTB_IS_ACCURATE [port]->read());
    282361                 
    283362                  if (in_PREDICT_VAL [port]->read() and out_PREDICT_ACK [port]->read())
    284363                    {
    285364                      LABEL("PREDICT         [%d] - Transaction accepted",port);
    286                       find = true;
     365                      have_transaction = true;
     366
     367                      if (_param->_have_port_depth)
     368                      TEST(Tprediction_ptr_t,out_PREDICT_UPDATE_PREDICTION_ID [port]->read(),ufpt_top [context]);
     369                     
     370                      ufpt_top [context] = (ufpt_top [context]+1)%_param->_size_ufpt_queue[context];
    287371                    }
    288372                 
    289                   SC_START(1);
    290                  
    291                 } while (not find);
    292               in_PREDICT_VAL              [port]->write(0);
    293              
    294               if (_param->_have_port_depth[context])
    295                 {
    296                   TEST(Tdepth_t,out_DEPTH_TAIL     [context]->read(), 0);
    297                 }
    298                   TEST(Tdepth_t,out_DEPTH_NB_BRANCH[context]->read(), i+1);
    299 
     373                  SC_START(1); // transition
     374                 
     375                } while (not have_transaction);
     376
     377              ufpt.push_back(request);
     378
     379              in_PREDICT_VAL [port]->write(0);
     380           
     381              if (_param->_have_port_depth)
     382              TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
     383              TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
    300384            }
    301385        }
    302386       
    303         LABEL("DECOD - hit ifetch");
    304        
    305         {
     387        {
     388          LABEL("DECOD");
    306389          uint32_t port = rand() % _param->_nb_inst_decod;
    307          
    308           for (uint32_t i=0; i<_param->_size_queue[context]; i++)
     390
     391          LABEL("  * context : %d",context);
     392          LABEL("  * port    : %d",port);
     393         
     394          for (uint32_t i=0; i<_param->_size_ufpt_queue[context]; i++)
    309395            {
    310              
    311               bool find = false;
     396              request_t request = ufpt.front();
     397
     398              bool have_transaction = false;
    312399              do
    313400                {
    314401                  in_DECOD_VAL                  [port]->write((rand()%100)<percent_transaction_decod);
    315                   in_DECOD_CONTEXT_ID           [port]->write(context);
    316                   in_DECOD_BTB_ADDRESS_SRC      [port]->write(0xdeadbeef+i);
    317                   in_DECOD_BTB_ADDRESS_DEST     [port]->write(0x21071981+i);
    318                   in_DECOD_BTB_CONDITION        [port]->write(BRANCH_CONDITION_FLAG_SET);
    319                   in_DECOD_BTB_LAST_TAKE        [port]->write(1);
    320                   in_DECOD_RAS_ADDRESS          [port]->write(0xdeaddead+i);
    321                   in_DECOD_RAS_INDEX            [port]->write((0x12345678+i)%_param->_size_ras_index[context]);
    322                   in_DECOD_MISS_IFETCH          [port]->write(false);
    323                   in_DECOD_MISS_DECOD           [port]->write(false);
    324                   in_DECOD_UPDATE_PREDICTION_ID [port]->write(i);
    325                  
    326                   if (_param->_have_port_depth[context])
    327                     {
    328                       TEST(Tdepth_t,out_DEPTH_TAIL     [context]->read(), 0);
    329                     }
    330                       TEST(Tdepth_t,out_DEPTH_NB_BRANCH[context]->read(), _param->_size_queue[context]);
    331                  
    332                   SC_START(0);
    333                  
    334                   LABEL("DECOD           [%d] %d - %d.",port,in_DECOD_VAL [port]->read(),out_DECOD_ACK [port]->read());
     402                  in_DECOD_CONTEXT_ID           [port]->write(request.context     );
     403                  in_DECOD_BTB_ADDRESS_SRC      [port]->write(request.address_src );
     404                  in_DECOD_BTB_ADDRESS_DEST     [port]->write(request.address_dest);
     405                  in_DECOD_BTB_CONDITION        [port]->write(request.condition   );
     406                  in_DECOD_BTB_LAST_TAKE        [port]->write(request.take        );
     407                  in_DECOD_RAS_ADDRESS          [port]->write(request.ras_address );
     408                  in_DECOD_RAS_INDEX            [port]->write(request.ras_index   );
     409                  in_DECOD_UPDATE_PREDICTION_ID [port]->write(request.ufpt_ptr    );
     410                  in_DECOD_MISS_IFETCH          [port]->write(request.miss_ifetch );
     411                  in_DECOD_MISS_DECOD           [port]->write(request.miss_decod  );
     412                  in_DECOD_IS_ACCURATE          [port]->write(request.is_accurate );
     413
     414                  SC_START(0); // fct melay
     415                 
     416                  LABEL("DECOD           [%d] %d - %d",
     417                        port,
     418                         in_PREDICT_VAL [port]->read(),
     419                        out_PREDICT_ACK [port]->read());
    335420                 
    336421                  if (in_DECOD_VAL [port]->read() and out_DECOD_ACK [port]->read())
    337422                    {
    338                       LABEL("DECOD           [%d] - Transaction accepted",port);
    339                       find = true;
     423                      LABEL("DECOD          [%d] - Transaction accepted",port);
     424                      have_transaction = true;
     425
     426                      request.upt_ptr = upt_top [context];
     427                      upt.push_back(request);
     428                      ufpt.pop_front();
     429
     430                      upt_top [context] = (upt_top [context]+1)%_param->_size_upt_queue[context];
    340431                    }
    341                  
    342                   SC_START(1);
    343                  
    344                 } while (not find);
     432
     433                  SC_START(1); // transition
     434
     435                } while (not have_transaction);
     436
    345437              in_DECOD_VAL              [port]->write(0);
    346438             
    347               if (_param->_have_port_depth[context])
    348                 {
    349                   TEST(Tdepth_t,out_DEPTH_TAIL     [context]->read(), 0);
    350                 }
    351                   TEST(Tdepth_t,out_DEPTH_NB_BRANCH[context]->read(), _param->_size_queue[context]);
    352             }
    353         }
     439              if (_param->_have_port_depth)
     440              TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
     441              TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
     442            }
     443        }
     444
     445        {
     446          LABEL("BRANCH_COMPLETE - hit ifetch");
    354447       
    355         LABEL("BRANCH_COMPLETE - hit ifetch");
     448          uint32_t port = rand() % _param->_nb_inst_branch_complete;
    356449       
    357         {
    358           uint32_t port = rand() % _param->_nb_inst_branch_complete;
    359          
    360           for (uint32_t i=0; i<_param->_size_queue[context]; i++)
     450          LABEL("  * port    : %d",port);
     451 
     452          std::list<request_t>::iterator it_upt = upt.begin();
     453
     454//        for (uint32_t i=0; i<_param->_size_ufpt_queue[context]; i++)
     455          for (uint32_t i=0; i<upt.size(); i++)
    361456            {
    362               bool find = false;
     457              bool have_transaction = false;
     458
    363459              do
    364460                {
    365                   in_BRANCH_COMPLETE_VAL                  [port]->write((rand()%100)<percent_transaction_branch_complete);
    366                   in_BRANCH_COMPLETE_CONTEXT_ID           [port]->write(context);
    367                   in_BRANCH_COMPLETE_DEPTH                [port]->write(i);
    368                   in_BRANCH_COMPLETE_ADDRESS              [port]->write(0xcacacaca+i);
    369                   in_BRANCH_COMPLETE_FLAG                 [port]->write(1);
    370                  
    371                   if (_param->_have_port_depth[context])
    372                     {
    373                       TEST(Tdepth_t,out_DEPTH_TAIL     [context]->read(), 0);
    374                     }
    375                       TEST(Tdepth_t,out_DEPTH_NB_BRANCH[context]->read(), _param->_size_queue[context]);
     461                  in_BRANCH_COMPLETE_VAL        [port]->write((rand()%100)<percent_transaction_branch_complete);
     462                  in_BRANCH_COMPLETE_CONTEXT_ID [port]->write(it_upt->context     );
     463                  in_BRANCH_COMPLETE_DEPTH      [port]->write(it_upt->upt_ptr     );
     464                  in_BRANCH_COMPLETE_ADDRESS    [port]->write(it_upt->address_good);
     465                  in_BRANCH_COMPLETE_FLAG       [port]->write(it_upt->flag        );
     466
     467                  if (_param->_have_port_depth)
     468                  TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
     469                  TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
    376470                 
    377471                  SC_START(0);
     
    382476                    {
    383477                      LABEL("BRANCH_COMPLETE [%d] - Transaction accepted",port);
    384                       find = true;
     478                      have_transaction = true;
    385479                     
    386                       TEST(Tcontrol_t,out_BRANCH_COMPLETE_MISS_PREDICTION[port]->read(),0);
    387                       TEST(Tcontrol_t,out_BRANCH_COMPLETE_TAKE           [port]->read(),1);
    388                       TEST(Taddress_t,out_BRANCH_COMPLETE_ADDRESS_SRC    [port]->read(),0xdeadbeef+i);
    389                       TEST(Taddress_t,out_BRANCH_COMPLETE_ADDRESS_DEST   [port]->read(),0x21071981+i);
     480                      TEST(Tcontrol_t,out_BRANCH_COMPLETE_MISS_PREDICTION[port]->read(),it_upt->miss_commit );
     481                      TEST(Tcontrol_t,out_BRANCH_COMPLETE_TAKE           [port]->read(),it_upt->take_good   );
     482                      TEST(Taddress_t,out_BRANCH_COMPLETE_ADDRESS_SRC    [port]->read(),it_upt->address_src );
     483                      TEST(Taddress_t,out_BRANCH_COMPLETE_ADDRESS_DEST   [port]->read(),it_upt->address_good);
     484
     485                      it_upt ++;
    390486                    }
    391487                 
    392488                  SC_START(1);
    393 
    394                 } while (not find);
    395               in_BRANCH_COMPLETE_VAL              [port]->write(0);
     489                } while (not have_transaction);
     490
     491              in_BRANCH_COMPLETE_VAL [port]->write(0);
    396492             
    397               if (_param->_have_port_depth[context])
    398                 {
    399                   TEST(Tdepth_t,out_DEPTH_TAIL     [context]->read(), 0);
    400                 }
    401                   TEST(Tdepth_t,out_DEPTH_NB_BRANCH[context]->read(), _param->_size_queue[context]);
     493              if (_param->_have_port_depth)
     494              TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
     495              TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
    402496            }
    403497        }
     498
     499        {
     500          LABEL("UPDATE - hit ifetch");
    404501       
    405         LABEL("UPDATE - hit ifetch");
     502          uint32_t port = 0;
    406503       
    407         {
    408           uint32_t port = 0; //rand() % _param->_nb_inst_update;
    409          
    410           for (uint32_t i=0; i<_param->_size_queue[context]; i++)
     504          LABEL("  * port    : %d",port);
     505          std::list<request_t>::iterator it_upt = upt.begin();
     506 
     507//        for (uint32_t i=0; i<_param->_size_ufpt_queue[context]; i++)
     508          for (uint32_t i=0; i<upt.size(); i++)
    411509            {
    412               bool find = false;
     510              LABEL("Address_src (-1): %.8x (%d)",out_UPDATE_BTB_ADDRESS_SRC [i]->read(),upt.size());
     511
     512              bool have_transaction = false;
     513
    413514              do
    414515                {
     516                  LABEL("Address_src (0) : %.8x",out_UPDATE_BTB_ADDRESS_SRC [i]->read());
     517
    415518                  in_UPDATE_ACK [port]->write((rand()%100)<percent_transaction_update);
    416                  
     519
     520//                   if (_param->_have_port_depth)
     521//                   TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
     522//                   TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
     523                 
     524                  LABEL("Address_src (1) : %.8x",out_UPDATE_BTB_ADDRESS_SRC [i]->read());
    417525                  SC_START(0);
     526                  LABEL("Address_src (2) : %.8x",out_UPDATE_BTB_ADDRESS_SRC [i]->read());
     527                 
     528                  LABEL("UPDATE [%d] %d - %d.",port,out_UPDATE_VAL [port]->read(),in_UPDATE_ACK [port]->read());
    418529                 
    419530                  if (out_UPDATE_VAL [port]->read() and in_UPDATE_ACK [port]->read())
    420531                    {
    421532                      LABEL("UPDATE [%d] - Transaction accepted",port);
    422                      
    423                       find = true;
    424                      
    425                       TEST(Tcontext_t         ,out_UPDATE_CONTEXT_ID            [port]->read(), context);
    426                       TEST(Tcontrol_t         ,out_UPDATE_MISS_PREDICTION       [port]->read(), 0);
    427                       TEST(Tcontrol_t         ,out_UPDATE_DIRECTION_GOOD        [port]->read(), 1);
    428                       TEST(Tcontrol_t         ,out_UPDATE_BTB_VAL               [port]->read(), 1);
    429                       TEST(Taddress_t         ,out_UPDATE_BTB_ADDRESS_SRC       [port]->read(), 0xdeadbeef+i);
    430                       TEST(Taddress_t         ,out_UPDATE_BTB_ADDRESS_DEST      [port]->read(), 0x21071981+i);       
    431                       TEST(Tbranch_condition_t,out_UPDATE_BTB_CONDITION         [port]->read(), BRANCH_CONDITION_FLAG_SET);
    432                       TEST(Tcontrol_t         ,out_UPDATE_DIR_VAL               [port]->read(), 1);
    433                       if (_param->_have_port_history)
    434                         TEST(Thistory_t         ,out_UPDATE_DIR_HISTORY           [port]->read(), i);
    435                       TEST(Tcontrol_t         ,out_UPDATE_RAS_VAL               [port]->read(), 0);
    436                       TEST(Tcontrol_t         ,out_UPDATE_RAS_PUSH              [port]->read(), 0);
    437                       TEST(Taddress_t         ,out_UPDATE_RAS_ADDRESS           [port]->read(), 0xdeaddead+i);
    438                       TEST(Tptr_t             ,out_UPDATE_RAS_INDEX             [port]->read(), (0x12345678+i)%_param->_size_ras_index[context]);
    439                       TEST(Tcontrol_t         ,out_UPDATE_RAS_PREDICTION_IFETCH [port]->read(), 1);
     533                      have_transaction = true;
     534                 
     535                      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));
     540                      if (update_btb(it_upt->condition))
     541                        {
     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                        }
     546                      TEST(Tcontrol_t         ,out_UPDATE_DIR_VAL               [i]->read(),update_dir(it_upt->condition));
     547                      if (update_dir(it_upt->condition))
     548                      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));
     551                      if (update_ras(it_upt->condition))
     552                        {
     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);
     557                        }
     558                      ++ it_upt;
    440559                    }
    441                  
     560
    442561                  SC_START(1);
    443                  
    444                 } while (not find);
    445               in_UPDATE_ACK              [port]->write(0);
     562                  LABEL("Address_src (3) : %.8x",out_UPDATE_BTB_ADDRESS_SRC [i]->read());
     563                 
     564                } while (not have_transaction);
     565
     566              LABEL("Address_src (4) : %.8x",out_UPDATE_BTB_ADDRESS_SRC [i]->read());
     567              in_UPDATE_ACK [port]->write(0);
     568              LABEL("Address_src (5) : %.8x",out_UPDATE_BTB_ADDRESS_SRC [i]->read());
     569//               if (_param->_have_port_depth)
     570//               TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
     571//               TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
    446572            }
    447          
    448           LABEL("Wait a moment");
    449           SC_START(2*_param->_size_queue[context]);
    450  
    451           // wait the garbage collector
    452           while ((not (_param->_have_port_depth[context]) or (out_DEPTH_TAIL     [context]->read() != 0)) and
    453                  (out_DEPTH_NB_BRANCH[context]->read() != 0))
    454             {
    455               LABEL("DEPTH [%d] nb_branch : %d - tail : %d",context,out_DEPTH_NB_BRANCH[context]->read(), out_DEPTH_TAIL [context]->read());
    456               SC_START(1);
    457             }
     573          upt.clear();
    458574        }
     575
     576        // Wait Garbage Collector
     577        {
     578          upt_bottom [context] = (upt_bottom [context]+_param->_size_ufpt_queue[context])%_param->_size_upt_queue[context];
     579//        upt_top    [context] = (upt_top    [context]);
     580
     581          while ((upt_bottom [context] != out_DEPTH_MIN [context]->read()) or
     582                 (upt_top    [context] != out_DEPTH_MAX [context]->read()))
     583            SC_START(1);
     584
     585        }
    459586      }
    460587
    461       {
    462         uint32_t context = rand() % _param->_nb_context;
    463        
    464 //      LABEL("KANE : %d",context);
    465 
    466         LABEL("PREDICT - fill the queue");
    467        
    468         {
    469           uint32_t port = rand() % _param->_nb_inst_predict;
    470          
    471           for (uint32_t i=0; i<_param->_size_queue[context]; i++)
    472             {
    473              
    474               bool find = false;
    475               do
    476                 {
    477                   in_PREDICT_VAL              [port]->write((rand()%100)<percent_transaction_predict);
    478                   in_PREDICT_CONTEXT_ID       [port]->write(context);
    479                   in_PREDICT_BTB_ADDRESS_SRC  [port]->write(0xdeadbeef+i);
    480                   in_PREDICT_BTB_ADDRESS_DEST [port]->write(0x21071981+i);
    481                   in_PREDICT_BTB_CONDITION    [port]->write(BRANCH_CONDITION_FLAG_SET);
    482                   in_PREDICT_BTB_LAST_TAKE    [port]->write(1);
    483                   in_PREDICT_BTB_IS_ACCURATE  [port]->write((rand()%100)<percent_transaction_predict);
    484                   in_PREDICT_DIR_HISTORY      [port]->write(i);
    485                   in_PREDICT_RAS_ADDRESS      [port]->write(0xdeaddead+i);
    486                   in_PREDICT_RAS_INDEX        [port]->write((0x12345678+i)%_param->_size_ras_index[context]);
    487                  
    488                   if (_param->_have_port_depth[context])
    489                     {
    490                       TEST(Tdepth_t,out_DEPTH_TAIL     [context]->read(), 0);
    491                     }
    492                       TEST(Tdepth_t,out_DEPTH_NB_BRANCH[context]->read(), i);
    493 
    494                   SC_START(0);
    495                  
    496                   LABEL("PREDICT         [%d] %d - %d (accurate : %d).",port,in_PREDICT_VAL [port]->read(),out_PREDICT_ACK [port]->read(), in_PREDICT_BTB_IS_ACCURATE [port]->read());
    497                  
    498                   if (in_PREDICT_VAL [port]->read() and out_PREDICT_ACK [port]->read())
    499                     {
    500                       LABEL("PREDICT         [%d] - Transaction accepted",port);
    501                       find = true;
    502                     }
    503                  
    504                   SC_START(1);
    505                  
    506                 } while (not find);
    507               in_PREDICT_VAL              [port]->write(0);
    508              
    509               if (_param->_have_port_depth[context])
    510                 {
    511                   TEST(Tdepth_t,out_DEPTH_TAIL     [context]->read(), 0);
    512                 }
    513                   TEST(Tdepth_t,out_DEPTH_NB_BRANCH[context]->read(), i+1);
    514             }
    515         }
    516        
    517         LABEL("DECOD - hit ifetch");
    518        
    519         {
    520           uint32_t port = rand() % _param->_nb_inst_decod;
    521          
    522           for (uint32_t i=0; i<_param->_size_queue[context]; i++)
    523             {
    524              
    525               bool find = false;
    526               do
    527                 {
    528                   in_DECOD_VAL                  [port]->write((rand()%100)<percent_transaction_decod);
    529                   in_DECOD_CONTEXT_ID           [port]->write(context);
    530                   in_DECOD_BTB_ADDRESS_SRC      [port]->write(0xdeadbeef+i);
    531                   in_DECOD_BTB_ADDRESS_DEST     [port]->write(0x21071981+i);
    532                   in_DECOD_BTB_CONDITION        [port]->write(BRANCH_CONDITION_FLAG_SET);
    533                   in_DECOD_BTB_LAST_TAKE        [port]->write(1);
    534                   in_DECOD_RAS_ADDRESS          [port]->write(0xdeaddead+i);
    535                   in_DECOD_RAS_INDEX            [port]->write((0x12345678+i)%_param->_size_ras_index[context]);
    536                   in_DECOD_MISS_IFETCH          [port]->write(false);
    537                   in_DECOD_MISS_DECOD           [port]->write(false);
    538                   in_DECOD_UPDATE_PREDICTION_ID [port]->write(i);
    539                  
    540                   if (_param->_have_port_depth[context])
    541                     {
    542                       TEST(Tdepth_t,out_DEPTH_TAIL     [context]->read(), 0);
    543                     }
    544                       TEST(Tdepth_t,out_DEPTH_NB_BRANCH[context]->read(), _param->_size_queue[context]);
    545                  
    546                   SC_START(0);
    547                  
    548                   LABEL("DECOD           [%d] %d - %d.",port,in_DECOD_VAL [port]->read(),out_DECOD_ACK [port]->read());
    549                  
    550                   if (in_DECOD_VAL [port]->read() and out_DECOD_ACK [port]->read())
    551                     {
    552                       LABEL("DECOD           [%d] - Transaction accepted",port);
    553                       find = true;
    554                     }
    555                  
    556                   SC_START(1);
    557                  
    558                 } while (not find);
    559               in_DECOD_VAL              [port]->write(0);
    560              
    561               if (_param->_have_port_depth[context])
    562                 {
    563                   TEST(Tdepth_t,out_DEPTH_TAIL     [context]->read(), 0);
    564                 }
    565                   TEST(Tdepth_t,out_DEPTH_NB_BRANCH[context]->read(), _param->_size_queue[context]);
    566             }
    567         }
    568        
    569         LABEL("BRANCH_COMPLETE - hit ifetch");
    570        
    571         {
    572           uint32_t port = rand() % _param->_nb_inst_branch_complete;
    573          
    574             {
    575               uint32_t i=0;
    576               bool find = false;
    577               do
    578                 {
    579                   in_BRANCH_COMPLETE_VAL                  [port]->write((rand()%100)<percent_transaction_branch_complete);
    580                   in_BRANCH_COMPLETE_CONTEXT_ID           [port]->write(context);
    581                   in_BRANCH_COMPLETE_DEPTH                [port]->write(i);
    582                   in_BRANCH_COMPLETE_ADDRESS              [port]->write(0xcacacaca+i);
    583                   in_BRANCH_COMPLETE_FLAG                 [port]->write(0);
    584                  
    585                   if (_param->_have_port_depth[context])
    586                     {
    587                       TEST(Tdepth_t,out_DEPTH_TAIL     [context]->read(), 0);
    588                     }
    589                       TEST(Tdepth_t,out_DEPTH_NB_BRANCH[context]->read(), _param->_size_queue[context]);
    590                  
    591                   SC_START(0);
    592                  
    593                   LABEL("BRANCH_COMPLETE [%d] %d - %d.",port,in_BRANCH_COMPLETE_VAL [port]->read(),out_BRANCH_COMPLETE_ACK [port]->read());
    594                  
    595                   if (in_BRANCH_COMPLETE_VAL [port]->read() and out_BRANCH_COMPLETE_ACK [port]->read())
    596                     {
    597                       LABEL("BRANCH_COMPLETE [%d] - Transaction accepted",port);
    598                       find = true;
    599                      
    600                       TEST(Tcontrol_t,out_BRANCH_COMPLETE_MISS_PREDICTION[port]->read(),1);
    601                       TEST(Tcontrol_t,out_BRANCH_COMPLETE_TAKE           [port]->read(),0);
    602                       TEST(Taddress_t,out_BRANCH_COMPLETE_ADDRESS_SRC    [port]->read(),0xdeadbeef+i);
    603                       TEST(Taddress_t,out_BRANCH_COMPLETE_ADDRESS_DEST   [port]->read(),0x21071981+i);
    604                     }
    605                  
    606                   SC_START(1);
    607 
    608                 } while (not find);
    609               in_BRANCH_COMPLETE_VAL              [port]->write(0);
    610             }
    611         }
    612        
    613         LABEL("UPDATE - miss ifetch");
    614        
    615         {
    616           uint32_t port = 0; //rand() % _param->_nb_inst_update;
    617          
    618 //        for (uint32_t i=0; i<_param->_size_queue[context]; i++)
    619             {
    620               uint32_t i=0;
    621 
    622               bool find = false;
    623               do
    624                 {
    625                   in_UPDATE_ACK [port]->write((rand()%100)<percent_transaction_update);
    626                  
    627                   SC_START(0);
    628                  
    629                   if (out_UPDATE_VAL [port]->read() and in_UPDATE_ACK [port]->read())
    630                     {
    631                       LABEL("UPDATE [%d] - Transaction accepted",port);
    632                      
    633                       find = true;
    634                      
    635                       TEST(Tcontext_t         ,out_UPDATE_CONTEXT_ID            [port]->read(), context);
    636                       TEST(Tcontrol_t         ,out_UPDATE_MISS_PREDICTION       [port]->read(), 1);
    637                       TEST(Tcontrol_t         ,out_UPDATE_DIRECTION_GOOD        [port]->read(), 0);
    638                       TEST(Tcontrol_t         ,out_UPDATE_BTB_VAL               [port]->read(), 1);
    639                       TEST(Taddress_t         ,out_UPDATE_BTB_ADDRESS_SRC       [port]->read(), 0xdeadbeef+i);
    640                       TEST(Taddress_t         ,out_UPDATE_BTB_ADDRESS_DEST      [port]->read(), 0x21071981+i);       
    641                       TEST(Tbranch_condition_t,out_UPDATE_BTB_CONDITION         [port]->read(), BRANCH_CONDITION_FLAG_SET);
    642                       TEST(Tcontrol_t         ,out_UPDATE_DIR_VAL               [port]->read(), 1);
    643                       if (_param->_have_port_history)
    644                         TEST(Thistory_t         ,out_UPDATE_DIR_HISTORY           [port]->read(), i);
    645                       TEST(Tcontrol_t         ,out_UPDATE_RAS_VAL               [port]->read(), 0);
    646                       TEST(Tcontrol_t         ,out_UPDATE_RAS_PUSH              [port]->read(), 0);
    647                       TEST(Taddress_t         ,out_UPDATE_RAS_ADDRESS           [port]->read(), 0xdeaddead+i);
    648                       TEST(Tptr_t             ,out_UPDATE_RAS_INDEX             [port]->read(), (0x12345678+i)%_param->_size_ras_index[context]);
    649                       TEST(Tcontrol_t         ,out_UPDATE_RAS_PREDICTION_IFETCH [port]->read(), 1);
    650                     }
    651                  
    652                   SC_START(1);
    653                  
    654                 } while (not find);
    655               in_UPDATE_ACK              [port]->write(0);
    656             }
    657            
    658             LABEL("Wait a moment");
    659             SC_START(_param->_size_queue[context]);
    660            
    661             // wait the garbage collector
    662             while (((not (_param->_have_port_depth[context])) or (out_DEPTH_TAIL     [context]->read() != 0)) and
    663                    (out_DEPTH_NB_BRANCH[context]->read() != 0))
    664                 {
    665                   LABEL("DEPTH [%d] nb_branch : %d - tail : %d",context,out_DEPTH_NB_BRANCH[context]->read(), out_DEPTH_TAIL [context]->read());
    666                   SC_START(1);
    667                 }
    668         }
    669       }
    670 
    671       LABEL ("Yo1");
    672       SC_START(1);
    673       LABEL ("Yo2");
    674 
    675     }
     588    }// ITERATION
    676589
    677590  /********************************************************
     
    699612  delete []  in_PREDICT_RAS_ADDRESS         ;
    700613  delete []  in_PREDICT_RAS_INDEX           ;
    701 //delete [] out_PREDICT_UPDATE_PREDICTION_ID;
     614  delete [] out_PREDICT_UPDATE_PREDICTION_ID;
    702615 
    703616  // ~~~~~[ Interface : "decod" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     
    715628  delete []  in_DECOD_UPDATE_PREDICTION_ID  ;
    716629//delete [] out_DECOD_DEPTH                 ;
     630  delete []  in_DECOD_IS_ACCURATE           ;
    717631 
    718632  // ~~~~~[ Interface : "branch_complete" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     
    756670
    757671  // ~~~~~[ Interface : "depth" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    758   delete [] out_DEPTH_NB_BRANCH;
    759   delete [] out_DEPTH_TAIL;
     672  delete [] out_DEPTH_CURRENT;
     673  delete [] out_DEPTH_MIN;
     674  delete [] out_DEPTH_MAX;
    760675
    761676#endif
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/include/Parameters.h

    r82 r88  
    2424  {
    2525    //-----[ fields ]------------------------------------------------------------
    26   public : uint32_t   _nb_context             ;
    27   public : uint32_t * _size_queue             ; // [nb_context]
    28   public : uint32_t   _size_address           ;
    29   public : uint32_t   _nb_inst_predict        ;
    30   public : uint32_t   _nb_inst_decod          ;
    31   public : uint32_t   _nb_inst_branch_complete;
    32   public : uint32_t   _nb_inst_update         ;
    33   public : uint32_t   _size_history           ;
    34   public : uint32_t * _size_ras_index         ; // [nb_context]
     26  public : uint32_t   _nb_context                ;
     27  public : uint32_t * _size_upt_queue            ; // [nb_context]
     28  public : uint32_t * _size_ufpt_queue           ; // [nb_context]
     29//public : uint32_t   _size_address              ;
     30  public : uint32_t   _nb_inst_predict           ;
     31  public : uint32_t   _nb_inst_decod             ;
     32  public : uint32_t   _nb_inst_branch_complete   ;
     33  public : uint32_t   _nb_inst_update            ;
     34  public : uint32_t   _size_history              ;
     35  public : uint32_t * _size_ras_index            ; // [nb_context]
     36  public : const bool _not_accurate_block_predict;
    3537
    36   public : uint32_t   _size_context_id        ;
    37   public : uint32_t * _size_depth             ; // [nb_context]
    38   public : uint32_t   _max_size_depth         ;
    39   public : uint32_t   _max_size_ras_index     ;
    40                      
    41   public : bool       _have_port_context_id   ;
    42   public : bool     * _have_port_depth        ; // [nb_context]
    43   public : bool       _have_port_max_depth    ;
    44   public : bool       _have_port_history      ;
     38//public : uint32_t   _size_context_id           ;
     39//public : uint32_t * _size_depth                ; // [nb_context]
     40//public : uint32_t   _max_size_depth            ;
     41  public : uint32_t   _max_size_ras_index        ;
     42                                                 
     43//public : bool       _have_port_context_id      ;
     44//public : bool     * _have_port_depth           ; // [nb_context]
     45//public : bool       _have_port_max_depth       ;
     46  public : bool       _have_port_history         ;
    4547   
    4648    //-----[ methods ]-----------------------------------------------------------
    4749  public : Parameters  (uint32_t   nb_context             ,
    48                         uint32_t * size_queue             ,
     50                        uint32_t * size_upt_queue         ,
     51                        uint32_t * size_ufpt_queue        ,
    4952                        uint32_t   size_address           ,
    5053                        uint32_t   nb_inst_predict        ,
     
    5356                        uint32_t   nb_inst_update         ,
    5457                        uint32_t   size_history           ,
    55                         uint32_t * size_ras_index         );
     58                        uint32_t * size_ras_index         ,
     59                        bool       is_toplevel=false);
    5660//public : Parameters  (Parameters & param) ;
    5761  public : ~Parameters () ;
     62
     63  public :        void            copy       (void);
    5864
    5965  public :        Parameters_test msg_error  (void);
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/include/Types.h

    r82 r88  
    2121  typedef enum
    2222    {
    23       UPDATE_PREDICTION_STATE_EMPTY      , // Slot is empty
    24       UPDATE_PREDICTION_STATE_WAIT_DECOD , // Fetch have access at the predictor
    25       UPDATE_PREDICTION_STATE_WAITEND    , // Have make a prediction, wait branch_complete
    26       UPDATE_PREDICTION_STATE_EVENT      , // have a event - must signal at the context_unit
    27       UPDATE_PREDICTION_STATE_OK         , // branch is complete and can update predictor
    28       UPDATE_PREDICTION_STATE_KO         , // have a event - must update predictor unit
    29       UPDATE_PREDICTION_STATE_END          // branch is updated
    30     } state_t;
     23      EVENT_STATE_OK                 , // Can predict
     24      EVENT_STATE_FLUSH_UFPT         , // in decod  stage, detect a miss, continue to execute but flush ufpt
     25      EVENT_STATE_FLUSH_UFPT_AND_UPT , // in commit stage, detect a miss, stop context and flush ufpt and upt
     26      EVENT_STATE_FLUSH_UPT_RAS      , // in commit stage, detect a miss, context is stop and ufpt is flush, update RAS
     27      EVENT_STATE_FLUSH_UPT          , // in commit stage, detect a miss, context is stop and ufpt is flush
     28      EVENT_STATE_UPDATE_CONTEXT       // prediction unit is update, send signal to context manager
     29    } event_state_t;
    3130
    32   class entry_t
     31  typedef enum
     32    {
     33      UPDATE_FETCH_PREDICTION_STATE_EMPTY       , // Slot is empty
     34      UPDATE_FETCH_PREDICTION_STATE_WAIT_DECOD  , // Have make a prediction, wait decod
     35      UPDATE_FETCH_PREDICTION_STATE_EVENT       , // previous branch is a miss prediction
     36      UPDATE_FETCH_PREDICTION_STATE_END           // branch is updated
     37    } ufpt_state_t;
     38
     39  typedef enum
     40    {
     41      UPDATE_PREDICTION_STATE_EMPTY             , // Slot is empty
     42      UPDATE_PREDICTION_STATE_WAIT_END          , // Have make a prediction, wait branch_complete
     43      UPDATE_PREDICTION_STATE_OK                , // this branch is a hit prediction
     44      UPDATE_PREDICTION_STATE_KO                , // this branch is a miss prediction
     45      UPDATE_PREDICTION_STATE_EVENT             , // previous branch is a miss prediction
     46      UPDATE_PREDICTION_STATE_END                 // branch is updated
     47    } upt_state_t;
     48
     49  class ufpt_entry_t
    3350  {
    34   public : state_t             _state;
    35   public : Tcontrol_t          _ifetch_prediction;
    36   public : Tbranch_condition_t _condition;
    37   public : Taddress_t          _address_src;
    38   public : Taddress_t          _address_dest;
    39   public : Tcontrol_t          _last_take;
    40   public : Tcontrol_t          _good_take;
    41   public : Thistory_t          _history;
    42   public : Taddress_t          _address_ras;
    43   public : Tptr_t              _index_ras;
     51  public : ufpt_state_t        _state            ;
     52  public : Tbranch_condition_t _condition        ;
     53  public : Taddress_t          _address_src      ;
     54  public : Taddress_t          _address_dest     ;
     55  public : Tcontrol_t          _last_take        ;
     56//public : Tcontrol_t          _good_take        ;
     57  public : Tcontrol_t          _is_accurate      ;
     58  public : Thistory_t          _history          ;
     59  public : Taddress_t          _address_ras      ;
     60  public : Tptr_t              _index_ras        ;
     61//public : Tcontrol_t          _ifetch_prediction;
    4462  };
     63
     64  class upt_entry_t
     65  {
     66  public : upt_state_t         _state            ;
     67  public : Tbranch_condition_t _condition        ;
     68  public : Taddress_t          _address_src      ;
     69  public : Taddress_t          _address_dest     ;
     70  public : Tcontrol_t          _last_take        ;
     71  public : Tcontrol_t          _good_take        ; // not in ufpt
     72  public : Tcontrol_t          _is_accurate      ;
     73  public : Thistory_t          _history          ;
     74  public : Taddress_t          _address_ras      ;
     75  public : Tptr_t              _index_ras        ;
     76  public : Tcontrol_t          _ifetch_prediction; // not in ufpt
     77  };
     78
     79
     80// BRANCH_CONDITION_NONE_WITHOUT_WRITE_STACK         
     81// BRANCH_CONDITION_NONE_WITH_WRITE_STACK             
     82// BRANCH_CONDITION_FLAG_UNSET                       
     83// BRANCH_CONDITION_FLAG_SET                         
     84// BRANCH_CONDITION_READ_REGISTER_WITHOUT_WRITE_STACK
     85// BRANCH_CONDITION_READ_REGISTER_WITH_WRITE_STACK   
     86// BRANCH_CONDITION_READ_STACK                       
     87
     88
     89#define update_btb(cond)  true
     90
     91#define update_dir(cond)  ((cond == BRANCH_CONDITION_FLAG_UNSET) or \
     92                           (cond == BRANCH_CONDITION_FLAG_SET))
     93
     94#define update_ras(cond)  ((cond == BRANCH_CONDITION_NONE_WITH_WRITE_STACK         ) or \
     95                           (cond == BRANCH_CONDITION_READ_REGISTER_WITH_WRITE_STACK) or \
     96                           (cond == BRANCH_CONDITION_READ_STACK                    ))
     97
     98#define push_ras(cond)    ((cond == BRANCH_CONDITION_NONE_WITH_WRITE_STACK         ) or \
     99                           (cond == BRANCH_CONDITION_READ_REGISTER_WITH_WRITE_STACK))
     100
     101#define pop_ras(cond)     ((cond == BRANCH_CONDITION_READ_STACK                    ))
     102
     103#define need_update(cond) update_ras(cond)
    45104
    46105}; // end namespace update_prediction_table
     
    51110}; // end namespace behavioural
    52111 
     112  template<> inline std::string toString<morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::event_state_t>(const morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::event_state_t& x)
     113  {
     114    switch (x)
     115      {
     116      case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::EVENT_STATE_OK                   : return "ok"                  ; break;
     117      case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::EVENT_STATE_FLUSH_UFPT           : return "flush_ufpt"          ; break;
     118      case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::EVENT_STATE_FLUSH_UFPT_AND_UPT   : return "flush_ufpt_and_upt"  ; break;
     119      case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::EVENT_STATE_FLUSH_UPT_RAS        : return "flush_upt_ras"       ; break;
     120      case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::EVENT_STATE_FLUSH_UPT            : return "flush_upt"           ; break;
     121      case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::EVENT_STATE_UPDATE_CONTEXT       : return "update_context"      ; break;
     122      default    : return ""      ; break;
     123      }
     124  };
    53125
    54   template<> inline std::string toString<morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::state_t>(const morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::state_t& x)
     126  template<> inline std::string toString<morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::ufpt_state_t>(const morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::ufpt_state_t& x)
     127  {
     128    switch (x)
     129      {
     130      case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::UPDATE_FETCH_PREDICTION_STATE_EMPTY      : return "empty"     ; break;
     131      case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::UPDATE_FETCH_PREDICTION_STATE_WAIT_DECOD : return "wait_decod"; break;
     132      case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::UPDATE_FETCH_PREDICTION_STATE_EVENT      : return "event"     ; break;
     133      case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::UPDATE_FETCH_PREDICTION_STATE_END        : return "end"       ; break;
     134      default    : return ""      ; break;
     135      }
     136  };
     137
     138  template<> inline std::string toString<morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::upt_state_t>(const morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::upt_state_t& x)
    55139  {
    56140    switch (x)
    57141      {
    58142      case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::UPDATE_PREDICTION_STATE_EMPTY      : return "empty"     ; break;
    59       case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::UPDATE_PREDICTION_STATE_WAIT_DECOD : return "wait_decod"; break;
    60       case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::UPDATE_PREDICTION_STATE_WAITEND    : return "waitend"   ; break;
    61       case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::UPDATE_PREDICTION_STATE_EVENT      : return "event"     ; break;
     143      case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::UPDATE_PREDICTION_STATE_WAIT_END   : return "wait_end"  ; break;
    62144      case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::UPDATE_PREDICTION_STATE_OK         : return "ok"        ; break;
    63145      case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::UPDATE_PREDICTION_STATE_KO         : return "ko"        ; break;
     146      case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::UPDATE_PREDICTION_STATE_EVENT      : return "event"     ; break;
    64147      case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::UPDATE_PREDICTION_STATE_END        : return "end"       ; break;
    65148      default    : return ""      ; break;
     
    67150  };
    68151
    69 
    70152}; // end namespace morpheo             
    71153
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/include/Update_Prediction_Table.h

    r82 r88  
    5151#ifdef STATISTICS
    5252  public    : Stat                           * _stat;
     53
     54  private   : counter_t                     ** _stat_nb_branch_hit       ; //[nb_context]
     55  private   : counter_t                     ** _stat_nb_branch_miss      ; //[nb_context]
     56  private   : counter_t                     ** _stat_nb_branch_unused    ; //[nb_context]
     57  private   : counter_t                     ** _stat_queue_nb_cycle_empty; //[nb_context]
     58  private   : counter_t                     ** _stat_queue_nb_cycle_full ; //[nb_context]
     59  private   : counter_t                     ** _stat_queue_nb_elt        ; //[nb_context]
     60
    5361#endif
    5462
     
    5967    // ~~~~~[ Interface ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    6068    // ~~~~~[ Interface : "" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    61   public    : SC_CLOCK                      *  in_CLOCK        ;
    62   public    : SC_IN (Tcontrol_t)            *  in_NRESET       ;
     69  public    : SC_CLOCK                      *  in_CLOCK                          ;
     70  public    : SC_IN (Tcontrol_t)            *  in_NRESET                         ;
    6371
    6472    // ~~~~~[ Interface : "predict" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    65   public    : SC_IN (Tcontrol_t         )  **  in_PREDICT_VAL                 ; //[nb_inst_predict]
    66   public    : SC_OUT(Tcontrol_t         )  ** out_PREDICT_ACK                 ; //[nb_inst_predict]
    67   public    : SC_IN (Tcontext_t         )  **  in_PREDICT_CONTEXT_ID          ; //[nb_inst_predict]
    68   public    : SC_IN (Taddress_t         )  **  in_PREDICT_BTB_ADDRESS_SRC     ; //[nb_inst_predict]
    69   public    : SC_IN (Taddress_t         )  **  in_PREDICT_BTB_ADDRESS_DEST    ; //[nb_inst_predict]
    70   public    : SC_IN (Tbranch_condition_t)  **  in_PREDICT_BTB_CONDITION       ; //[nb_inst_predict]
    71   public    : SC_IN (Tcontrol_t         )  **  in_PREDICT_BTB_LAST_TAKE       ; //[nb_inst_predict]
    72   public    : SC_IN (Tcontrol_t         )  **  in_PREDICT_BTB_IS_ACCURATE     ; //[nb_inst_predict]
    73   public    : SC_IN (Thistory_t         )  **  in_PREDICT_DIR_HISTORY         ; //[nb_inst_predict]
    74   public    : SC_IN (Taddress_t         )  **  in_PREDICT_RAS_ADDRESS         ; //[nb_inst_predict]
    75   public    : SC_IN (Tptr_t             )  **  in_PREDICT_RAS_INDEX           ; //[nb_inst_predict]
    76 //public    : SC_OUT(Tprediction_ptr_t  )  ** out_PREDICT_UPDATE_PREDICTION_ID; //[nb_inst_predict]
     73  public    : SC_IN (Tcontrol_t         )  **  in_PREDICT_VAL                    ; //[nb_inst_predict]
     74  public    : SC_OUT(Tcontrol_t         )  ** out_PREDICT_ACK                    ; //[nb_inst_predict]
     75  public    : SC_IN (Tcontext_t         )  **  in_PREDICT_CONTEXT_ID             ; //[nb_inst_predict]
     76  public    : SC_IN (Taddress_t         )  **  in_PREDICT_BTB_ADDRESS_SRC        ; //[nb_inst_predict]
     77  public    : SC_IN (Taddress_t         )  **  in_PREDICT_BTB_ADDRESS_DEST       ; //[nb_inst_predict]
     78  public    : SC_IN (Tbranch_condition_t)  **  in_PREDICT_BTB_CONDITION          ; //[nb_inst_predict]
     79  public    : SC_IN (Tcontrol_t         )  **  in_PREDICT_BTB_LAST_TAKE          ; //[nb_inst_predict]
     80  public    : SC_IN (Tcontrol_t         )  **  in_PREDICT_BTB_IS_ACCURATE        ; //[nb_inst_predict]
     81  public    : SC_IN (Thistory_t         )  **  in_PREDICT_DIR_HISTORY            ; //[nb_inst_predict]
     82  public    : SC_IN (Taddress_t         )  **  in_PREDICT_RAS_ADDRESS            ; //[nb_inst_predict]
     83  public    : SC_IN (Tptr_t             )  **  in_PREDICT_RAS_INDEX              ; //[nb_inst_predict]
     84  public    : SC_OUT(Tprediction_ptr_t  )  ** out_PREDICT_UPDATE_PREDICTION_ID   ; //[nb_inst_predict]
    7785
    7886    // ~~~~~[ Interface : "decod" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    79   public    : SC_IN (Tcontrol_t         )  **  in_DECOD_VAL                   ; //[nb_inst_decod]
    80   public    : SC_OUT(Tcontrol_t         )  ** out_DECOD_ACK                   ; //[nb_inst_decod]
    81   public    : SC_IN (Tcontext_t         )  **  in_DECOD_CONTEXT_ID            ; //[nb_inst_decod]
    82   public    : SC_IN (Taddress_t         )  **  in_DECOD_BTB_ADDRESS_SRC       ; //[nb_inst_decod]
    83   public    : SC_IN (Taddress_t         )  **  in_DECOD_BTB_ADDRESS_DEST      ; //[nb_inst_decod]
    84   public    : SC_IN (Tbranch_condition_t)  **  in_DECOD_BTB_CONDITION         ; //[nb_inst_decod]
    85   public    : SC_IN (Tcontrol_t         )  **  in_DECOD_BTB_LAST_TAKE         ; //[nb_inst_decod]
    86 //public    : SC_IN (Tcontrol_t         )  **  in_DECOD_BTB_IS_ACCURATE       ; //[nb_inst_decod]
    87 //public    : SC_IN (Thistory_t         )  **  in_DECOD_DIR_HISTORY           ; //[nb_inst_decod] // if ifetch prediction is miss -> miss btb -> make a static state
    88   public    : SC_IN (Taddress_t         )  **  in_DECOD_RAS_ADDRESS           ; //[nb_inst_decod]
    89   public    : SC_IN (Tptr_t             )  **  in_DECOD_RAS_INDEX             ; //[nb_inst_decod]
    90   public    : SC_IN (Tcontrol_t         )  **  in_DECOD_MISS_IFETCH           ; //[nb_inst_decod]
    91   public    : SC_IN (Tcontrol_t         )  **  in_DECOD_MISS_DECOD            ; //[nb_inst_decod]
    92   public    : SC_IN (Tprediction_ptr_t  )  **  in_DECOD_UPDATE_PREDICTION_ID  ; //[nb_inst_decod]
    93 //public    : SC_OUT(Tdepth_t           )  ** out_DECOD_DEPTH                 ; //[nb_inst_decod]
     87  public    : SC_IN (Tcontrol_t         )  **  in_DECOD_VAL                      ; //[nb_inst_decod]
     88  public    : SC_OUT(Tcontrol_t         )  ** out_DECOD_ACK                      ; //[nb_inst_decod]
     89  public    : SC_IN (Tcontext_t         )  **  in_DECOD_CONTEXT_ID               ; //[nb_inst_decod]
     90  public    : SC_IN (Taddress_t         )  **  in_DECOD_BTB_ADDRESS_SRC          ; //[nb_inst_decod]
     91  public    : SC_IN (Taddress_t         )  **  in_DECOD_BTB_ADDRESS_DEST         ; //[nb_inst_decod]
     92  public    : SC_IN (Tbranch_condition_t)  **  in_DECOD_BTB_CONDITION            ; //[nb_inst_decod]
     93  public    : SC_IN (Tcontrol_t         )  **  in_DECOD_BTB_LAST_TAKE            ; //[nb_inst_decod]
     94//public    : SC_IN (Thistory_t         )  **  in_DECOD_DIR_HISTORY              ; //[nb_inst_decod] // if ifetch prediction is miss -> miss btb -> make a static state
     95  public    : SC_IN (Taddress_t         )  **  in_DECOD_RAS_ADDRESS              ; //[nb_inst_decod]
     96  public    : SC_IN (Tptr_t             )  **  in_DECOD_RAS_INDEX                ; //[nb_inst_decod]
     97  public    : SC_IN (Tcontrol_t         )  **  in_DECOD_MISS_IFETCH              ; //[nb_inst_decod]
     98  public    : SC_IN (Tcontrol_t         )  **  in_DECOD_MISS_DECOD               ; //[nb_inst_decod]
     99  public    : SC_IN (Tprediction_ptr_t  )  **  in_DECOD_UPDATE_PREDICTION_ID     ; //[nb_inst_decod]
     100//public    : SC_OUT(Tdepth_t           )  ** out_DECOD_DEPTH                    ; //[nb_inst_decod]
     101  public    : SC_IN (Tcontrol_t         )  **  in_DECOD_IS_ACCURATE              ; //[nb_inst_decod]
    94102
    95103    // ~~~~~[ Interface : "branch_complete" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     
    106114
    107115    // ~~~~~[ Interface : "branch_event" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    108   public    : SC_OUT(Tcontrol_t         )  ** out_BRANCH_EVENT_VAL            ; //[nb_context]
    109   public    : SC_IN (Tcontrol_t         )  **  in_BRANCH_EVENT_ACK            ; //[nb_context]
    110 //public    : SC_OUT(Tcontext_t         )  ** out_BRANCH_EVENT_CONTEXT_ID     ; //[nb_context]
    111 //public    : SC_OUT(Tdepth_t           )  ** out_BRANCH_EVENT_DEPTH          ; //[nb_context]
    112 //public    : SC_OUT(Tcontrol_t         )  ** out_BRANCH_EVENT_MISS_PREDICTION; //[nb_context] is always miss prediction
    113   public    : SC_OUT(Taddress_t         )  ** out_BRANCH_EVENT_ADDRESS_SRC    ; //[nb_context]
    114   public    : SC_OUT(Taddress_t         )  ** out_BRANCH_EVENT_ADDRESS_DEST   ; //[nb_context]
     116  public    : SC_OUT(Tcontrol_t         )  ** out_BRANCH_EVENT_VAL               ; //[nb_context]
     117  public    : SC_IN (Tcontrol_t         )  **  in_BRANCH_EVENT_ACK               ; //[nb_context]
     118//public    : SC_OUT(Tcontext_t         )  ** out_BRANCH_EVENT_CONTEXT_ID        ; //[nb_context]
     119//public    : SC_OUT(Tdepth_t           )  ** out_BRANCH_EVENT_DEPTH             ; //[nb_context]
     120//public    : SC_OUT(Tcontrol_t         )  ** out_BRANCH_EVENT_MISS_PREDICTION   ; //[nb_context] is always miss prediction
     121  public    : SC_OUT(Taddress_t         )  ** out_BRANCH_EVENT_ADDRESS_SRC       ; //[nb_context]
     122  public    : SC_OUT(Taddress_t         )  ** out_BRANCH_EVENT_ADDRESS_DEST      ; //[nb_context]
    115123
    116124    // ~~~~~[ Interface : "update" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    117   public    : SC_OUT(Tcontrol_t         )  ** out_UPDATE_VAL                  ; //[nb_inst_update]
    118   public    : SC_IN (Tcontrol_t         )  **  in_UPDATE_ACK                  ; //[nb_inst_update]
    119   public    : SC_OUT(Tcontext_t         )  ** out_UPDATE_CONTEXT_ID           ; //[nb_inst_update]
    120   public    : SC_OUT(Tcontrol_t         )  ** out_UPDATE_MISS_PREDICTION      ; //[nb_inst_update]
    121   public    : SC_OUT(Tcontrol_t         )  ** out_UPDATE_DIRECTION_GOOD       ; //[nb_inst_update]
    122   public    : SC_OUT(Tcontrol_t         )  ** out_UPDATE_BTB_VAL              ; //[nb_inst_update]
    123   public    : SC_OUT(Taddress_t         )  ** out_UPDATE_BTB_ADDRESS_SRC      ; //[nb_inst_update]
    124   public    : SC_OUT(Taddress_t         )  ** out_UPDATE_BTB_ADDRESS_DEST     ; //[nb_inst_update]
    125   public    : SC_OUT(Tbranch_condition_t)  ** out_UPDATE_BTB_CONDITION        ; //[nb_inst_update]
    126   public    : SC_OUT(Tcontrol_t         )  ** out_UPDATE_DIR_VAL              ; //[nb_inst_update]
    127   public    : SC_OUT(Thistory_t         )  ** out_UPDATE_DIR_HISTORY          ; //[nb_inst_update]
    128   public    : SC_OUT(Tcontrol_t         )  ** out_UPDATE_RAS_VAL              ; //[nb_inst_update]
    129   public    : SC_OUT(Tcontrol_t         )  ** out_UPDATE_RAS_PUSH             ; //[nb_inst_update]
    130   public    : SC_OUT(Taddress_t         )  ** out_UPDATE_RAS_ADDRESS          ; //[nb_inst_update]
    131   public    : SC_OUT(Tptr_t             )  ** out_UPDATE_RAS_INDEX            ; //[nb_inst_update]
    132   public    : SC_OUT(Tcontrol_t         )  ** out_UPDATE_RAS_PREDICTION_IFETCH; //[nb_inst_update]
     125  public    : SC_OUT(Tcontrol_t         )  ** out_UPDATE_VAL                     ; //[nb_inst_update]
     126  public    : SC_IN (Tcontrol_t         )  **  in_UPDATE_ACK                     ; //[nb_inst_update]
     127  public    : SC_OUT(Tcontext_t         )  ** out_UPDATE_CONTEXT_ID              ; //[nb_inst_update]
     128  public    : SC_OUT(Tcontrol_t         )  ** out_UPDATE_MISS_PREDICTION         ; //[nb_inst_update]
     129  public    : SC_OUT(Tcontrol_t         )  ** out_UPDATE_DIRECTION_GOOD          ; //[nb_inst_update]
     130  public    : SC_OUT(Tcontrol_t         )  ** out_UPDATE_BTB_VAL                 ; //[nb_inst_update]
     131  public    : SC_OUT(Taddress_t         )  ** out_UPDATE_BTB_ADDRESS_SRC         ; //[nb_inst_update]
     132  public    : SC_OUT(Taddress_t         )  ** out_UPDATE_BTB_ADDRESS_DEST        ; //[nb_inst_update]
     133  public    : SC_OUT(Tbranch_condition_t)  ** out_UPDATE_BTB_CONDITION           ; //[nb_inst_update]
     134  public    : SC_OUT(Tcontrol_t         )  ** out_UPDATE_DIR_VAL                 ; //[nb_inst_update]
     135  public    : SC_OUT(Thistory_t         )  ** out_UPDATE_DIR_HISTORY             ; //[nb_inst_update]
     136  public    : SC_OUT(Tcontrol_t         )  ** out_UPDATE_RAS_VAL                 ; //[nb_inst_update]
     137  public    : SC_OUT(Tcontrol_t         )  ** out_UPDATE_RAS_PUSH                ; //[nb_inst_update]
     138  public    : SC_OUT(Taddress_t         )  ** out_UPDATE_RAS_ADDRESS             ; //[nb_inst_update]
     139  public    : SC_OUT(Tptr_t             )  ** out_UPDATE_RAS_INDEX               ; //[nb_inst_update]
     140  public    : SC_OUT(Tcontrol_t         )  ** out_UPDATE_RAS_PREDICTION_IFETCH   ; //[nb_inst_update]
    133141
    134142    // ~~~~~[ Interface : "depth" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    135   public    : SC_OUT(Tdepth_t           )  ** out_DEPTH_NB_BRANCH; //[nb_context]
    136   public    : SC_OUT(Tdepth_t           )  ** out_DEPTH_TAIL; //[nb_context]
     143  public    : SC_OUT(Tdepth_t           )  ** out_DEPTH_CURRENT                  ; //[nb_context]
     144  public    : SC_OUT(Tdepth_t           )  ** out_DEPTH_MIN                      ; //[nb_context]
     145  public    : SC_OUT(Tdepth_t           )  ** out_DEPTH_MAX                      ; //[nb_context]
     146    // If DEPTH_CURRENT :
     147    // equal at     DEPTH_MIN            -> not speculative
     148    // not include ]DEPTH_MIN:DEPTH_MAX[ -> previous branch miss
     149    //     include ]DEPTH_MIN:DEPTH_MAX[ -> speculative
    137150
    138151    // ~~~~~[ Component ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
    139152
    140153    // ~~~~~[ Register ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
    141   private   : uint32_t                      * reg_TOP                    ; //[nb_context]
    142   private   : uint32_t                      * reg_BOTTOM                 ; //[nb_context]
    143   private   : uint32_t                      * reg_NB_ELT                 ; //[nb_context]
    144   private   : uint32_t                      * reg_NB_ELT_UPDATE          ; //[nb_context]
    145   private   : uint32_t                      * reg_NB_ELT_NEED_UPDATE     ; //[nb_context]
    146   private   : entry_t                      ** reg_UPDATE_PREDICTION_TABLE; //[nb_context][size_queue]
    147   private   : uint32_t                        reg_UPDATE_PRIORITY        ;
     154  private   : uint32_t                        reg_UPDATE_PRIORITY                ;
     155                                                                                 
     156  private   : ufpt_entry_t                 ** reg_UPDATE_FETCH_PREDICTION_TABLE  ; //[nb_context][size_ufpt_queue]
     157  private   : uint32_t                      * reg_UFPT_BOTTOM                    ; //[nb_context]
     158  private   : uint32_t                      * reg_UFPT_TOP                       ; //[nb_context]
     159  private   : uint32_t                      * reg_UFPT_UPDATE                    ; //[nb_context]
     160  private   : uint32_t                      * reg_UFPT_NB_NEED_UPDATE            ; //[nb_context]
     161                                                                                             
     162  private   : upt_entry_t                  ** reg_UPDATE_PREDICTION_TABLE        ; //[nb_context][size_upt_queue]
     163  private   : uint32_t                      * reg_UPT_BOTTOM                     ; //[nb_context]
     164  private   : uint32_t                      * reg_UPT_TOP                        ; //[nb_context]
     165  private   : uint32_t                      * reg_UPT_UPDATE                     ; //[nb_context]
     166  private   : uint32_t                      * reg_UPT_NB_NEED_UPDATE             ; //[nb_context]
     167                                                                                             
     168  private   : bool                          * reg_IS_ACCURATE                    ; //[nb_context]
     169
     170  private   : event_state_t                 * reg_EVENT_STATE                    ; //[nb_context]
     171  private   : Tcontrol_t                    * reg_EVENT_RAS_CORRUPTED            ; //[nb_context] // RAS must be flush
     172  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
     174  private   : Taddress_t                    * reg_EVENT_ADDRESS_DEST             ; //[nb_context] // Address dest
    148175
    149176    // ~~~~~[ Internal ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    150177  private   : Tcontrol_t                    * internal_PREDICT_ACK                    ; //[nb_inst_predict]
     178  private   : Tdepth_t                      * internal_PREDICT_UPDATE_PREDICTION_ID   ; //[nb_inst_predict]
    151179  private   : Tcontrol_t                    * internal_DECOD_ACK                      ; //[nb_inst_decod]
     180  private   : uint32_t                      * internal_DECOD_UPT_PTR_WRITE            ; //[nb_inst_decod]
    152181  private   : Tcontrol_t                    * internal_BRANCH_COMPLETE_ACK            ; //[nb_inst_branch_complete]
    153182  private   : Tcontrol_t                    * internal_BRANCH_COMPLETE_MISS_PREDICTION; //[nb_inst_branch_complete]
     
    157186  private   : Tdepth_t                      * internal_BRANCH_EVENT_DEPTH             ; //[nb_context]
    158187  private   : Tcontrol_t                    * internal_UPDATE_VAL                     ; //[nb_inst_update]
     188  private   : Tcontrol_t                    * internal_UPDATE_VAL_WITHOUT_ACK         ; //[nb_inst_update]
    159189  private   : Tcontext_t                    * internal_UPDATE_CONTEXT_ID              ; //[nb_inst_update]
     190  private   : bool                          * internal_UPDATE_FROM_UFPT               ; //[nb_inst_update]
    160191  private   : Tdepth_t                      * internal_UPDATE_DEPTH                   ; //[nb_inst_update]
     192  private   : bool                          * internal_UPDATE_RAS                     ; //[nb_inst_update]
     193
    161194#endif
    162195
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Parameters.cpp

    r82 r88  
    2121#define FUNCTION "Update_Prediction_Table::Parameters"
    2222  Parameters::Parameters (uint32_t   nb_context             ,
    23                           uint32_t * size_queue             ,
     23                          uint32_t * size_upt_queue         ,
     24                          uint32_t * size_ufpt_queue        ,
    2425                          uint32_t   size_address           ,
    2526                          uint32_t   nb_inst_predict        ,
     
    2829                          uint32_t   nb_inst_update         ,
    2930                          uint32_t   size_history           ,
    30                           uint32_t * size_ras_index         )
     31                          uint32_t * size_ras_index         ,
     32                          bool       is_toplevel):
     33    _not_accurate_block_predict (false)
    3134  {
    3235    log_printf(FUNC,Update_Prediction_Table,FUNCTION,"Begin");
    3336
    3437    _nb_context              = nb_context             ;
    35     _size_queue              = size_queue             ;
    36     _size_address            = size_address           ;
     38    _size_upt_queue          = size_upt_queue         ;
     39    _size_ufpt_queue         = size_ufpt_queue        ;
     40//  _size_address            = size_address           ;
    3741    _nb_inst_predict         = nb_inst_predict        ;
    3842    _nb_inst_decod           = nb_inst_decod          ;
     
    4246    _size_ras_index          = size_ras_index         ;
    4347   
    44     _size_context_id         = log2(nb_context);
    45     _size_depth              = new uint32_t[_nb_context];
    46     _have_port_depth         = new bool    [_nb_context];
    47     for (uint32_t i=0; i<_nb_context; i++)
    48       {
    49         _size_depth      [i] = log2(_size_queue[i]);
    50         _have_port_depth [i] = (_size_depth [i] > 0);
    51       }
    52     _max_size_depth          = max<uint32_t>(_size_depth,_nb_context);
    5348    _max_size_ras_index      = max<uint32_t>(_size_ras_index,nb_context);
    5449
    55     _have_port_context_id    = _size_context_id> 0;
    56     _have_port_max_depth     = _max_size_depth > 0;
    5750    _have_port_history       = _size_history   > 0;
     51
     52    test();
     53
     54    if (is_toplevel)
     55      {
     56        _size_instruction_address = size_address;
     57        _size_context_id          = log2(nb_context);
     58        _size_depth               = log2(max<uint32_t>(_size_upt_queue,_nb_context));
     59
     60        _have_port_context_id    = _size_context_id> 0;
     61        _have_port_depth          = _size_depth > 0;
     62
     63        copy ();
     64      }
    5865   
    59     test();
    6066    log_printf(FUNC,Update_Prediction_Table,FUNCTION,"End");
    6167  };
     
    7581  {
    7682    log_printf(FUNC,Update_Prediction_Table,FUNCTION,"Begin");
    77     delete [] _size_depth     ;
    78     delete [] _have_port_depth;
     83//     delete [] _size_depth     ;
     84//     delete [] _have_port_depth;
     85    log_printf(FUNC,Update_Prediction_Table,FUNCTION,"End");
     86  };
     87
     88#undef  FUNCTION
     89#define FUNCTION "Update_Prediction_Table::copy"
     90  void Parameters::copy (void)
     91  {
     92    log_printf(FUNC,Update_Prediction_Table,FUNCTION,"Begin");
    7993    log_printf(FUNC,Update_Prediction_Table,FUNCTION,"End");
    8094  };
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Parameters_msg_error.cpp

    r82 r88  
    88#include "Behavioural/include/Types.h"
    99#include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/include/Parameters.h"
     10#include "Common/include/Max.h"
    1011#include <sstream>
    1112
     
    2728    Parameters_test test ("Update_Prediction_Table");
    2829
    29     if (morpheo::behavioural::test<Tdepth_t>(_max_size_depth) == false)
    30       test.error("type \"Tdepth_t\" is too small.");
    31 
     30    for (uint32_t i=0; i<_nb_context; i++)
     31      if (_size_ufpt_queue [i] > _size_upt_queue [i])
     32        test.error(toString(_("context \"%d\" : size_upt_queue must be >= at size_ufpt_queue\n"),i));
     33   
    3234    log_printf(FUNC,Update_Prediction_Table,FUNCTION,"End");
    3335
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Parameters_print.cpp

    r81 r88  
    2828    xml.balise_open("update_prediction_table");
    2929    xml.singleton_begin("nb_context             "); xml.attribut("value",toString(_nb_context             )); xml.singleton_end();
    30     xml.singleton_begin("size_address           "); xml.attribut("value",toString(_size_address           )); xml.singleton_end();
     30//  xml.singleton_begin("size_address           "); xml.attribut("value",toString(_size_address           )); xml.singleton_end();
    3131    xml.singleton_begin("nb_inst_predict        "); xml.attribut("value",toString(_nb_inst_predict        )); xml.singleton_end();
    3232    xml.singleton_begin("nb_inst_decod          "); xml.attribut("value",toString(_nb_inst_decod          )); xml.singleton_end();
     
    4040        xml.  attribut("id"  ,toString(i));
    4141        xml. balise_open_end();
    42         xml.  singleton_begin("size_queue             "); xml.attribut("value",toString(_size_queue             [i])); xml.singleton_end();
     42        xml.  singleton_begin("size_upt_queue         "); xml.attribut("value",toString(_size_upt_queue         [i])); xml.singleton_end();
     43        xml.  singleton_begin("size_ufpt_queue        "); xml.attribut("value",toString(_size_ufpt_queue        [i])); xml.singleton_end();
    4344        xml.  singleton_begin("size_ras_index         "); xml.attribut("value",toString(_size_ras_index         [i])); xml.singleton_end();
    4445        xml. balise_close();
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table.cpp

    r82 r88  
    4040    usage_environment(_usage);
    4141
     42#if DEBUG_Update_Prediction_Table == true
     43    log_printf(INFO,Update_Prediction_Table,FUNCTION,_("<%s> Parameters"),_name.c_str());
     44
     45    std::cout << *param << std::endl;
     46#endif   
     47
    4248    log_printf(INFO,Update_Prediction_Table,FUNCTION,"Allocation");
    4349
     
    4955
    5056#ifdef STATISTICS
    51     if (_usage & USE_STATISTICS)
     57    if (usage_is_set(_usage,USE_STATISTICS))
    5258      {
    5359        log_printf(INFO,Update_Prediction_Table,FUNCTION,"Allocation of statistics");
     
    5864
    5965#ifdef VHDL
    60     if (_usage & USE_VHDL)
     66    if (usage_is_set(_usage,USE_VHDL))
    6167      {
    6268        // generate the vhdl
     
    6874
    6975#ifdef SYSTEMC
    70     if (_usage & USE_SYSTEMC)
     76    if (usage_is_set(_usage,USE_SYSTEMC))
    7177      {
    7278
     
    9197        SC_METHOD (genMoore);
    9298        dont_initialize ();
    93         sensitive << (*(in_CLOCK)).neg();
     99        sensitive << (*(in_CLOCK)).neg(); // use internal register
    94100       
    95101# ifdef SYSTEMCASS_SPECIFIC
     
    106112            if (_param->_have_port_context_id)
    107113              sensitive << (*(in_PREDICT_CONTEXT_ID [i]));
    108             sensitive << (*(in_PREDICT_BTB_IS_ACCURATE [i]));
     114//          sensitive << (*(in_PREDICT_BTB_IS_ACCURATE [i]));
    109115          }
    110116       
     
    128134            if (_param->_have_port_context_id)
    129135              sensitive << (*(in_DECOD_CONTEXT_ID [i]));
    130             sensitive << (*(in_DECOD_MISS_IFETCH [i]))
    131                       << (*(in_DECOD_MISS_DECOD  [i]));
    132136          }
    133137       
     
    136140        for (uint32_t i=0; i<_param->_nb_inst_decod; i++)
    137141          {
    138             (*(out_DECOD_ACK                  [i])) (*(in_DECOD_MISS_IFETCH [i]));
    139             (*(out_DECOD_ACK                  [i])) (*(in_DECOD_MISS_DECOD  [i]));
    140142            if (_param->_have_port_context_id)
    141143            (*(out_DECOD_ACK                  [i])) (*(in_DECOD_CONTEXT_ID  [i]));
     
    152154            if (_param->_have_port_context_id)
    153155            sensitive << (*(in_BRANCH_COMPLETE_CONTEXT_ID [i]));
    154             if (_param->_have_port_max_depth)
     156            if (_param->_have_port_depth)
    155157            sensitive << (*(in_BRANCH_COMPLETE_DEPTH [i]));
    156158            sensitive << (*(in_BRANCH_COMPLETE_FLAG    [i]))
     
    164166            if (_param->_have_port_context_id)
    165167            (*(out_BRANCH_COMPLETE_MISS_PREDICTION [i])) (*(in_BRANCH_COMPLETE_CONTEXT_ID [i]));
    166             if (_param->_have_port_max_depth)
     168            if (_param->_have_port_depth)
    167169            (*(out_BRANCH_COMPLETE_MISS_PREDICTION [i])) (*(in_BRANCH_COMPLETE_DEPTH      [i]));
    168170            (*(out_BRANCH_COMPLETE_MISS_PREDICTION [i])) (*(in_BRANCH_COMPLETE_FLAG       [i]));
     
    171173            if (_param->_have_port_context_id)
    172174            (*(out_BRANCH_COMPLETE_TAKE            [i])) (*(in_BRANCH_COMPLETE_CONTEXT_ID [i]));
    173             if (_param->_have_port_max_depth)
     175            if (_param->_have_port_depth)
    174176            (*(out_BRANCH_COMPLETE_TAKE            [i])) (*(in_BRANCH_COMPLETE_DEPTH      [i]));
    175177            (*(out_BRANCH_COMPLETE_TAKE            [i])) (*(in_BRANCH_COMPLETE_FLAG       [i]));
     
    177179            if (_param->_have_port_context_id)
    178180            (*(out_BRANCH_COMPLETE_ADDRESS_SRC     [i])) (*(in_BRANCH_COMPLETE_CONTEXT_ID [i]));
    179             if (_param->_have_port_max_depth)
     181            if (_param->_have_port_depth)
    180182            (*(out_BRANCH_COMPLETE_ADDRESS_SRC     [i])) (*(in_BRANCH_COMPLETE_DEPTH      [i]));
    181183
    182184            if (_param->_have_port_context_id)
    183185            (*(out_BRANCH_COMPLETE_ADDRESS_DEST    [i])) (*(in_BRANCH_COMPLETE_CONTEXT_ID [i]));
    184             if (_param->_have_port_max_depth)
     186            if (_param->_have_port_depth)
    185187            (*(out_BRANCH_COMPLETE_ADDRESS_DEST    [i])) (*(in_BRANCH_COMPLETE_DEPTH      [i]));
    186188            (*(out_BRANCH_COMPLETE_ADDRESS_DEST    [i])) (*(in_BRANCH_COMPLETE_ADDRESS    [i]));
     
    200202
    201203#ifdef STATISTICS
    202     if (_usage & USE_STATISTICS)
     204    if (usage_is_set(_usage,USE_STATISTICS))
    203205      {
    204206        statistics_deallocation();
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_allocation.cpp

    r82 r88  
    6363      ALLOC1_VALACK_OUT(out_PREDICT_ACK                 ,ACK);
    6464      ALLOC1_SIGNAL_IN ( in_PREDICT_CONTEXT_ID          ,"context_id"          ,Tcontext_t         ,_param->_size_context_id);
    65       ALLOC1_SIGNAL_IN ( in_PREDICT_BTB_ADDRESS_SRC     ,"btb_address_src"     ,Taddress_t         ,_param->_size_address);
    66       ALLOC1_SIGNAL_IN ( in_PREDICT_BTB_ADDRESS_DEST    ,"btb_address_dest"    ,Taddress_t         ,_param->_size_address);
     65      ALLOC1_SIGNAL_OUT(out_PREDICT_UPDATE_PREDICTION_ID,"update_prediction_id",Tprediction_ptr_t  ,_param->_size_depth);
     66      ALLOC1_SIGNAL_IN ( in_PREDICT_BTB_ADDRESS_SRC     ,"btb_address_src"     ,Taddress_t         ,_param->_size_instruction_address);
     67      ALLOC1_SIGNAL_IN ( in_PREDICT_BTB_ADDRESS_DEST    ,"btb_address_dest"    ,Taddress_t         ,_param->_size_instruction_address);
    6768      ALLOC1_SIGNAL_IN ( in_PREDICT_BTB_CONDITION       ,"btb_condition"       ,Tbranch_condition_t,_param->_size_branch_condition);
    6869      ALLOC1_SIGNAL_IN ( in_PREDICT_BTB_LAST_TAKE       ,"btb_last_take"       ,Tcontrol_t         ,1);
    6970      ALLOC1_SIGNAL_IN ( in_PREDICT_BTB_IS_ACCURATE     ,"btb_is_accurate"     ,Tcontrol_t         ,1);
    7071      ALLOC1_SIGNAL_IN ( in_PREDICT_DIR_HISTORY         ,"dir_history"         ,Thistory_t         ,_param->_size_history);
    71       ALLOC1_SIGNAL_IN ( in_PREDICT_RAS_ADDRESS         ,"ras_address"         ,Taddress_t         ,_param->_size_address);
     72      ALLOC1_SIGNAL_IN ( in_PREDICT_RAS_ADDRESS         ,"ras_address"         ,Taddress_t         ,_param->_size_instruction_address);
    7273      ALLOC1_SIGNAL_IN ( in_PREDICT_RAS_INDEX           ,"ras_index"           ,Tptr_t             ,_param->_max_size_ras_index);
    73 //       ALLOC1_SIGNAL_OUT(out_PREDICT_UPDATE_PREDICTION_ID,"update_prediction_id",Tprediction_ptr_t  ,_param->_size_depth);
    7474    }
    7575
    7676    // ~~~~~[ Interface : "decod" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    7777    {
    78       ALLOC1_INTERFACE("decod", IN,SOUTH, "decod", _param->_nb_inst_predict);
     78      ALLOC1_INTERFACE("decod", IN,SOUTH, "decod", _param->_nb_inst_decod);
    7979
    8080      ALLOC1_VALACK_IN ( in_DECOD_VAL                 ,VAL);
    8181      ALLOC1_VALACK_OUT(out_DECOD_ACK                 ,ACK);
    8282      ALLOC1_SIGNAL_IN ( in_DECOD_CONTEXT_ID          ,"context_id"          ,Tcontext_t         ,_param->_size_context_id);
    83       ALLOC1_SIGNAL_IN ( in_DECOD_BTB_ADDRESS_SRC     ,"btb_address_src"     ,Taddress_t         ,_param->_size_address);
    84       ALLOC1_SIGNAL_IN ( in_DECOD_BTB_ADDRESS_DEST    ,"btb_address_dest"    ,Taddress_t         ,_param->_size_address);
     83      ALLOC1_SIGNAL_IN ( in_DECOD_BTB_ADDRESS_SRC     ,"btb_address_src"     ,Taddress_t         ,_param->_size_instruction_address);
     84      ALLOC1_SIGNAL_IN ( in_DECOD_BTB_ADDRESS_DEST    ,"btb_address_dest"    ,Taddress_t         ,_param->_size_instruction_address);
    8585      ALLOC1_SIGNAL_IN ( in_DECOD_BTB_CONDITION       ,"btb_condition"       ,Tbranch_condition_t,_param->_size_branch_condition);
    8686      ALLOC1_SIGNAL_IN ( in_DECOD_BTB_LAST_TAKE       ,"btb_last_take"       ,Tcontrol_t         ,1);
    87       ALLOC1_SIGNAL_IN ( in_DECOD_RAS_ADDRESS         ,"ras_address"         ,Taddress_t         ,_param->_size_address);
     87      ALLOC1_SIGNAL_IN ( in_DECOD_RAS_ADDRESS         ,"ras_address"         ,Taddress_t         ,_param->_size_instruction_address);
    8888      ALLOC1_SIGNAL_IN ( in_DECOD_RAS_INDEX           ,"ras_index"           ,Tptr_t             ,_param->_max_size_ras_index);
    8989      ALLOC1_SIGNAL_IN ( in_DECOD_MISS_IFETCH         ,"miss_ifetch"         ,Tcontrol_t         ,1);
    9090      ALLOC1_SIGNAL_IN ( in_DECOD_MISS_DECOD          ,"miss_decod"          ,Tcontrol_t         ,1);
    91       ALLOC1_SIGNAL_IN ( in_DECOD_UPDATE_PREDICTION_ID,"update_prediction_id",Tprediction_ptr_t  ,_param->_max_size_depth);
     91      ALLOC1_SIGNAL_IN ( in_DECOD_UPDATE_PREDICTION_ID,"update_prediction_id",Tprediction_ptr_t  ,_param->_size_depth);
    9292//    ALLOC1_SIGNAL_OUT(out_DECOD_DEPTH               ,"depth"               ,Tdepth_t           ,_param->_size_depth);
     93      ALLOC1_SIGNAL_IN ( in_DECOD_IS_ACCURATE         ,"is_accurate"         ,Tcontrol_t         ,1);
    9394    }
    9495
     
    100101      ALLOC1_VALACK_OUT(out_BRANCH_COMPLETE_ACK            ,ACK);
    101102      ALLOC1_SIGNAL_IN ( in_BRANCH_COMPLETE_CONTEXT_ID     ,"context_id"     ,Tcontext_t,_param->_size_context_id);
    102       ALLOC1_SIGNAL_IN ( in_BRANCH_COMPLETE_DEPTH          ,"depth"          ,Tdepth_t  ,_param->_max_size_depth);
    103       ALLOC1_SIGNAL_IN ( in_BRANCH_COMPLETE_ADDRESS        ,"address"        ,Taddress_t,_param->_size_address);
     103      ALLOC1_SIGNAL_IN ( in_BRANCH_COMPLETE_DEPTH          ,"depth"          ,Tdepth_t  ,_param->_size_depth);
     104      ALLOC1_SIGNAL_IN ( in_BRANCH_COMPLETE_ADDRESS        ,"address"        ,Taddress_t,_param->_size_instruction_address);
    104105      ALLOC1_SIGNAL_IN ( in_BRANCH_COMPLETE_FLAG           ,"flag"           ,Tcontrol_t,1);
    105106      ALLOC1_SIGNAL_OUT(out_BRANCH_COMPLETE_MISS_PREDICTION,"miss_prediction",Tcontrol_t,1);
    106107      ALLOC1_SIGNAL_OUT(out_BRANCH_COMPLETE_TAKE           ,"take"           ,Tcontrol_t,1);
    107       ALLOC1_SIGNAL_OUT(out_BRANCH_COMPLETE_ADDRESS_SRC    ,"address_src"    ,Taddress_t,_param->_size_address);
    108       ALLOC1_SIGNAL_OUT(out_BRANCH_COMPLETE_ADDRESS_DEST   ,"address_dest"   ,Taddress_t,_param->_size_address);
     108      ALLOC1_SIGNAL_OUT(out_BRANCH_COMPLETE_ADDRESS_SRC    ,"address_src"    ,Taddress_t,_param->_size_instruction_address);
     109      ALLOC1_SIGNAL_OUT(out_BRANCH_COMPLETE_ADDRESS_DEST   ,"address_dest"   ,Taddress_t,_param->_size_instruction_address);
    109110    }
    110111
     
    116117      ALLOC1_VALACK_IN ( in_BRANCH_EVENT_ACK            ,ACK);
    117118//    ALLOC1_SIGNAL_OUT(out_BRANCH_EVENT_CONTEXT_ID     ,"context_id"     ,Tcontext_t,_param->_size_context_id);
    118 //    ALLOC1_SIGNAL_OUT(out_BRANCH_EVENT_DEPTH          ,"depth"          ,Tdepth_t  ,_param->_max_size_depth);
     119//    ALLOC1_SIGNAL_OUT(out_BRANCH_EVENT_DEPTH          ,"depth"          ,Tdepth_t  ,_param->_size_depth);
    119120//    ALLOC1_SIGNAL_OUT(out_BRANCH_EVENT_MISS_PREDICTION,"miss_prediction",Tcontrol_t,1);
    120       ALLOC1_SIGNAL_OUT(out_BRANCH_EVENT_ADDRESS_SRC    ,"address_src"    ,Taddress_t,_param->_size_address);
    121       ALLOC1_SIGNAL_OUT(out_BRANCH_EVENT_ADDRESS_DEST   ,"address_dest"   ,Taddress_t,_param->_size_address);
     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);
    122123    }
    123124
     
    132133      ALLOC1_SIGNAL_OUT(out_UPDATE_DIRECTION_GOOD       ,"direction_good"       ,Tcontrol_t         ,1);
    133134      ALLOC1_SIGNAL_OUT(out_UPDATE_BTB_VAL              ,"btb_val"              ,Tcontrol_t         ,1);
    134       ALLOC1_SIGNAL_OUT(out_UPDATE_BTB_ADDRESS_SRC      ,"btb_address_src"      ,Taddress_t         ,_param->_size_address);
    135       ALLOC1_SIGNAL_OUT(out_UPDATE_BTB_ADDRESS_DEST     ,"btb_address_dest"     ,Taddress_t         ,_param->_size_address);
     135      ALLOC1_SIGNAL_OUT(out_UPDATE_BTB_ADDRESS_SRC      ,"btb_address_src"      ,Taddress_t         ,_param->_size_instruction_address);
     136      ALLOC1_SIGNAL_OUT(out_UPDATE_BTB_ADDRESS_DEST     ,"btb_address_dest"     ,Taddress_t         ,_param->_size_instruction_address);
    136137      ALLOC1_SIGNAL_OUT(out_UPDATE_BTB_CONDITION        ,"btb_condition"        ,Tbranch_condition_t,_param->_size_branch_condition);
    137138      ALLOC1_SIGNAL_OUT(out_UPDATE_DIR_VAL              ,"dir_val"              ,Tcontrol_t         ,1);
     
    139140      ALLOC1_SIGNAL_OUT(out_UPDATE_RAS_VAL              ,"ras_val"              ,Tcontrol_t         ,1);
    140141      ALLOC1_SIGNAL_OUT(out_UPDATE_RAS_PUSH             ,"ras_push"             ,Tcontrol_t         ,1);
    141       ALLOC1_SIGNAL_OUT(out_UPDATE_RAS_ADDRESS          ,"ras_address"          ,Taddress_t         ,_param->_size_address);
     142      ALLOC1_SIGNAL_OUT(out_UPDATE_RAS_ADDRESS          ,"ras_address"          ,Taddress_t         ,_param->_size_instruction_address);
    142143      ALLOC1_SIGNAL_OUT(out_UPDATE_RAS_INDEX            ,"ras_index"            ,Tptr_t             ,_param->_max_size_ras_index);
    143144      ALLOC1_SIGNAL_OUT(out_UPDATE_RAS_PREDICTION_IFETCH,"ras_prediction_ifetch",Tcontrol_t         ,1);
     
    147148    {
    148149      ALLOC1_INTERFACE("depth",OUT,SOUTH, "depth", _param->_nb_context);
    149 
    150       ALLOC1_SIGNAL_OUT(out_DEPTH_TAIL     ,"TAIL"     ,Tdepth_t,_param->_size_depth[alloc_signal_it1]);
    151       ALLOC1_SIGNAL_OUT(out_DEPTH_NB_BRANCH,"NB_BRANCH",Tdepth_t,_param->_size_depth[alloc_signal_it1]+1);
    152     }
    153 
     150      ALLOC1_SIGNAL_OUT(out_DEPTH_CURRENT,"CURRENT",Tdepth_t,_param->_size_depth);
     151      ALLOC1_SIGNAL_OUT(out_DEPTH_MIN    ,"MIN"    ,Tdepth_t,_param->_size_depth);
     152      ALLOC1_SIGNAL_OUT(out_DEPTH_MAX    ,"MAX"    ,Tdepth_t,_param->_size_depth+1);
     153    }
     154
     155    if (usage_is_set(_usage,USE_SYSTEMC))
     156      {
    154157    // ~~~~~[ Internal ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    155     internal_PREDICT_ACK                     = new Tcontrol_t [_param->_nb_inst_predict];
    156     internal_DECOD_ACK                       = new Tcontrol_t [_param->_nb_inst_decod];
    157     internal_BRANCH_COMPLETE_ACK             = new Tcontrol_t [_param->_nb_inst_branch_complete];
    158     internal_BRANCH_COMPLETE_MISS_PREDICTION = new Tcontrol_t [_param->_nb_inst_branch_complete];
    159     internal_BRANCH_COMPLETE_TAKE            = new Tcontrol_t [_param->_nb_inst_branch_complete];
    160     internal_BRANCH_COMPLETE_ADDRESS_DEST    = new Taddress_t [_param->_nb_inst_branch_complete];
    161     internal_BRANCH_EVENT_VAL                = new Tcontrol_t [_param->_nb_context];
    162     internal_BRANCH_EVENT_DEPTH              = new Tdepth_t   [_param->_nb_context];
    163     internal_UPDATE_VAL                      = new Tcontrol_t [_param->_nb_inst_update];
    164     internal_UPDATE_CONTEXT_ID               = new Tcontext_t [_param->_nb_inst_update];
    165     internal_UPDATE_DEPTH                    = new Tdepth_t   [_param->_nb_inst_update];
     158    ALLOC1(internal_PREDICT_ACK                     ,Tcontrol_t,_param->_nb_inst_predict);
     159    ALLOC1(internal_PREDICT_UPDATE_PREDICTION_ID    ,Tdepth_t  ,_param->_nb_inst_predict);
     160    ALLOC1(internal_DECOD_ACK                       ,Tcontrol_t,_param->_nb_inst_decod);
     161    ALLOC1(internal_DECOD_UPT_PTR_WRITE             ,uint32_t  ,_param->_nb_inst_decod);
     162    ALLOC1(internal_BRANCH_COMPLETE_ACK             ,Tcontrol_t,_param->_nb_inst_branch_complete);
     163    ALLOC1(internal_BRANCH_COMPLETE_MISS_PREDICTION ,Tcontrol_t,_param->_nb_inst_branch_complete);
     164    ALLOC1(internal_BRANCH_COMPLETE_TAKE            ,Tcontrol_t,_param->_nb_inst_branch_complete);
     165    ALLOC1(internal_BRANCH_COMPLETE_ADDRESS_DEST    ,Taddress_t,_param->_nb_inst_branch_complete);
     166    ALLOC1(internal_BRANCH_EVENT_VAL                ,Tcontrol_t,_param->_nb_context);
     167    ALLOC1(internal_BRANCH_EVENT_DEPTH              ,Tdepth_t  ,_param->_nb_context);
     168    ALLOC1(internal_UPDATE_VAL                      ,Tcontrol_t,_param->_nb_inst_update);
     169    ALLOC1(internal_UPDATE_VAL_WITHOUT_ACK          ,Tcontrol_t,_param->_nb_inst_update);
     170    ALLOC1(internal_UPDATE_CONTEXT_ID               ,Tcontext_t,_param->_nb_inst_update);
     171    ALLOC1(internal_UPDATE_FROM_UFPT                ,bool      ,_param->_nb_inst_update);
     172    ALLOC1(internal_UPDATE_DEPTH                    ,Tdepth_t  ,_param->_nb_inst_update);
     173    ALLOC1(internal_UPDATE_RAS                      ,bool      ,_param->_nb_inst_update);
    166174
    167175    // ~~~~~[ Register ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
    168     reg_TOP                     = new uint32_t  [_param->_nb_context];
    169     reg_BOTTOM                  = new uint32_t  [_param->_nb_context];
    170     reg_NB_ELT                  = new uint32_t  [_param->_nb_context];
    171     reg_NB_ELT_UPDATE           = new uint32_t  [_param->_nb_context];
    172     reg_NB_ELT_NEED_UPDATE      = new uint32_t  [_param->_nb_context];
    173     reg_UPDATE_PREDICTION_TABLE = new entry_t * [_param->_nb_context];
    174     for (uint32_t i=0; i<_param->_nb_context; i++)
    175       {
    176 #ifndef NO_INIT
    177         reg_TOP [i] = 0;
    178 #endif
    179         reg_UPDATE_PREDICTION_TABLE [i] = new entry_t [_param->_size_queue[i]];
     176
     177    ALLOC1(reg_IS_ACCURATE                  ,bool         ,_param->_nb_context);
     178                                                         
     179    ALLOC2(reg_UPDATE_FETCH_PREDICTION_TABLE,ufpt_entry_t ,_param->_nb_context,_param->_size_ufpt_queue[it1]);
     180    ALLOC1(reg_UFPT_BOTTOM                  ,uint32_t     ,_param->_nb_context);
     181    ALLOC1(reg_UFPT_TOP                     ,uint32_t     ,_param->_nb_context);
     182    ALLOC1(reg_UFPT_UPDATE                  ,uint32_t     ,_param->_nb_context);
     183    ALLOC1(reg_UFPT_NB_NEED_UPDATE          ,uint32_t     ,_param->_nb_context);
     184                                                         
     185    ALLOC2(reg_UPDATE_PREDICTION_TABLE      ,upt_entry_t  ,_param->_nb_context,_param->_size_upt_queue[it1]);
     186    ALLOC1(reg_UPT_BOTTOM                   ,uint32_t     ,_param->_nb_context);
     187    ALLOC1(reg_UPT_TOP                      ,uint32_t     ,_param->_nb_context);
     188    ALLOC1(reg_UPT_UPDATE                   ,uint32_t     ,_param->_nb_context);
     189    ALLOC1(reg_UPT_NB_NEED_UPDATE           ,uint32_t     ,_param->_nb_context);
     190
     191    ALLOC1(reg_EVENT_STATE                  ,event_state_t,_param->_nb_context);
     192    ALLOC1(reg_EVENT_RAS_CORRUPTED          ,Tcontrol_t   ,_param->_nb_context);
     193    ALLOC1(reg_EVENT_ADDRESS_SRC            ,Taddress_t   ,_param->_nb_context);
     194    ALLOC1(reg_EVENT_ADDRESS_SRC_VAL        ,Tcontrol_t   ,_param->_nb_context);
     195    ALLOC1(reg_EVENT_ADDRESS_DEST           ,Taddress_t   ,_param->_nb_context);
    180196      }
     197
    181198    // ~~~~~[ Component ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
    182199
    183200#ifdef POSITION
    184     _component->generate_file();
     201    if (usage_is_set(_usage,USE_POSITION))
     202      _component->generate_file();
    185203#endif
    186204
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_deallocation.cpp

    r82 r88  
    77
    88#include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/include/Update_Prediction_Table.h"
     9#include "Behavioural/include/Allocation.h"
    910
    1011namespace morpheo                    {
     
    4243        delete []  in_PREDICT_RAS_ADDRESS         ;
    4344        delete []  in_PREDICT_RAS_INDEX           ;
    44 //      if (_param->_have_port_depth)
    45 //      delete [] out_PREDICT_UPDATE_PREDICTION_ID;
     45        if (_param->_have_port_depth)
     46        delete [] out_PREDICT_UPDATE_PREDICTION_ID;
    4647       
    4748        // ~~~~~[ Interface : "decod" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     
    5859        delete []  in_DECOD_MISS_IFETCH           ;
    5960        delete []  in_DECOD_MISS_DECOD            ;
    60         if (_param->_have_port_max_depth)
     61        if (_param->_have_port_depth)
    6162        delete []  in_DECOD_UPDATE_PREDICTION_ID  ;
    6263//      if (_param->_have_port_depth)
    6364//      delete [] out_DECOD_DEPTH                 ;
     65        delete []  in_DECOD_IS_ACCURATE           ;
    6466       
    6567        // ~~~~~[ Interface : "branch_complete" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     
    6870        if (_param->_have_port_context_id)
    6971        delete []  in_BRANCH_COMPLETE_CONTEXT_ID     ;
    70         if (_param->_have_port_max_depth)
     72        if (_param->_have_port_depth)
    7173        delete []  in_BRANCH_COMPLETE_DEPTH          ;
    7274        delete []  in_BRANCH_COMPLETE_ADDRESS        ;
     
    8284//      if (_param->_have_port_context_id)
    8385//      delete []  in_BRANCH_EVENT_CONTEXT_ID     ;
    84 //      if (_param->_have_port_max_depth)
     86//      if (_param->_have_port_depth)
    8587//      delete []  in_BRANCH_EVENT_DEPTH          ;
    8688//      delete [] out_BRANCH_EVENT_MISS_PREDICTION;
     
    109111
    110112        // ~~~~~[ Interface : "depth" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    111         if (_param->_have_port_max_depth)
     113        if (_param->_have_port_depth)
    112114          {
    113         delete [] out_DEPTH_NB_BRANCH;
    114         delete [] out_DEPTH_TAIL;
     115        delete [] out_DEPTH_CURRENT;
     116        delete [] out_DEPTH_MIN;
    115117          }
    116       }
    117 
    118     // ~~~~~[ Internal ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    119     delete [] internal_PREDICT_ACK                     ;
    120     delete [] internal_DECOD_ACK                       ;
    121     delete [] internal_BRANCH_COMPLETE_ACK             ;
    122     delete [] internal_BRANCH_COMPLETE_MISS_PREDICTION ;
    123     delete [] internal_BRANCH_COMPLETE_TAKE            ;
    124     delete [] internal_BRANCH_COMPLETE_ADDRESS_DEST    ;
    125     delete [] internal_BRANCH_EVENT_VAL                ;
    126     delete [] internal_BRANCH_EVENT_DEPTH              ;
    127     delete [] internal_UPDATE_VAL                      ;
    128     delete [] internal_UPDATE_CONTEXT_ID               ;
    129     delete [] internal_UPDATE_DEPTH                    ;
    130 
    131     // ~~~~~[ Register ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
    132     delete [] reg_TOP;
    133     delete [] reg_BOTTOM;
    134     delete [] reg_NB_ELT;
    135     delete [] reg_NB_ELT_UPDATE;
    136     delete [] reg_NB_ELT_NEED_UPDATE;
    137     for (uint32_t i=0; i<_param->_nb_context; i++)
    138       delete [] reg_UPDATE_PREDICTION_TABLE [i];
    139     delete [] reg_UPDATE_PREDICTION_TABLE;
     118        delete [] out_DEPTH_MAX;
     119       
     120        // ~~~~~[ Internal ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     121        DELETE1(internal_PREDICT_ACK                     ,_param->_nb_inst_predict);
     122        DELETE1(internal_PREDICT_UPDATE_PREDICTION_ID    ,_param->_nb_inst_predict);
     123        DELETE1(internal_DECOD_ACK                       ,_param->_nb_inst_decod);
     124        DELETE1(internal_DECOD_UPT_PTR_WRITE             ,_param->_nb_inst_decod);
     125        DELETE1(internal_BRANCH_COMPLETE_ACK             ,_param->_nb_inst_branch_complete);
     126        DELETE1(internal_BRANCH_COMPLETE_MISS_PREDICTION ,_param->_nb_inst_branch_complete);
     127        DELETE1(internal_BRANCH_COMPLETE_TAKE            ,_param->_nb_inst_branch_complete);
     128        DELETE1(internal_BRANCH_COMPLETE_ADDRESS_DEST    ,_param->_nb_inst_branch_complete);
     129        DELETE1(internal_BRANCH_EVENT_VAL                ,_param->_nb_context);
     130        DELETE1(internal_BRANCH_EVENT_DEPTH              ,_param->_nb_context);
     131        DELETE1(internal_UPDATE_VAL                      ,_param->_nb_inst_update);
     132        DELETE1(internal_UPDATE_VAL_WITHOUT_ACK          ,_param->_nb_inst_update);
     133        DELETE1(internal_UPDATE_CONTEXT_ID               ,_param->_nb_inst_update);
     134        DELETE1(internal_UPDATE_FROM_UFPT                ,_param->_nb_inst_update);
     135        DELETE1(internal_UPDATE_DEPTH                    ,_param->_nb_inst_update);
     136        DELETE1(internal_UPDATE_RAS                      ,_param->_nb_inst_update);
     137       
     138        // ~~~~~[ Register ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
     139        DELETE1(reg_IS_ACCURATE                  ,_param->_nb_context);
     140       
     141        DELETE2(reg_UPDATE_FETCH_PREDICTION_TABLE,_param->_nb_context,_param->_size_ufpt_queue[it1]);
     142        DELETE1(reg_UFPT_BOTTOM                  ,_param->_nb_context);
     143        DELETE1(reg_UFPT_TOP                     ,_param->_nb_context);
     144        DELETE1(reg_UFPT_UPDATE                  ,_param->_nb_context);
     145        DELETE1(reg_UFPT_NB_NEED_UPDATE          ,_param->_nb_context);
     146       
     147        DELETE2(reg_UPDATE_PREDICTION_TABLE      ,_param->_nb_context,_param->_size_upt_queue[it1]);
     148        DELETE1(reg_UPT_BOTTOM                   ,_param->_nb_context);
     149        DELETE1(reg_UPT_TOP                      ,_param->_nb_context);
     150        DELETE1(reg_UPT_UPDATE                   ,_param->_nb_context);
     151        DELETE1(reg_UPT_NB_NEED_UPDATE           ,_param->_nb_context);
     152       
     153        DELETE1(reg_EVENT_STATE                  ,_param->_nb_context);
     154        DELETE1(reg_EVENT_RAS_CORRUPTED          ,_param->_nb_context);
     155        DELETE1(reg_EVENT_ADDRESS_SRC            ,_param->_nb_context);
     156        DELETE1(reg_EVENT_ADDRESS_SRC_VAL        ,_param->_nb_context);
     157        DELETE1(reg_EVENT_ADDRESS_DEST           ,_param->_nb_context);
     158       }
    140159
    141160    // ~~~~~[ Component ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_end_cycle.cpp

    r81 r88  
    2525
    2626#ifdef STATISTICS
    27     _stat->end_cycle();
     27    if (usage_is_set(_usage,USE_STATISTICS))
     28      _stat->end_cycle();
    2829#endif   
    2930
     
    3132    // Evaluation before read the ouput signal
    3233//  sc_start(0);
     34    if (usage_is_set(_usage,USE_VHDL_TESTBENCH))
    3335    _interfaces->testbench();
    3436#endif
  • 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

    r82 r88  
    2222  void Update_Prediction_Table::genMealy_branch_complete (void)
    2323  {
    24     log_printf(FUNC,Update_Prediction_Table,FUNCTION,"Begin");
     24    log_begin(Update_Prediction_Table,FUNCTION);
     25    log_function(Update_Prediction_Table,FUNCTION,_name.c_str());
    2526   
    2627    for (uint32_t i=0; i<_param->_nb_inst_branch_complete; i++)
     28#ifdef DEBUG_TEST
     29      // just to don't have exception in not transaction
     30      if (PORT_READ(in_BRANCH_COMPLETE_VAL [i]))
     31#endif
    2732      {
     33        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * BRANCH_COMPLETE [%d]",i);
     34
    2835        Tcontext_t          context   = (_param->_have_port_context_id)?PORT_READ(in_BRANCH_COMPLETE_CONTEXT_ID [i]):0;
    29         Tdepth_t            depth     = (_param->_have_port_max_depth )?PORT_READ(in_BRANCH_COMPLETE_DEPTH      [i]):0;
     36        Tdepth_t            depth     = (_param->_have_port_depth    )?PORT_READ(in_BRANCH_COMPLETE_DEPTH      [i]):0;
    3037        Tcontrol_t          miss      = false;
    3138        Tcontrol_t          take      = reg_UPDATE_PREDICTION_TABLE [context][depth]._last_take   ;
    3239        Taddress_t          addr_dest = reg_UPDATE_PREDICTION_TABLE [context][depth]._address_dest;
    3340        Tbranch_condition_t condition = reg_UPDATE_PREDICTION_TABLE [context][depth]._condition   ;
     41
     42        Tcontrol_t          flag      = PORT_READ(in_BRANCH_COMPLETE_FLAG [i]);
     43        Taddress_t          addr_good = PORT_READ(in_BRANCH_COMPLETE_ADDRESS [i]);
     44
     45        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * context        : %d",context);
     46        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * depth          : %d",depth  );
     47        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * condition      : %s",toString(condition).c_str());
     48        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * flag           : %d",flag);
     49        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * address_good   : %.8x",addr_good);
     50
     51        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * (before)");
     52        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * miss         : %d",miss);
     53        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * take         : %d",take);
     54        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * address_dest : %.8x",addr_dest);
    3455
    3556        switch (condition)
     
    3960            {
    4061              //miss      : always hit
    41               //addr_dest : know in decod stage
     62              //addr_dest : compute in decod stage
     63
     64#ifdef DEBUG_TEST
     65              if (take != 1)
     66                throw ERRORMORPHEO(FUNCTION,toString("Branch_complete[%d] (condition %s) : bad direction.",i,toString(condition).c_str()));
     67              if (addr_dest != addr_good)
     68                throw ERRORMORPHEO(FUNCTION,toString("Branch_complete[%d] (condition %s) : bad destination address.",i,toString(condition).c_str()));
     69#endif
     70
    4271              break;
    4372            }
    4473          case BRANCH_CONDITION_FLAG_UNSET                        : // l.bnf
    4574            {
    46               Tcontrol_t take_good = PORT_READ(in_BRANCH_COMPLETE_FLAG [i]) == 0;
     75              //addr_dest : compute in decod stage
     76              //miss if the direction is bad
     77              Tcontrol_t take_good = not flag; // flag set = not take
     78
    4779              miss = (take != take_good);
    4880              take = take_good;
    49               //addr_dest : know in decod stage
     81
     82#ifdef DEBUG_TEST
     83              if (addr_dest != addr_good)
     84                throw ERRORMORPHEO(FUNCTION,toString("Branch_complete[%d] (condition %s) : bad destination address.",i,toString(condition).c_str()));
     85#endif
     86
    5087              break;
    5188            }
    5289          case BRANCH_CONDITION_FLAG_SET                          : // l.bf
    5390            {
    54 //            log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * BRANCH_CONDITION_FLAG_SET");
    55              
    56               Tcontrol_t take_good = PORT_READ(in_BRANCH_COMPLETE_FLAG [i]) == 1;
     91              //addr_dest : compute in decod stage
     92              //miss if the direction is bad
     93              Tcontrol_t take_good = flag; // flag set = take
     94
    5795              miss = (take != take_good);
    5896              take = take_good;
    5997
    60 //            log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * flag      : %d",PORT_READ(in_BRANCH_COMPLETE_FLAG [i]));
    61 //            log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * take_good : %d",take_good);
    62 //            log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * miss      : %d",miss);
    63              
    64               //addr_dest : know in decod stage
     98#ifdef DEBUG_TEST
     99              if (addr_dest != addr_good)
     100                throw ERRORMORPHEO(FUNCTION,toString("Branch_complete[%d] (condition %s) : bad destination address.",i,toString(condition).c_str()));
     101#endif
     102
    65103              break;
    66104            }
     
    69107          case BRANCH_CONDITION_READ_STACK                        : // l.jr (rb==r9)
    70108            {
    71               Taddress_t addr_good = PORT_READ(in_BRANCH_COMPLETE_ADDRESS [i]);
    72               miss = ((take == 1) and
    73                       (addr_dest = addr_good));
    74               take = 1;
     109              // miss if destination address is bad
     110              miss      = (addr_dest != addr_good);
    75111              addr_dest = addr_good;
     112
     113#ifdef DEBUG_TEST
     114              if (take != 1)
     115                throw ERRORMORPHEO(FUNCTION,toString("Branch_complete[%d] (condition %s) : bad direction.",i,toString(condition).c_str()));
     116#endif
     117             
    76118              break;
    77119            }
    78120          }
    79121
    80 //      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * miss      : %d",miss);
    81 //      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * take      : %d",take);
    82 //      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * address   : %x",addr_dest);
    83 
     122        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * (after)");
     123        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * miss         : %d",miss);
     124        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * take         : %d",take);
     125        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * address_dest : %.8x",addr_dest);
     126       
    84127        internal_BRANCH_COMPLETE_MISS_PREDICTION [i] = miss     ;
    85128        internal_BRANCH_COMPLETE_TAKE            [i] = take     ;
    86129        internal_BRANCH_COMPLETE_ADDRESS_DEST    [i] = addr_dest;
    87 
     130       
    88131        PORT_WRITE(out_BRANCH_COMPLETE_MISS_PREDICTION [i], internal_BRANCH_COMPLETE_MISS_PREDICTION [i]);
    89132        PORT_WRITE(out_BRANCH_COMPLETE_TAKE            [i], internal_BRANCH_COMPLETE_TAKE            [i]);
     
    92135      }
    93136
    94     log_printf(FUNC,Update_Prediction_Table,FUNCTION,"End");
     137    log_end(Update_Prediction_Table,FUNCTION);
    95138  };
    96139
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_genMealy_decod.cpp

    r82 r88  
    2222  void Update_Prediction_Table::genMealy_decod (void)
    2323  {
    24     log_printf(FUNC,Update_Prediction_Table,FUNCTION,"Begin");
     24    log_begin(Update_Prediction_Table,FUNCTION);
     25    log_function(Update_Prediction_Table,FUNCTION,_name.c_str());
    2526   
     27    // WARNING : One branch per context per cycle
    2628    for (uint32_t i=0; i<_param->_nb_inst_decod; i++)
    2729      {
    28         Tcontrol_t miss = PORT_READ(in_DECOD_MISS_DECOD [i]);
     30        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * DECOD [%d]",i);
    2931
    30         if (miss)
    31           {
    32             // miss : need a empty slot.
    33             Tcontext_t context = (_param->_have_port_context_id)?PORT_READ(in_DECOD_CONTEXT_ID [i]):0;
    34             uint32_t   top     = reg_TOP[context];
    35             internal_DECOD_ACK [i] = (reg_UPDATE_PREDICTION_TABLE [context][top]._state == UPDATE_PREDICTION_STATE_EMPTY);
    36           }
    37         else
    38           {
    39             internal_DECOD_ACK [i] = true;
    40           }
     32        Tcontext_t    context     = (_param->_have_port_context_id)?PORT_READ(in_DECOD_CONTEXT_ID [i]):0;
     33        bool          is_accurate = reg_IS_ACCURATE [context];
     34        event_state_t event_state = reg_EVENT_STATE [context];
     35        uint32_t      ptr_write   = reg_UPT_TOP     [context];
     36
     37        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * context     : %d",context    );
     38        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * is_accurate : %d",is_accurate);
     39        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * event_state : %s",toString(event_state).c_str());
     40        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * ptr_write   : %d",ptr_write  );
     41        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * upt_state   : %s",toString(reg_UPDATE_PREDICTION_TABLE [context][ptr_write]._state).c_str());
     42
     43        // ack :
     44        //   * in all case (miss or hit), need empty slot
     45        //   * is_accurate
     46        //   * event_state : don't update upt
     47        internal_DECOD_ACK           [i] = ((reg_UPDATE_PREDICTION_TABLE [context][ptr_write]._state == UPDATE_PREDICTION_STATE_EMPTY) and
     48                                            is_accurate and
     49//                                             (
     50                                             (event_state == EVENT_STATE_OK            )//  or
     51//                                              (event_state == EVENT_STATE_FLUSH_UFPT    ) or
     52//                                              (event_state == EVENT_STATE_UPDATE_CONTEXT))
     53                                            );
     54        internal_DECOD_UPT_PTR_WRITE [i] = ptr_write;
     55
     56        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * ack         : %d",internal_DECOD_ACK [i]);
    4157
    4258        PORT_WRITE(out_DECOD_ACK [i], internal_DECOD_ACK [i]);
    4359      }
    4460
    45     log_printf(FUNC,Update_Prediction_Table,FUNCTION,"End");
     61    log_end(Update_Prediction_Table,FUNCTION);
    4662  };
    4763
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_genMealy_predict.cpp

    r81 r88  
    2222  void Update_Prediction_Table::genMealy_predict (void)
    2323  {
    24     log_printf(FUNC,Update_Prediction_Table,FUNCTION,"Begin");
    25    
     24    log_begin(Update_Prediction_Table,FUNCTION);
     25    log_function(Update_Prediction_Table,FUNCTION,_name.c_str());
     26
     27    if (PORT_READ(in_NRESET) != 0)
     28      {
     29
    2630    for (uint32_t i=0; i<_param->_nb_inst_predict; i++)
    2731      {
    2832        Tcontext_t context = (_param->_have_port_context_id)?PORT_READ(in_PREDICT_CONTEXT_ID [i]):0;
    29         uint32_t   top     = reg_TOP[context];
     33        uint32_t   top     = reg_UFPT_TOP[context];
    3034
    31 //      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"PREDICT [%d] (genMealy)",i);
    32 //      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * context     : %d",context);
    33 //      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * top         : %d",top);
    34 //      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * state       : %s",toString(reg_UPDATE_PREDICTION_TABLE [context][top]._state).c_str());
    35 //      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * is accurate : %d",PORT_READ(in_PREDICT_BTB_IS_ACCURATE [i]));
     35        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"PREDICT [%d] (genMealy)",i);
     36        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * context     : %d",context);
     37        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * top         : %d",top);
     38        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * state       : %s",toString(reg_UPDATE_FETCH_PREDICTION_TABLE [context][top]._state).c_str());
     39        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * is accurate : %d",PORT_READ(in_PREDICT_BTB_IS_ACCURATE [i]));
    3640//      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * need update : %d",reg_NB_ELT_NEED_UPDATE [context]);
    3741
    38         // Not Full, accurate and no previous miss
    39         // Optimisation to restart faster :
    40         //   don't counter nb_elt_ko, but just nb_elt that need a update (change branch structure)
    41         internal_PREDICT_ACK [i] = ((reg_UPDATE_PREDICTION_TABLE [context][top]._state == UPDATE_PREDICTION_STATE_EMPTY) and
    42                                     PORT_READ(in_PREDICT_BTB_IS_ACCURATE [i]) and
    43                                     (reg_NB_ELT_NEED_UPDATE [context] == 0));
     42        internal_PREDICT_UPDATE_PREDICTION_ID [i] = top;
    4443
    45 //      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * ACK         : %d",internal_PREDICT_ACK [i]);
     44        if (_param->_have_port_depth)
     45        PORT_WRITE(out_PREDICT_UPDATE_PREDICTION_ID [i], internal_PREDICT_UPDATE_PREDICTION_ID [i]);
    4646
     47        bool is_accurate = not _param->_not_accurate_block_predict or reg_IS_ACCURATE[context];
     48
     49        // Ack if :
     50        //  * slot is empty
     51        //  * no previous miss
     52        //  * is_accurate
     53        internal_PREDICT_ACK [i] = ((reg_UPDATE_FETCH_PREDICTION_TABLE [context][top]._state == UPDATE_FETCH_PREDICTION_STATE_EMPTY) and
     54//                                  PORT_READ(in_PREDICT_BTB_IS_ACCURATE [i]) and
     55                                    (reg_EVENT_STATE [context] == EVENT_STATE_OK) and
     56                                    is_accurate);
     57
     58
     59        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * ACK         : %d",internal_PREDICT_ACK [i]);
    4760        PORT_WRITE(out_PREDICT_ACK [i], internal_PREDICT_ACK [i]);
    4861      }
    4962
    50     log_printf(FUNC,Update_Prediction_Table,FUNCTION,"End");
     63      }//don't reset
     64
     65    log_end(Update_Prediction_Table,FUNCTION);
    5166  };
    5267
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_genMoore.cpp

    r82 r88  
    2222  void Update_Prediction_Table::genMoore (void)
    2323  {
    24     log_printf(FUNC,Update_Prediction_Table,FUNCTION,"Begin");
     24    log_begin(Update_Prediction_Table,FUNCTION);
     25    log_function(Update_Prediction_Table,FUNCTION,_name.c_str());
     26    log_printf(NONE,Update_Prediction_Table,FUNCTION,FUNCTION);
     27
     28    if (PORT_READ(in_NRESET) == 1)
     29      {
    2530
    2631    // ===================================================================
     
    3035    for (uint32_t i=0; i<_param->_nb_context; i++)
    3136      {
    32         if (_param->_have_port_depth [i])
    33           {
    34             PORT_WRITE(out_DEPTH_TAIL      [i], reg_BOTTOM [i]);
    35           }
    36         PORT_WRITE(out_DEPTH_NB_BRANCH [i], reg_NB_ELT [i]);
    37       }
     37        if (_param->_have_port_depth)
     38          {
     39        PORT_WRITE(out_DEPTH_CURRENT [i], reg_UPT_TOP    [i]);
     40        PORT_WRITE(out_DEPTH_MIN     [i], reg_UPT_BOTTOM [i]);
     41          }
     42        PORT_WRITE(out_DEPTH_MAX     [i], reg_UPT_TOP    [i]);
     43      }
     44
    3845    // ===================================================================
    3946    // =====[ UPDATE ]====================================================
    4047    // ===================================================================
    4148
    42     Tdepth_t tab_depth [_param->_nb_context];
     49    bool     retire_ras_from_ufpt [_param->_nb_context]; // event ufpt -> restore RAS, else update upt
     50    bool     retire_ras_from_upt  [_param->_nb_context]; // event upt  -> restore RAS, else restore others structure
     51    bool     ufpt_update          [_param->_nb_context];
     52    bool     upt_update           [_param->_nb_context];
     53    Tdepth_t tab_ufpt_depth       [_param->_nb_context];
     54    Tdepth_t tab_upt_depth        [_param->_nb_context];
     55
    4356    for (uint32_t i=0; i<_param->_nb_context; i++)
    44       tab_depth [i] = reg_BOTTOM [i];
     57      {
     58        event_state_t event_state = reg_EVENT_STATE [i];
     59
     60        retire_ras_from_ufpt [i] = ((event_state == EVENT_STATE_FLUSH_UFPT        ) or
     61                                    (event_state == EVENT_STATE_FLUSH_UFPT_AND_UPT));
     62        retire_ras_from_upt  [i] = (event_state == EVENT_STATE_FLUSH_UPT_RAS);
     63
     64        ufpt_update          [i] = true;
     65        upt_update           [i] = true;
     66        tab_ufpt_depth       [i] = reg_UFPT_UPDATE [i];
     67        tab_upt_depth        [i] = reg_UPT_UPDATE  [i];
     68      }
    4569
    4670    for (uint32_t i=0; i<_param->_nb_inst_update; i++)
    4771      {
    48         uint32_t   context = (reg_UPDATE_PRIORITY+i)%_param->_nb_context;
    49         Tdepth_t   depth   = tab_depth[context];
    50         state_t    state   = reg_UPDATE_PREDICTION_TABLE [context][depth]._state;
     72        Tcontext_t          context     = (reg_UPDATE_PRIORITY+i)%_param->_nb_context;
     73
     74        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * UPDATE [%d] (genMoore)",i);
     75        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * context         : %d",context);
     76        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * event_state     : %s",toString(reg_EVENT_STATE [context]).c_str());
     77
     78        Tcontrol_t          val                  = false;
     79        Tcontrol_t          val_without_ack      = false;
     80        Tcontrol_t          miss_prediction      ;
     81        Tcontrol_t          direction_good       ;
     82        Tcontrol_t          btb_val              ;
     83        Taddress_t          btb_address_src      ;
     84        Taddress_t          btb_address_dest     ;
     85        Tbranch_condition_t btb_condition        ;
     86        Tcontrol_t          dir_val              ;
     87        Thistory_t          dir_history          ;
     88        Tcontrol_t          ras_val              ;
     89        Tcontrol_t          ras_push             ;
     90        Taddress_t          ras_address          ;
     91        Tptr_t              ras_index            ;
     92        Tcontrol_t          ras_prediction_ifetch;
     93
     94        // Test if update fetch prediction table need update port
     95        if (retire_ras_from_ufpt [context])
     96          {
     97            if (ufpt_update [context])
     98              {
     99                // Update Fetch Prediction Table
     100                // An update of ufpt is to previous miss. Just restore Return Address Stack
     101               
     102                Tdepth_t            depth     = tab_ufpt_depth[context];
     103                ufpt_state_t        state     = reg_UPDATE_FETCH_PREDICTION_TABLE [context][depth]._state;
     104                Tbranch_condition_t condition = reg_UPDATE_FETCH_PREDICTION_TABLE [context][depth]._condition;
     105               
     106                log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * Update Fetch Prediction Table");
     107                log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * depth           : %d",depth    );
     108                log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * state           : %s",toString(state    ).c_str());
     109                log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * condition       : %s",toString(condition).c_str());
     110               
     111                val                   = (state == UPDATE_FETCH_PREDICTION_STATE_EVENT);
     112                miss_prediction       = 1;
     113//              direction_good        = ;
     114                btb_val               = 0; // don't update btb (is update by the event branch)
     115//              btb_address_src       = ;
     116//              btb_address_dest      = ;
     117//              btb_condition         = ;
     118                dir_val               = 0; // don't update btb (is update by the event branch (if conditionnal branch))
     119//              dir_history           = ;
     120                ras_val               = update_ras(condition); // repop/ repush data -> don't corrupt ras
     121                ras_push              = push_ras(condition);
     122                ras_address           = reg_UPDATE_FETCH_PREDICTION_TABLE [context][depth]._address_ras;
     123                ras_index             = reg_UPDATE_FETCH_PREDICTION_TABLE [context][depth]._index_ras;
     124                ras_prediction_ifetch = 1;
     125               
     126                internal_UPDATE_FROM_UFPT [i] = true;
     127                internal_UPDATE_DEPTH     [i] = depth;
     128                internal_UPDATE_RAS       [i] = false;
     129
     130                // Warning : don't update same entry
     131                if (depth == reg_UFPT_BOTTOM[context])
     132                  ufpt_update [context] = false;
     133               
     134                tab_ufpt_depth[context] = (depth==0)?(_param->_size_ufpt_queue[context]-1):(depth-1);
     135              }
     136          }
     137        else
     138          {
     139            if (upt_update [context])
     140              {
     141                // Update Prediction Table
     142               
     143                Tdepth_t            depth     = tab_upt_depth[context];
     144                upt_state_t         state     = reg_UPDATE_PREDICTION_TABLE [context][depth]._state;
     145                Tbranch_condition_t condition = reg_UPDATE_PREDICTION_TABLE [context][depth]._condition;
     146                Tcontrol_t          ifetch    = reg_UPDATE_PREDICTION_TABLE [context][depth]._ifetch_prediction;
     147               
     148                log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * Update Prediction Table");
     149                log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * depth           : %d",depth    );
     150                log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * state           : %s",toString(state    ).c_str());
     151                log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * condition       : %s",toString(condition).c_str());
     152             
     153                Tcontrol_t          state_is_ok_ko           = ((state == UPDATE_PREDICTION_STATE_OK) or
     154                                                                (state == UPDATE_PREDICTION_STATE_KO));
     155                Tcontrol_t          state_is_event           = (state == UPDATE_PREDICTION_STATE_EVENT);
     156                Tcontrol_t          state_is_event_update    = state_is_event and     need_update(condition);
     157                Tcontrol_t          state_is_event_no_update = state_is_event and not need_update(condition);
     158
     159                if (retire_ras_from_upt [context])
     160                  {
     161                val                   = state_is_event_update;
     162                val_without_ack       = state_is_event_no_update;
     163                  }
     164                else
     165                  {
     166                val                   = state_is_ok_ko;
     167                val_without_ack       = false;
     168                  }                 
     169
     170                miss_prediction       = (state != UPDATE_PREDICTION_STATE_OK);
     171                direction_good        = reg_UPDATE_PREDICTION_TABLE [context][depth]._good_take   ;
     172                btb_val               = update_btb(condition);
     173                btb_address_src       = reg_UPDATE_PREDICTION_TABLE [context][depth]._address_src ;
     174                btb_address_dest      = reg_UPDATE_PREDICTION_TABLE [context][depth]._address_dest;
     175                btb_condition         = condition;
     176                dir_val               = update_dir(condition) and ifetch; // if not ifetch, then static prediction
     177                dir_history           = reg_UPDATE_PREDICTION_TABLE [context][depth]._history     ;
     178                ras_val               = update_ras(condition); // repop/ repush data -> don't corrupt ras
     179                ras_push              = push_ras(condition);
     180                ras_address           = reg_UPDATE_PREDICTION_TABLE [context][depth]._address_ras;
     181                ras_index             = reg_UPDATE_PREDICTION_TABLE [context][depth]._index_ras;
     182                ras_prediction_ifetch = ifetch;
     183
     184                internal_UPDATE_FROM_UFPT [i] = false;
     185                internal_UPDATE_DEPTH     [i] = depth;
     186                internal_UPDATE_RAS       [i] = retire_ras_from_upt [context];
     187
     188                // Warning : don't update same entry
     189                if (retire_ras_from_upt [context])
     190                  {
     191                    // Restore RAS.
     192                    if ((depth == reg_UPT_BOTTOM[context]) or not (val or val_without_ack))
     193                      upt_update [context] = false;
     194                   
     195                    tab_upt_depth[context] = (depth==0)?(_param->_size_upt_queue[context]-1):(depth-1);
     196                  }
     197                else
     198                  {
     199                    if ((depth == reg_UPT_TOP [context]) or not (val or val_without_ack))
     200                      upt_update [context] = false;
     201                   
     202                    tab_upt_depth[context] = (depth+1)%_param->_size_upt_queue[context];
     203                  }
     204              }
     205          }
     206
     207        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * val             : %d",val    );
     208        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * val_without_ack : %d",val_without_ack);
     209        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * btb_val         : %d",btb_val);
     210        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * dir_val         : %d",dir_val);
     211        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * ras_val         : %d",ras_val);
     212
     213        internal_UPDATE_VAL             [i] = val;
     214        internal_UPDATE_VAL_WITHOUT_ACK [i] = val_without_ack;
     215        internal_UPDATE_CONTEXT_ID      [i] = context;
     216
     217        PORT_WRITE(out_UPDATE_VAL                   [i],internal_UPDATE_VAL [i]);
     218        if (val)
     219          {
     220        if (_param->_have_port_context_id)
     221        PORT_WRITE(out_UPDATE_CONTEXT_ID            [i],context              );
     222        PORT_WRITE(out_UPDATE_MISS_PREDICTION       [i],miss_prediction      );
     223        PORT_WRITE(out_UPDATE_DIRECTION_GOOD        [i],direction_good       );
     224        PORT_WRITE(out_UPDATE_BTB_VAL               [i],btb_val              );
     225        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
     229        PORT_WRITE(out_UPDATE_BTB_ADDRESS_DEST      [i],btb_address_dest     );
     230        PORT_WRITE(out_UPDATE_BTB_CONDITION         [i],btb_condition        );
     231        PORT_WRITE(out_UPDATE_DIR_VAL               [i],dir_val              );
     232        if (_param->_have_port_history)
     233        PORT_WRITE(out_UPDATE_DIR_HISTORY           [i],dir_history          );
     234        PORT_WRITE(out_UPDATE_RAS_VAL               [i],ras_val              );
     235        PORT_WRITE(out_UPDATE_RAS_PUSH              [i],ras_push             );
     236        PORT_WRITE(out_UPDATE_RAS_ADDRESS           [i],ras_address          );
     237        PORT_WRITE(out_UPDATE_RAS_INDEX             [i],ras_index            );
     238        PORT_WRITE(out_UPDATE_RAS_PREDICTION_IFETCH [i],ras_prediction_ifetch);
     239          }
     240      }
     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;
    51249       
    52         Tcontrol_t val     = ((state == UPDATE_PREDICTION_STATE_OK) or
    53                               (state == UPDATE_PREDICTION_STATE_KO));
    54 
    55 //      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"UPDATE [%d] (genMoore)",i);
    56 //      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * context     : %d",context);
    57 //      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * depth       : %d",depth);
    58 //      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * state       : %s",toString(state).c_str());
    59 //      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * val         : %d",val);
    60 //      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * addr_src    : %x",reg_UPDATE_PREDICTION_TABLE [context][depth]._address_src );
    61 //      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * addr_dest   : %x",reg_UPDATE_PREDICTION_TABLE [context][depth]._address_dest);
    62 
    63         if (val)
    64           {
    65             Tbranch_condition_t cond    = reg_UPDATE_PREDICTION_TABLE [context][depth]._condition;
    66                      
    67             Tcontrol_t          ifetch  = reg_UPDATE_PREDICTION_TABLE [context][depth]._ifetch_prediction;
    68             Tcontrol_t          btb_val = true;
    69             Tcontrol_t          dir_val = (ifetch and // not ifetch == static prediction
    70                                            ((cond == BRANCH_CONDITION_FLAG_UNSET) or
    71                                             (cond == BRANCH_CONDITION_FLAG_SET)));
    72             Tcontrol_t          ras_val = ((cond == BRANCH_CONDITION_NONE_WITH_WRITE_STACK) or
    73                                            (cond == BRANCH_CONDITION_READ_REGISTER_WITH_WRITE_STACK) or
    74                                            (cond == BRANCH_CONDITION_READ_STACK));
    75            
    76             Tcontrol_t          push = ((cond == BRANCH_CONDITION_NONE_WITH_WRITE_STACK) or
    77                                         (cond == BRANCH_CONDITION_READ_REGISTER_WITH_WRITE_STACK));
    78 
    79             if (_param->_have_port_context_id)
    80             PORT_WRITE(out_UPDATE_CONTEXT_ID            [i],context);
    81             PORT_WRITE(out_UPDATE_MISS_PREDICTION       [i],(state == UPDATE_PREDICTION_STATE_KO));
    82             PORT_WRITE(out_UPDATE_DIRECTION_GOOD        [i],reg_UPDATE_PREDICTION_TABLE [context][depth]._good_take   );
    83             PORT_WRITE(out_UPDATE_BTB_VAL               [i],btb_val);
    84             PORT_WRITE(out_UPDATE_BTB_ADDRESS_SRC       [i],reg_UPDATE_PREDICTION_TABLE [context][depth]._address_src );
    85             PORT_WRITE(out_UPDATE_BTB_ADDRESS_DEST      [i],reg_UPDATE_PREDICTION_TABLE [context][depth]._address_dest);
    86             PORT_WRITE(out_UPDATE_BTB_CONDITION         [i],cond);
    87             PORT_WRITE(out_UPDATE_DIR_VAL               [i],dir_val);
    88             if (_param->_have_port_history)
    89             PORT_WRITE(out_UPDATE_DIR_HISTORY           [i],reg_UPDATE_PREDICTION_TABLE [context][depth]._history     );
    90             PORT_WRITE(out_UPDATE_RAS_VAL               [i],ras_val);
    91             PORT_WRITE(out_UPDATE_RAS_PUSH              [i],push);
    92             PORT_WRITE(out_UPDATE_RAS_ADDRESS           [i],reg_UPDATE_PREDICTION_TABLE [context][depth]._address_ras );
    93             PORT_WRITE(out_UPDATE_RAS_INDEX             [i],reg_UPDATE_PREDICTION_TABLE [context][depth]._index_ras   );
    94             PORT_WRITE(out_UPDATE_RAS_PREDICTION_IFETCH [i],ifetch);
    95 
    96             internal_UPDATE_CONTEXT_ID [i] = context;
    97             internal_UPDATE_DEPTH      [i] = depth;
    98 
    99             tab_depth[context] = (depth+1)%_param->_size_queue[context];
    100           }
    101 
    102         internal_UPDATE_VAL [i] = val;
    103         PORT_WRITE(out_UPDATE_VAL [i], internal_UPDATE_VAL [i]);
    104       }
    105 
    106     // ===================================================================
    107     // =====[ BRANCH_EVENT ]==============================================
    108     // ===================================================================
    109     for (uint32_t i=0; i<_param->_nb_context; i++)
    110       {
    111         Tdepth_t   depth   = (reg_BOTTOM [i] + reg_NB_ELT_UPDATE [i])%_param->_size_queue [i];
    112         state_t    state   = reg_UPDATE_PREDICTION_TABLE [i][depth]._state;
    113        
    114         Tcontrol_t val     = (state == UPDATE_PREDICTION_STATE_EVENT);
    115 
    116         if (val)
    117           {
    118             PORT_WRITE(out_BRANCH_EVENT_ADDRESS_SRC  [i], reg_UPDATE_PREDICTION_TABLE [i][depth]._address_src );
    119             PORT_WRITE(out_BRANCH_EVENT_ADDRESS_DEST [i], reg_UPDATE_PREDICTION_TABLE [i][depth]._address_dest);
    120             internal_BRANCH_EVENT_DEPTH [i] = depth;
    121           }
    122 
    123         internal_BRANCH_EVENT_VAL   [i] = val;
    124         PORT_WRITE(out_BRANCH_EVENT_VAL [i], internal_BRANCH_EVENT_VAL [i]);
    125       }
    126     log_printf(FUNC,Update_Prediction_Table,FUNCTION,"End");
     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      }
     266    log_end(Update_Prediction_Table,FUNCTION);
    127267  };
    128268
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_statistics_allocation.cpp

    r81 r88  
    2727                      "Update_Prediction_Table",
    2828                      param_statistics);
     29
     30//     _stat_nb_branch_hit        = new counter_t * [_param->_nb_context];
     31//     _stat_nb_branch_miss       = new counter_t * [_param->_nb_context];
     32//     _stat_nb_branch_unused     = new counter_t * [_param->_nb_context];
     33//     _stat_queue_nb_cycle_empty = new counter_t * [_param->_nb_context];
     34//     _stat_queue_nb_cycle_full  = new counter_t * [_param->_nb_context];
     35//     _stat_queue_nb_elt         = new counter_t * [_param->_nb_context];
     36 
     37//     for (uint32_t i=0; i<_param->_nb_context; ++i)
     38//       {
     39//         _stat_nb_branch_hit        [i] = _stat->create_counter("nb_branch_hit_"       +toString(i),"",toString(_("Branch hit speculation (context %d)"),i));
     40//         _stat_nb_branch_miss       [i] = _stat->create_counter("nb_branch_miss_"      +toString(i),"",toString(_("Branch miss speculation (context %d)"),i));
     41//         _stat_nb_branch_unused     [i] = _stat->create_counter("nb_branch_unused_"    +toString(i),"",toString(_("Branch unused, because an previous branch have miss speculation (context %d)"),i));
     42//         _stat_queue_nb_cycle_empty [i] = _stat->create_counter("queue_nb_cycle_empty_"+toString(i),"",toString(_("Cycle number where the Update Prediction Table is empty (context %d)"),i));
     43//         _stat_queue_nb_cycle_full  [i] = _stat->create_counter("queue_nb_cycle_full_" +toString(i),"",toString(_("Cycle number where the Update Prediction Table is full (%d elements) (context %d)"),_param->_size_queue[i],i));
     44//         _stat_queue_nb_elt         [i] = _stat->create_counter("queue_nb_elt_"        +toString(i),"",toString(_("Average branchement by cycle in Update Prediction Table (context %d)"),i));
     45//       }
    2946   
    3047    log_printf(FUNC,Update_Prediction_Table,FUNCTION,"End");
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_statistics_deallocation.cpp

    r81 r88  
    2626    log_printf(INFO,Update_Prediction_Table,FUNCTION,"Generate Statistics file");
    2727   
    28     delete _stat;
     28    delete    _stat;
     29//     delete [] _stat_nb_branch_hit       ;
     30//     delete [] _stat_nb_branch_miss      ;
     31//     delete [] _stat_nb_branch_unused    ;
     32//     delete [] _stat_queue_nb_cycle_empty;
     33//     delete [] _stat_queue_nb_cycle_full ;
     34//     delete [] _stat_queue_nb_elt        ;
    2935   
    3036    log_printf(FUNC,Update_Prediction_Table,FUNCTION,"End");
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_transition.cpp

    r82 r88  
    1717namespace update_prediction_table {
    1818
    19 
    2019#undef  FUNCTION
    2120#define FUNCTION "Update_Prediction_Table::transition"
    2221  void Update_Prediction_Table::transition (void)
    2322  {
    24     log_printf(FUNC,Update_Prediction_Table,FUNCTION,"Begin");
     23    log_begin(Update_Prediction_Table,FUNCTION);
     24    log_function(Update_Prediction_Table,FUNCTION,_name.c_str());
    2525
    2626    if (PORT_READ(in_NRESET) == 0)
    2727      {
     28        // Initialisation
     29
     30        reg_UPDATE_PRIORITY = 0;
     31
     32        // All pointer is set at 0
    2833        for (uint32_t i=0; i<_param->_nb_context; i++)
    2934          {
    30             reg_TOP                [i] = 0;
    31             reg_BOTTOM             [i] = 0;
    32             reg_NB_ELT             [i] = 0;
    33             reg_NB_ELT_UPDATE      [i] = 0;
    34             reg_NB_ELT_NEED_UPDATE [i] = 0;
    35             for (uint32_t j=0; j<_param->_size_queue[i]; j++)
    36               reg_UPDATE_PREDICTION_TABLE [i][j]._state = UPDATE_PREDICTION_STATE_EMPTY;
    37           }
    38         reg_UPDATE_PRIORITY = 0;
     35            for (uint32_t j=0; j<_param->_size_ufpt_queue[i]; ++j)
     36              reg_UPDATE_FETCH_PREDICTION_TABLE [i][j]._state = UPDATE_FETCH_PREDICTION_STATE_EMPTY;
     37            reg_UFPT_BOTTOM          [i] = 0;
     38            reg_UFPT_TOP             [i] = 0;
     39            reg_UFPT_UPDATE          [i] = 0;
     40            reg_UFPT_NB_NEED_UPDATE  [i] = 0;
     41                                                               
     42            for (uint32_t j=0; j<_param->_size_upt_queue[i]; ++j)
     43              reg_UPDATE_PREDICTION_TABLE [i][j]._state = UPDATE_PREDICTION_STATE_EMPTY;
     44            reg_UPT_BOTTOM           [i] = 0;
     45            reg_UPT_TOP              [i] = 0;
     46            reg_UPT_UPDATE           [i] = 0;
     47            reg_UPT_NB_NEED_UPDATE   [i] = 0;
     48                                                                                   
     49            reg_IS_ACCURATE          [i] = true;
     50
     51            reg_EVENT_STATE          [i] = EVENT_STATE_OK;
     52          }
    3953      }
    4054    else
    4155      {
    4256        // ===================================================================
     57        // =====[ GARBAGE COLLECTOR ]=========================================
     58        // ===================================================================
     59
     60        // Each cycle, if the most lastest branch have update all prediction struction (state = end), free this slot
     61        //   * Update state -> new status is "empty"
     62        //   * Update pointer (bottom and accurate)
     63        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * GARBAGE COLLECTOR");
     64        for (uint32_t i=0; i<_param->_nb_context; i++)
     65          {
     66            // UPDATE_FETCH_PREDICTION_TABLE
     67            {
     68              uint32_t bottom = reg_UFPT_BOTTOM [i];
     69             
     70              // Test if state is end
     71              if (reg_UPDATE_FETCH_PREDICTION_TABLE [i][bottom]._state == UPDATE_FETCH_PREDICTION_STATE_END)
     72                {
     73                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UFPT [%d][%d]",i,bottom);
     74                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UFPT [%d][%d].state =  UPDATE_FETCH_PREDICTION_STATE_EMPTY",i,bottom);
     75
     76                  // Free slot
     77                  reg_UPDATE_FETCH_PREDICTION_TABLE [i][bottom]._state = UPDATE_FETCH_PREDICTION_STATE_EMPTY;
     78                  // Update pointer
     79                  reg_UFPT_BOTTOM [i] = (bottom+1)%_param->_size_ufpt_queue[i];
     80                }
     81            }
     82
     83            // UPDATE_PREDICTION_TABLE
     84            {
     85              uint32_t bottom = reg_UPT_BOTTOM [i];
     86             
     87              // Test if state is end
     88              if (reg_UPDATE_PREDICTION_TABLE [i][bottom]._state == UPDATE_PREDICTION_STATE_END)
     89                {
     90                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT [%d][%d]",i,bottom);
     91                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT [%d][%d]._state =  UPDATE_PREDICTION_STATE_EMPTY",i,bottom);
     92
     93                  // Free slot
     94                  reg_UPDATE_PREDICTION_TABLE [i][bottom]._state = UPDATE_PREDICTION_STATE_EMPTY;
     95                  // Update pointer
     96                  reg_UPT_BOTTOM [i] = (bottom+1)%_param->_size_upt_queue[i];
     97                }
     98            }
     99          }
     100
     101        // ===================================================================
    43102        // =====[ PREDICT ]===================================================
    44103        // ===================================================================
     104       
     105        // An ifetch_unit compute next cycle and have an branch : predict_val is set
     106        //   * Alloc new entry -> new status is "wait decod"
     107        //   * Save input (to restore in miss or error)
     108        //   * Update pointer
     109
    45110        for (uint32_t i=0; i<_param->_nb_inst_predict; i++)
    46111          if (PORT_READ(in_PREDICT_VAL[i]) and internal_PREDICT_ACK [i])
    47112            {
    48113              Tcontext_t context = (_param->_have_port_context_id)?PORT_READ(in_PREDICT_CONTEXT_ID [i]):0;
    49               uint32_t   top     = reg_TOP [context];
    50 
    51               log_printf(TRACE,Update_Prediction_Table,FUNCTION,"PREDICT[%d] - Accepted",i);
    52               log_printf(TRACE,Update_Prediction_Table,FUNCTION," * context : %d",context);
    53               log_printf(TRACE,Update_Prediction_Table,FUNCTION," * top     : %d",top);
    54               log_printf(TRACE,Update_Prediction_Table,FUNCTION," * nb_elt  : %d",reg_NB_ELT[context]);
    55 
    56               reg_UPDATE_PREDICTION_TABLE [context][top]._state        = UPDATE_PREDICTION_STATE_WAIT_DECOD;
    57               reg_UPDATE_PREDICTION_TABLE [context][top]._ifetch_prediction = true;
    58               reg_UPDATE_PREDICTION_TABLE [context][top]._condition    = PORT_READ(in_PREDICT_BTB_CONDITION    [i]);
    59               reg_UPDATE_PREDICTION_TABLE [context][top]._address_src  = PORT_READ(in_PREDICT_BTB_ADDRESS_SRC  [i]);
    60               reg_UPDATE_PREDICTION_TABLE [context][top]._address_dest = PORT_READ(in_PREDICT_BTB_ADDRESS_DEST [i]);
    61               reg_UPDATE_PREDICTION_TABLE [context][top]._last_take    = PORT_READ(in_PREDICT_BTB_LAST_TAKE    [i]);
    62             //reg_UPDATE_PREDICTION_TABLE [context][top]._good_take   
    63               reg_UPDATE_PREDICTION_TABLE [context][top]._history      = (_param->_have_port_history)?PORT_READ(in_PREDICT_DIR_HISTORY [i]):0;
    64               reg_UPDATE_PREDICTION_TABLE [context][top]._address_ras  = PORT_READ(in_PREDICT_RAS_ADDRESS      [i]);
    65               reg_UPDATE_PREDICTION_TABLE [context][top]._index_ras    = PORT_READ(in_PREDICT_RAS_INDEX        [i]);
    66 
    67               reg_TOP    [context] = (top+1)%_param->_size_queue [context];
    68               reg_NB_ELT [context] ++;
     114              uint32_t   top     = internal_PREDICT_UPDATE_PREDICTION_ID [i];
     115
     116              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * PREDICT[%d] - Accepted",i);
     117              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * context : %d",context);
     118              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * top     : %d",top);
     119
     120#ifdef DEBUG_TEST
     121              if (reg_UPDATE_FETCH_PREDICTION_TABLE [context][top]._state != UPDATE_FETCH_PREDICTION_STATE_EMPTY)
     122                throw ERRORMORPHEO(FUNCTION,_("Predict : invalid state."));
     123#endif
     124
     125              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UFPT [%d][%d].state <- UPDATE_FETCH_PREDICTION_STATE_WAIT_DECOD (predict)",context,top);
     126              reg_UPDATE_FETCH_PREDICTION_TABLE [context][top]._state        = UPDATE_FETCH_PREDICTION_STATE_WAIT_DECOD;
     127
     128              Tbranch_condition_t condition = PORT_READ(in_PREDICT_BTB_CONDITION [i]);
     129
     130              reg_UPDATE_FETCH_PREDICTION_TABLE [context][top]._condition    = condition;
     131              reg_UPDATE_FETCH_PREDICTION_TABLE [context][top]._address_src  = PORT_READ(in_PREDICT_BTB_ADDRESS_SRC  [i]);
     132              reg_UPDATE_FETCH_PREDICTION_TABLE [context][top]._address_dest = PORT_READ(in_PREDICT_BTB_ADDRESS_DEST [i]);
     133              reg_UPDATE_FETCH_PREDICTION_TABLE [context][top]._last_take    = PORT_READ(in_PREDICT_BTB_LAST_TAKE    [i]);
     134              reg_UPDATE_FETCH_PREDICTION_TABLE [context][top]._is_accurate  = PORT_READ(in_PREDICT_BTB_IS_ACCURATE  [i]);
     135              reg_UPDATE_FETCH_PREDICTION_TABLE [context][top]._history      = (_param->_have_port_history)?PORT_READ(in_PREDICT_DIR_HISTORY [i]):0;
     136              reg_UPDATE_FETCH_PREDICTION_TABLE [context][top]._address_ras  = PORT_READ(in_PREDICT_RAS_ADDRESS      [i]);
     137              reg_UPDATE_FETCH_PREDICTION_TABLE [context][top]._index_ras    = PORT_READ(in_PREDICT_RAS_INDEX        [i]);
     138
     139              reg_UFPT_TOP     [context] = (top+1)%_param->_size_ufpt_queue [context];
     140//            reg_UFPT_UPDATE  [context] = reg_UFPT_TOP [context];
     141              if (need_update(condition))
     142                reg_UFPT_NB_NEED_UPDATE [context] ++;
    69143            }
    70144
     
    72146        // =====[ DECOD ]=====================================================
    73147        // ===================================================================
     148
     149
     150        // An decod is detected by decod stage
     151        //   1) Hit prediction : The instruction bundle have a branch predicted in ifetch stage and it is this branch
     152        //      * Update state, wait_decod -> wait_end
     153        //      * Pop ufpt -> push upt
     154        //      * Update accurate register : if the predict stage have tagged this branch as not accurate, stop decod
     155        //   2) Miss           : The instruction bundle have a branch but it is not predicted
     156        //      * Flush ufpt
     157        //      * decod information is write in upt
     158
    74159        for (uint32_t i=0; i<_param->_nb_inst_decod; i++)
    75160          if (PORT_READ(in_DECOD_VAL[i]) and internal_DECOD_ACK [i])
    76161            {
    77               Tcontext_t context     = (_param->_have_port_context_id)?PORT_READ(in_DECOD_CONTEXT_ID [i]):0;
    78               Tcontrol_t miss_ifetch = PORT_READ(in_DECOD_MISS_IFETCH [i]);
    79               Tcontrol_t miss_decod  = PORT_READ(in_DECOD_MISS_DECOD  [i]);
    80 
    81               log_printf(TRACE,Update_Prediction_Table,FUNCTION,"DECOD[%d] - Accepted",i);
    82               log_printf(TRACE,Update_Prediction_Table,FUNCTION," * context     : %d",context);
    83               log_printf(TRACE,Update_Prediction_Table,FUNCTION," * miss_ifetch : %d",miss_ifetch);
    84               log_printf(TRACE,Update_Prediction_Table,FUNCTION," * miss_decod  : %d",miss_decod);
    85               log_printf(TRACE,Update_Prediction_Table,FUNCTION," * nb_elt      : %d",reg_NB_ELT[context]);
     162              Tcontext_t          context       = (_param->_have_port_context_id)?PORT_READ(in_DECOD_CONTEXT_ID [i]):0;
     163              Tcontrol_t          miss_ifetch   = PORT_READ(in_DECOD_MISS_IFETCH [i]);
     164              Tcontrol_t          miss_decod    = PORT_READ(in_DECOD_MISS_DECOD  [i]);
     165              uint32_t            upt_ptr_write = internal_DECOD_UPT_PTR_WRITE [i];
     166              Tbranch_condition_t condition  ;
     167              Tcontrol_t          is_accurate;
     168
     169              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * DECOD[%d] - Accepted",i);
     170              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * context       : %d",context);
     171              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * miss_ifetch   : %d",miss_ifetch);
     172              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * miss_decod    : %d",miss_decod);
     173              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * upt_ptr_write : %d",upt_ptr_write);
    86174             
    87               // Test if miss ifetch
    88               //   miss ifetch = decod a branch and the predict unit have not predict this branch ... gloup :P
    89               if (miss_ifetch or miss_decod)
     175              if (miss_ifetch or miss_decod)
    90176                {
    91                   Tdepth_t depth = (_param->_have_port_max_depth)?PORT_READ(in_DECOD_UPDATE_PREDICTION_ID [i]):0;
    92                   Tdepth_t top   = reg_TOP [context];
    93 
    94                   reg_UPDATE_PREDICTION_TABLE [context][top]._state        = UPDATE_PREDICTION_STATE_WAITEND;
    95                   reg_UPDATE_PREDICTION_TABLE [context][top]._ifetch_prediction = false; // static prediction
    96                   reg_UPDATE_PREDICTION_TABLE [context][top]._condition    = PORT_READ(in_DECOD_BTB_CONDITION    [i]);
    97                   reg_UPDATE_PREDICTION_TABLE [context][top]._address_src  = PORT_READ(in_DECOD_BTB_ADDRESS_SRC  [i]);
    98                   reg_UPDATE_PREDICTION_TABLE [context][top]._address_dest = PORT_READ(in_DECOD_BTB_ADDRESS_DEST [i]);
    99                   reg_UPDATE_PREDICTION_TABLE [context][top]._last_take    = PORT_READ(in_DECOD_BTB_LAST_TAKE    [i]);
    100                 //reg_UPDATE_PREDICTION_TABLE [context][top]._good_take
    101                 //reg_UPDATE_PREDICTION_TABLE [context][top]._history
    102                   reg_UPDATE_PREDICTION_TABLE [context][top]._address_ras  = PORT_READ(in_DECOD_RAS_ADDRESS      [i]);
    103                   reg_UPDATE_PREDICTION_TABLE [context][top]._index_ras    = PORT_READ(in_DECOD_RAS_INDEX        [i]);
    104 
    105                   // Invalid all previous "ifetch" prediction
    106                   // (ifetch prediction = prediction make in fetch stage and not again comming in decod stage)
    107                   uint32_t nb_elt_miss        = ((top> depth)?top:(top+_param->_size_queue[context]))-depth;
    108                   uint32_t nb_elt_need_update = 0;
    109                   for (uint32_t j=0; j<nb_elt_miss; j++)
    110                     {
    111                       uint32_t k=(depth+j)%_param->_size_queue[context];
    112                      
    113                       // Ifetch have make a prediction and it's a miss
    114                       // When ifetch predict :
    115                       //   * btb is not change       -> needn't update
    116                       //   * direction is not change -> needn't update
    117                       //   * ras have change         -> need    update
    118 
    119                       Tbranch_condition_t cond = reg_UPDATE_PREDICTION_TABLE [context][k]._condition;
    120                       if ((cond == BRANCH_CONDITION_NONE_WITH_WRITE_STACK) or
    121                           (cond == BRANCH_CONDITION_READ_REGISTER_WITH_WRITE_STACK) or
    122                           (cond == BRANCH_CONDITION_READ_STACK))
    123                         {
    124                           nb_elt_need_update ++;
    125                           reg_UPDATE_PREDICTION_TABLE [context][k]._state = UPDATE_PREDICTION_STATE_KO;
    126                         }
    127                       else
    128                         {
    129                           reg_UPDATE_PREDICTION_TABLE [context][k]._state = UPDATE_PREDICTION_STATE_END;
    130                         }
    131                     }
    132                   reg_UPDATE_PREDICTION_TABLE [context][depth]._state = UPDATE_PREDICTION_STATE_EVENT; // rewrite
    133 
    134                   reg_TOP                [context] = (depth+1)%_param->_size_queue [context];
    135                   reg_NB_ELT_NEED_UPDATE [context] += nb_elt_need_update;
    136                   reg_NB_ELT             [context] ++;
     177                  // Have a miss !!!
     178
     179                  // 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                    }
     205
     206                  // Push upt (from decod interface)
     207                  condition   = PORT_READ(in_DECOD_BTB_CONDITION [i]);
     208                  is_accurate = PORT_READ(in_DECOD_IS_ACCURATE   [i]);
     209
     210                  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]);
     214//                reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._good_take;
     215                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._is_accurate       = is_accurate;
     216//                reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._history           = ; // static prediction
     217                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._address_ras       = PORT_READ(in_DECOD_RAS_ADDRESS [i]);
     218                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._index_ras         = PORT_READ(in_DECOD_RAS_INDEX   [i]);
     219                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._ifetch_prediction = false; // static prediction
    137220                }
    138221              else
    139222                {
    140223                  // Normal case : branch is previous predicated, change state of branch
    141                   Tdepth_t depth = (_param->_have_port_max_depth)?PORT_READ(in_DECOD_UPDATE_PREDICTION_ID [i]):0;
    142 
    143                   reg_UPDATE_PREDICTION_TABLE [context][depth]._state = UPDATE_PREDICTION_STATE_WAITEND;
     224                  uint32_t ufpt_ptr_read = (_param->_have_port_depth)?PORT_READ(in_DECOD_UPDATE_PREDICTION_ID [i]):0;
     225
     226                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * ufpt_ptr_read : %d",ufpt_ptr_read);
     227
     228#ifdef DEBUG_TEST
     229                  if (reg_UPDATE_FETCH_PREDICTION_TABLE [context][ufpt_ptr_read]._state != UPDATE_FETCH_PREDICTION_STATE_WAIT_DECOD)
     230                    throw ERRORMORPHEO(FUNCTION,_("Decod : invalid ufpt state."));
     231#endif
     232                  // Change state
     233                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UFPT [%d][%d].state <- UPDATE_FETCH_PREDICTION_STATE_END (decod - hit)",context,ufpt_ptr_read);
     234                  reg_UPDATE_FETCH_PREDICTION_TABLE [context][ufpt_ptr_read]._state = UPDATE_FETCH_PREDICTION_STATE_END;
     235
     236                  // Push upt (from Pop ufpt)
     237                  condition   = reg_UPDATE_FETCH_PREDICTION_TABLE [context][ufpt_ptr_read]._condition;
     238                  is_accurate = reg_UPDATE_FETCH_PREDICTION_TABLE [context][ufpt_ptr_read]._is_accurate;
     239
     240                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._condition         = condition;
     241                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._address_src       = reg_UPDATE_FETCH_PREDICTION_TABLE [context][ufpt_ptr_read]._address_src ;
     242                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._address_dest      = reg_UPDATE_FETCH_PREDICTION_TABLE [context][ufpt_ptr_read]._address_dest;
     243                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._last_take         = reg_UPDATE_FETCH_PREDICTION_TABLE [context][ufpt_ptr_read]._last_take   ;
     244//                reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._good_take;
     245                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._is_accurate       = is_accurate;
     246                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._history           = reg_UPDATE_FETCH_PREDICTION_TABLE [context][ufpt_ptr_read]._history     ;
     247                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._address_ras       = reg_UPDATE_FETCH_PREDICTION_TABLE [context][ufpt_ptr_read]._address_ras ;
     248                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._index_ras         = reg_UPDATE_FETCH_PREDICTION_TABLE [context][ufpt_ptr_read]._index_ras   ;
     249                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._ifetch_prediction = true; // prediction from ifetch
     250
     251                  // Update pointer
     252                  if (need_update(condition))
     253                    {
     254                      reg_UFPT_NB_NEED_UPDATE [context] --;
     255                    }
    144256                }
     257
     258              // All case !!!
     259
     260#ifdef DEBUG_TEST
     261              if (reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._state != UPDATE_PREDICTION_STATE_EMPTY)
     262                throw ERRORMORPHEO(FUNCTION,_("Decod : invalid upt state."));
     263#endif
     264             
     265              // Change state
     266              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT  [%d][%d].state <- UPDATE_PREDICTION_STATE_WAIT_END (decod - hit)",context,upt_ptr_write);
     267              reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._state = UPDATE_PREDICTION_STATE_WAIT_END;
     268             
     269              // Write new accurate
     270#ifdef DEBUG_TEST
     271              if (not reg_IS_ACCURATE [context]  and not is_accurate)
     272                throw ERRORMORPHEO(FUNCTION,_("Decod : invalid accurate flag."));
     273#endif
     274              reg_IS_ACCURATE [context] = is_accurate;
     275             
     276              // Update pointer
     277              reg_UPT_TOP     [context] = (upt_ptr_write+1)%_param->_size_upt_queue [context];
     278//            reg_UPT_UPDATE  [context] = reg_UPT_TOP [context];
     279              if (need_update(condition))
     280                {
     281                  reg_UPT_NB_NEED_UPDATE  [context] ++;
     282                }
    145283            }
    146284
     
    148286        // =====[ BRANCH_COMPLETE ]===========================================
    149287        // ===================================================================
     288       
     289        // The branch is complete
     290        //   * Hit  prediction :
     291        //     * update status
     292        //   * Miss prediction :
    150293        for (uint32_t i=0; i<_param->_nb_inst_branch_complete; i++)
    151294          if (PORT_READ(in_BRANCH_COMPLETE_VAL[i]) and internal_BRANCH_COMPLETE_ACK [i])
    152295            {
    153296              Tcontext_t context = (_param->_have_port_context_id)?PORT_READ(in_BRANCH_COMPLETE_CONTEXT_ID [i]):0;
    154               Tdepth_t   depth   = (_param->_have_port_max_depth     )?PORT_READ(in_BRANCH_COMPLETE_DEPTH      [i]):0;
    155 
    156               log_printf(TRACE,Update_Prediction_Table,FUNCTION,"BRANCH_COMPLETE[%d] - Accepted",i);
    157               log_printf(TRACE,Update_Prediction_Table,FUNCTION," * context : %d",context);
    158               log_printf(TRACE,Update_Prediction_Table,FUNCTION," * depth   : %d",depth);
    159               log_printf(TRACE,Update_Prediction_Table,FUNCTION," * nb_elt  : %d",reg_NB_ELT[context]);
     297              Tdepth_t   depth   = (_param->_have_port_depth     )?PORT_READ(in_BRANCH_COMPLETE_DEPTH      [i]):0;
     298
     299              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * BRANCH_COMPLETE[%d] - Accepted",i);
     300              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * context : %d",context);
     301              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]);
    160303             
    161304              if (internal_BRANCH_COMPLETE_MISS_PREDICTION [i])
    162305                {
    163306                  // Miss case
    164                   reg_UPDATE_PREDICTION_TABLE [context][depth]._state = UPDATE_PREDICTION_STATE_EVENT;
    165 
    166                   // Another prediction (prediction with depth higer)
    167                   Tdepth_t top                = reg_TOP [context];
    168                   uint32_t nb_elt_miss        = ((top> depth)?top:(top+_param->_size_queue[context]))-depth;
    169                   uint32_t nb_elt_need_update = 1;
    170                   for (uint32_t j=1; j<nb_elt_miss; j++)
    171                     {
    172                       uint32_t k=(depth+j)%_param->_size_queue[context];
     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];
    173319                     
    174                       // Ifetch have make a prediction and it's a miss
    175                       // When ifetch predict :
    176                       //   * btb is not change       -> needn't update
    177                       //   * direction is not change -> needn't update
    178                       //   * ras have change         -> need    update
    179 
    180                       Tbranch_condition_t cond = reg_UPDATE_PREDICTION_TABLE [context][k]._condition;
    181                       if ((cond == BRANCH_CONDITION_NONE_WITH_WRITE_STACK) or
    182                           (cond == BRANCH_CONDITION_READ_REGISTER_WITH_WRITE_STACK) or
    183                           (cond == BRANCH_CONDITION_READ_STACK))
    184                         {
    185                           nb_elt_need_update ++;
    186                           reg_UPDATE_PREDICTION_TABLE [context][k]._state = UPDATE_PREDICTION_STATE_KO;
    187                         }
    188                       else
    189                         {
    190                           reg_UPDATE_PREDICTION_TABLE [context][k]._state = UPDATE_PREDICTION_STATE_END;
    191                         }
    192                     }
    193                   reg_NB_ELT_NEED_UPDATE [context] += nb_elt_need_update;
    194 
    195                   // Update pointer :
    196                   reg_TOP                [context]  = depth;
    197                   reg_NB_ELT             [context] -= nb_elt_miss;
     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
    198350                }
    199351              else
    200352                {
    201                   // Hit case
    202 #ifdef DEBUG_TEST
    203                   if (reg_UPDATE_PREDICTION_TABLE [context][depth]._state != UPDATE_PREDICTION_STATE_WAITEND)
    204                     ERRORMORPHEO(FUNCTION,"Branche complete : invalid state");
    205 #endif
    206                   reg_UPDATE_PREDICTION_TABLE [context][depth]._state = UPDATE_PREDICTION_STATE_OK;
     353                  // Hit case
     354
     355#ifdef DEBUG_TEST
     356                  if (reg_UPDATE_PREDICTION_TABLE [context][depth]._state != UPDATE_PREDICTION_STATE_WAIT_END)
     357                    throw ERRORMORPHEO(FUNCTION,_("Branch complete : invalid upt state."));
     358#endif
     359                   
     360                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT  [%d][%d].state <- UPDATE_PREDICTION_STATE_OK (branch_complete, ifetch hit)",context,depth);
     361                  reg_UPDATE_PREDICTION_TABLE [context][depth]._state = UPDATE_PREDICTION_STATE_OK;
    207362                }
    208363
    209               // In all case : update good_take and address_destination
    210               reg_UPDATE_PREDICTION_TABLE [context][depth]._good_take    = internal_BRANCH_COMPLETE_TAKE         [i];
    211               reg_UPDATE_PREDICTION_TABLE [context][depth]._address_dest = internal_BRANCH_COMPLETE_ADDRESS_DEST [i];
    212             }
     364              // In all case : update good_take
     365              reg_UPDATE_PREDICTION_TABLE [context][depth]._good_take = internal_BRANCH_COMPLETE_TAKE [i];
     366            }
    213367
    214368        // ===================================================================
     
    216370        // ===================================================================
    217371        for (uint32_t i=0; i<_param->_nb_inst_update; i++)
    218           if (internal_UPDATE_VAL[i] and PORT_READ(in_UPDATE_ACK [i]))
     372          if ((internal_UPDATE_VAL[i] and PORT_READ(in_UPDATE_ACK [i])) or
     373              (internal_UPDATE_VAL_WITHOUT_ACK [i]))
    219374            {
    220375              Tcontext_t context = internal_UPDATE_CONTEXT_ID [i];
    221376              Tdepth_t   depth   = internal_UPDATE_DEPTH      [i];
    222 
    223               log_printf(TRACE,Update_Prediction_Table,FUNCTION,"UPDATE[%d] - Accepted",i);
    224               log_printf(TRACE,Update_Prediction_Table,FUNCTION," * context : %d",context);
    225               log_printf(TRACE,Update_Prediction_Table,FUNCTION," * depth   : %d",depth);
    226 
    227               if (reg_UPDATE_PREDICTION_TABLE [context][depth]._state == UPDATE_PREDICTION_STATE_KO)
    228                 reg_NB_ELT_NEED_UPDATE [context] --;
    229 
    230               reg_UPDATE_PREDICTION_TABLE [context][depth]._state = UPDATE_PREDICTION_STATE_END;
     377              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * UPDATE[%d] - Accepted",i);
     378              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * context : %d",context);
     379              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * depth   : %d",depth);
     380
     381              if (internal_UPDATE_FROM_UFPT [i])
     382                {
     383                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * Update Fetch Prediction Table");
     384                 
     385                  // Change state
     386#ifdef DEBUG_TEST
     387                  if (reg_UPDATE_FETCH_PREDICTION_TABLE [context][depth]._state != UPDATE_FETCH_PREDICTION_STATE_EVENT)
     388                    throw ERRORMORPHEO(FUNCTION,_("Update : invalid ufpt state."));
     389#endif
     390
     391                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UFPT [%d][%d].state <- UPDATE_FETCH_PREDICTION_STATE_END (update)",context,depth);
     392
     393                  reg_UPDATE_FETCH_PREDICTION_TABLE [context][depth]._state = UPDATE_FETCH_PREDICTION_STATE_END;
     394
     395                  // Update pointer
     396                  reg_UFPT_UPDATE [context] = (depth==0)?(_param->_size_ufpt_queue[context]-1):(depth-1);
     397
     398                  // Free a register that need update ?
     399                  if (need_update(reg_UPDATE_FETCH_PREDICTION_TABLE [context][depth]._condition))
     400                    reg_UFPT_NB_NEED_UPDATE [context] --;
     401                }
     402              else
     403                {
     404                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * Update Prediction Table");
     405                 
     406                  // 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."));
     412#endif
     413
     414                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT  [%d][%d].state <- UPDATE_PREDICTION_STATE_END (update)",context,depth);
     415
     416                  reg_UPDATE_PREDICTION_TABLE [context][depth]._state = UPDATE_PREDICTION_STATE_END;
     417
     418                  // Update pointer
     419                  if (internal_UPDATE_RAS [i])
     420                    reg_UPT_UPDATE [context] = (depth==0)?(_param->_size_upt_queue[context]-1):(depth-1);
     421                  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] --;
     427                  // Free the branch with no accurate ?
     428                  if (reg_UPDATE_PREDICTION_TABLE [context][depth]._is_accurate == false)
     429                    reg_IS_ACCURATE [i] = true;
     430                }
    231431            }
    232432       
     
    234434        reg_UPDATE_PRIORITY = (reg_UPDATE_PRIORITY+1)%_param->_nb_context;
    235435
    236         // ===================================================================
    237         // =====[ BRANCH_EVENT ]==============================================
    238         // ===================================================================
    239         for (uint32_t i=0; i<_param->_nb_context; i++)
    240           if (internal_BRANCH_EVENT_VAL [i] and PORT_READ(in_BRANCH_EVENT_ACK [i]))
    241           {
    242             Tdepth_t depth = internal_BRANCH_EVENT_DEPTH [i];
    243            
    244             reg_UPDATE_PREDICTION_TABLE [i][depth]._state = UPDATE_PREDICTION_STATE_KO;
    245           }
    246 
    247         // ===================================================================
    248         // =====[ GARBAGE COLLECTOR ]=========================================
    249         // ===================================================================
    250 
    251         for (uint32_t i=0; i<_param->_nb_context; i++)
    252           {
    253             uint32_t bottom = reg_BOTTOM [i];
    254            
    255             // Test if the tail of queue is finish (ok or ko and update)
    256             if (reg_UPDATE_PREDICTION_TABLE [i][bottom]._state == UPDATE_PREDICTION_STATE_END)
    257               {
    258                 log_printf(TRACE,Update_Prediction_Table,FUNCTION,"GARBAGE_COLLECTOR");
    259                 log_printf(TRACE,Update_Prediction_Table,FUNCTION," * context : %d",i);
    260                 log_printf(TRACE,Update_Prediction_Table,FUNCTION," * bottom  : %d",bottom);
    261 
    262                 reg_UPDATE_PREDICTION_TABLE [i][bottom]._state = UPDATE_PREDICTION_STATE_EMPTY;
    263                 reg_BOTTOM [i] = (bottom+1)%_param->_size_queue [i];
    264                 if (reg_NB_ELT [i]>0)
    265                   reg_NB_ELT [i] --;
    266               }
    267           }
    268       }
     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//             }
    269462
    270463#if (DEBUG >= DEBUG_TRACE)
    271     log_printf(TRACE,Update_Prediction_Table,FUNCTION,"Dump Update_Prediction_Table");
    272     log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * reg_UPDATE_PRIORITY      : %d",reg_UPDATE_PRIORITY);
     464    log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * Dump Update_Prediction_Table");
     465    log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_UPDATE_PRIORITY       : %d",reg_UPDATE_PRIORITY);
    273466    for (uint32_t i=0; i<_param->_nb_context; i++)
    274467      {
    275         log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * Update_Prediction_Table   [%d]",i);
    276         log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_TOP                : %d",reg_TOP                [i]);
    277         log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_BOTTOM             : %d",reg_BOTTOM             [i]);
    278         log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_NB_ELT             : %d",reg_NB_ELT             [i]);
    279         log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_NB_ELT_NEED_UPDATE : %d",reg_NB_ELT_NEED_UPDATE [i]);
    280         for (uint32_t j=0; j<_param->_size_queue[i]; j++)
    281           log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      [%d] %s %x",j,toString(reg_UPDATE_PREDICTION_TABLE [i][j]._state).c_str(),reg_UPDATE_PREDICTION_TABLE [i][j]._address_src);
     468        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_IS_ACCURATE           : %d",reg_IS_ACCURATE        [i]);
     469        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]);
     471        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]);
     473        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_EVENT_ADDRESS_DEST    : %.8x",reg_EVENT_ADDRESS_DEST    [i]);
     474
     475        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * Update_Fetch_Prediction_Table   [%d]",i);
     476        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * reg_UFPT_BOTTOM         : %d",reg_UFPT_BOTTOM         [i]);
     477        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * reg_UFPT_TOP            : %d",reg_UFPT_TOP            [i]);
     478        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * reg_UFPT_NB_NEED_UPDATE : %d",reg_UFPT_NB_NEED_UPDATE [i]);
     479        for (uint32_t j=0; j<_param->_size_ufpt_queue[i]; j++)
     480          log_printf(TRACE,Update_Prediction_Table,FUNCTION,"        [%d] %.4d, %.8x %.8x, %.1d   %.1d, %.8d %.8x %.4d - %s",
     481                     j,
     482                     reg_UPDATE_FETCH_PREDICTION_TABLE [i][j]._condition,
     483                     reg_UPDATE_FETCH_PREDICTION_TABLE [i][j]._address_src,
     484                     reg_UPDATE_FETCH_PREDICTION_TABLE [i][j]._address_dest,
     485                     reg_UPDATE_FETCH_PREDICTION_TABLE [i][j]._last_take,
     486                     reg_UPDATE_FETCH_PREDICTION_TABLE [i][j]._is_accurate,
     487                     reg_UPDATE_FETCH_PREDICTION_TABLE [i][j]._history,
     488                     reg_UPDATE_FETCH_PREDICTION_TABLE [i][j]._address_ras,
     489                     reg_UPDATE_FETCH_PREDICTION_TABLE [i][j]._index_ras,
     490                     toString(reg_UPDATE_FETCH_PREDICTION_TABLE [i][j]._state).c_str()
     491                     );
     492
     493        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * Update_Prediction_Table   [%d]",i);
     494        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * reg_UPT_BOTTOM          : %d",reg_UPT_BOTTOM         [i]);
     495        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * reg_UPT_TOP             : %d",reg_UPT_TOP            [i]);
     496        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]);
     498        for (uint32_t j=0; j<_param->_size_upt_queue[i]; j++)
     499          log_printf(TRACE,Update_Prediction_Table,FUNCTION,"        [%d] %.4d, %.8x %.8x, %.1d %.1d %.1d, %.8d %.8x %.4d - %s",
     500                     j,
     501                     reg_UPDATE_PREDICTION_TABLE [i][j]._condition,
     502                     reg_UPDATE_PREDICTION_TABLE [i][j]._address_src,
     503                     reg_UPDATE_PREDICTION_TABLE [i][j]._address_dest,
     504                     reg_UPDATE_PREDICTION_TABLE [i][j]._last_take,
     505                     reg_UPDATE_PREDICTION_TABLE [i][j]._good_take,
     506                     reg_UPDATE_PREDICTION_TABLE [i][j]._is_accurate,
     507                     reg_UPDATE_PREDICTION_TABLE [i][j]._history,
     508                     reg_UPDATE_PREDICTION_TABLE [i][j]._address_ras,
     509                     reg_UPDATE_PREDICTION_TABLE [i][j]._index_ras,
     510                     toString(reg_UPDATE_PREDICTION_TABLE [i][j]._state).c_str()
     511                     );
    282512      }
    283513#endif
     514      }
    284515
    285516
     
    287518    end_cycle ();
    288519#endif
    289 
    290     log_printf(FUNC,Update_Prediction_Table,FUNCTION,"End");
     520   
     521    log_end(Update_Prediction_Table,FUNCTION);
    291522  };
    292523
Note: See TracChangeset for help on using the changeset viewer.