Ignore:
Timestamp:
Feb 5, 2009, 12:18:31 PM (15 years ago)
Author:
rosiere
Message:

1) Bug fix : Load Miss Speculation (in Commit_unit, Update Prediction Table and Context State)
2) Change address, in rob write address_next.
3) Move Meta_Predictor in save directory

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

    r101 r105  
    5050            reg_IS_ACCURATE          [i] = true;
    5151           
     52            reg_EVENT_VAL            [i] = false;
    5253            reg_EVENT_STATE          [i] = EVENT_STATE_OK;
    5354          }
     
    5556    else
    5657      {
    57         bool flush_UFPT [_param->_nb_context];
     58        bool flush_UFPT    [_param->_nb_context];
    5859        for (uint32_t i=0; i<_param->_nb_context; i++)
    59           flush_UFPT [i] = false;
     60          {
     61            flush_UFPT    [i] = false;
     62          }
    6063
    6164        // ===================================================================
     
    6669        //   * Update state -> new status is "empty"
    6770        //   * Update pointer (bottom and accurate)
    68         log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * GARBAGE COLLECTOR");
     71        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * GARBAGE COLLECTOR (BEGIN)");
    6972        for (uint32_t i=0; i<_param->_nb_context; i++)
    7073          {
     
    113116//                   if (bottom = reg_UPT_UPDATE [i])
    114117//                     reg_UPT_UPDATE [i] = reg_UPT_BOTTOM [i];
    115                   if (end_ko) // free
     118
     119                  if (reg_EVENT_VAL [i] and (reg_EVENT_UPT_PTR [i] == bottom))
     120//                   if (end_ko) // free
    116121                    {
     122                      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * END EVENT");
     123                     
     124                      reg_EVENT_VAL  [i] = false;
    117125                      reg_UPT_TOP    [i] = reg_UPT_TOP_EVENT [i];
    118126                      reg_UPT_UPDATE [i] = reg_UPT_TOP_EVENT [i];
    119 
     127                     
    120128                      if (reg_UPT_BOTTOM [i] != reg_UPT_TOP [i])
    121129                        reg_UPT_EMPTY [i] = false;
     
    124132            }
    125133          }
     134        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * GARBAGE COLLECTOR (END)");
    126135
    127136        // ===================================================================
     
    218227                  else
    219228                    {
    220                       log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_FLUSH_UFPT (decod - miss - flush ufpt)",context);
    221                       reg_EVENT_STATE [context] = EVENT_STATE_FLUSH_UFPT;
     229                      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_MISS_FLUSH_UFPT (decod - miss - flush ufpt)",context);
     230                      reg_EVENT_STATE [context] = EVENT_STATE_MISS_FLUSH_UFPT;
    222231                    }
    223232
     
    273282                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._address_ras       = reg_UPDATE_FETCH_PREDICTION_TABLE [context][ufpt_ptr_read]._address_ras ;
    274283                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._index_ras         = reg_UPDATE_FETCH_PREDICTION_TABLE [context][ufpt_ptr_read]._index_ras   ;
    275                   reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._ifetch_prediction = true; // prediction from ifetch
     284                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._ifetch_prediction = true ; // prediction from ifetch
    276285
    277286                  // Update pointer
     
    283292
    284293              // All case !!!
    285 
    286294#ifdef DEBUG_TEST
    287295              if (reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._state != UPDATE_PREDICTION_STATE_EMPTY)
     
    352360
    353361                  if (reg_UPT_BOTTOM [context] == reg_UPT_TOP [context])
    354                     reg_UPT_EMPTY [i] = true;
     362                    reg_UPT_EMPTY [context] = true;
    355363
    356364#ifdef DEBUG_TEST
     
    364372                  Taddress_t    address_src         = reg_UPDATE_PREDICTION_TABLE [context][depth]._address_src;
    365373                  event_state_t event_state         = reg_EVENT_STATE [context];
    366                   bool          previous_update_ras = (event_state == EVENT_STATE_FLUSH_UPT);
    367                   bool          update_ras          = (new_update != depth);
    368 
    369                   log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * update_ras : %d",update_ras);
     374                  bool          previous_update_ras = ((event_state == EVENT_STATE_MISS_FLUSH_UFPT_AND_UPT ) or
     375                                                       (event_state == EVENT_STATE_MISS_FLUSH_UPT          ) or
     376                                                       (event_state == EVENT_STATE_EVENT_FLUSH_UFPT_AND_UPT) or
     377                                                       (event_state == EVENT_STATE_EVENT_FLUSH_UPT));
     378//                   bool          update_ras          = (new_update != depth);
     379
     380//                   log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * update_ras : %d",update_ras);
    370381
    371382                  if (reg_UFPT_NB_NEED_UPDATE [context] > 0)
    372383                    {
    373                       log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_FLUSH_UFPT_AND_UPT (branch_complete - miss)",context);
    374                       reg_EVENT_STATE [context] = EVENT_STATE_FLUSH_UFPT_AND_UPT;
     384                      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_MISS_FLUSH_UFPT_AND_UPT (branch_complete - miss)",context);
     385                      reg_EVENT_STATE [context] = EVENT_STATE_MISS_FLUSH_UFPT_AND_UPT;
    375386                    }
    376387                  else
    377388                    {
    378                       if (not previous_update_ras)
     389//                       if (not previous_update_ras)
    379390                        {
    380391                          // have ras prediction ?
    381                           log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_FLUSH_UPT (branch_complete - miss)",context);
    382 
    383                           reg_EVENT_STATE [context] = EVENT_STATE_FLUSH_UPT;
     392                          log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_MISS_FLUSH_UPT (branch_complete - miss)",context);
     393
     394                          reg_EVENT_STATE [context] = EVENT_STATE_MISS_FLUSH_UPT;
    384395             
    385396                        }
     
    442453                        switch (reg_EVENT_STATE [context])
    443454                          {
    444                           case EVENT_STATE_FLUSH_UFPT             : reg_EVENT_STATE [context] = EVENT_STATE_UPDATE_CONTEXT; break;
     455                          case EVENT_STATE_MISS_FLUSH_UFPT         : reg_EVENT_STATE [context] = EVENT_STATE_UPDATE_CONTEXT; break;
    445456                            // impossible to have an update on ufpt and reg_upt_update>reg_upt_top
    446                           case EVENT_STATE_FLUSH_UFPT_AND_UPT : reg_EVENT_STATE [context] = EVENT_STATE_FLUSH_UPT ; break;
     457                          case EVENT_STATE_MISS_FLUSH_UFPT_AND_UPT : reg_EVENT_STATE [context] = EVENT_STATE_MISS_FLUSH_UPT ; break;
     458                          case EVENT_STATE_EVENT_FLUSH_UFPT        : reg_EVENT_STATE [context] = EVENT_STATE_OK             ; break;
     459                          case EVENT_STATE_EVENT_FLUSH_UFPT_AND_UPT: reg_EVENT_STATE [context] = EVENT_STATE_EVENT_FLUSH_UPT; break;
    447460                          default : break;
    448461                          }
     
    478491                        {
    479492                          if ((reg_UPDATE_PREDICTION_TABLE [context][depth]._state != UPDATE_PREDICTION_STATE_EVENT) and
    480                               (reg_UPDATE_PREDICTION_TABLE [context][depth]._state != UPDATE_PREDICTION_STATE_KO   ))
     493                              (reg_UPDATE_PREDICTION_TABLE [context][depth]._state != UPDATE_PREDICTION_STATE_KO   ) )
    481494                            throw ERRORMORPHEO(FUNCTION,_("Update : invalid upt state."));
    482495                        }
     
    507520                         
    508521                          reg_UPDATE_PREDICTION_TABLE [context][depth]._state = UPDATE_PREDICTION_STATE_END_KO;
     522
     523                          reg_EVENT_VAL     [context] = true;
     524                          reg_EVENT_UPT_PTR [context] = depth;
    509525
    510526#ifdef STATISTICS
     
    541557                          if (end_event)
    542558                            {
    543                               reg_UPT_UPDATE [context] = reg_UPT_BOTTOM[context];
    544                               reg_EVENT_STATE [context] = EVENT_STATE_UPDATE_CONTEXT;
     559//                               reg_UPT_UPDATE [context] = reg_UPT_BOTTOM[context];
     560
     561                              if (reg_EVENT_STATE [context] == EVENT_STATE_EVENT_FLUSH_UPT)
     562                                {
     563                                  reg_EVENT_STATE [context] = EVENT_STATE_OK;
     564                                }
     565                              else
     566                                reg_EVENT_STATE [context] = EVENT_STATE_UPDATE_CONTEXT;
    545567                            }
    546568                          else
     
    593615          if (PORT_READ(in_EVENT_VAL [i]) and internal_EVENT_ACK [i])
    594616            {
     617              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * EVENT");
     618
    595619              //----------------------------------------------------------------
    596620              // Cases
     
    606630             
    607631              Tevent_type_t  event_type  = PORT_READ(in_EVENT_TYPE  [i]);
    608 //            Tdepth_t       depth       = PORT_READ(in_EVENT_DEPTH [i]);
    609            
     632
    610633              // Test if end of miss -> all previous branch is complete
    611634              //                     -> all next     branch is finish
    612               if (event_type  == EVENT_TYPE_MISS_SPECULATION)
     635
     636              switch (event_type)
    613637                {
    614                   log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * EVENT");
    615                   log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * type  : EVENT_TYPE_MISS_SPECULATION");
    616                  
    617 #ifdef DEBUG_TEST
    618                   if (reg_EVENT_STATE [i] != EVENT_STATE_WAIT_END_EVENT)
    619                     throw ERRORMORPHEO(FUNCTION,_("Event : invalid event state."));
    620 #endif
    621                  
    622                   // Change state
    623                   log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_OK (event)",i);
    624                  
    625                   reg_EVENT_STATE [i] = EVENT_STATE_OK;
    626                   reg_IS_ACCURATE [i] = true;
    627 
    628 //                   Tdepth_t depth = reg_UPT_TOP [i];
    629 
    630 #ifdef DEBUG_TEST
    631 //                   if (reg_UPDATE_PREDICTION_TABLE [i][depth]._state != UPDATE_PREDICTION_STATE_END_KO_WAIT_END)
    632 //                     throw ERRORMORPHEO(FUNCTION,_("Event : invalid upt event state."));
    633 //                   if (reg_UPDATE_PREDICTION_TABLE [i][depth]._state != UPDATE_PREDICTION_STATE_END_KO)
    634 //                     throw ERRORMORPHEO(FUNCTION,_("Event : invalid upt event state."));
    635 #endif
    636                  
    637 //                   log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT  [%d][%d].state <- UPDATE_PREDICTION_STATE_END_KO (update)",i,depth);
     638                case EVENT_TYPE_BRANCH_MISS_SPECULATION :
     639                  {
     640                    log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * type  : EVENT_TYPE_BRANCH_MISS_SPECULATION");
     641                   
     642#ifdef DEBUG_TEST
     643                    if (reg_EVENT_STATE [i] != EVENT_STATE_WAIT_END_EVENT)
     644                      throw ERRORMORPHEO(FUNCTION,_("Event : invalid event state."));
     645#endif
     646                   
     647                    // Change state
     648                    log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_OK (event)",i);
     649                   
     650                    reg_EVENT_STATE [i] = EVENT_STATE_OK;
     651                    reg_IS_ACCURATE [i] = true;
     652                   
     653//                  Tdepth_t depth = reg_UPT_TOP [i];
     654
     655#ifdef DEBUG_TEST
     656//                  if (reg_UPDATE_PREDICTION_TABLE [i][depth]._state != UPDATE_PREDICTION_STATE_END_KO_WAIT_END)
     657//                    throw ERRORMORPHEO(FUNCTION,_("Event : invalid upt event state."));
     658//                  if (reg_UPDATE_PREDICTION_TABLE [i][depth]._state != UPDATE_PREDICTION_STATE_END_KO)
     659//                    throw ERRORMORPHEO(FUNCTION,_("Event : invalid upt event state."));
     660#endif
     661                 
     662//                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT  [%d][%d].state <- UPDATE_PREDICTION_STATE_END_KO (update)",i,depth);
    638663                         
    639 //                   reg_UPDATE_PREDICTION_TABLE [i][depth]._state = UPDATE_PREDICTION_STATE_END_KO;
    640 
     664//                  reg_UPDATE_PREDICTION_TABLE [i][depth]._state = UPDATE_PREDICTION_STATE_END_KO;
     665
     666                    break;
     667                  }
     668                case EVENT_TYPE_LOAD_MISS_SPECULATION :
     669                case EVENT_TYPE_EXCEPTION             :
     670                  {
     671                    log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * type  : EVENT_TYPE_LOAD_MISS_SPECULATION");
     672
     673                    // Have a miss !!!
     674                    // Flush UPFT
     675                    flush_UFPT [i] = true;
     676                   
     677                    // Flush UPT
     678                    Tdepth_t depth      = (_param->_have_port_depth)?PORT_READ(in_EVENT_DEPTH [i]):0;
     679                    uint32_t top        = reg_UPT_TOP    [i];
     680                    uint32_t bottom     = reg_UPT_BOTTOM [i];
     681                    uint32_t new_update = ((top==0)?_param->_size_upt_queue[i]:top)-1;
     682                    uint32_t full       = ((depth == top) and (top == bottom) and not reg_UPT_EMPTY [i]);
     683                    log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * top        : %d",top);
     684                    log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * depth      : %d",depth);
     685                    log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * new_update : %d",new_update);
     686
     687                   
     688#ifdef DEBUG_TEST
     689                    if (reg_UPDATE_PREDICTION_TABLE [i][depth]._state != UPDATE_PREDICTION_STATE_WAIT_END)
     690                      throw ERRORMORPHEO(FUNCTION,_("Branch complete : invalid upt state."));
     691#endif
     692
     693                    // flush all slot after the event
     694                    for (uint32_t j=depth;
     695                         j!=top;
     696                         j=(j+1)%_param->_size_upt_queue[i])
     697                      reg_UPDATE_PREDICTION_TABLE [i][j]._state = UPDATE_PREDICTION_STATE_EVENT;
     698                     
     699                    // test full :
     700                    if (full)
     701                      reg_UPDATE_PREDICTION_TABLE [i][depth]._state = UPDATE_PREDICTION_STATE_EVENT;
     702             
     703//                  reg_UPT_BOTTOM    [i];
     704                    // TODO : special case : event is an exception on branch, also depth is not valid
     705                    reg_UPT_TOP       [i] = depth; // depth is again valid
     706                    reg_UPT_TOP_EVENT [i] = top;
     707
     708                    if (bottom == reg_UPT_TOP [i])
     709                      reg_UPT_EMPTY [i] = true;
     710
     711                    reg_EVENT_VAL     [i] = true;
     712                    reg_EVENT_UPT_PTR [i] = depth;
     713                    event_state_t event_state         = reg_EVENT_STATE [i];
     714                    bool          previous_update_ras = ((event_state == EVENT_STATE_MISS_FLUSH_UFPT_AND_UPT ) or
     715                                                         (event_state == EVENT_STATE_MISS_FLUSH_UPT          ) or
     716                                                         (event_state == EVENT_STATE_EVENT_FLUSH_UFPT_AND_UPT) or
     717                                                         (event_state == EVENT_STATE_EVENT_FLUSH_UPT));
     718                    bool          update_ras          = (top != depth) or full;
     719
     720                    log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * update_ras : %d",update_ras);
     721                   
     722                    // new state :
     723                    //   * test if ufpt is empty
     724                    //     * ok : flush upft and upt
     725                    //     * ko : test if have previous flush upt
     726                    //            * ok : nothing
     727                    //            * ko : flush upt
     728                    if (reg_UFPT_NB_NEED_UPDATE [i] > 0)
     729                      {
     730                        if (update_ras)
     731                          {
     732                            log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_EVENT_FLUSH_UFPT_AND_UPT (branch_complete - miss)",i);
     733                            reg_EVENT_STATE [i] = EVENT_STATE_EVENT_FLUSH_UFPT_AND_UPT;
     734                          }
     735                        else
     736                          {
     737                            log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_EVENT_FLUSH_UFPT (branch_complete - miss)",i);
     738                            reg_EVENT_STATE [i] = EVENT_STATE_EVENT_FLUSH_UFPT;
     739                          }                         
     740                      }
     741                    else
     742                      {
     743//                         if (not previous_update_ras)
     744                        if (update_ras)
     745                          {
     746                            // have ras prediction ?
     747                            log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_EVENT_FLUSH_UPT (branch_complete - miss)",i);
     748                           
     749                            reg_EVENT_STATE [i] = EVENT_STATE_EVENT_FLUSH_UPT;
     750                          }
     751                        else
     752                          {
     753                            reg_EVENT_STATE [i] = EVENT_STATE_OK;
     754                          }
     755                      }
     756                   
     757                    if (not previous_update_ras and update_ras)
     758                      {
     759                        reg_UPT_UPDATE [i]  = new_update;
     760                      }
     761                    // else no update
     762                   
     763                    reg_EVENT_DEPTH           [i] = depth;
     764//                  reg_EVENT_ADDRESS_SRC     [i] = address_src; // delay_slot is compute in I_State
     765//                  reg_EVENT_ADDRESS_DEST_VAL[i] = good_take;
     766//                  reg_EVENT_ADDRESS_DEST    [i] = good_addr;
     767
     768                    break;
     769                  }
     770                default :
     771                  {
     772                    // nothing
     773                    break;
     774                  }
    641775                }
    642776            }
     
    706840      {
    707841        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_IS_ACCURATE           : %d",reg_IS_ACCURATE        [i]);
     842        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_EVENT_VAL             : %d"  ,reg_EVENT_VAL             [i]);
     843        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_EVENT_UPT_PTR         : %d"  ,reg_EVENT_UPT_PTR         [i]);
    708844        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_EVENT_STATE           : %s"  ,toString(reg_EVENT_STATE [i]).c_str());
    709845        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_EVENT_DEPTH           : %d"  ,reg_EVENT_DEPTH           [i]);
Note: See TracChangeset for help on using the changeset viewer.