Ignore:
Timestamp:
Feb 27, 2009, 7:37:40 PM (15 years ago)
Author:
rosiere
Message:

1) Decod_queue : multi implementation (one_fifo, multi_fifo)
2) Issue_queue : multi implementation (in_order, out_of_order)
3) Direction : Add Meta predictor
4) Context_State : re add Branch_complete, More priority to Load miss (is not speculative)
5) Return_Address_Stack : update reg_PREDICT pointer on decod miss prediction
6) UPT : Fix bug in multi event
7) Prediction_glue : in read_stack case, insert in UPT pc_next
8) Rename select : when rob have an event (need flush), read_r{a,b,c} and write_r{d,e} is set at 0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/src/Two_Level_Branch_Predictor_transition.cpp

    r110 r111  
    2525  {
    2626    log_begin(Two_Level_Branch_Predictor,FUNCTION);
     27    log_function(Two_Level_Branch_Predictor,FUNCTION,_name.c_str());
     28
     29    if (PORT_READ(in_NRESET) == 0)
     30      {
     31      }
     32    else
     33      {
     34        // ===================================================================
     35        // =====[ PREDICT ]===================================================
     36        // ===================================================================
     37
     38        for (uint32_t i=0; i<_param->_nb_inst_predict; ++i)
     39          if (PORT_READ(in_PREDICT_VAL[i]) and internal_PREDICT_ACK[i])
     40            {
     41              log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * PREDICT [%d]",i);
     42
     43              // Predict if
     44              //  * update_on_prediction and direction is valid
     45              if (_param->_update_on_prediction)
     46                if (PORT_READ(in_PREDICT_DIRECTION_VAL [i]))
     47                  {
     48                    Tcontrol_t direction = PORT_READ(in_PREDICT_DIRECTION [i]);
     49                   
     50                    if (_param->_have_bht)
     51                      {
     52                        Thistory_t bht_num_reg = internal_PREDICT_BHT_NUM_REG [i];
     53                        log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * bht_num_reg      : %d",bht_num_reg);
     54
     55                        Thistory_t bht_history = reg_BHT[bht_num_reg];
     56                        log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * bht_history (old): %x",bht_history);
     57
     58                       
     59                        bht_history = ((bht_history<<1) | direction)&_param->_bht_history_mask ;
     60                        log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * bht_history (new): %x",bht_history);
     61                        reg_BHT [bht_num_reg] = bht_history;
     62                      }
     63
     64                    if (_param->_have_pht)
     65                      {
     66                        Thistory_t pht_num_reg = internal_PREDICT_PHT_NUM_REG  [i];
     67                        Thistory_t pht_num_bank= internal_PREDICT_PHT_NUM_BANK [i];
     68                        log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * pht_num_reg      : %d",pht_num_reg);
     69                        log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * pht_num_bank     : %d",pht_num_bank);
     70
     71                        Thistory_t pht_history = reg_PHT [pht_num_bank][pht_num_reg];
     72                        log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * pht_history (old): %x",pht_history);
     73                       
     74                        // PHT : saturation counter
     75                        pht_history = (direction==1)?((pht_history<_param->_pht_counter_max)?(pht_history+1):(pht_history)):((pht_history>0)?(pht_history-1):(pht_history));
     76                       
     77                        log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * pht_history (new): %x",pht_history);
     78                       
     79                        reg_PHT [pht_num_bank][pht_num_reg] = pht_history;
     80                      }
     81                  }
     82            }       
     83
     84        // ===================================================================
     85        // =====[ UPDATE ]====================================================
     86        // ===================================================================
     87       
     88        for (uint32_t i=0; i<_param->_nb_inst_update; ++i)
     89          if (PORT_READ(in_UPDATE_VAL[i]) and internal_UPDATE_ACK[i])
     90            {
     91              log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * UPDATE [%d]",i);
     92             
     93              // Update if
     94              //  * update_on_prediction and miss
     95              //  * not update_on_prediction
     96              if (not _param->_update_on_prediction or (_param->_update_on_prediction and PORT_READ(in_UPDATE_MISS [i])))
     97                {
     98                  Taddress_t address     = PORT_READ(in_UPDATE_ADDRESS   [i]);
     99                  Thistory_t history     = PORT_READ(in_UPDATE_HISTORY   [i]);
     100                  Tcontrol_t direction   = PORT_READ(in_UPDATE_DIRECTION [i])&1;
     101
     102                  log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * address          : %.8x",address);
     103                  log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * direction        : %d",direction);
     104
     105                  Thistory_t pht_bht_history = 0;
     106
     107                  if (_param->_have_bht)
     108                    {
     109                      Thistory_t bht_history = (history>>_param->_bht_history_rshift)&_param->_bht_history_mask;
     110                      Thistory_t bht_num_reg = address & _param->_bht_address_mask;
     111                     
     112                      pht_bht_history = bht_history;
     113                     
     114                      log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * bht_history (old): %x",bht_history);
     115                      log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * bht_num_reg      : %x",bht_num_reg);
     116                     
     117                      // BHT : shift register
     118                     
     119                      bht_history = ((bht_history<<1) | direction)&_param->_bht_history_mask ;
     120                      log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * bht_history (new): %x",bht_history);
     121                      reg_BHT [bht_num_reg]               = bht_history;
     122                    }
     123
     124                  if (_param->_have_pht)
     125                    {
     126                      Thistory_t pht_history = (history>>_param->_pht_history_rshift)&_param->_pht_history_mask;
     127                      Thistory_t pht_num_reg = pht_bht_history xor ((address&_param->_pht_address_share_mask)<<_param->_pht_address_share_lshift);
     128                      Thistory_t pht_num_bank= (address>>_param->_pht_address_bank_rshift)&_param->_pht_address_bank_mask;
     129                     
     130                      log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * bht_history (old): %x",pht_bht_history);
     131                      log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * pht_history (old): %x",pht_history);
     132                      log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * pht_num_reg      : %x",pht_num_reg);
     133                      log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * pht_num_bank     : %x",pht_num_bank);
     134                     
     135                      // PHT : saturation counter
     136                      pht_history = (direction==1)?((pht_history<_param->_pht_counter_max)?(pht_history+1):(pht_history)):((pht_history>0)?(pht_history-1):(pht_history));
     137                     
     138                      log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * pht_history (new): %x",pht_history);
     139                     
     140                      reg_PHT [pht_num_bank][pht_num_reg] = pht_history;
     141                    }
     142                }
     143            }
     144      }
     145
     146#if defined(DEBUG) and DEBUG_Two_Level_Branch_Predictor and (DEBUG >= DEBUG_TRACE)
     147    if (0)
     148    {
     149      log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * Dump Two_Level_Branch_Predictor");
     150
     151      if (_param->_have_bht)
     152        {
     153          log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * Dump BHT");
     154
     155          uint32_t limit = 4;
     156
     157          for (uint32_t i=0; i<_param->_bht_nb_shifter; i+=limit)
     158            {
     159              std::string str = "";
     160
     161              for (uint32_t j=0; j<limit; j++)
     162                {
     163                  uint32_t index = i+j;
     164                  if (index >= _param->_bht_nb_shifter)
     165                    break;
     166                  else
     167                    str+=toString("[%.4d] %.4x ",index,reg_BHT[index]);
     168                }
     169             
     170              log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"    %s",str.c_str());
     171            }
     172        }
     173
     174      if (_param->_have_pht)
     175        {
     176          log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * Dump PHT");
     177
     178          uint32_t limit = 4;
     179
     180          for (uint32_t num_bank=0; num_bank <_param->_pht_nb_bank; ++num_bank)
     181            {
     182              log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  [%.4d]",num_bank);
     183
     184              for (uint32_t i=0; i<_param->_pht_size_bank; i+=limit)
     185                {
     186                  std::string str = "";
     187                 
     188                  for (uint32_t j=0; j<limit; j++)
     189                    {
     190                      uint32_t index = i+j;
     191                      if (index >= _param->_pht_nb_counter)
     192                        break;
     193                      else
     194                        str+=toString("[%.4d] %.4x ",index,reg_PHT[num_bank][index]);
     195                    }
     196                 
     197                  log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"    %s",str.c_str());
     198                }
     199            }
     200        }
     201    }
     202#endif
    27203
    28204#if defined(STATISTICS) or defined(VHDL_TESTBENCH)
Note: See TracChangeset for help on using the changeset viewer.