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/Update_Prediction_Table/src/Update_Prediction_Table_transition.cpp

    r109 r111  
    102102              if (end)
    103103                {
     104#if defined(DEBUG) and defined(DEBUG_Update_Prediction_Table) and (DEBUG_Update_Prediction_Table == true)
     105                  if (reg_UPDATE_PREDICTION_TABLE [i][bottom]._retire_ok)
     106                    {
     107                      uint32_t num_thread = _param->_translate_num_context_to_num_thread [i];
     108                      branchement_log_file [num_thread]
     109                        << std::hex
     110                        << "0x" << reg_UPDATE_PREDICTION_TABLE [i][bottom]._address_src  << " "
     111                        << "0x" << reg_UPDATE_PREDICTION_TABLE [i][bottom]._address_dest << " "
     112                        << std::dec
     113                        <<         reg_UPDATE_PREDICTION_TABLE [i][bottom]._good_take    << " "
     114                        << std::endl;
     115                    }
     116#endif
    104117                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT [%d][%d]",i,bottom);
    105118                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT [%d][%d]._state =  UPDATE_PREDICTION_STATE_EMPTY",i,bottom);
     
    180193//            reg_UFPT_UPDATE  [context] = reg_UFPT_TOP [context];
    181194              if (need_update(condition))
    182                 reg_UFPT_NB_NEED_UPDATE [context] ++;
     195                {
     196                  reg_UFPT_NB_NEED_UPDATE [context] ++;
     197                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_UFPT_NB_NEED_UPDATE (after) : %d",reg_UFPT_NB_NEED_UPDATE [context]);
     198
     199                }
    183200            }
    184201
     
    293310                    {
    294311                      reg_UFPT_NB_NEED_UPDATE [context] --;
     312                      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_UFPT_NB_NEED_UPDATE (after) : %d",reg_UFPT_NB_NEED_UPDATE [context]);
     313
    295314                    }
    296315                }
     
    305324              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT  [%d][%d].state <- UPDATE_PREDICTION_STATE_WAIT_END (decod - hit)",context,upt_ptr_write);
    306325              reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._state = UPDATE_PREDICTION_STATE_WAIT_END;
    307              
     326              reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._retire_ok = false;
     327
    308328              // Write new accurate
    309329#ifdef DEBUG_TEST
     
    377397                      // Free a register that need update ?
    378398                      if (need_update(reg_UPDATE_FETCH_PREDICTION_TABLE [context][depth]._condition))
    379                         reg_UFPT_NB_NEED_UPDATE [context] --;
     399                        {
     400                          reg_UFPT_NB_NEED_UPDATE [context] --;
     401                          log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_UFPT_NB_NEED_UPDATE (after) : %d",reg_UFPT_NB_NEED_UPDATE [context]);
     402                        }
    380403                    }
    381404                  else
     
    402425#ifdef STATISTICS
    403426                      Tbranch_condition_t condition = reg_UPDATE_PREDICTION_TABLE [context][depth]._condition;
     427#endif
    404428                      bool ok     = (reg_UPDATE_PREDICTION_TABLE [context][depth]._state == UPDATE_PREDICTION_STATE_OK);
    405 #endif
    406429                      bool ko     = (reg_UPDATE_PREDICTION_TABLE [context][depth]._state == UPDATE_PREDICTION_STATE_KO);
     430
     431                      if (ok or ko)
     432                        reg_UPDATE_PREDICTION_TABLE [context][depth]._retire_ok = true;
    407433
    408434                      // Have an update, test the state to transiste to the good state
     
    513539              if (miss)
    514540                {
     541                  // Flush UPT
     542                  uint32_t      top                 = reg_UPT_TOP [context];
     543                  uint32_t      new_update          = ((top==0)?_param->_size_upt_queue[context]:top)-1;
     544                                                   
     545                  Taddress_t    address_src         = reg_UPDATE_PREDICTION_TABLE [context][depth]._address_src;
     546                  event_state_t event_state         = reg_EVENT_STATE [context];
     547                  upt_state_t   event_top           = reg_UPDATE_PREDICTION_TABLE [context][top]._state;
     548                  bool          previous_ufpt_event = ((event_state == EVENT_STATE_MISS_FLUSH_UFPT_AND_UPT ) or
     549                                                       (event_state == EVENT_STATE_MISS_FLUSH_UFPT         ) or
     550                                                       (event_state == EVENT_STATE_EVENT_FLUSH_UFPT_AND_UPT) or
     551                                                       (event_state == EVENT_STATE_EVENT_FLUSH_UFPT        ));
     552
     553                  bool          previous_upt_event  = ((event_state == EVENT_STATE_MISS_FLUSH_UFPT_AND_UPT ) or
     554                                                       (event_state == EVENT_STATE_MISS_FLUSH_UPT          ) or
     555                                                       (event_state == EVENT_STATE_EVENT_FLUSH_UFPT_AND_UPT) or
     556                                                       (event_state == EVENT_STATE_EVENT_FLUSH_UPT         ) or
     557                                                       (event_top   == UPDATE_PREDICTION_STATE_END_KO      ) or
     558                                                       (event_top   == UPDATE_PREDICTION_STATE_KO          )
     559//                                                   (event_state == EVENT_STATE_WAIT_END_EVENT          ) or
     560//                                                   ((event_state == EVENT_STATE_UPDATE_CONTEXT         ) and
     561//                                                    (reg_EVENT_SOURCE [context] == EVENT_SOURCE_UPT))
     562                                                  );
     563//                bool          update_ras     = (new_update != depth);
     564
     565                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * top                 : %d",top);
     566                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * new_update          : %d",new_update);
     567//                log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * update_ras          : %d",update_ras);
     568                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * previous_upt_event  : %d",previous_upt_event);
     569                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * previous_ufpt_event : %d",previous_ufpt_event);
     570
    515571                  // Have a miss !!!
    516572                  // Flush UPFT
    517                   flush_UFPT [context] = true;
     573                  flush_UFPT [context] = not previous_ufpt_event;
    518574                 
    519                   // Flush UPT
    520                   uint32_t      top            = reg_UPT_TOP [context];
    521                   uint32_t      new_update     = ((top==0)?_param->_size_upt_queue[context]:top)-1;
    522 
    523                   Taddress_t    address_src    = reg_UPDATE_PREDICTION_TABLE [context][depth]._address_src;
    524                   event_state_t event_state    = reg_EVENT_STATE [context];
    525                   bool          previous_event = ((event_state == EVENT_STATE_MISS_FLUSH_UFPT_AND_UPT ) or
    526                                                   (event_state == EVENT_STATE_MISS_FLUSH_UPT          ) or
    527                                                   (event_state == EVENT_STATE_EVENT_FLUSH_UFPT_AND_UPT) or
    528                                                   (event_state == EVENT_STATE_EVENT_FLUSH_UPT         ) or
    529                                                   ((event_state == EVENT_STATE_UPDATE_CONTEXT          ) and
    530                                                    (reg_EVENT_SOURCE [context] == EVENT_SOURCE_UPT)));
    531 //                bool          update_ras     = (new_update != depth);
    532 
    533                   log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * top            : %d",top);
    534                   log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * new_update     : %d",new_update);
    535 //                log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * update_ras     : %d",update_ras);
    536                   log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * previous_event : %d",previous_event);
    537 
    538575                  if (reg_UPDATE_PREDICTION_TABLE [context][depth]._state == UPDATE_PREDICTION_STATE_WAIT_END)
    539576                    {
     
    541578                           j!=top;
    542579                           j=(j+1)%_param->_size_upt_queue[context])
    543                         reg_UPDATE_PREDICTION_TABLE [context][j]._state = UPDATE_PREDICTION_STATE_EVENT;
     580                        {
     581                          reg_UPDATE_PREDICTION_TABLE [context][j]._state = UPDATE_PREDICTION_STATE_EVENT;
     582                          reg_UPDATE_PREDICTION_TABLE [context][j]._retire_ok = false;
     583                        }
    544584                     
    545585                 
     
    548588//                    reg_UPT_TOP_EVENT [context] = top;
    549589
    550                       if (not previous_event)
     590                      if (not previous_upt_event)
    551591                        {
    552592                          reg_UPT_TOP_EVENT [context] = top;
     
    556596                        {
    557597                          // Have event. Top index this slot
    558                          
    559                           switch (reg_UPDATE_PREDICTION_TABLE [context][top]._state)
     598                          reg_UPDATE_PREDICTION_TABLE [context][top]._retire_ok = false;
     599
     600                          switch (event_top)
    560601                            {
    561602                            case UPDATE_PREDICTION_STATE_END_KO :
     
    573614                            default :
    574615                              {
     616//                                 reg_UPDATE_PREDICTION_TABLE [context][top]._state = UPDATE_PREDICTION_STATE_EVENT;
     617//                                 break;
     618
    575619#ifdef DEBUG_TEST
    576620                                throw ERRORMORPHEO(FUNCTION,_("Branch complete : invalid upt state."));
     
    585629                      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT  [%d][%d].state <- UPDATE_PREDICTION_STATE_KO (branch_complete, ifetch hit)",context,depth);
    586630                      reg_UPDATE_PREDICTION_TABLE [context][depth]._state = UPDATE_PREDICTION_STATE_KO;
    587                      
    588                       if (reg_UFPT_NB_NEED_UPDATE [context] > 0)
     631
     632                      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_UFPT_NB_NEED_UPDATE [%d] : %d",context,reg_UFPT_NB_NEED_UPDATE [context]);
     633                     
     634                      if ( (reg_UFPT_NB_NEED_UPDATE [context] > 0) or
     635                           (reg_UFPT_NB_UPDATE      [context] > 0))
    589636                        {
    590637                          log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_MISS_FLUSH_UFPT_AND_UPT (branch_complete - miss)",context);
     
    736783                    uint32_t bottom     = reg_UPT_BOTTOM [i];
    737784                    uint32_t new_update = ((top==0)?_param->_size_upt_queue[i]:top)-1;
    738                     bool     full       = ((depth == top) and (top == bottom) and not reg_UPT_EMPTY [i]);
    739785//                     bool     empty      = reg_UPT_EMPTY [i];
    740786
     
    749795                                                         (event_state == EVENT_STATE_EVENT_FLUSH_UPT));
    750796
    751                     bool find = false; // have slot to update ???
     797                    bool     find = false; // have slot to update ???
     798                    Tdepth_t depth_new = depth;
    752799
    753800                    // flush all slot after the event
     
    760807                          find = true;
    761808                          reg_UPDATE_PREDICTION_TABLE [i][j]._state = UPDATE_PREDICTION_STATE_EVENT;
    762                         }
     809                          reg_UPDATE_PREDICTION_TABLE [i][j]._retire_ok = false;
     810                        }
     811                      else
     812                        if (not find) // while state == end or empty
     813                          depth_new ++;
    763814                   
    764815                    if ((reg_UPDATE_PREDICTION_TABLE [i][depth]._state != UPDATE_PREDICTION_STATE_END) and
     
    767818                        find = true;
    768819                        reg_UPDATE_PREDICTION_TABLE [i][depth]._state = UPDATE_PREDICTION_STATE_EVENT;
     820                        reg_UPDATE_PREDICTION_TABLE [i][depth]._retire_ok = false;
     821
    769822                      }
     823                    else
     824                      // while state == end or empty
     825                      depth = (depth_new+1)%_param->_size_upt_queue[i];
    770826
    771827                    log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * find       : %d",find);
     828                    log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * depth_new  : %d",depth_new);
    772829                   
    773830                    // Test if have update slot
    774831                    if (find)
    775832                      {
    776                         // flush all slot after the event
    777                         for (uint32_t j=(depth+1)%_param->_size_upt_queue[i];
    778                              j!=top;
    779                              j=(j+1)%_param->_size_upt_queue[i])
    780                           reg_UPDATE_PREDICTION_TABLE [i][j]._state = UPDATE_PREDICTION_STATE_EVENT;
    781 
    782                         reg_UPDATE_PREDICTION_TABLE [i][depth]._state = UPDATE_PREDICTION_STATE_EVENT;
     833//                         // flush all slot after the event
     834//                         for (uint32_t j=(depth+1)%_param->_size_upt_queue[i];
     835//                              j!=top;
     836//                              j=(j+1)%_param->_size_upt_queue[i])
     837//                           reg_UPDATE_PREDICTION_TABLE [i][j]._state = UPDATE_PREDICTION_STATE_EVENT;
     838
     839//                         reg_UPDATE_PREDICTION_TABLE [i][depth]._state = UPDATE_PREDICTION_STATE_EVENT;
    783840                       
    784841                        // reg_UPT_BOTTOM    [i];
     
    791848                      }
    792849
    793                     bool          update_ras = find and ((top != depth) or full);
     850                    bool     full       = ((depth == top) and (top == bottom) and not reg_UPT_EMPTY [i]);
     851                    bool     update_ras = find and ((top != depth) or full);
    794852                   
    795853                    log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * update_ras : %d",update_ras);
     
    807865                    reg_EVENT_UPT_PTR [i] = depth;
    808866
    809                     if (reg_UFPT_NB_NEED_UPDATE [i] > 0)
     867                    log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_UFPT_NB_NEED_UPDATE          : %d",reg_UFPT_NB_NEED_UPDATE [i]);
     868//                     if (reg_UFPT_NB_NEED_UPDATE [i] > 0)
     869                    if ( (reg_UFPT_NB_NEED_UPDATE [i] > 0) or
     870                         (reg_UFPT_NB_UPDATE      [i] > 0))
    810871                      {
    811872                        if (update_ras)
     
    871932              if (reg_UFPT_NB_NEED_UPDATE [i] == 0)
    872933                {
    873 
    874934                  // No entry need prediction, flush all entry -> Reset
    875935                  for (uint32_t j=0; j<_param->_size_ufpt_queue[i]; ++j)
     
    881941              else
    882942                {
     943                  uint32_t bottom = reg_UFPT_BOTTOM [i];
    883944                  for (uint32_t j=0; j<_param->_size_ufpt_queue[i]; ++j)
    884                     // EMPTY : no event
    885                     // END   : already update
    886                     // EVENT : previous event
    887                     if (reg_UPDATE_FETCH_PREDICTION_TABLE [i][j]._state == UPDATE_FETCH_PREDICTION_STATE_WAIT_DECOD)
    888                       {
    889                         reg_UFPT_NB_UPDATE [i] ++;
    890                         reg_UPDATE_FETCH_PREDICTION_TABLE [i][j]._state = UPDATE_FETCH_PREDICTION_STATE_EVENT;
    891                       }
    892 
    893                   // TOP is next write slot : last slot is TOP-1
    894                   uint32_t top = reg_UFPT_TOP [i];
    895                   reg_UFPT_UPDATE    [i] = ((top==0)?_param->_size_ufpt_queue[i]:top)-1;
     945                    {
     946                      uint32_t index = (bottom+j)%_param->_size_ufpt_queue[i];
     947                      // EMPTY : no event
     948                      // END   : already update
     949                      // EVENT : previous event
     950                      if (reg_UPDATE_FETCH_PREDICTION_TABLE [i][index]._state == UPDATE_FETCH_PREDICTION_STATE_WAIT_DECOD)
     951                        {
     952                          reg_UFPT_UPDATE    [i] = index;
     953                          reg_UFPT_NB_UPDATE [i] ++;
     954                          reg_UPDATE_FETCH_PREDICTION_TABLE [i][index]._state = UPDATE_FETCH_PREDICTION_STATE_EVENT;
     955                        }
     956                    }
     957
     958//                   // TOP is next write slot : last slot is TOP-1
     959//                   uint32_t top = reg_UFPT_TOP [i];
     960//                   reg_UFPT_UPDATE    [i] = ((top==0)?_param->_size_ufpt_queue[i]:top)-1;
    896961
    897962//                reg_UFPT_BOTTOM    [i];
Note: See TracChangeset for help on using the changeset viewer.