Ignore:
Timestamp:
Dec 31, 2008, 11:18:08 AM (16 years ago)
Author:
rosiere
Message:

1) Fix bug (read unit, RAT -> write in R0, SPR desallocation ...)
2) Change VHDL Execute_queue -> use Generic/Queue?
3) Complete document on VHDL generation
4) Add soc test

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Prediction_unit_Glue/src/Prediction_unit_Glue_genMealy_predict.cpp

    r88 r98  
    2424    log_begin(Prediction_unit_Glue,FUNCTION);
    2525    log_function(Prediction_unit_Glue,FUNCTION,_name.c_str());
    26    
     26
     27    if (PORT_READ(in_NRESET))
     28      {
     29 
     30    // Init
    2731    Tcontrol_t ack [_param->_nb_context];
    2832    for (uint32_t i=0; i<_param->_nb_context; i++)
    29       {
    30         ack [i] = 0;
    31 
    32 //      if (_param->_have_port_depth)
    33 //        {
    34 //      PORT_WRITE(out_DEPTH_TAIL      [i],PORT_READ(in_DEPTH_UPT_TAIL      [i]));
    35 //        }
    36 //      PORT_WRITE(out_DEPTH_NB_BRANCH [i],PORT_READ(in_DEPTH_UPT_NB_BRANCH [i]));
    37       }
     33      ack [i] = 0;
    3834
    3935    for (uint32_t i=0; i<_param->_nb_inst_branch_predict; i++)
     
    4137        log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"  * PREDICT [%d]",i);
    4238
    43         Tcontrol_t btb_val;
    44         Tcontrol_t dir_val;
    45         Tcontrol_t ras_val;
    46         Tcontrol_t upt_val;
    47 
    48         Tcontext_t context = (reg_PREDICT_PRIORITY+i)%_param->_nb_context;
     39        Tcontrol_t btb_val = false;
     40        Tcontrol_t dir_val = false;
     41        Tcontrol_t ras_val = false;
     42        Tcontrol_t upt_val = false;
     43
     44        Tcontrol_t btb_ack = PORT_READ(in_PREDICT_BTB_ACK [i]);
     45        Tcontrol_t dir_ack = PORT_READ(in_PREDICT_DIR_ACK [i]);
     46        Tcontrol_t ras_ack = PORT_READ(in_PREDICT_RAS_ACK [i]);
     47        Tcontrol_t upt_ack = PORT_READ(in_PREDICT_UPT_ACK [i]);
     48
     49        Tcontext_t context = (reg_PREDICT_PRIORITY+i)%_param->_nb_context; // priority
    4950        log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * context    : %d",context);
    5051
    5152        ack [context] = 1;
    52            
     53
    5354        if (PORT_READ(in_PREDICT_VAL[context]) == 0)
    5455          {
    5556            log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * not valid ...");
    5657
    57             btb_val = false;
    58             dir_val = false;
    59             ras_val = false;
    60             upt_val = false;
     58//             btb_val = false;
     59//             dir_val = false;
     60//             ras_val = false;
     61//             upt_val = false;
    6162          }
    6263        else
     
    6768            Taddress_t          pc_current            = PORT_READ(in_PREDICT_PC_CURRENT            [context]);
    6869            Tcontrol_t          pc_current_is_ds_take = PORT_READ(in_PREDICT_PC_CURRENT_IS_DS_TAKE [context]);
     70
     71            log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * pc_previous           : 0x%.8x",pc_previous          );
     72            log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * pc_current            : 0x%.8x",pc_current           );
     73            log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * pc_current_is_ds_take : %d"    ,pc_current_is_ds_take);
    6974
    7075            Taddress_t          pc_next                     ;
     
    7580           
    7681            // STEP (1) - Compute the address source
     82            // if pc_current is a ds take, then pc_previous is a branchement
    7783            Taddress_t          address     = (pc_current_is_ds_take)?pc_previous:pc_current;
    7884            Taddress_t          address_lsb = pc_current%_param->_nb_instruction [context]; //if pc_current_is_ds_take, then pc_current%_param->_nb_instruction [context] == 0
    7985            Taddress_t          address_msb;
    8086
    81             log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * address    : 0x%x",address);
     87            log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * address               : 0x%.8x",address);
     88            log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * address_lsb           : %d"    ,address_lsb);
    8289
    8390            // STEP (2) - Test if branch (access at branch_target_buffer)
    8491            btb_val = true;
    85             ack [context] &= PORT_READ(in_PREDICT_BTB_ACK [i]);
    8692
    8793            if (_param->_have_port_context_id)
    8894            PORT_WRITE(out_PREDICT_BTB_CONTEXT_ID [i],context);
    8995            PORT_WRITE(out_PREDICT_BTB_ADDRESS    [i],address);
     96
     97            ack [context] &= btb_ack;
     98
     99            log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * btb_ack               : %d"    ,btb_ack);
     100
     101            // BTB_ack = 0 ?
     102            if (not btb_ack)
     103              continue;
    90104
    91105            // special case :
     
    95109            Tcontrol_t          is_accurate = PORT_READ(in_PREDICT_BTB_IS_ACCURATE  [i]) and not (pc_current_is_ds_take and not hit);
    96110
     111            log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * hit                   : %d"    ,hit);
     112            log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * is_accurate           : %d"    ,is_accurate);
     113
    97114            // STEP (3) : Test if have branch in the packet
    98115            if (hit == 1)
    99116              {
    100117                // STEP (3a) : branch - test condition
    101 
    102118                bool                use_dir      = false;
    103119                bool                use_ras      = false;
    104120                bool                use_upt      = false;
    105121               
    106                 Tbranch_condition_t cond         = PORT_READ(in_PREDICT_BTB_CONDITION    [i]);
     122                Tbranch_condition_t condition    = PORT_READ(in_PREDICT_BTB_CONDITION    [i]);
    107123                Taddress_t          address_src  = PORT_READ(in_PREDICT_BTB_ADDRESS_SRC  [i]);
    108124                Taddress_t          address_dest = PORT_READ(in_PREDICT_BTB_ADDRESS_DEST [i]);
    109                 Tcontrol_t          push;
     125                Tcontrol_t          push     ;
    110126                Tcontrol_t          direction;
    111127
    112                 switch (cond)
     128                log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * condition             : %s"    ,toString(condition).c_str());
     129                log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * address_src           : 0x%.8x",address_src);
     130                log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * address_dest          : 0x%.8x",address_dest);
     131
     132                switch (condition)
    113133                  {
    114134                  case BRANCH_CONDITION_NONE_WITHOUT_WRITE_STACK          : // l.j
     
    188208                if (use_dir)
    189209                  {
    190                     ack[context] &= PORT_READ(in_PREDICT_DIR_ACK [i]);
     210                    ack[context] &= dir_ack;
    191211                    PORT_WRITE(out_PREDICT_DIR_ADDRESS_SRC [i], address_src);
    192212                    PORT_WRITE(out_PREDICT_DIR_STATIC      [i], address_dest<address_src); // if destination is previous : the static direction is take
     
    196216                if (use_ras)
    197217                  {
    198                     ack[context] &= PORT_READ(in_PREDICT_RAS_ACK [i]);
     218                    ack[context] &= ras_ack;
    199219                    if (_param->_have_port_context_id)
    200220                    PORT_WRITE(out_PREDICT_RAS_CONTEXT_ID   [i], context);
     
    207227                if (use_upt)
    208228                  {
    209                     ack[context] &= PORT_READ(in_PREDICT_UPT_ACK [i]);
     229                    ack[context] &= upt_ack;
    210230                   
     231                    if (_param->_have_port_context_id)
    211232                    PORT_WRITE(out_PREDICT_UPT_CONTEXT_ID       [i],context);
    212233                    PORT_WRITE(out_PREDICT_UPT_BTB_ADDRESS_SRC  [i],address_src);
    213234                    PORT_WRITE(out_PREDICT_UPT_BTB_ADDRESS_DEST [i],address_dest);
    214                     PORT_WRITE(out_PREDICT_UPT_BTB_CONDITION    [i],cond);
     235                    PORT_WRITE(out_PREDICT_UPT_BTB_CONDITION    [i],condition);
    215236                    PORT_WRITE(out_PREDICT_UPT_BTB_LAST_TAKE    [i],direction);
    216237                    PORT_WRITE(out_PREDICT_UPT_BTB_IS_ACCURATE  [i],is_accurate);
     
    225246                //   * use_ras and ras_ack
    226247                //   * use_upt and upt_ack
    227 //              ack [context] = (PORT_READ(in_PREDICT_BTB_ACK [i]) and
    228 //                               (use_dir and PORT_READ(in_PREDICT_DIR_ACK [i])) and
    229 //                               (use_ras and PORT_READ(in_PREDICT_RAS_ACK [i])) and
    230 //                               (use_upt and PORT_READ(in_PREDICT_UPT_ACK [i])));
    231 
    232                 dir_val = (use_dir and
    233                            PORT_READ(in_PREDICT_BTB_ACK [i]) and
    234                            (not use_ras or (use_ras and PORT_READ(in_PREDICT_RAS_ACK [i]))) and
    235                            (not use_upt or (use_upt and PORT_READ(in_PREDICT_UPT_ACK [i]))));
    236 
    237                 ras_val = (use_ras and
    238                            PORT_READ(in_PREDICT_BTB_ACK [i]) and
    239                            (not use_dir or (use_dir and PORT_READ(in_PREDICT_DIR_ACK [i]))) and
    240                            (not use_upt or (use_upt and PORT_READ(in_PREDICT_UPT_ACK [i]))));
    241 
    242                 upt_val = (use_upt and
    243                            PORT_READ(in_PREDICT_BTB_ACK [i]) and
    244                            (not use_dir or (use_dir and PORT_READ(in_PREDICT_DIR_ACK [i]))) and
    245                            (not use_ras or (use_ras and PORT_READ(in_PREDICT_RAS_ACK [i]))));
     248//              ack [context] = (btb_ack and
     249//                               (use_dir and dir_ack) and
     250//                               (use_ras and ras_ack) and
     251//                               (use_upt and upt_ack));
     252
     253                dir_val = (btb_ack and
     254                           use_dir and
     255//                         use_ras and
     256//                         use_upt and
     257//                         (not use_dir or (use_dir and dir_ack)) and
     258                           (not use_ras or (use_ras and ras_ack)) and
     259                           (not use_upt or (use_upt and upt_ack)));
     260
     261                ras_val = (btb_ack and
     262//                         use_dir and
     263                           use_ras and
     264//                         use_upt and
     265                           (not use_dir or (use_dir and dir_ack)) and
     266//                         (not use_ras or (use_ras and ras_ack)) and
     267                           (not use_upt or (use_upt and upt_ack)));
     268
     269                upt_val = (btb_ack and
     270//                         use_dir and
     271//                         use_ras and
     272                           use_upt and
     273                           (not use_dir or (use_dir and dir_ack)) and
     274                           (not use_ras or (use_ras and ras_ack))//  and
     275//                         (not use_upt or (use_upt and upt_ack))
     276                           );
    246277
    247278//              pc_next      - is previously computed
     
    252283                log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"      * address_src     : 0x%x",address_src);
    253284                log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"      * address_src_lsb : %d",address_src_lsb);
     285
    254286                if (address_src_lsb == (_param->_nb_instruction [context]-1))
    255287                  {
     
    288320              PORT_WRITE(out_PREDICT_PC_NEXT_IS_DS_TAKE          [context]   , pc_next_is_ds_take         );
    289321
     322              Taddress_t address_limit_min = address_lsb;
     323              Taddress_t address_limit_max = ((pc_current_is_ds_take)?(address_lsb+1):address_msb);
     324
    290325              log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * instruction enable :");
    291326              log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"      * nb_inst : %d",_param->_nb_instruction [context]);
    292               log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"      * [0:%d[ = 0",address_lsb);
    293               log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"      * [%d:%d[ = 1",address_lsb,((pc_current_is_ds_take)?1:address_msb));
    294               log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"      * [%d:%d[ = 0",((pc_current_is_ds_take)?1:address_msb),_param->_nb_instruction [context]);
    295 
    296               for (uint32_t j=0; j<address_lsb; j++)
     327              log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"      * [0:%d[ = 0" ,address_limit_min);
     328              log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"      * [%d:%d[ = 1",address_limit_min,address_limit_max);
     329              log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"      * [%d:%d[ = 0",address_limit_max,_param->_nb_instruction [context]);
     330
     331              for (uint32_t j=0; j<address_limit_min; j++)
    297332              PORT_WRITE(out_PREDICT_INSTRUCTION_ENABLE          [context][j], 0); // Before the address : not valid
    298               for (uint32_t j=address_lsb; j<((pc_current_is_ds_take)?1:address_msb); j++)
     333              for (uint32_t j=address_limit_min; j<address_limit_max; j++)
    299334              PORT_WRITE(out_PREDICT_INSTRUCTION_ENABLE          [context][j], 1); // Vald packet
    300               for (uint32_t j=((pc_current_is_ds_take)?1:address_msb); j<_param->_nb_instruction [context]; j++)
     335              for (uint32_t j=address_limit_max; j<_param->_nb_instruction [context]; j++)
    301336              PORT_WRITE(out_PREDICT_INSTRUCTION_ENABLE          [context][j], 0); // After last address (branch) : not valid
    302337              if (_param->_have_port_inst_ifetch_ptr)
     
    316351    for (uint32_t i=0; i<_param->_nb_context; i++)
    317352      PORT_WRITE(out_PREDICT_ACK[i],ack[i]);
     353      }
    318354
    319355    log_end(Prediction_unit_Glue,FUNCTION);
Note: See TracChangeset for help on using the changeset viewer.