Ignore:
Timestamp:
May 25, 2009, 7:40:26 PM (15 years ago)
Author:
rosiere
Message:

1) Prediction unit : static prediction not blocking

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

    r115 r119  
    249249              Taddress_t          address_src   = PORT_READ(in_DECOD_BTB_ADDRESS_SRC  [i]);
    250250              Taddress_t          address_dest  = PORT_READ(in_DECOD_BTB_ADDRESS_DEST [i]);
    251               Tcontrol_t          last_take     = PORT_READ(in_DECOD_BTB_LAST_TAKE    [i]);
     251              Tcontrol_t          direction     = PORT_READ(in_DECOD_BTB_LAST_TAKE    [i]);
    252252
    253253              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * DECOD[%d] - Accepted",i);
     
    259259              if (miss_ifetch or miss_decod)
    260260                {
     261                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * miss !!!");
     262
    261263                  // Have a miss !!!
     264                  condition   = PORT_READ(in_DECOD_BTB_CONDITION [i]);
     265                  is_accurate = PORT_READ(in_DECOD_IS_ACCURATE   [i]);
     266
     267                  // if can_continue else don't wait the end of all instruction
     268                  // can_continue = not miss_commit and the destination is accurate (know)
     269                  Tcontrol_t can_continue = is_accurate;
     270
    262271#ifdef DEBUG_TEST
    263272                  if (reg_EVENT_STATE [context] != EVENT_STATE_OK)
    264273                    throw ERRORMORPHEO(FUNCTION,_("Decod : invalid event state."));
    265274#endif
    266                   if (reg_UFPT_NB_NEED_UPDATE [context] == 0)
     275
     276                  // miss_ifetch = branch is previously predict, but it's not the good
     277                  //   * need flush ufpt
     278                  // miss_decod  = branch was not detected
     279                  //   * not necessary
     280
     281                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * can_continue: %d",can_continue);
     282                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * direction   : %d",direction   );
     283                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * miss_ifetch : %d",miss_ifetch );
     284                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * change    : %d",(not (can_continue and not direction and not miss_ifetch)));
     285
     286                  // if can_continue (destination is know) and direction is not take, don't need flush fetch_unit.
     287                  if (not (can_continue and not direction and not miss_ifetch))
    267288                    {
    268                       // Change state
    269                       log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_UPDATE_CONTEXT (decod - miss - no flush ufpt)",context);
    270                       reg_EVENT_STATE [context] = EVENT_STATE_UPDATE_CONTEXT;
    271 //                       reg_EVENT_SOURCE[context] = EVENT_SOURCE_UFPT;
     289                      if (reg_UFPT_NB_NEED_UPDATE [context] == 0)
     290                        {
     291                          // Change state
     292                          log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_UPDATE_CONTEXT (decod - miss - no flush ufpt)",context);
     293                          reg_EVENT_STATE [context] = EVENT_STATE_UPDATE_CONTEXT;
     294//                        reg_EVENT_SOURCE[context] = EVENT_SOURCE_UFPT;
     295                        }
     296                      else
     297                        {
     298                          log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_MISS_FLUSH_UFPT (decod - miss - flush ufpt)",context);
     299                          reg_EVENT_STATE [context] = EVENT_STATE_MISS_FLUSH_UFPT;
     300                        }
     301
     302                      // Flush UPFT
     303                      flush_UFPT [context] = true;
     304
     305                      reg_EVENT_IS_BRANCH       [context] = true;
     306                      reg_EVENT_DEPTH           [context] = upt_ptr_write;
     307                      reg_EVENT_ADDRESS_SRC     [context] = address_src; // delay_slot is compute in Context_State
     308                      reg_EVENT_ADDRESS_DEST_VAL[context] = direction;
     309                      reg_EVENT_ADDRESS_DEST    [context] = address_dest;
     310                      reg_EVENT_CAN_CONTINUE    [context] = can_continue;
    272311                    }
    273                   else
    274                     {
    275                       log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_MISS_FLUSH_UFPT (decod - miss - flush ufpt)",context);
    276                       reg_EVENT_STATE [context] = EVENT_STATE_MISS_FLUSH_UFPT;
    277                     }
    278 
    279                   // Flush UPFT
    280                   flush_UFPT [context] = true;
    281 
    282                   reg_EVENT_IS_BRANCH       [context] = true;
    283                   reg_EVENT_DEPTH           [context] = upt_ptr_write;
    284                   reg_EVENT_ADDRESS_SRC     [context] = address_src; // delay_slot is compute in Context_State
    285                   reg_EVENT_ADDRESS_DEST_VAL[context] = last_take;
    286                   reg_EVENT_ADDRESS_DEST    [context] = address_dest;
    287 
     312                 
    288313                  // Push upt (from decod interface)
    289                   condition   = PORT_READ(in_DECOD_BTB_CONDITION [i]);
    290                   is_accurate = PORT_READ(in_DECOD_IS_ACCURATE   [i]);
    291 
    292314                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._condition         = condition;
    293315                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._address_src       = address_src ;
    294316                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._address_dest      = address_dest;
    295                   reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._last_take         = last_take   ;
     317                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._last_take         = direction   ;
    296318//                reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._good_take;
    297319                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._is_accurate       = is_accurate;
     
    336358                      reg_UFPT_NB_NEED_UPDATE [context] --;
    337359                      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_UFPT_NB_NEED_UPDATE (after) : %d",reg_UFPT_NB_NEED_UPDATE [context]);
    338 
    339360                    }
    340361                }
     
    349370              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT  [%d][%d].state <- UPDATE_PREDICTION_STATE_WAIT_END (decod - hit)",context,upt_ptr_write);
    350371              reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._state = UPDATE_PREDICTION_STATE_WAIT_END;
    351               reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._retire_ok = false;
     372              reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._retire_ok   = false;
     373              reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._miss_commit = false;
    352374
    353375              // Write new accurate
     
    356378                throw ERRORMORPHEO(FUNCTION,_("Decod : invalid accurate flag."));
    357379#endif
     380
     381              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * is_accurate : %d",is_accurate);
     382
    358383              reg_IS_ACCURATE [context] = is_accurate;
    359384             
     
    728753                      reg_EVENT_ADDRESS_DEST_VAL[context] = good_take;
    729754                      reg_EVENT_ADDRESS_DEST    [context] = good_addr;
     755                      reg_EVENT_CAN_CONTINUE    [context] = false;
     756
    730757                    }
     758                  reg_UPDATE_PREDICTION_TABLE [context][depth]._miss_commit = true;
    731759                }
    732760              else
     
    770798
    771799              // if different : an other branch is occured
    772               if (reg_EVENT_STATE [i] == EVENT_STATE_UPDATE_CONTEXT)
     800              if (reg_EVENT_STATE        [i] == EVENT_STATE_UPDATE_CONTEXT)
    773801                {
    774802                  // Change state
    775803                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_WAIT_END_EVENT (branch_event)",i);
    776                  
    777804                  reg_EVENT_STATE [i] = EVENT_STATE_WAIT_END_EVENT;
    778805                }
     
    809836                  {
    810837                    log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * type  : EVENT_TYPE_BRANCH_MISS_SPECULATION");
     838
     839// #ifdef DEBUG_TEST
     840//                     if (reg_EVENT_STATE [i] != EVENT_STATE_WAIT_END_EVENT)
     841//                       throw ERRORMORPHEO(FUNCTION,_("Event : invalid event state."));
     842// #endif
     843                    // Special case : test if event and branch_complete !
     844                    if (reg_EVENT_STATE [i] == EVENT_STATE_WAIT_END_EVENT)
     845                      {
    811846                   
    812 #ifdef DEBUG_TEST
    813                     if (reg_EVENT_STATE [i] != EVENT_STATE_WAIT_END_EVENT)
    814                       throw ERRORMORPHEO(FUNCTION,_("Event : invalid event state."));
    815 #endif
    816                    
    817                     // Change state
    818                     log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_OK (event)",i);
    819                    
    820                     reg_EVENT_STATE [i] = EVENT_STATE_OK;
    821                     reg_IS_ACCURATE [i] = true;
    822 
    823                     Tdepth_t depth = reg_EVENT_UPT_PTR [i];
    824 
    825                     if (reg_UPDATE_PREDICTION_TABLE [i][depth]._state == UPDATE_PREDICTION_STATE_END_KO)
    826                       {
    827                         log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT  [%d][%d].state <- UPDATE_PREDICTION_STATE_END (event)",i,depth);
     847                        // Change state
     848                        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_OK (event)",i);
    828849                       
    829                         reg_UPDATE_PREDICTION_TABLE [i][depth]._state = UPDATE_PREDICTION_STATE_END;
    830                       }
    831 
     850                        reg_EVENT_STATE [i] = EVENT_STATE_OK;
     851                        reg_IS_ACCURATE [i] = true;
     852                       
     853                        Tdepth_t depth = reg_EVENT_UPT_PTR [i];
     854                       
     855                        if (reg_UPDATE_PREDICTION_TABLE [i][depth]._state == UPDATE_PREDICTION_STATE_END_KO)
     856                          {
     857                            log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT  [%d][%d].state <- UPDATE_PREDICTION_STATE_END (event)",i,depth);
     858                           
     859                            reg_UPDATE_PREDICTION_TABLE [i][depth]._state = UPDATE_PREDICTION_STATE_END;
     860                          }
     861                       
    832862#ifdef DEBUG_TEST
    833863//                     if (reg_UPDATE_PREDICTION_TABLE [i][depth]._state != UPDATE_PREDICTION_STATE_END_KO_WAIT_END)
     
    840870                   
    841871//                     reg_UPDATE_PREDICTION_TABLE [i][depth]._state = UPDATE_PREDICTION_STATE_END_KO;
    842                    
     872                      }
    843873                    break;
    844874                  }
     
    11911221        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_EVENT_ADDRESS_DEST_VAL: %d"  ,reg_EVENT_ADDRESS_DEST_VAL[i]);
    11921222        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_EVENT_ADDRESS_DEST    : %.8x (%.8x)",reg_EVENT_ADDRESS_DEST    [i],reg_EVENT_ADDRESS_DEST    [i]<<2);
     1223        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_EVENT_CAN_CONTINUE    : %d"  ,reg_EVENT_CAN_CONTINUE    [i]);
    11931224
    11941225        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * Update_Fetch_Prediction_Table   [%d]",i);
Note: See TracChangeset for help on using the changeset viewer.