Ignore:
Timestamp:
Jan 8, 2009, 2:06:27 PM (15 years ago)
Author:
rosiere
Message:

1) Bug fix (Operation, Instruction)
2) Modif Return Address Stack
3) Add Soft Test
4) Add Soc Test

Location:
trunk
Files:
32 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore set to
      Makefile.flags
      Makefile.tools
      Makefile.tools_path
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Execute_loop/Execute_loop/Multi_Execute_unit/Execute_unit/Functionnal_unit/Operation/src/Operation.cpp

    r98 r100  
    255255    // Result
    256256    op->_timing       = param->_timing[op->_type][op->_operation];
    257     op->_data_rd      = imm;
     257    op->_data_rd      = imm<<2; // add "00"
    258258  //op->_data_re      = 0;
    259259    op->_exception    = EXCEPTION_ALU_NONE;
    260260    op->_no_sequence  = 1;
    261     op->_address      = gpr;
     261    op->_address      = gpr>>2; // del "00"
    262262  };
    263263
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Execute_loop/Execute_loop/Multi_Execute_unit/Execute_unit/Functionnal_unit/SelfTest/src/test.cpp

    r97 r100  
    279279                                                                                       
    280280                                                                                       
    281   transaction_in.push_back(execute_transaction(_param,0,0,0, 31,OPERATION_BRANCH_L_JALR    ,TYPE_BRANCH,0,0xdeadbeef,0x0       ,0x12345678,0              ,0,63,0xdeadbeef,0,15,FLAG_CY        ,EXCEPTION_NONE     ,1,0x12345678)); // jr
    282   transaction_in.push_back(execute_transaction(_param,0,0,0, 32,OPERATION_BRANCH_L_JALR    ,TYPE_BRANCH,1,0xdeadbeef,0x0       ,0x12345678,0              ,1,63,0xdeadbeef,0,15,FLAG_CY        ,EXCEPTION_NONE     ,1,0x12345678)); // jal
    283   transaction_in.push_back(execute_transaction(_param,0,0,0, 33,OPERATION_BRANCH_L_JALR    ,TYPE_BRANCH,1,0xdeadbeef,0x0       ,0x12345678,0              ,1,63,0xdeadbeef,0,15,FLAG_CY        ,EXCEPTION_NONE     ,1,0x12345678)); // jalr
     281  transaction_in.push_back(execute_transaction(_param,0,0,0, 31,OPERATION_BRANCH_L_JALR    ,TYPE_BRANCH,0,0xdeadbeef,0x0       ,0x12345678,0              ,0,63,0xdeadbeef,0,15,FLAG_CY        ,EXCEPTION_NONE     ,1,0x12345678>>2)); // jr
     282  transaction_in.push_back(execute_transaction(_param,0,0,0, 32,OPERATION_BRANCH_L_JALR    ,TYPE_BRANCH,1,0xdeadbeef,0x0       ,0x12345678,0              ,1,63,0xdeadbeef<<2,0,15,FLAG_CY        ,EXCEPTION_NONE     ,1,0x12345678>>2)); // jal
     283  transaction_in.push_back(execute_transaction(_param,0,0,0, 33,OPERATION_BRANCH_L_JALR    ,TYPE_BRANCH,1,0xdeadbeef,0x0       ,0x12345678,0              ,1,63,0xdeadbeef<<2,0,15,FLAG_CY        ,EXCEPTION_NONE     ,1,0x12345678>>2)); // jalr
    284284                                                             
    285285  transaction_in.push_back(execute_transaction(_param,0,0,0, 34,OPERATION_EXTEND_L_EXTEND_S,TYPE_EXTEND,1,8         ,0x12345678,0x0       ,0              ,1,63,0x00000078,0,15,FLAG_CY        ,EXCEPTION_NONE     ,0));
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Execute_loop/Execute_loop/Multi_Execute_unit/Execute_unit/Functionnal_unit/src/Functionnal_unit_transition.cpp

    r98 r100  
    138138            log_printf(TRACE,Functionnal_unit,FUNCTION,"    * exception     : %d"  ,_execute_operation_in->_exception  );
    139139            log_printf(TRACE,Functionnal_unit,FUNCTION,"    * no_sequence   : %d"  ,_execute_operation_in->_no_sequence);
    140             log_printf(TRACE,Functionnal_unit,FUNCTION,"    * address       : %.8x",_execute_operation_in->_address    );
     140            log_printf(TRACE,Functionnal_unit,FUNCTION,"    * address       : %.8x (%.8x)",_execute_operation_in->_address,_execute_operation_in->_address<<2);
    141141
    142142#ifdef STATISTICS
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Execute_loop/Execute_loop/Multi_Read_unit/Read_unit/Read_queue/src/Read_queue_vhdl.cpp

    r98 r100  
    3232    param_queue = new morpheo::behavioural::generic::queue::Parameters
    3333      (_param->_size_queue,
    34        _param->_size_internal_queue
     34       _param->_size_internal_queue,
     35       0
    3536       );
    3637   
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Execute_loop/Execute_loop/Multi_Write_unit/Write_unit/Execute_queue/src/Execute_queue_vhdl.cpp

    r98 r100  
    3434    param_queue = new morpheo::behavioural::generic::queue::Parameters
    3535      (_param->_size_queue,
    36        _param->_size_internal_queue
     36       _param->_size_internal_queue,
     37       0
    3738       );
    3839   
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Decod_unit/Decod/Instruction/src/Instruction.cpp

    r97 r100  
    903903    inst->_type               = instruction_information(INSTRUCTION_L_JALR)._type     ; //TYPE_BRANCH;
    904904    inst->_operation          = instruction_information(INSTRUCTION_L_JALR)._operation; //OPERATION_BRANCH_L_JALR;
    905     inst->_has_immediat       = 0;
    906     inst->_immediat           = 0; // unnecessary
     905    inst->_has_immediat       = 1;
     906    inst->_immediat           = inst->_address_next+1;
    907907    inst->_read_ra            = 0;
    908908    inst->_num_reg_ra         = 0; //unnecessary
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Prediction_unit_Glue/SelfTest/config_mono_context.cfg

    r82 r100  
    331       1       *4      # nb_decod_unit     
    4430      30      +32     # size_address       
    5 1       1       *4      # nb_instruction  [0] [nb_context]
     51       4       *2      # nb_instruction  [0] [nb_context]
    661       1       *4      # size_depth      [0] [nb_context]
    774       4       *4      # nb_inst_decod   [0] [nb_decod_unit]
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Prediction_unit_Glue/SelfTest/src/test.cpp

    r88 r100  
    362362
    363363  // Initialisation
     364  const bool test1 = false;
     365  const bool test2 = true ;
     366  const bool test3 = false;
     367  const bool test4 = false;
    364368
    365369  const uint32_t seed = 0;
     
    402406      LABEL("Iteration %d",iteration);
    403407
     408      if (test1)
    404409      {
    405410        LABEL("Test sequential");
     
    481486      }
    482487
     488      if (test2)
    483489      {
    484490        LABEL("Test no sequential - L.J");
     
    489495        for (uint32_t i=0; i<_param->_nb_instruction [context]; i++)
    490496          {
    491             Taddress_t addr      = (1<<(_param->_nb_instruction[context]+4));
    492             Taddress_t addr_src  = addr+i;
     497            Taddress_t pc_current  = (1<<(_param->_nb_instruction[context]+3));
     498            Taddress_t pc_previous = pc_current-1;
     499            Taddress_t addr_src  = pc_current+i;
    493500            Taddress_t addr_dest = 0xdeadbeef;
    494            
    495             in_PREDICT_PC_PREVIOUS           [context]->write(0);
    496             in_PREDICT_PC_CURRENT            [context]->write(addr);
    497             in_PREDICT_PC_CURRENT_IS_DS_TAKE [context]->write(0);
     501            Tcontrol_t is_ds_take= rand()%2;
     502
     503            in_PREDICT_PC_PREVIOUS           [context]->write(pc_previous);
     504            in_PREDICT_PC_CURRENT            [context]->write(pc_current);
     505            in_PREDICT_PC_CURRENT_IS_DS_TAKE [context]->write(is_ds_take);
    498506
    499507            bool find = false;
     
    515523                    LABEL(" * BTB address : 0x%x",out_PREDICT_BTB_ADDRESS    [port]->read());
    516524                    if ((out_PREDICT_BTB_CONTEXT_ID [port]->read() == context) and
    517                         (out_PREDICT_BTB_ADDRESS    [port]->read() == addr   ))
     525                        (out_PREDICT_BTB_ADDRESS    [port]->read() == (is_ds_take)?pc_previous:pc_current   ))
    518526                      {
    519527                        in_PREDICT_BTB_ACK          [port]->write((rand()%100)<percent_transaction_predict);
     
    531539                SC_START(0);
    532540
     541                LABEL ("PREDICT_VAL : %d", in_PREDICT_VAL[context]->read());
     542                LABEL ("PREDICT_ACK : %d",out_PREDICT_ACK[context]->read());
     543               
    533544                if (in_PREDICT_VAL[context]->read() and out_PREDICT_ACK[context]->read())
    534545                  {
    535546                    LABEL ("PREDICT         [%d] - Transaction accepted",context);
     547                    LABEL ("  * pc_previous: 0x%x",pc_previous );
     548                    LABEL ("  * pc_current : 0x%x",pc_current      );
     549                    LABEL ("  * addr_src   : 0x%x",addr_src  );
     550                    LABEL ("  * addr_dest  : 0x%x",addr_dest );
     551                    LABEL ("  * is_ds_take : %d"  ,is_ds_take);
     552
    536553                    find = true;
    537 
    538                     TEST(Taddress_t        ,out_PREDICT_PC_NEXT                     [context]->read(),addr_dest);
    539                     TEST(Tcontrol_t        ,out_PREDICT_PC_NEXT_IS_DS_TAKE          [context]->read(),i==(_param->_nb_instruction [context]-1));
     554                   
     555                    Tcontrol_t next_is_ds_take = (not is_ds_take and (i==(_param->_nb_instruction [context]-1)));
     556
     557                    TEST(Tcontrol_t        ,out_PREDICT_PC_NEXT_IS_DS_TAKE          [context]->read(), next_is_ds_take);
     558                    TEST(Taddress_t        ,out_PREDICT_PC_NEXT                     [context]->read(),(next_is_ds_take)?(addr_src+1):addr_dest);
    540559                    TEST(Tinst_ifetch_ptr_t,out_PREDICT_INST_IFETCH_PTR             [context]->read(),i);
    541                     TEST(Tbranch_state_t   ,out_PREDICT_BRANCH_STATE                [context]->read(),BRANCH_STATE_NSPEC_TAKE);
     560                    TEST(Tbranch_state_t   ,out_PREDICT_BRANCH_STATE                [context]->read(),(next_is_ds_take)?BRANCH_STATE_NONE:BRANCH_STATE_NSPEC_TAKE);
    542561//                  TEST(Tprediction_ptr_t ,out_PREDICT_BRANCH_UPDATE_PREDICTION_ID [context]->read(),0);
    543562
    544                     uint32_t k=((addr_src%_param->_nb_instruction[context])==_param->_nb_instruction[context]-1)?_param->_nb_instruction[context]:((addr_src%_param->_nb_instruction[context])+2);
     563                    uint32_t k=((is_ds_take)?1:((next_is_ds_take)?_param->_nb_instruction[context]:((addr_src%_param->_nb_instruction [context])+2)));
     564
     565
     566// ((addr_src%_param->_nb_instruction[context])==_param->_nb_instruction[context]-1)?_param->_nb_instruction[context]:((addr_src%_param->_nb_instruction[context])+2);
     567
    545568                    LABEL("instruction enable : ");
    546569                    LABEL("  [0:%d[ = 1",k);
    547                     LABEL("  [%d:%d[ = 1",k,_param->_nb_instruction[context]);
     570                    LABEL("  [%d:%d[ = 0",k,_param->_nb_instruction[context]);
    548571                    for (uint32_t j=0; j<k; j++)
    549                       TEST(Tcontrol_t        ,out_PREDICT_INSTRUCTION_ENABLE [context][j]->read(),1);
     572                    TEST(Tcontrol_t        ,out_PREDICT_INSTRUCTION_ENABLE [context][j]->read(),1);
    550573                    for (uint32_t j=k; j<_param->_nb_instruction[context]; j++)
    551                       TEST(Tcontrol_t        ,out_PREDICT_INSTRUCTION_ENABLE [context][j]->read(),0);
     574                    TEST(Tcontrol_t        ,out_PREDICT_INSTRUCTION_ENABLE [context][j]->read(),0);
    552575
    553576                    TEST(Tcontrol_t        ,out_PREDICT_BTB_VAL        [port]->read(),1);
    554577                    TEST(Tcontext_t        ,out_PREDICT_BTB_CONTEXT_ID [port]->read(),context);
    555                     TEST(Taddress_t        ,out_PREDICT_BTB_ADDRESS    [port]->read(),addr);
     578                    TEST(Taddress_t        ,out_PREDICT_BTB_ADDRESS    [port]->read(),(is_ds_take)?pc_previous:pc_current);
    556579                  }
    557580               
     
    571594          }
    572595      }
    573 
     596     
     597      if (test3)
    574598      {
    575599        LABEL("Decod - Ok");
     
    618642      }
    619643
     644      if (test4)
    620645      {
    621646        LABEL("Decod - Ko");
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Prediction_unit_Glue/src/Prediction_unit_Glue_genMealy_predict.cpp

    r98 r100  
    2727    if (PORT_READ(in_NRESET))
    2828      {
    29  
    3029    // Init
    3130    Tcontrol_t ack [_param->_nb_context];
     
    3635      {
    3736        log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"  * PREDICT [%d]",i);
    38 
     37       
     38        // No access
    3939        Tcontrol_t btb_val = false;
    4040        Tcontrol_t dir_val = false;
     
    4242        Tcontrol_t upt_val = false;
    4343
     44        // Get ack
    4445        Tcontrol_t btb_ack = PORT_READ(in_PREDICT_BTB_ACK [i]);
    4546        Tcontrol_t dir_ack = PORT_READ(in_PREDICT_DIR_ACK [i]);
     
    4748        Tcontrol_t upt_ack = PORT_READ(in_PREDICT_UPT_ACK [i]);
    4849
     50        // Read context_id
    4951        Tcontext_t context = (reg_PREDICT_PRIORITY+i)%_param->_nb_context; // priority
    5052        log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * context    : %d",context);
    5153
     54        // Now : ack transaction
    5255        ack [context] = 1;
    5356
    5457        if (PORT_READ(in_PREDICT_VAL[context]) == 0)
    5558          {
     59            // Nothing
    5660            log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * not valid ...");
    5761
     
    6367        else
    6468          {
     69            // Have transaction
    6570            log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * valid ...");
    6671
     72            // Read information (PC)
    6773            Taddress_t          pc_previous           = PORT_READ(in_PREDICT_PC_PREVIOUS           [context]);
    6874            Taddress_t          pc_current            = PORT_READ(in_PREDICT_PC_CURRENT            [context]);
    6975            Tcontrol_t          pc_current_is_ds_take = PORT_READ(in_PREDICT_PC_CURRENT_IS_DS_TAKE [context]);
    7076
    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           );
     77            log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * pc_previous           : 0x%.8x (0x%.8x)",pc_previous,pc_previous<<2);
     78            log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * pc_current            : 0x%.8x (0x%.8x)",pc_current ,pc_current <<2);
    7379            log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * pc_current_is_ds_take : %d"    ,pc_current_is_ds_take);
    7480
     
    8086           
    8187            // STEP (1) - Compute the address source
    82             // if pc_current is a ds take, then pc_previous is a branchement
     88            //   -> if pc_current is a ds take, then pc_previous is a branchement
     89            //      get branchement address to send at the BTB
    8390            Taddress_t          address     = (pc_current_is_ds_take)?pc_previous:pc_current;
     91            // Address_lsb = position in fetch packet
    8492            Taddress_t          address_lsb = pc_current%_param->_nb_instruction [context]; //if pc_current_is_ds_take, then pc_current%_param->_nb_instruction [context] == 0
    8593            Taddress_t          address_msb;
    8694
    87             log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * address               : 0x%.8x",address);
     95            log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * address               : 0x%.8x (0x%.8x)",address,address<<2);
    8896            log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * address_lsb           : %d"    ,address_lsb);
    8997
    9098            // STEP (2) - Test if branch (access at branch_target_buffer)
     99            // Access at the btb
    91100            btb_val = true;
    92101
     102            // Create the request
    93103            if (_param->_have_port_context_id)
    94104            PORT_WRITE(out_PREDICT_BTB_CONTEXT_ID [i],context);
    95105            PORT_WRITE(out_PREDICT_BTB_ADDRESS    [i],address);
    96106
     107            // Transaction can be ack if btb is not busy
    97108            ack [context] &= btb_ack;
    98109
    99110            log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * btb_ack               : %d"    ,btb_ack);
    100111
    101             // BTB_ack = 0 ?
     112            // BTB_ack = 0 ? else can continue
    102113            if (not btb_ack)
    103114              continue;
    104115
    105             // special case :
    106             //  if pc_current_is_ds, then pc_previous have branch, also hit must be set.
    107             //  else : a another branch have eject this branch : can't accurate
     116            // Test a special case :
     117            //  if pc_current is a delay slot, then pc_previous is a branchement instruction, also hit must be set.
     118            //  else : an another branch instruction have eject this branch : can't accurate
    108119            Tcontrol_t          hit         = PORT_READ(in_PREDICT_BTB_HIT[i]);
    109120            Tcontrol_t          is_accurate = PORT_READ(in_PREDICT_BTB_IS_ACCURATE  [i]) and not (pc_current_is_ds_take and not hit);
     
    112123            log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * is_accurate           : %d"    ,is_accurate);
    113124
    114             // STEP (3) : Test if have branch in the packet
     125            // STEP (3) : Test if BTB find a branch instruction in the packet
    115126            if (hit == 1)
    116127              {
     128                log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * BTB hit : no sequential order");
     129
    117130                // STEP (3a) : branch - test condition
    118131                bool                use_dir      = false;
    119132                bool                use_ras      = false;
    120133                bool                use_upt      = false;
    121                
    122                 Tbranch_condition_t condition    = PORT_READ(in_PREDICT_BTB_CONDITION    [i]);
    123                 Taddress_t          address_src  = PORT_READ(in_PREDICT_BTB_ADDRESS_SRC  [i]);
    124                 Taddress_t          address_dest = PORT_READ(in_PREDICT_BTB_ADDRESS_DEST [i]);
    125                 Tcontrol_t          push     ;
    126                 Tcontrol_t          direction;
    127 
    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)
    133                   {
    134                   case BRANCH_CONDITION_NONE_WITHOUT_WRITE_STACK          : // l.j
    135                     {
    136                       // use none unit (dir, upt and ras)
    137                       direction    = true;
    138                       pc_next      = address_dest;
    139                       branch_state = BRANCH_STATE_NSPEC_TAKE;
    140                       break;
    141                     }
    142                   case BRANCH_CONDITION_NONE_WITH_WRITE_STACK             : // l.jal
    143                     {
    144                       use_upt      = true;
    145                       use_ras      = true;
    146                       push         = true;
    147                       direction    = true;
    148                       pc_next      = address_dest;
    149                       branch_state = BRANCH_STATE_NSPEC_TAKE;
    150                       break;
    151                     }
    152                   case BRANCH_CONDITION_FLAG_UNSET                        : // l.bnf
    153                   case BRANCH_CONDITION_FLAG_SET                          : // l.bf
    154                     {
    155                       use_upt      = true;
    156                       use_dir      = true;
    157                       // Test direction
    158                       direction = PORT_READ(in_PREDICT_DIR_DIRECTION [i]); // Direction is not the "flag predict" ... also flag_unset and flag_set is the same
    159                       if (direction = 1)
    160                         {
    161                           branch_state = BRANCH_STATE_SPEC_TAKE;
    162                           pc_next      = address_dest;
    163                         }
    164                       else
    165                         {
    166                           branch_state = BRANCH_STATE_SPEC_NTAKE;
    167                           pc_next      = address_src+2; // +1 = delay slot
    168                         }
    169                       break;
    170                     }
    171                   case BRANCH_CONDITION_READ_REGISTER_WITHOUT_WRITE_STACK : // l.jr (rb!=9)
    172                     {
    173                       use_upt      = true;
    174                       use_ras      = true;
    175                       push         = true;
    176                       direction    = true;
    177                       pc_next      = address_dest;
    178                       branch_state = BRANCH_STATE_SPEC_TAKE;
    179                       break;
    180                     }
    181                   case BRANCH_CONDITION_READ_REGISTER_WITH_WRITE_STACK    : // l.jalr
    182                     {
    183                       use_upt      = true;
    184                       use_ras      = true;
    185                       push         = true;
    186                       direction    = true;
    187                       pc_next      = address_dest;
    188                       branch_state = BRANCH_STATE_NSPEC_TAKE;
    189                       break;
    190                     }
    191                   case BRANCH_CONDITION_READ_STACK                        : // l.jr (rb==9)
    192                     {
    193                       use_upt      = true;
    194                       use_ras      = true;
    195                       push         = false;
    196                       direction    = true;
    197                       pc_next      = PORT_READ(in_PREDICT_RAS_ADDRESS_POP  [i]);
    198                       branch_state = BRANCH_STATE_SPEC_TAKE;
    199                       break;
    200                     }
    201                   default :
    202                     {
    203                       ERRORMORPHEO(FUNCTION,"Unknow Condition");
    204                       break;
    205                     }
    206                   }
    207 
    208                 if (use_dir)
    209                   {
    210                     ack[context] &= dir_ack;
    211                     PORT_WRITE(out_PREDICT_DIR_ADDRESS_SRC [i], address_src);
    212                     PORT_WRITE(out_PREDICT_DIR_STATIC      [i], address_dest<address_src); // if destination is previous : the static direction is take
    213 //                  PORT_WRITE(out_PREDICT_DIR_LAST_TAKE   [i], PORT_READ(in_PREDICT_BTB_LAST_TAKE [i]));
    214                   }
    215 
    216                 if (use_ras)
    217                   {
    218                     ack[context] &= ras_ack;
    219                     if (_param->_have_port_context_id)
    220                     PORT_WRITE(out_PREDICT_RAS_CONTEXT_ID   [i], context);
    221                     PORT_WRITE(out_PREDICT_RAS_PUSH         [i], push);
    222                     PORT_WRITE(out_PREDICT_RAS_ADDRESS_PUSH [i], address_src+2);
    223 
    224                     is_accurate &= PORT_READ(in_PREDICT_RAS_HIT [i]); // if miss - prediction is not accurate
    225                   }
    226 
    227                 if (use_upt)
    228                   {
    229                     ack[context] &= upt_ack;
    230                    
    231                     if (_param->_have_port_context_id)
    232                     PORT_WRITE(out_PREDICT_UPT_CONTEXT_ID       [i],context);
    233                     PORT_WRITE(out_PREDICT_UPT_BTB_ADDRESS_SRC  [i],address_src);
    234                     PORT_WRITE(out_PREDICT_UPT_BTB_ADDRESS_DEST [i],address_dest);
    235                     PORT_WRITE(out_PREDICT_UPT_BTB_CONDITION    [i],condition);
    236                     PORT_WRITE(out_PREDICT_UPT_BTB_LAST_TAKE    [i],direction);
    237                     PORT_WRITE(out_PREDICT_UPT_BTB_IS_ACCURATE  [i],is_accurate);
    238 //                  PORT_WRITE(out_PREDICT_UPT_DIR_HISTORY      [i],PORT_READ(in_PREDICT_DIR_HISTORY      [i]));
    239                     PORT_WRITE(out_PREDICT_UPT_RAS_ADDRESS      [i],PORT_READ(in_PREDICT_RAS_ADDRESS_POP  [i]));
    240 //                  PORT_WRITE(out_PREDICT_UPT_RAS_INDEX        [i],PORT_READ(in_PREDICT_RAS_INDEX        [i]));
    241                   }
    242 
    243                 // ack = 1 if :
    244                 //   *             btb_ack
    245                 //   * use_dir and dir_ack
    246                 //   * use_ras and ras_ack
    247                 //   * use_upt and upt_ack
    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                            );
    277 
    278 //              pc_next      - is previously computed
    279 //              branch_state - is previously computed
    280 
    281                 Taddress_t address_src_lsb  = address_src%_param->_nb_instruction [context];
    282 
    283                 log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"      * address_src     : 0x%x",address_src);
     134
     135                Taddress_t          address_src      = PORT_READ(in_PREDICT_BTB_ADDRESS_SRC  [i]);
     136                Taddress_t          address_src_lsb  = address_src%_param->_nb_instruction [context];
     137
     138                inst_ifetch_ptr = address_src_lsb;
     139
     140                log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"      * address_src     : 0x%.8x (0x%.8x)",address_src,address_src<<2);
    284141                log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"      * address_src_lsb : %d",address_src_lsb);
    285142
    286                 if (address_src_lsb == (_param->_nb_instruction [context]-1))
     143                // Special case :
     144                //   * BTB hit and the branchement is the PC current and it's the last slot.
     145                //     -> next pc must be the delay slot
     146                if ((not pc_current_is_ds_take) and // if pc_current is ds_take, alors pc_next is the destination of branchement
     147                    (address_src_lsb == (_param->_nb_instruction [context]-1)))
    287148                  {
    288149                    // branch is in the last slot of the packet
    289150                    log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"      * branch is in the last slot of the packet");
    290151               
     152                    // Branch is the last slot : next paquet is the delay slot
     153                    pc_next            = address_src+1; // sequencial
     154                    pc_next_is_ds_take = 1;
    291155                    address_msb        = _param->_nb_instruction [context]; // == (address_src_lsb+1)
    292                     pc_next_is_ds_take = 1;
     156                    branch_state       = BRANCH_STATE_NONE;
    293157                  }
    294158                else
    295159                  {
     160                    Tbranch_condition_t condition    = PORT_READ(in_PREDICT_BTB_CONDITION    [i]);
     161                    Taddress_t          address_dest = PORT_READ(in_PREDICT_BTB_ADDRESS_DEST [i]);
     162                    Tcontrol_t          push     ;
     163                    Tcontrol_t          direction;
     164                   
     165                    log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * condition             : %s"    ,toString(condition).c_str());
     166                    log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * address_src           : 0x%.8x (0x%.8x)",address_src ,address_src <<2);
     167                    log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * address_dest          : 0x%.8x (0x%.8x)",address_dest,address_dest<<2);
     168                   
     169                    switch (condition)
     170                      {
     171                      case BRANCH_CONDITION_NONE_WITHOUT_WRITE_STACK          : // l.j
     172                        {
     173                          log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"      * BRANCH_CONDITION_NONE_WITHOUT_WRITE_STACK");
     174                         
     175                          // use none unit (dir, upt and ras)
     176                          direction    = true;
     177                          pc_next      = address_dest;
     178                          branch_state = BRANCH_STATE_NSPEC_TAKE;
     179                          break;
     180                        }
     181                      case BRANCH_CONDITION_NONE_WITH_WRITE_STACK             : // l.jal
     182                        {
     183                          log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"      * BRANCH_CONDITION_NONE_WITH_WRITE_STACK");
     184                         
     185                          use_upt      = true;
     186                          use_ras      = true;
     187                          push         = true;
     188                          direction    = true;
     189                          pc_next      = address_dest;
     190                          branch_state = BRANCH_STATE_NSPEC_TAKE;
     191                          break;
     192                        }
     193                      case BRANCH_CONDITION_FLAG_UNSET                        : // l.bnf
     194                      case BRANCH_CONDITION_FLAG_SET                          : // l.bf
     195                        {
     196                          log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"      * BRANCH_CONDITION_FLAG");
     197                         
     198                          use_upt      = true;
     199                          use_dir      = true;
     200                          // Test direction
     201                          direction = PORT_READ(in_PREDICT_DIR_DIRECTION [i]); // Direction is not the "flag predict" ... also flag_unset and flag_set is the same
     202                          if (direction = 1)
     203                            {
     204                              branch_state = BRANCH_STATE_SPEC_TAKE;
     205                              pc_next      = address_dest;
     206                            }
     207                          else
     208                            {
     209                              branch_state = BRANCH_STATE_SPEC_NTAKE;
     210                              pc_next      = address_src+2; // +1 = delay slot
     211                            }
     212                          break;
     213                        }
     214                      case BRANCH_CONDITION_READ_REGISTER_WITHOUT_WRITE_STACK : // l.jr (rb!=9)
     215                        {
     216                          log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"      * BRANCH_CONDITION_READ_REGISTER_WITHOUT_WRITE_STACK");
     217                         
     218                          use_upt      = true;
     219                          use_ras      = true;
     220                          push         = true;
     221                          direction    = true;
     222                          pc_next      = address_dest;
     223                          branch_state = BRANCH_STATE_SPEC_TAKE;
     224                          break;
     225                        }
     226                      case BRANCH_CONDITION_READ_REGISTER_WITH_WRITE_STACK    : // l.jalr
     227                        {
     228                          log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"      * BRANCH_CONDITION_READ_REGISTER_WITH_WRITE_STACK");
     229                         
     230                          use_upt      = true;
     231                          use_ras      = true;
     232                          push         = true;
     233                          direction    = true;
     234                          pc_next      = address_dest;
     235                          branch_state = BRANCH_STATE_NSPEC_TAKE;
     236                          break;
     237                        }
     238                      case BRANCH_CONDITION_READ_STACK                        : // l.jr (rb==9)
     239                        {
     240                          log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"      * BRANCH_CONDITION_READ_STACK");
     241                          use_upt      = true;
     242                          use_ras      = true;
     243                          push         = false;
     244                          direction    = true;
     245                          pc_next      = PORT_READ(in_PREDICT_RAS_ADDRESS_POP  [i]);
     246                          branch_state = BRANCH_STATE_SPEC_TAKE;
     247                          break;
     248                        }
     249                      default :
     250                        {
     251                          ERRORMORPHEO(FUNCTION,"Unknow Condition");
     252                          break;
     253                        }
     254                      }
     255                   
     256                    if (use_dir)
     257                      {
     258                        ack[context] &= dir_ack;
     259                        PORT_WRITE(out_PREDICT_DIR_ADDRESS_SRC [i], address_src);
     260                        PORT_WRITE(out_PREDICT_DIR_STATIC      [i], address_dest<address_src); // if destination is previous : the static direction is take
     261//                      PORT_WRITE(out_PREDICT_DIR_LAST_TAKE   [i], PORT_READ(in_PREDICT_BTB_LAST_TAKE [i]));
     262                      }
     263                   
     264                    if (use_ras)
     265                      {
     266                        ack[context] &= ras_ack;
     267                        if (_param->_have_port_context_id)
     268                        PORT_WRITE(out_PREDICT_RAS_CONTEXT_ID   [i], context);
     269                        PORT_WRITE(out_PREDICT_RAS_PUSH         [i], push);
     270                        PORT_WRITE(out_PREDICT_RAS_ADDRESS_PUSH [i], address_src+2);
     271                       
     272                        is_accurate &= PORT_READ(in_PREDICT_RAS_HIT [i]); // if miss - prediction is not accurate
     273                      }
     274                   
     275                    if (use_upt)
     276                      {
     277                        ack[context] &= upt_ack;
     278                       
     279                        if (_param->_have_port_context_id)
     280                        PORT_WRITE(out_PREDICT_UPT_CONTEXT_ID       [i],context);
     281                        PORT_WRITE(out_PREDICT_UPT_BTB_ADDRESS_SRC  [i],address_src);
     282                        PORT_WRITE(out_PREDICT_UPT_BTB_ADDRESS_DEST [i],address_dest);
     283                        PORT_WRITE(out_PREDICT_UPT_BTB_CONDITION    [i],condition);
     284                        PORT_WRITE(out_PREDICT_UPT_BTB_LAST_TAKE    [i],direction);
     285                        PORT_WRITE(out_PREDICT_UPT_BTB_IS_ACCURATE  [i],is_accurate);
     286//                      PORT_WRITE(out_PREDICT_UPT_DIR_HISTORY      [i],PORT_READ(in_PREDICT_DIR_HISTORY      [i]));
     287                        PORT_WRITE(out_PREDICT_UPT_RAS_ADDRESS      [i],PORT_READ(in_PREDICT_RAS_ADDRESS_POP  [i]));
     288//                      PORT_WRITE(out_PREDICT_UPT_RAS_INDEX        [i],PORT_READ(in_PREDICT_RAS_INDEX        [i]));
     289                      }
     290                   
     291                    // ack = 1 if :
     292                    //   *             btb_ack
     293                    //   * use_dir and dir_ack
     294                    //   * use_ras and ras_ack
     295                    //   * use_upt and upt_ack
     296//                  ack [context] = (btb_ack and
     297//                                   (use_dir and dir_ack) and
     298//                                   (use_ras and ras_ack) and
     299//                                   (use_upt and upt_ack));
     300
     301                    dir_val = (btb_ack and
     302                               use_dir and
     303//                             use_ras and
     304//                             use_upt and
     305//                             (not use_dir or (use_dir and dir_ack)) and
     306                               (not use_ras or (use_ras and ras_ack)) and
     307                               (not use_upt or (use_upt and upt_ack)));
     308                   
     309                    ras_val = (btb_ack and
     310//                             use_dir and
     311                               use_ras and
     312//                             use_upt and
     313                               (not use_dir or (use_dir and dir_ack)) and
     314//                             (not use_ras or (use_ras and ras_ack)) and
     315                               (not use_upt or (use_upt and upt_ack)));
     316                   
     317                    upt_val = (btb_ack and
     318//                             use_dir and
     319//                             use_ras and
     320                               use_upt and
     321                               (not use_dir or (use_dir and dir_ack)) and
     322                               (not use_ras or (use_ras and ras_ack))//  and
     323//                             (not use_upt or (use_upt and upt_ack))
     324                               );
     325                   
     326//                  pc_next      - is previously computed
     327//                  branch_state - is previously computed
     328
     329
    296330                    // branch is in the last slot of the packet
    297331                    address_msb        = (address_src_lsb+2); // +1 == delayed slot
    298332                    pc_next_is_ds_take = 0;
    299333                  }
    300                 log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"      * address_msb     : %d",address_msb);
    301 
    302                 inst_ifetch_ptr             = address_src_lsb;
     334
    303335//              branch_update_prediction_id = (_param->_have_port_depth)?((PORT_READ(in_DEPTH_UPT_TAIL[context])+PORT_READ(in_DEPTH_UPT_NB_BRANCH [context]))%_param->_array_size_depth[context]):0;
    304336              }
     
    308340                log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * BTB miss : sequential order");
    309341
    310                 pc_next                     = address-address_lsb+_param->_nb_instruction [context]; // sequencial
     342                // Take the address packet base and add new packet
     343                pc_next                     = pc_current-address_lsb+_param->_nb_instruction [context]; // sequencial
    311344                pc_next_is_ds_take          = 0; // no branch, also no delay slot
    312345                inst_ifetch_ptr             = 0;
     
    316349                address_msb = _param->_nb_instruction [context];
    317350              }
    318              
    319               PORT_WRITE(out_PREDICT_PC_NEXT                     [context]   , pc_next                    );
    320               PORT_WRITE(out_PREDICT_PC_NEXT_IS_DS_TAKE          [context]   , pc_next_is_ds_take         );
    321 
    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 
    325               log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * instruction enable :");
    326               log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"      * nb_inst : %d",_param->_nb_instruction [context]);
    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++)
    332               PORT_WRITE(out_PREDICT_INSTRUCTION_ENABLE          [context][j], 0); // Before the address : not valid
    333               for (uint32_t j=address_limit_min; j<address_limit_max; j++)
    334               PORT_WRITE(out_PREDICT_INSTRUCTION_ENABLE          [context][j], 1); // Vald packet
    335               for (uint32_t j=address_limit_max; j<_param->_nb_instruction [context]; j++)
    336               PORT_WRITE(out_PREDICT_INSTRUCTION_ENABLE          [context][j], 0); // After last address (branch) : not valid
    337               if (_param->_have_port_inst_ifetch_ptr)
    338               PORT_WRITE(out_PREDICT_INST_IFETCH_PTR             [context]   , inst_ifetch_ptr            );
    339               PORT_WRITE(out_PREDICT_BRANCH_STATE                [context]   , branch_state               );
    340               if (_param->_have_port_depth)
    341               PORT_WRITE(out_PREDICT_BRANCH_UPDATE_PREDICTION_ID [context]   , PORT_READ(in_PREDICT_UPT_BRANCH_UPDATE_PREDICTION_ID [i]));
     351
     352            log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * address_msb           : %d",address_msb);
     353            log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * pc_next               : 0x%.8x (0x%.8x)",pc_next,pc_next<<2);
     354            log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * pc_next_is_ds_take    : %d"    ,pc_next_is_ds_take);
     355           
     356            // Write Output
     357            PORT_WRITE(out_PREDICT_PC_NEXT                     [context]   , pc_next                    );
     358            PORT_WRITE(out_PREDICT_PC_NEXT_IS_DS_TAKE          [context]   , pc_next_is_ds_take         );
     359
     360            // Create enable mask
     361            Taddress_t address_limit_min = address_lsb;
     362            Taddress_t address_limit_max = ((pc_current_is_ds_take)?(address_lsb+1):address_msb);
     363
     364            log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"    * instruction enable :");
     365            log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"      * nb_inst : %d",_param->_nb_instruction [context]);
     366            log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"      * [0:%d[ = 0" ,address_limit_min);
     367            log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"      * [%d:%d[ = 1",address_limit_min,address_limit_max);
     368            log_printf(TRACE,Prediction_unit_Glue,FUNCTION,"      * [%d:%d[ = 0",address_limit_max,_param->_nb_instruction [context]);
     369
     370            for (uint32_t j=0; j<address_limit_min; j++)
     371            PORT_WRITE(out_PREDICT_INSTRUCTION_ENABLE          [context][j], 0); // Before the address : not valid
     372            for (uint32_t j=address_limit_min; j<address_limit_max; j++)
     373            PORT_WRITE(out_PREDICT_INSTRUCTION_ENABLE          [context][j], 1); // Valid packet
     374            for (uint32_t j=address_limit_max; j<_param->_nb_instruction [context]; j++)
     375            PORT_WRITE(out_PREDICT_INSTRUCTION_ENABLE          [context][j], 0); // After last address (branch) : not valid
     376
     377            if (_param->_have_port_inst_ifetch_ptr)
     378            PORT_WRITE(out_PREDICT_INST_IFETCH_PTR             [context]   , inst_ifetch_ptr            );
     379            PORT_WRITE(out_PREDICT_BRANCH_STATE                [context]   , branch_state               );
     380            if (_param->_have_port_depth)
     381            PORT_WRITE(out_PREDICT_BRANCH_UPDATE_PREDICTION_ID [context]   , PORT_READ(in_PREDICT_UPT_BRANCH_UPDATE_PREDICTION_ID [i]));
    342382          }
    343383
     
    348388        PORT_WRITE(out_PREDICT_UPT_VAL [i], upt_val);
    349389      }
    350 
     390   
     391    // Write output
    351392    for (uint32_t i=0; i<_param->_nb_context; i++)
    352393      PORT_WRITE(out_PREDICT_ACK[i],ack[i]);
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Return_Address_Stack/SelfTest/src/test.cpp

    r95 r100  
    125125
    126126  // Initialisation
    127 
     127  const bool test1 = true;
     128  const bool test2 = true;
     129  const bool test3 = true;
     130  const bool test4 = true;
     131 
    128132  const uint32_t seed = 0;
    129133//const uint32_t seed = static_cast<uint32_t>(time(NULL));
     
    144148    {
    145149      LABEL("Iteration %d",iteration);
    146 
    147       if (1)
     150     
     151      if (test1)
    148152        {
    149         uint32_t port = rand()%_param->_nb_inst_predict;
    150 
    151         LABEL("PREDICT - PUSH");
     153          uint32_t port = rand()%_param->_nb_inst_predict;
     154         
     155          LABEL("PREDICT - PUSH");
     156         
     157          in_PREDICT_VAL  [port]->write(1);
     158          in_PREDICT_PUSH [port]->write(1);
     159         
     160          for (uint32_t i=0; i<_param->_nb_context; i++)
     161            for (uint32_t j=0; j<_param->_size_queue[i]; j++)
     162              {
     163                in_PREDICT_CONTEXT_ID   [port]->write(i);
     164                in_PREDICT_ADDRESS_PUSH [port]->write(0xdeadbeef+j);
     165               
     166                SC_START(0);
     167               
     168                TEST(Tcontrol_t, out_PREDICT_ACK  [port]->read(), 1);
     169                TEST(Tptr_t    , out_PREDICT_INDEX[port]->read(),(j+1)%_param->_size_queue[i]);
     170               
     171                SC_START(1);
     172               
     173              }
     174          in_PREDICT_VAL [port]->write(0);
     175         
     176          SC_START(1);
     177         
     178          in_PREDICT_VAL  [port]->write(1);
     179          in_PREDICT_PUSH [port]->write(1);
     180          for (uint32_t i=0; i<_param->_nb_context; i++)
     181            for (uint32_t j=0; j<_param->_size_queue[i]; j++)
     182              {
     183                in_PREDICT_CONTEXT_ID   [port]->write(i);
     184                in_PREDICT_ADDRESS_PUSH [port]->write(0x21071981+j);
     185               
     186                SC_START(0);
     187               
     188                TEST(Tcontrol_t, out_PREDICT_ACK        [port]->read(), 1);
     189                TEST(Tptr_t    , out_PREDICT_INDEX      [port]->read(),(j+1)%_param->_size_queue[i]);
     190                TEST(Taddress_t, out_PREDICT_ADDRESS_POP[port]->read(),0xdeadbeef+j);
     191               
     192                SC_START(1);
     193              }
     194          in_PREDICT_VAL [port]->write(0);
     195         
     196          LABEL("PREDICT - POP");
     197         
     198          in_PREDICT_VAL  [port]->write(1);
     199          in_PREDICT_PUSH [port]->write(0);
     200          for (uint32_t i=0; i<_param->_nb_context; i++)
     201            for (uint32_t j=0; j< _param->_size_queue[i]; j++)
     202              {
     203                in_PREDICT_CONTEXT_ID   [port]->write(i);
     204                in_PREDICT_ADDRESS_PUSH [port]->write(0xbabedead);
     205               
     206                SC_START(0);
     207               
     208                TEST(Tcontrol_t, out_PREDICT_ACK        [port]->read(), 1);
     209                TEST(Tcontrol_t, out_PREDICT_HIT        [port]->read(), 1);
     210                uint32_t k=(_param->_size_queue[i]-j)%_param->_size_queue[i];
     211                TEST(Tptr_t    , out_PREDICT_INDEX      [port]->read(), k);
     212                TEST(Taddress_t, out_PREDICT_ADDRESS_POP[port]->read(),(0x21071981+((k==0)?(_param->_size_queue[i]-1):(k-1))));
     213               
     214                SC_START(1);
     215              }
     216          in_PREDICT_VAL [port]->write(0);
     217
     218          // Now, the stack is empty
     219        }
     220
     221      if (test2)
     222        {
     223          uint32_t port = rand()%_param->_nb_inst_decod;
     224         
     225          LABEL("DECOD - without predict");
     226         
     227          LABEL("DECOD - PUSH"); 
     228         
     229          in_DECOD_VAL             [port]->write(1);
     230          in_DECOD_PUSH            [port]->write(1);
     231          in_DECOD_MISS_PREDICTION [port]->write(0);
     232         
     233          for (uint32_t i=0; i<_param->_nb_context; i++)
     234            for (uint32_t j=0; j<_param->_size_queue[i]; j++)
     235              {
     236                in_DECOD_CONTEXT_ID   [port]->write(i);
     237                in_DECOD_ADDRESS_PUSH [port]->write(0xbeefcaca+j);
     238               
     239                SC_START(0);
     240               
     241                TEST(Tcontrol_t, out_DECOD_ACK  [port]->read(), 1);
     242                TEST(Tptr_t    , out_DECOD_INDEX[port]->read(),(j+1)%_param->_size_queue[i]);
     243               
     244                SC_START(1);
     245               
     246              }
     247          in_DECOD_VAL [port]->write(0);
    152248       
    153         in_PREDICT_VAL  [port]->write(1);
    154         in_PREDICT_PUSH [port]->write(1);
    155         for (uint32_t i=0; i<_param->_nb_context; i++)
    156           for (uint32_t j=0; j<_param->_size_queue[i]; j++)
    157             {
    158               in_PREDICT_CONTEXT_ID   [port]->write(i);
    159               in_PREDICT_ADDRESS_PUSH [port]->write(0xdeadbeef+j);
    160              
    161               SC_START(0);
    162              
    163               TEST(Tcontrol_t, out_PREDICT_ACK  [port]->read(), 1);
    164               TEST(Tptr_t    , out_PREDICT_INDEX[port]->read(),(j+1)%_param->_size_queue[i]);
    165              
    166               SC_START(1);
    167              
    168             }
    169         in_PREDICT_VAL [port]->write(0);
    170        
    171         SC_START(1);
    172        
    173         in_PREDICT_VAL  [port]->write(1);
    174         in_PREDICT_PUSH [port]->write(1);
    175         for (uint32_t i=0; i<_param->_nb_context; i++)
    176           for (uint32_t j=0; j<_param->_size_queue[i]; j++)
    177             {
    178               in_PREDICT_CONTEXT_ID   [port]->write(i);
    179               in_PREDICT_ADDRESS_PUSH [port]->write(0x21071981+j);
    180              
    181               SC_START(0);
    182              
    183               TEST(Tcontrol_t, out_PREDICT_ACK        [port]->read(), 1);
    184               TEST(Tptr_t    , out_PREDICT_INDEX      [port]->read(),(j+1)%_param->_size_queue[i]);
    185               TEST(Taddress_t, out_PREDICT_ADDRESS_POP[port]->read(),0xdeadbeef+j);
    186              
    187               SC_START(1);
    188             }
    189         in_PREDICT_VAL [port]->write(0);
    190        
    191         LABEL("PREDICT - POP");
    192        
    193         in_PREDICT_VAL  [port]->write(1);
    194         in_PREDICT_PUSH [port]->write(0);
    195         for (uint32_t i=0; i<_param->_nb_context; i++)
    196           for (uint32_t j=0; j< _param->_size_queue[i]; j++)
    197             {
    198               in_PREDICT_CONTEXT_ID   [port]->write(i);
    199               in_PREDICT_ADDRESS_PUSH [port]->write(0xbabedead);
    200              
    201               SC_START(0);
    202              
    203               TEST(Tcontrol_t, out_PREDICT_ACK        [port]->read(), 1);
    204               TEST(Tcontrol_t, out_PREDICT_HIT        [port]->read(), 1);
    205               uint32_t k=(_param->_size_queue[i]-j)%_param->_size_queue[i];
    206               TEST(Tptr_t    , out_PREDICT_INDEX      [port]->read(), k);
    207               TEST(Taddress_t, out_PREDICT_ADDRESS_POP[port]->read(),(0x21071981+((k==0)?(_param->_size_queue[i]-1):(k-1))));
    208              
    209               SC_START(1);
    210             }
    211         in_PREDICT_VAL [port]->write(0);
    212         }
    213 
    214       // Now, the stack is empty
    215 
    216       if (1)
    217         {
    218         uint32_t port1 = rand()%_param->_nb_inst_decod;
    219         uint32_t port2 = rand()%_param->_nb_inst_predict;
    220 
    221         LABEL("DECOD - without predict");
    222        
    223         LABEL("DECOD - PUSH"); 
    224        
    225         in_DECOD_VAL             [port1]->write(1);
    226         in_DECOD_PUSH            [port1]->write(1);
    227         in_DECOD_MISS_PREDICTION [port1]->write(0);
    228        
    229         for (uint32_t i=0; i<_param->_nb_context; i++)
    230           for (uint32_t j=0; j<_param->_size_queue[i]; j++)
    231             {
    232               in_DECOD_CONTEXT_ID   [port1]->write(i);
    233               in_DECOD_ADDRESS_PUSH [port1]->write(0xbeefcaca+j);
    234              
    235               SC_START(0);
    236              
    237               TEST(Tcontrol_t, out_DECOD_ACK  [port1]->read(), 1);
    238               TEST(Tptr_t    , out_DECOD_INDEX[port1]->read(),(j+1)%_param->_size_queue[i]);
    239              
    240               SC_START(1);
    241              
    242             }
    243         in_DECOD_VAL [port1]->write(0);
    244        
    245         SC_START(1);
    246        
    247         in_DECOD_VAL  [port1]->write(1);
    248         in_DECOD_PUSH [port1]->write(1);
    249         for (uint32_t i=0; i<_param->_nb_context; i++)
    250           for (uint32_t j=0; j<_param->_size_queue[i]; j++)
    251             {
    252               in_DECOD_CONTEXT_ID   [port1]->write(i);
    253               in_DECOD_ADDRESS_PUSH [port1]->write(0x21071981+j);
    254              
    255               SC_START(0);
    256              
    257               TEST(Tcontrol_t, out_DECOD_ACK        [port1]->read(), 1);
    258               TEST(Tptr_t    , out_DECOD_INDEX      [port1]->read(),(j+1)%_param->_size_queue[i]);
    259               TEST(Taddress_t, out_DECOD_ADDRESS_POP[port1]->read(),0xbeefcaca+j);
    260              
    261               SC_START(1);
    262             }
    263         in_DECOD_VAL [port1]->write(0);
    264        
    265         LABEL("DECOD - POP");
    266        
    267         in_DECOD_VAL  [port1]->write(1);
    268         in_DECOD_PUSH [port1]->write(0);
    269         for (uint32_t i=0; i<_param->_nb_context; i++)
    270           for (uint32_t j=0; j< _param->_size_queue[i]; j++)
    271             {
    272               in_DECOD_CONTEXT_ID   [port1]->write(i);
    273               in_DECOD_ADDRESS_PUSH [port1]->write(0xbabedead);
    274              
    275               SC_START(0);
    276              
    277               TEST(Tcontrol_t, out_DECOD_ACK        [port1]->read(), 1);
    278               TEST(Tcontrol_t, out_DECOD_HIT        [port1]->read(), 1);
    279               uint32_t k=(_param->_size_queue[i]-j)%_param->_size_queue[i];
    280               TEST(Tptr_t    , out_DECOD_INDEX      [port1]->read(), k);
    281               TEST(Taddress_t, out_DECOD_ADDRESS_POP[port1]->read(),(0x21071981+((k==0)?(_param->_size_queue[i]-1):(k-1))));
    282              
    283               SC_START(1);
    284             }
    285         in_DECOD_VAL [port1]->write(0);
    286 
    287         LABEL("DECOD - with predict");
    288        
    289         LABEL("DECOD - PUSH (size_queue/2)"); 
    290        
    291         in_DECOD_VAL             [port1]->write(1);
    292         in_DECOD_PUSH            [port1]->write(1);
    293         in_DECOD_MISS_PREDICTION [port1]->write(1);
    294        
    295         for (uint32_t i=0; i<_param->_nb_context; i++)
    296           for (uint32_t j=0; j<_param->_size_queue[i]/2;j++)
    297             {
    298               in_DECOD_CONTEXT_ID   [port1]->write(i);
    299               in_DECOD_ADDRESS_PUSH [port1]->write(0x01234567+j);
    300              
    301               SC_START(0);
    302              
    303               TEST(Tcontrol_t, out_DECOD_ACK  [port1]->read(), 1);
    304               TEST(Tptr_t    , out_DECOD_INDEX[port1]->read(),(j+1)%_param->_size_queue[i]);
    305              
    306               SC_START(1);
    307              
    308             }
    309         in_DECOD_VAL [port1]->write(0);
    310 
    311         LABEL("PREDICT - PUSH (size_queue/2)"); 
    312        
    313         in_PREDICT_VAL             [port2]->write(1);
    314         in_PREDICT_PUSH            [port2]->write(1);
    315        
    316         for (uint32_t i=0; i<_param->_nb_context; i++)
    317           for (uint32_t j=0; j<_param->_size_queue[i]/2;j++)
    318             {
    319               in_PREDICT_CONTEXT_ID   [port2]->write(i);
    320               in_PREDICT_ADDRESS_PUSH [port2]->write((0x89abcdef+j)+(_param->_size_queue[i]/2));
    321              
    322               SC_START(0);
    323              
    324               TEST(Tcontrol_t, out_PREDICT_ACK  [port2]->read(), 1);
    325               TEST(Tptr_t    , out_PREDICT_INDEX[port2]->read(),(j+1+(_param->_size_queue[i]/2))%_param->_size_queue[i]);
    326              
    327               SC_START(1);
    328             }
    329 
    330         in_PREDICT_VAL [port2]->write(0);
    331 
    332         LABEL("PREDICT - POP (size_queue/2)"); 
    333 
    334         in_PREDICT_VAL  [port2]->write(1);
    335         in_PREDICT_PUSH [port2]->write(0);
    336         for (uint32_t i=0; i<_param->_nb_context; i++)
    337           {
    338             for (uint32_t j=0; j< _param->_size_queue[i]/2; j++)
    339               {
    340                 in_PREDICT_CONTEXT_ID   [port2]->write(i);
    341                 in_PREDICT_ADDRESS_PUSH [port2]->write(0xbabedead);
    342                
    343                 SC_START(0);
    344                
    345                 TEST(Tcontrol_t, out_PREDICT_ACK        [port2]->read(), 1);
    346                 TEST(Tcontrol_t, out_PREDICT_HIT        [port2]->read(), 1);
    347                 uint32_t k=  (_param->_size_queue[i]-j)%_param->_size_queue[i];
    348                 TEST(Tptr_t    , out_PREDICT_INDEX      [port2]->read(), k);
    349 
    350                 Taddress_t res = (0x89abcdef+((k==0)?(_param->_size_queue[i]-1):(k-1)));
    351                 LABEL("k      : %d",k);
    352                 LABEL("res    : %x",res);
    353                 LABEL("@_pop  : %x",out_PREDICT_ADDRESS_POP[port2]->read());
    354 
    355                 TEST(Taddress_t, out_PREDICT_ADDRESS_POP[port2]->read(),res);
    356                
    357                 SC_START(1);
    358               }
    359 
    360             for (uint32_t j=0; j< _param->_size_queue[i]/2; j++)
    361               {
    362                 in_PREDICT_CONTEXT_ID   [port2]->write(i);
    363                 in_PREDICT_ADDRESS_PUSH [port2]->write(0xbabedead);
    364                
    365                 SC_START(0);
    366                
    367                 TEST(Tcontrol_t, out_PREDICT_ACK        [port2]->read(), 1);
    368                 TEST(Tcontrol_t, out_PREDICT_HIT        [port2]->read(), 1);
    369                 uint32_t k=(_param->_size_queue[i]/2-j)%_param->_size_queue[i];
    370                 TEST(Tptr_t    , out_PREDICT_INDEX      [port2]->read(), k);
    371 
    372                 Taddress_t res = (0x01234567+((k==0)?(_param->_size_queue[i]/2-1):(k-1)));
    373 
    374                 LABEL("k      : %d",k);
    375                 LABEL("res    : %x",res);
    376                 LABEL("@_pop  : %x",out_PREDICT_ADDRESS_POP[port2]->read());
    377 
    378                 TEST(Taddress_t, out_PREDICT_ADDRESS_POP[port2]->read(),res);
    379                
    380                 SC_START(1);
    381               }
    382           }
    383 
    384         in_PREDICT_VAL [port2]->write(0);
    385 
    386         in_DECOD_VAL  [port1]->write(1);
    387         in_DECOD_PUSH [port1]->write(0);
    388         in_DECOD_MISS_PREDICTION [port1]->write(0);
    389 
    390         for (uint32_t i=0; i<_param->_nb_context; i++)
    391           {
    392             for (uint32_t j=0; j< _param->_size_queue[i]/2; j++)
    393               {
    394                 in_DECOD_CONTEXT_ID   [port1]->write(i);
    395                 in_DECOD_ADDRESS_PUSH [port1]->write(0xbabedead);
    396                
    397                 SC_START(0);
    398                
    399                 TEST(Tcontrol_t, out_DECOD_ACK        [port1]->read(), 1);
    400                 TEST(Tcontrol_t, out_DECOD_HIT        [port1]->read(), 1);
    401                 uint32_t k=(_param->_size_queue[i]/2-j)%_param->_size_queue[i];
    402                 TEST(Tptr_t    , out_DECOD_INDEX      [port1]->read(), k);
    403 
    404                 Taddress_t res = (0x01234567+((k==0)?(_param->_size_queue[i]/2-1):(k-1)));
    405 
    406                 LABEL("k      : %d",k);
    407                 LABEL("res    : %x",res);
    408                 LABEL("@_pop  : %x",out_DECOD_ADDRESS_POP[port1]->read());
    409 
    410                 TEST(Taddress_t, out_DECOD_ADDRESS_POP[port1]->read(),res);
    411                
    412                 SC_START(1);
    413               }
    414           }
    415 
    416         in_DECOD_VAL [port1]->write(0);
     249          SC_START(1);
     250         
     251          in_DECOD_VAL  [port]->write(1);
     252          in_DECOD_PUSH [port]->write(1);
     253          for (uint32_t i=0; i<_param->_nb_context; i++)
     254            for (uint32_t j=0; j<_param->_size_queue[i]; j++)
     255              {
     256                in_DECOD_CONTEXT_ID   [port]->write(i);
     257                in_DECOD_ADDRESS_PUSH [port]->write(0x21071981+j);
     258               
     259                SC_START(0);
     260               
     261                TEST(Tcontrol_t, out_DECOD_ACK        [port]->read(), 1);
     262                TEST(Tptr_t    , out_DECOD_INDEX      [port]->read(),(j+1)%_param->_size_queue[i]);
     263                TEST(Taddress_t, out_DECOD_ADDRESS_POP[port]->read(),0xbeefcaca+j);
     264               
     265                SC_START(1);
     266              }
     267          in_DECOD_VAL [port]->write(0);
     268         
     269          LABEL("DECOD - POP");
     270         
     271          in_DECOD_VAL  [port]->write(1);
     272          in_DECOD_PUSH [port]->write(0);
     273          for (uint32_t i=0; i<_param->_nb_context; i++)
     274            for (uint32_t j=0; j< _param->_size_queue[i]; j++)
     275              {
     276                in_DECOD_CONTEXT_ID   [port]->write(i);
     277                in_DECOD_ADDRESS_PUSH [port]->write(0xbabedead);
     278               
     279                SC_START(0);
     280               
     281                TEST(Tcontrol_t, out_DECOD_ACK        [port]->read(), 1);
     282                TEST(Tcontrol_t, out_DECOD_HIT        [port]->read(), 1);
     283                uint32_t k=(_param->_size_queue[i]-j)%_param->_size_queue[i];
     284                TEST(Tptr_t    , out_DECOD_INDEX      [port]->read(), k);
     285                TEST(Taddress_t, out_DECOD_ADDRESS_POP[port]->read(),(0x21071981+((k==0)?(_param->_size_queue[i]-1):(k-1))));
     286               
     287                SC_START(1);
     288              }
     289          in_DECOD_VAL [port]->write(0);
     290          // Now, the stack is empty
     291        }
     292
     293      if (test3)
     294        {
     295          uint32_t port1 = rand()%_param->_nb_inst_predict;
     296          uint32_t port2 = rand()%_param->_nb_inst_decod;
     297          uint32_t port3 = rand()%_param->_nb_inst_update;
     298
     299          LABEL("Test UPDATE");
     300
     301          LABEL("Predict");
     302          in_PREDICT_VAL  [port1]->write(1);
     303          in_PREDICT_PUSH [port1]->write(1);
     304          for (uint32_t i=0; i<_param->_nb_context; i++)
     305            for (uint32_t j=0; j<_param->_size_queue[i]; j++)
     306              {
     307                in_PREDICT_CONTEXT_ID   [port1]->write(i);
     308                in_PREDICT_ADDRESS_PUSH [port1]->write(0x25071959+j);
     309               
     310                SC_START(0);
     311               
     312                TEST(Tcontrol_t, out_PREDICT_ACK        [port1]->read(), 1);
     313                TEST(Tptr_t    , out_PREDICT_INDEX      [port1]->read(),(j+1)%_param->_size_queue[i]);
     314//              TEST(Taddress_t, out_PREDICT_ADDRESS_POP[port1]->read(),0xdeadbeef+j);
     315               
     316                SC_START(1);
     317              }
     318          in_PREDICT_VAL [port1]->write(0);
     319
     320          LABEL("Decod");
     321          in_DECOD_VAL  [port2]->write(1);
     322          in_DECOD_PUSH [port2]->write(1);
     323          for (uint32_t i=0; i<_param->_nb_context; i++)
     324            for (uint32_t j=0; j<_param->_size_queue[i]/2; j++)
     325              {
     326                in_DECOD_CONTEXT_ID      [port2]->write(i);
     327                in_DECOD_ADDRESS_PUSH    [port2]->write(0x25071959+j);
     328                in_DECOD_MISS_PREDICTION [port2]->write(0);
     329               
     330                SC_START(0);
     331               
     332                TEST(Tcontrol_t, out_DECOD_ACK        [port2]->read(), 1);
     333                TEST(Tptr_t    , out_DECOD_INDEX      [port2]->read(),(j+1)%_param->_size_queue[i]);
     334                TEST(Taddress_t, out_DECOD_ADDRESS_POP[port2]->read(),0x25071959+j);
     335               
     336                SC_START(1);
     337              }
     338          in_DECOD_VAL [port2]->write(0);
     339
     340          LABEL("Update Decod OK");
     341          in_UPDATE_VAL  [port3]->write(1);
     342          in_UPDATE_PUSH [port3]->write(1);
     343          in_UPDATE_FLUSH[port3]->write(0);
     344          for (uint32_t i=0; i<_param->_nb_context; i++)
     345            for (uint32_t j=0; j<_param->_size_queue[i]/2; j++)
     346              {
     347                uint32_t x=(_param->_size_queue[i]/2)-1;
     348                in_UPDATE_CONTEXT_ID        [port3]->write(i);
     349                in_UPDATE_MISS_PREDICTION   [port3]->write(0);
     350                in_UPDATE_PREDICTION_IFETCH [port3]->write(0);
     351                in_UPDATE_INDEX             [port3]->write((x+1)%_param->_size_queue[i]);
     352                in_UPDATE_ADDRESS           [port3]->write(0x25071959+x);
     353               
     354                SC_START(0);
     355               
     356                TEST(Tcontrol_t, out_UPDATE_ACK        [port3]->read(), 1);
     357               
     358                SC_START(1);
     359              }
     360          in_UPDATE_VAL [port3]->write(0);
     361
     362          LABEL("Update FLUSH");
     363          in_UPDATE_VAL  [port3]->write(1);
     364          in_UPDATE_FLUSH[port3]->write(1);
     365          for (uint32_t i=0; i<_param->_nb_context; i++)
     366            for (uint32_t j=0; j<_param->_size_queue[i]/2; j++)
     367              {
     368                in_UPDATE_CONTEXT_ID        [port3]->write(i);
     369                SC_START(1);
     370                TEST(Tcontrol_t, out_UPDATE_ACK        [port3]->read(), 1);
     371              }
     372          in_UPDATE_VAL [port3]->write(0);
     373
     374
     375// Tcontrol_t, in_UPDATE_VAL               
     376// Tcontrol_t,out_UPDATE_ACK               
     377// Tcontext_t, in_UPDATE_CONTEXT_ID       
     378// Tcontrol_t, in_UPDATE_PUSH             
     379// Tcontrol_t, in_UPDATE_FLUSH             
     380// Tptr_t    , in_UPDATE_INDEX             
     381// Taddress_t, in_UPDATE_ADDRESS           
     382// Tcontrol_t, in_UPDATE_MISS_PREDICTION   
     383// Tcontrol_t, in_UPDATE_PREDICTION_IFETCH
     384
     385
     386        }
     387
     388      if (test4)
     389        {
     390          uint32_t port1 = rand()%_param->_nb_inst_predict;
     391          uint32_t port2 = rand()%_param->_nb_inst_decod;
     392          uint32_t port3 = rand()%_param->_nb_inst_update;
     393
     394          LABEL("Test UPDATE");
     395
     396          LABEL("Predict");
     397          in_PREDICT_VAL  [port1]->write(1);
     398          in_PREDICT_PUSH [port1]->write(1);
     399          for (uint32_t i=0; i<_param->_nb_context; i++)
     400            for (uint32_t j=0; j<_param->_size_queue[i]; j++)
     401              {
     402                in_PREDICT_CONTEXT_ID   [port1]->write(i);
     403                in_PREDICT_ADDRESS_PUSH [port1]->write(0x14011959+j);
     404               
     405                SC_START(0);
     406               
     407                TEST(Tcontrol_t, out_PREDICT_ACK        [port1]->read(), 1);
     408                TEST(Tptr_t    , out_PREDICT_INDEX      [port1]->read(),(j+1)%_param->_size_queue[i]);
     409//              TEST(Taddress_t, out_PREDICT_ADDRESS_POP[port1]->read(),0xdeadbeef+j);
     410               
     411                SC_START(1);
     412              }
     413          in_PREDICT_VAL [port1]->write(0);
     414
     415          LABEL("Decod");
     416          in_DECOD_VAL  [port2]->write(1);
     417          in_DECOD_PUSH [port2]->write(1);
     418          for (uint32_t i=0; i<_param->_nb_context; i++)
     419            for (uint32_t j=0; j<_param->_size_queue[i]/2; j++)
     420              {
     421                in_DECOD_CONTEXT_ID      [port2]->write(i);
     422                in_DECOD_ADDRESS_PUSH    [port2]->write(0x14011959+j);
     423                in_DECOD_MISS_PREDICTION [port2]->write(0);
     424               
     425                SC_START(0);
     426               
     427                TEST(Tcontrol_t, out_DECOD_ACK        [port2]->read(), 1);
     428                TEST(Tptr_t    , out_DECOD_INDEX      [port2]->read(),(j+1)%_param->_size_queue[i]);
     429                TEST(Taddress_t, out_DECOD_ADDRESS_POP[port2]->read(),0x14011959+j);
     430               
     431                SC_START(1);
     432              }
     433          in_DECOD_VAL [port2]->write(0);
     434
     435          LABEL("Update Decod KO");
     436          in_UPDATE_VAL  [port3]->write(1);
     437          in_UPDATE_PUSH [port3]->write(1);
     438          in_UPDATE_FLUSH[port3]->write(0);
     439          for (uint32_t i=0; i<_param->_nb_context; i++)
     440            for (uint32_t j=0; j<_param->_size_queue[i]/2; j++)
     441              {
     442                uint32_t x=(_param->_size_queue[i]/2);
     443                in_UPDATE_CONTEXT_ID        [port3]->write(i);
     444                in_UPDATE_MISS_PREDICTION   [port3]->write(1);
     445                in_UPDATE_PREDICTION_IFETCH [port3]->write(0);
     446                in_UPDATE_INDEX             [port3]->write((x-j)%_param->_size_queue[i]);
     447                in_UPDATE_ADDRESS           [port3]->write(0xffffffff+x);
     448               
     449                SC_START(0);
     450               
     451                TEST(Tcontrol_t, out_UPDATE_ACK        [port3]->read(), 1);
     452               
     453                SC_START(1);
     454              }
     455          in_UPDATE_VAL [port3]->write(0);
     456
     457          LABEL("Decod");
     458          in_DECOD_VAL  [port2]->write(1);
     459          in_DECOD_PUSH [port2]->write(1);
     460          for (uint32_t i=0; i<_param->_nb_context; i++)
     461            for (uint32_t j=0; j<_param->_size_queue[i]/2; j++)
     462              {
     463                in_DECOD_CONTEXT_ID      [port2]->write(i);
     464                in_DECOD_ADDRESS_PUSH    [port2]->write(0x14011959+j);
     465                in_DECOD_MISS_PREDICTION [port2]->write(0);
     466               
     467                SC_START(0);
     468               
     469                TEST(Tcontrol_t, out_DECOD_ACK        [port2]->read(), 1);
     470                TEST(Tptr_t    , out_DECOD_INDEX      [port2]->read(),(j+1)%_param->_size_queue[i]);
     471                TEST(Taddress_t, out_DECOD_ADDRESS_POP[port2]->read(),0x14011959+j);
     472               
     473                SC_START(1);
     474              }
     475          in_DECOD_VAL [port2]->write(0);
     476
     477
     478          LABEL("Update Decod KO");
     479          in_UPDATE_VAL  [port3]->write(1);
     480          in_UPDATE_PUSH [port3]->write(1);
     481          in_UPDATE_FLUSH[port3]->write(0);
     482          for (uint32_t i=0; i<_param->_nb_context; i++)
     483            for (uint32_t j=0; j<_param->_size_queue[i]/2; j++)
     484              {
     485                uint32_t x=(_param->_size_queue[i]/2);
     486                in_UPDATE_CONTEXT_ID        [port3]->write(i);
     487                in_UPDATE_MISS_PREDICTION   [port3]->write(1);
     488                in_UPDATE_PREDICTION_IFETCH [port3]->write(0);
     489                in_UPDATE_INDEX             [port3]->write((x-j)%_param->_size_queue[i]);
     490                in_UPDATE_ADDRESS           [port3]->write(0xffffffff+x);
     491               
     492                SC_START(0);
     493               
     494                TEST(Tcontrol_t, out_UPDATE_ACK        [port3]->read(), 1);
     495               
     496                SC_START(1);
     497              }
     498          in_UPDATE_VAL [port3]->write(0);
     499
     500          LABEL("Update Predict KO");
     501          in_UPDATE_VAL  [port3]->write(1);
     502          in_UPDATE_PUSH [port3]->write(1);
     503          in_UPDATE_FLUSH[port3]->write(0);
     504          for (uint32_t i=0; i<_param->_nb_context; i++)
     505            for (uint32_t j=0; j<_param->_size_queue[i]; j++)
     506              {
     507                uint32_t x=(_param->_size_queue[i]);
     508                in_UPDATE_CONTEXT_ID        [port3]->write(i);
     509                in_UPDATE_MISS_PREDICTION   [port3]->write(1);
     510                in_UPDATE_PREDICTION_IFETCH [port3]->write(1);
     511                in_UPDATE_INDEX             [port3]->write((x-j)%_param->_size_queue[i]);
     512                in_UPDATE_ADDRESS           [port3]->write(0xffffffff+x);
     513               
     514                SC_START(0);
     515               
     516                TEST(Tcontrol_t, out_UPDATE_ACK        [port3]->read(), 1);
     517               
     518                SC_START(1);
     519              }
     520          in_UPDATE_VAL [port3]->write(0);
     521
     522          LABEL("Predict");
     523          in_PREDICT_VAL  [port1]->write(1);
     524          in_PREDICT_PUSH [port1]->write(1);
     525          for (uint32_t i=0; i<_param->_nb_context; i++)
     526            for (uint32_t j=0; j<_param->_size_queue[i]; j++)
     527              {
     528                in_PREDICT_CONTEXT_ID   [port1]->write(i);
     529                in_PREDICT_ADDRESS_PUSH [port1]->write(0x14011959+j);
     530               
     531                SC_START(0);
     532               
     533                TEST(Tcontrol_t, out_PREDICT_ACK        [port1]->read(), 1);
     534                TEST(Tptr_t    , out_PREDICT_INDEX      [port1]->read(),(j+1)%_param->_size_queue[i]);
     535                TEST(Taddress_t, out_PREDICT_ADDRESS_POP[port1]->read(),0x14011959+j);
     536               
     537                SC_START(1);
     538              }
     539          in_PREDICT_VAL [port1]->write(0);
     540
     541          LABEL("Update Predict KO");
     542          in_UPDATE_VAL  [port3]->write(1);
     543          in_UPDATE_PUSH [port3]->write(0);
     544          in_UPDATE_FLUSH[port3]->write(0);
     545          for (uint32_t i=0; i<_param->_nb_context; i++)
     546            for (uint32_t j=0; j<_param->_size_queue[i]; j++)
     547              {
     548                uint32_t x=(_param->_size_queue[i]);
     549                in_UPDATE_CONTEXT_ID        [port3]->write(i);
     550                in_UPDATE_MISS_PREDICTION   [port3]->write(1);
     551                in_UPDATE_PREDICTION_IFETCH [port3]->write(1);
     552                in_UPDATE_INDEX             [port3]->write((x+j+1)%_param->_size_queue[i]);
     553                in_UPDATE_ADDRESS           [port3]->write(0x87654321+j);
     554               
     555                SC_START(0);
     556               
     557                TEST(Tcontrol_t, out_UPDATE_ACK        [port3]->read(), 1);
     558               
     559                SC_START(1);
     560              }
     561          in_UPDATE_VAL [port3]->write(0);
     562
     563          LABEL("Predict");
     564          in_PREDICT_VAL  [port1]->write(1);
     565          in_PREDICT_PUSH [port1]->write(1);
     566          for (uint32_t i=0; i<_param->_nb_context; i++)
     567            for (uint32_t j=0; j<_param->_size_queue[i]; j++)
     568              {
     569                in_PREDICT_CONTEXT_ID   [port1]->write(i);
     570                in_PREDICT_ADDRESS_PUSH [port1]->write(0x14011959+j);
     571               
     572                SC_START(0);
     573               
     574                TEST(Tcontrol_t, out_PREDICT_ACK        [port1]->read(), 1);
     575                TEST(Tptr_t    , out_PREDICT_INDEX      [port1]->read(),(j+1)%_param->_size_queue[i]);
     576                TEST(Taddress_t, out_PREDICT_ADDRESS_POP[port1]->read(),0x87654321+j);
     577               
     578                SC_START(1);
     579              }
     580          in_PREDICT_VAL [port1]->write(0);
     581
     582          LABEL("Update FLUSH");
     583          in_UPDATE_VAL  [port3]->write(1);
     584          in_UPDATE_FLUSH[port3]->write(1);
     585          for (uint32_t i=0; i<_param->_nb_context; i++)
     586            for (uint32_t j=0; j<_param->_size_queue[i]/2; j++)
     587              {
     588                in_UPDATE_CONTEXT_ID        [port3]->write(i);
     589                SC_START(1);
     590                TEST(Tcontrol_t, out_UPDATE_ACK        [port3]->read(), 1);
     591              }
     592          in_UPDATE_VAL [port3]->write(0);
    417593        }
    418594    }
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Return_Address_Stack/include/Return_Address_Stack.h

    r95 r100  
    8888  public    : SC_IN (Tcontext_t)           **  in_UPDATE_CONTEXT_ID       ; //[nb_inst_update]
    8989  public    : SC_IN (Tcontrol_t)           **  in_UPDATE_PUSH             ; //[nb_inst_update]  1 = push, else pop
    90   public    : SC_IN (Tcontrol_t)           **  in_UPDATE_FLUSH            ; //[nb_inst_update]  1 = push, else pop
     90  public    : SC_IN (Tcontrol_t)           **  in_UPDATE_FLUSH            ; //[nb_inst_update]
    9191  public    : SC_IN (Taddress_t)           **  in_UPDATE_ADDRESS          ; //[nb_inst_update]
    9292  public    : SC_IN (Tptr_t    )           **  in_UPDATE_INDEX            ; //[nb_inst_update]
     
    9999  private   : ras_entry_t                  ** reg_stack         ; //[nb_context][size_queue]
    100100  private   : Tptr_t                        * reg_TOP           ; //[nb_context]
    101   private   : Tptr_t                        * reg_BOTTOM        ; //[nb_context]
     101//private   : Tptr_t                        * reg_BOTTOM        ; //[nb_context]
    102102  private   : Tptr_t                        * reg_NB_ELT        ; //[nb_context]
    103103  private   : Tptr_t                        * reg_PREDICT_TOP   ; //[nb_context]
    104   private   : Tptr_t                        * reg_PREDICT_BOTTOM; //[nb_context]
     104//private   : Tptr_t                        * reg_PREDICT_BOTTOM; //[nb_context]
    105105  private   : Tptr_t                        * reg_PREDICT_NB_ELT; //[nb_context]
    106106
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Return_Address_Stack/include/Types.h

    r81 r100  
    2121  class ras_entry_t
    2222  {
    23   public : bool       _val    ;
    24   public : bool       _predict;
    25   public : bool       _miss   ;
     23//public : bool       _val    ;
     24//public : bool       _predict;
     25//public : bool       _miss   ;
    2626  public : Taddress_t _address;
    2727  };
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Return_Address_Stack/src/Return_Address_Stack_allocation.cpp

    r95 r100  
    107107
    108108    reg_TOP              = new Tptr_t     [_param->_nb_context];
    109     reg_BOTTOM           = new Tptr_t     [_param->_nb_context];
     109//  reg_BOTTOM           = new Tptr_t     [_param->_nb_context];
    110110    reg_NB_ELT           = new Tptr_t     [_param->_nb_context];
    111111
    112112    reg_PREDICT_TOP      = new Tptr_t     [_param->_nb_context];
    113     reg_PREDICT_BOTTOM   = new Tptr_t     [_param->_nb_context];
     113//  reg_PREDICT_BOTTOM   = new Tptr_t     [_param->_nb_context];
    114114    reg_PREDICT_NB_ELT   = new Tptr_t     [_param->_nb_context];
    115115
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Return_Address_Stack/src/Return_Address_Stack_deallocation.cpp

    r95 r100  
    6464        delete [] reg_stack;
    6565        delete [] reg_TOP;
    66         delete [] reg_BOTTOM;
     66//      delete [] reg_BOTTOM;
    6767        delete [] reg_NB_ELT;
    6868        delete [] reg_PREDICT_TOP;
    69         delete [] reg_PREDICT_BOTTOM;
     69//      delete [] reg_PREDICT_BOTTOM;
    7070        delete [] reg_PREDICT_NB_ELT;
    7171       
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Return_Address_Stack/src/Return_Address_Stack_genMealy_decod.cpp

    r81 r100  
    2222  void Return_Address_Stack::genMealy_decod (void)
    2323  {
    24     log_printf(FUNC,Return_Address_Stack,FUNCTION,"Begin");
     24    log_begin(Return_Address_Stack,FUNCTION);
     25    log_function(Return_Address_Stack,FUNCTION,_name.c_str());
    2526
    2627#ifdef DEBUG_TEST
     28    // just to test if have many transaction on a same context
    2729    bool context_valid [_param->_nb_context];
    2830    for (uint32_t i=0; i<_param->_nb_context; i++)
     
    3234    for (uint32_t i=0; i<_param->_nb_inst_decod; i++)
    3335      {
     36        // Read context number
    3437        Tcontext_t context = (_param->_have_port_context_id)?PORT_READ(in_DECOD_CONTEXT_ID [i]):0;
    3538
     
    4952        // if pop  : val and not miss
    5053        //   when the predictor : if hit = 0, wait (is not accurate)
    51         internal_DECOD_HIT [i] = (push or (reg_stack[context][top]._val and not reg_stack[context][top]._miss and (reg_NB_ELT[context]>0)));
     54        internal_DECOD_HIT [i] = (push or (reg_NB_ELT[context]>0));
    5255        PORT_WRITE(out_DECOD_HIT         [i], internal_DECOD_HIT [i]);
    5356
     
    6164      }
    6265
    63     log_printf(FUNC,Return_Address_Stack,FUNCTION,"End");
     66    log_end(Return_Address_Stack,FUNCTION);
    6467  };
    6568
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Return_Address_Stack/src/Return_Address_Stack_genMealy_predict.cpp

    r81 r100  
    2222  void Return_Address_Stack::genMealy_predict (void)
    2323  {
    24     log_printf(FUNC,Return_Address_Stack,FUNCTION,"Begin");
     24    log_begin(Return_Address_Stack,FUNCTION);
     25    log_function(Return_Address_Stack,FUNCTION,_name.c_str());
    2526
    2627#ifdef DEBUG_TEST
     28    // just to test if have many transaction on a same context
    2729    bool context_valid [_param->_nb_context];
    2830    for (uint32_t i=0; i<_param->_nb_context; i++)
     
    3234    for (uint32_t i=0; i<_param->_nb_inst_predict; i++)
    3335      {
     36        // Read context number
    3437        Tcontext_t context = (_param->_have_port_context_id)?PORT_READ(in_PREDICT_CONTEXT_ID [i]):0;
    35 
     38       
    3639#ifdef DEBUG_TEST
    3740        if (PORT_READ(in_PREDICT_VAL [i]))
     
    4245          }
    4346#endif
    44 
     47       
     48        // Get top
    4549        Tptr_t     top  = reg_PREDICT_TOP[context];
    4650        Tcontrol_t push = PORT_READ(in_PREDICT_PUSH [i]);
    4751
    48         // if push : value is hit
    49         // if pop  : val and not miss
    50         internal_PREDICT_HIT [i] = (push or (reg_stack[context][top]._val and not reg_stack[context][top]._miss and (reg_PREDICT_NB_ELT[context]>0)));
     52        // Hit :
     53        //   * if push : value is hit
     54        //   * if pop  : no empty
     55        internal_PREDICT_HIT [i] = (push or (reg_PREDICT_NB_ELT[context]>0));
     56
    5157        PORT_WRITE(out_PREDICT_HIT         [i], internal_PREDICT_HIT [i]);
    5258
    5359        // if pop  : address_pop   = stack [top]
    54         // if push : stock [top+1] = address_push; also stock [top+1] is erase ! give the old value at the update table
     60        // if push : stock [top+1] = address_push; also stack [top+1] is erase ! save the old value in the update table
    5561        if (push)
    5662          top = (top+1)%_param->_size_queue[context];
     
    6066      }
    6167
    62     log_printf(FUNC,Return_Address_Stack,FUNCTION,"End");
     68    log_end(Return_Address_Stack,FUNCTION);
    6369  };
    6470
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Return_Address_Stack/src/Return_Address_Stack_transition.cpp

    r95 r100  
    2222  void Return_Address_Stack::transition (void)
    2323  {
    24     log_printf(FUNC,Return_Address_Stack,FUNCTION,"Begin");
     24    log_begin(Return_Address_Stack,FUNCTION);
     25    log_function(Return_Address_Stack,FUNCTION,_name.c_str());
    2526
    2627    if (PORT_READ(in_NRESET)==0)
    2728      {
     29        // Reset all structure
    2830        for (uint32_t i=0; i<_param->_nb_context; i++)
    2931          {
    3032            reg_TOP    [i] = 0;
    31             reg_BOTTOM [i] = 0;
     33//          reg_BOTTOM [i] = 0;
    3234            reg_NB_ELT [i] = 0;
    3335
    3436            reg_PREDICT_TOP    [i] = 0;
    35             reg_PREDICT_BOTTOM [i] = 0;
     37//          reg_PREDICT_BOTTOM [i] = 0;
    3638            reg_PREDICT_NB_ELT [i] = 0;
    37 
    38             for (uint32_t j=0; j<_param->_size_queue [i]; j++)
    39               {
    40                 reg_stack[i][j]._val     = false;
    41                 reg_stack[i][j]._predict = false;
    42                 reg_stack[i][j]._miss    = false;
    43               }
    4439          }
    4540      }
     
    5247          if (PORT_READ(in_PREDICT_VAL [i]) and internal_PREDICT_ACK [i])
    5348            {
    54               log_printf(TRACE,Return_Address_Stack,FUNCTION,"PREDICT[%d] : Transaction",i);
     49              log_printf(TRACE,Return_Address_Stack,FUNCTION,"  * PREDICT [%d] : Transaction",i);
     50             
     51              // Read information and pointer
    5552              Tcontext_t context    = (_param->_have_port_context_id)?PORT_READ(in_PREDICT_CONTEXT_ID [i]):0;
    5653              Tcontrol_t push       = PORT_READ(in_PREDICT_PUSH [i]);
     54
    5755              Tptr_t     top_old    = reg_PREDICT_TOP    [context];
    5856              Tptr_t     top_new    = top_old;
    59               Tptr_t     bottom_old = reg_PREDICT_BOTTOM [context];
    60 
    61               log_printf(TRACE,Return_Address_Stack,FUNCTION," * context : %d",context);
    62 
    63               // Hit  : push or (val and not miss and not empty)
     57//            Tptr_t     bottom_old = reg_PREDICT_BOTTOM [context];
     58//            Tptr_t     bottom_new = bottom_old;
     59              Tptr_t     nb_elt_old = reg_PREDICT_NB_ELT [context];
     60              Tptr_t     nb_elt_new = nb_elt_old;
     61
     62              log_printf(TRACE,Return_Address_Stack,FUNCTION,"    * context : %d",context);
     63
     64              // Hit  : push or not empty
    6465              // Miss : ifetch is stall, no update
     66
     67              // Test if hit
    6568              if (internal_PREDICT_HIT [i])
    6669                {
    67                   log_printf(TRACE,Return_Address_Stack,FUNCTION," * before");
    68                   log_printf(TRACE,Return_Address_Stack,FUNCTION,"   * reg_predict_top     : %d",reg_PREDICT_TOP    [context]);
    69                   log_printf(TRACE,Return_Address_Stack,FUNCTION,"   * reg_predict_bottom  : %d",reg_PREDICT_BOTTOM [context]);
    70                   log_printf(TRACE,Return_Address_Stack,FUNCTION,"   * reg_predict_nb_elt  : %d",reg_PREDICT_NB_ELT [context]);
    71 
     70                  log_printf(TRACE,Return_Address_Stack,FUNCTION,"    * before");
     71                  log_printf(TRACE,Return_Address_Stack,FUNCTION,"      * reg_predict_top     : %d",top_old);
     72//                log_printf(TRACE,Return_Address_Stack,FUNCTION,"      * reg_predict_bottom  : %d",bottom_old);
     73                  log_printf(TRACE,Return_Address_Stack,FUNCTION,"      * reg_predict_nb_elt  : %d",nb_elt_old);
     74
     75                  // Test if push
    7276                  if (push)
    7377                    {
     78                      log_printf(TRACE,Return_Address_Stack,FUNCTION,"    * push (call procedure)");
     79
    7480                      // push : increase the top (circular)
    7581                      top_new = (top_old+1)%_param->_size_queue[context];
    76                      
    77                       reg_stack [context][top_new]._val     = true; // New addr
    78                       reg_stack [context][top_new]._predict = true; // Is speculative (erase a old addr (or not))
    79                     //reg_stack [context][top_new]._miss    = ;
     82
     83                      // Write new value in Queue
    8084                      reg_stack [context][top_new]._address = PORT_READ(in_PREDICT_ADDRESS_PUSH [i]);
    8185
    82                       // the stack is full, erase the most old stack
    83 
    8486                      // Test if full
    85                       if (reg_PREDICT_NB_ELT[context]==_param->_size_queue[context])
    86                         reg_PREDICT_BOTTOM [context] = (bottom_old+1)%_param->_size_queue[context];
    87                       // A new data is write : the stack is not empty
    88                       if (reg_PREDICT_NB_ELT[context]< _param->_size_queue[context])
    89                         reg_PREDICT_NB_ELT[context]++;
     87                      //   -> is full, the push erase the oldest value in stack, also nb_elt is the same
     88                      //   -> is not full, increase nb_elt
     89//                    if (nb_elt_old==_param->_size_queue[context])
     90//                      bottom_new = (bottom_old+1)%_param->_size_queue[context];
     91//                       else
     92//                      nb_elt_new ++;
     93                      if (nb_elt_old!=_param->_size_queue[context])
     94                        nb_elt_new ++;
    9095                    }
    9196                  else
    9297                    {
    9398                      // pop
    94 //                    top_new = (top_old==0)?(_param->_size_queue[context]-1):(top_old-1);
    95                      
    96                     //reg_stack [context][top_new]._val     = ;
    97                     //reg_stack [context][top_new]._predict = ;
    98                     //reg_stack [context][top_new]._miss    = ;
    99                     //reg_stack [context][top_new]._address = ;
    100 
    101                       // the stack is empty
    102                       if (reg_PREDICT_NB_ELT[context]>0)
     99                      log_printf(TRACE,Return_Address_Stack,FUNCTION,"    * pop (return procedure)");
     100
     101                      // Test if the stack is empty
     102                      if (nb_elt_old>0)
    103103                        {
    104104                          top_new = (top_old==0)?(_param->_size_queue[context]-1):(top_old-1);
    105                           reg_PREDICT_NB_ELT[context] --;
     105                          nb_elt_new --;
    106106                        }
     107                      // no else : can't pop
    107108                    }
    108109                 
    109                   reg_PREDICT_TOP [context] = top_new;
    110 
    111                   log_printf(TRACE,Return_Address_Stack,FUNCTION," * after");
    112                   log_printf(TRACE,Return_Address_Stack,FUNCTION,"   * reg_predict_top     : %d",reg_PREDICT_TOP    [context]);
    113                   log_printf(TRACE,Return_Address_Stack,FUNCTION,"   * reg_predict_bottom  : %d",reg_PREDICT_BOTTOM [context]);
    114                   log_printf(TRACE,Return_Address_Stack,FUNCTION,"   * reg_predict_nb_elt  : %d",reg_PREDICT_NB_ELT [context]);
    115                 }
    116             }
     110                  // Write new pointer
     111                  reg_PREDICT_TOP    [context] = top_new;
     112//                reg_PREDICT_BOTTOM [context] = bottom_new;
     113                  reg_PREDICT_NB_ELT [context] = nb_elt_new;
     114
     115                  log_printf(TRACE,Return_Address_Stack,FUNCTION,"    * after");
     116                  log_printf(TRACE,Return_Address_Stack,FUNCTION,"      * reg_predict_top     : %d",top_new);
     117//                log_printf(TRACE,Return_Address_Stack,FUNCTION,"      * reg_predict_bottom  : %d",bottom_new);
     118                  log_printf(TRACE,Return_Address_Stack,FUNCTION,"      * reg_predict_nb_elt  : %d",nb_elt_new);
     119                }
     120            }
    117121
    118122        // ===================================================================
     
    122126          if (PORT_READ(in_DECOD_VAL [i]) and internal_DECOD_ACK [i])
    123127            {
    124               log_printf(TRACE,Return_Address_Stack,FUNCTION,"DECOD[%d] : Transaction",i);
     128              log_printf(TRACE,Return_Address_Stack,FUNCTION,"  * DECOD [%d] : Transaction",i);
     129
     130              // Read information
    125131              Tcontext_t context    = (_param->_have_port_context_id)?PORT_READ(in_DECOD_CONTEXT_ID [i]):0;
    126132              Tcontrol_t push       = PORT_READ(in_DECOD_PUSH [i]);
     133
     134              // Read pointer
    127135              Tptr_t     top_old    = reg_TOP    [context];
    128136              Tptr_t     top_new    = top_old;
    129               Tptr_t     bottom_old = reg_BOTTOM [context];
    130               //Tcontrol_t hit        = internal_DECOD_HIT [i];
    131               Tcontrol_t miss       = PORT_READ(in_DECOD_MISS_PREDICTION [i]);
    132 
    133               log_printf(TRACE,Return_Address_Stack,FUNCTION," * context : %d",context);
    134 
    135               log_printf(TRACE,Return_Address_Stack,FUNCTION," * before");
    136               log_printf(TRACE,Return_Address_Stack,FUNCTION,"   * reg_top     : %d",reg_TOP    [context]);
    137               log_printf(TRACE,Return_Address_Stack,FUNCTION,"   * reg_bottom  : %d",reg_BOTTOM [context]);
    138               log_printf(TRACE,Return_Address_Stack,FUNCTION,"   * reg_nb_elt  : %d",reg_NB_ELT [context]);
    139 
    140               if (push)
    141                 {
    142                   // push : increase the top (circular)
    143                   top_new = (top_old+1)%_param->_size_queue[context];
    144                  
    145                   reg_stack [context][top_new]._val     = true;  // New address
    146                   reg_stack [context][top_new]._predict = false; // No speculative
    147                   reg_stack [context][top_new]._miss    = false;
    148                   reg_stack [context][top_new]._address = PORT_READ(in_DECOD_ADDRESS_PUSH [i]);
    149                  
    150                   // Test if full : if true, then icrease the bottom (erase the most old stack)
    151                   if (reg_NB_ELT[context]==_param->_size_queue[context])
    152                     reg_BOTTOM [context] = (bottom_old+1)%_param->_size_queue[context];
    153                   // A new data is write : the stack is not empty
    154                   if (reg_NB_ELT[context]< _param->_size_queue[context])
    155                     reg_NB_ELT[context]++;
    156                 }
    157               else
    158                 {
    159                   // pop
    160 //                top_new = (top_old==0)?(_param->_size_queue[context]-1):(top_old-1);
    161 
    162                   //reg_stack [context][top_new]._val     = ;
    163                   //reg_stack [context][top_new]._predict = ;
    164                   //reg_stack [context][top_new]._miss    = ;
    165                   //reg_stack [context][top_new]._address = ;
    166                  
    167                   // the stack is empty
    168                   if (reg_NB_ELT[context]>0)
    169                     {
    170                       top_new = (top_old==0)?(_param->_size_queue[context]-1):(top_old-1);
    171                       reg_NB_ELT[context] --;
    172                     }
    173                 }
    174              
    175               reg_TOP [context] = top_new;
    176              
    177               log_printf(TRACE,Return_Address_Stack,FUNCTION," * after");
    178               log_printf(TRACE,Return_Address_Stack,FUNCTION,"   * reg_top     : %d",reg_TOP    [context]);
    179               log_printf(TRACE,Return_Address_Stack,FUNCTION,"   * reg_bottom  : %d",reg_BOTTOM [context]);
    180               log_printf(TRACE,Return_Address_Stack,FUNCTION,"   * reg_nb_elt  : %d",reg_NB_ELT [context]);
    181 
     137//            Tptr_t     bottom_old = reg_BOTTOM [context];
     138//            Tptr_t     bottom_new = bottom_old;
     139              Tptr_t     nb_elt_old = reg_NB_ELT [context];
     140              Tptr_t     nb_elt_new = nb_elt_old;
     141
     142              log_printf(TRACE,Return_Address_Stack,FUNCTION,"    * context : %d",context);
     143
     144              log_printf(TRACE,Return_Address_Stack,FUNCTION,"    * before");
     145              log_printf(TRACE,Return_Address_Stack,FUNCTION,"      * reg_predict_top     : %d",top_old);
     146//            log_printf(TRACE,Return_Address_Stack,FUNCTION,"      * reg_predict_bottom  : %d",bottom_old);
     147              log_printf(TRACE,Return_Address_Stack,FUNCTION,"      * reg_predict_nb_elt  : %d",nb_elt_old);
     148
     149              // Test if push
     150              if (push)
     151                {
     152                  log_printf(TRACE,Return_Address_Stack,FUNCTION,"    * push (call procedure)");
     153                 
     154                  // push : increase the top (circular)
     155                  top_new = (top_old+1)%_param->_size_queue[context];
     156                 
     157                  // Write new value in Queue
     158                  reg_stack [context][top_new]._address = PORT_READ(in_DECOD_ADDRESS_PUSH [i]);
     159                 
     160                  // Test if full
     161                  //   -> is full, the push erase the oldest value in stack, also nb_elt is the same
     162                  //   -> is not full, increase nb_elt
     163//                   if (nb_elt_old==_param->_size_queue[context])
     164//                     bottom_new = (bottom_old+1)%_param->_size_queue[context];
     165//                   else
     166//                     nb_elt_new ++;
     167                  if (nb_elt_old!=_param->_size_queue[context])
     168                    nb_elt_new ++;
     169                }
     170              else
     171                {
     172                  // pop
     173                  log_printf(TRACE,Return_Address_Stack,FUNCTION,"    * pop (return procedure)");
     174                 
     175                  // Test if the stack is empty
     176                  if (nb_elt_old>0)
     177                    {
     178                      top_new = (top_old==0)?(_param->_size_queue[context]-1):(top_old-1);
     179                      nb_elt_new --;
     180                    }
     181                  // no else : can't pop
     182                }
     183             
     184              // Write new pointer
     185              reg_TOP    [context] = top_new;
     186//            reg_BOTTOM [context] = bottom_new;
     187              reg_NB_ELT [context] = nb_elt_new;
     188             
     189              log_printf(TRACE,Return_Address_Stack,FUNCTION,"    * after");
     190              log_printf(TRACE,Return_Address_Stack,FUNCTION,"      * reg_predict_top     : %d",top_new);
     191//            log_printf(TRACE,Return_Address_Stack,FUNCTION,"      * reg_predict_bottom  : %d",bottom_new);
     192              log_printf(TRACE,Return_Address_Stack,FUNCTION,"      * reg_predict_nb_elt  : %d",nb_elt_new);
     193             
    182194              // have previous miss of ifetch ?
    183195              // 2 miss :
    184196              //   1) miss predict : is very limited (local at context), can be update very quickly
    185197              //   2) miss decod   : result is in commit stage ...
    186               if (miss)
    187                 {
    188                   reg_PREDICT_BOTTOM [context] = reg_BOTTOM [context];
    189                   reg_PREDICT_TOP    [context] = reg_TOP    [context];
    190                   reg_PREDICT_NB_ELT [context] = reg_NB_ELT [context];
     198
     199              // manage by Update_Fetch_Prediction_Table and Update_Prediction_Table
     200              // Note :
     201              //   if decod miss : ifetch can have predict call and return branchement. Also, the head of decod can be false
     202
     203//            Tcontrol_t miss       = PORT_READ(in_DECOD_MISS_PREDICTION [i]);
     204
     205//            if (miss)
     206//              {
     207//                reg_PREDICT_BOTTOM [context] = reg_BOTTOM [context];
     208//                reg_PREDICT_TOP    [context] = reg_TOP    [context];
     209//                reg_PREDICT_NB_ELT [context] = reg_NB_ELT [context];
    191210                 
    192                   // Scan full assoc !!!
    193                   for (uint32_t j=0; j<_param->_size_queue [context]; j++)
    194                     // Test if this slot is tagged with "predict" : if true, tagged as miss
    195                     if (reg_stack [context][j]._predict)
    196                       {
    197                         reg_stack [context][j]._predict = false;
    198                         reg_stack [context][j]._miss    = true;
    199                       }
    200                 }
     211//                // Scan full assoc !!!
     212//                for (uint32_t j=0; j<_param->_size_queue [context]; j++)
     213//                  // Test if this slot is tagged with "predict" : if true, tagged as miss
     214//                  if (reg_stack [context][j]._predict)
     215//                    {
     216//                      reg_stack [context][j]._predict = false;
     217//                      reg_stack [context][j]._miss    = true;
     218//                    }
     219//              }
    201220            }
    202221
     
    207226          if (PORT_READ(in_UPDATE_VAL [i]) and internal_UPDATE_ACK [i])
    208227            {
    209               throw ERRORMORPHEO(FUNCTION,"Fonction à implémenter !!!!!!!!!!!!");
    210              
    211 
    212 //            Tcontrol_t miss   = PORT_READ(in_UPDATE_MISS_PREDICTION [i]);
    213 //            //
    214 //            if (miss)
    215 //              {
    216 //                Tcontrol_t context = (_param->_have_port_context_id)?PORT_READ(in_UPDATE_CONTEXT_ID [i]):0;
    217 //                Tcontrol_t ifetch  = PORT_READ(in_UPDATE_PREDICTION_IFETCH [i]);
    218 //                Tcontrol_t push    = PORT_READ(in_UPDATE_PUSH             [i]);
    219 //                Tcontrol_t flush   = PORT_READ(in_UPDATE_FLUSH            [i]);
    220 //                Tptr_t     index   = PORT_READ(in_UPDATE_INDEX            [i]);
    221 //                Taddress_t address = PORT_READ(in_UPDATE_ADDRESS          [i]);
    222                  
    223 //                if (push)
    224 //                  {
    225 // //                 // push
    226 // //                 top_new = (top_old+1)%_param->_size_queue[context];
    227                      
    228 // //                 reg_stack [context][index]._val     = true;
    229 // //                 reg_stack [context][index]._predict = false;
    230 // //                 reg_stack [context][index]._miss    = false;
    231 // //                 reg_stack [context][index]._address = PORT_READ(in_UPDATE_ADDRESS [i]);
    232 
    233 //                  }
    234 //                else
    235 //                  {
    236 // //               //reg_stack [context][top_new]._val     = ;
    237 // //               //reg_stack [context][top_new]._predict = ;
    238 // //               //reg_stack [context][top_new]._miss    = ;
    239 // //               //reg_stack [context][top_new]._address = ;
    240 //                  }
    241                  
    242 // // //                  // Mouais bof .......
    243 // // //                  reg_PREDICT_TOP [context] = index;
    244 //              }
     228              log_printf(TRACE,Return_Address_Stack,FUNCTION,"  * UPDATE [%d] : Transaction",i);
     229
     230              Tcontext_t context_id        = (_param->_have_port_context_id)?PORT_READ(in_UPDATE_CONTEXT_ID [i]):0;
     231              Tcontrol_t flush             = PORT_READ(in_UPDATE_FLUSH             [i]);
     232
     233              log_printf(TRACE,Return_Address_Stack,FUNCTION,"    * context_id        : %d",context_id);
     234              log_printf(TRACE,Return_Address_Stack,FUNCTION,"    * flush             : %d",flush     );
     235             
     236              // An miss prediction on call/return = Return Address Stack is corrupted.
     237              if (flush)
     238                {
     239                  // All pointer is set at 0
     240                  reg_TOP    [context_id] = 0;
     241//                reg_BOTTOM [context_id] = 0;
     242                  reg_NB_ELT [context_id] = 0;
     243                 
     244                  reg_PREDICT_TOP    [context_id] = 0;
     245//                reg_PREDICT_BOTTOM [context_id] = 0;
     246                  reg_PREDICT_NB_ELT [context_id] = 0;
     247                }
     248              else
     249                {
     250                  // if miss_prediction -> restore queue
     251                  // else, the prediction is correct
     252                  Tcontrol_t miss_prediction   = PORT_READ(in_UPDATE_MISS_PREDICTION   [i]);
     253
     254                  log_printf(TRACE,Return_Address_Stack,FUNCTION,"    * miss_prediction   : %d",miss_prediction);
     255
     256#ifdef DEBUG_TEST
     257                  Tptr_t     index             = PORT_READ(in_UPDATE_INDEX             [i]);
     258                  Tcontrol_t prediction_ifetch = PORT_READ(in_UPDATE_PREDICTION_IFETCH [i]);
     259                  log_printf(TRACE,Return_Address_Stack,FUNCTION,"    * index             : %d",index);
     260                  log_printf(TRACE,Return_Address_Stack,FUNCTION,"    * prediction_ifetch : %d",prediction_ifetch);
     261
     262//                   if (prediction_ifetch)
     263//                     {
     264//                       if (index != reg_PREDICT_TOP [context_id])
     265//                         throw ERRORMORPHEO(FUNCTION,_("Index is different of predict_top"));
     266//                     }
     267//                   else
     268//                     {
     269//                       if (index != reg_TOP [context_id])
     270//                         throw ERRORMORPHEO(FUNCTION,_("Index is different of top"));
     271//                     }
     272                 
     273#endif
     274                  if (miss_prediction)
     275                    {
     276                      Tcontrol_t push              = PORT_READ(in_UPDATE_PUSH              [i]);
     277                      log_printf(TRACE,Return_Address_Stack,FUNCTION,"    * push              : %d",push);
     278#ifndef DEBUG_TEST
     279                      Tptr_t     index             = PORT_READ(in_UPDATE_INDEX             [i]);
     280                      Tcontrol_t prediction_ifetch = PORT_READ(in_UPDATE_PREDICTION_IFETCH [i]);
     281                      log_printf(TRACE,Return_Address_Stack,FUNCTION,"    * index             : %d",index);
     282                      log_printf(TRACE,Return_Address_Stack,FUNCTION,"    * prediction_ifetch : %d",prediction_ifetch);
     283#endif
     284
     285
     286                      Tptr_t     top_old    = (prediction_ifetch)?reg_PREDICT_TOP    [context_id]:reg_TOP    [context_id];
     287                      Tptr_t     top_new    = top_old;
     288
     289//                    Tptr_t     bottom_old = (prediction_ifetch)?reg_PREDICT_BOTTOM [context_id]:reg_BOTTOM [context_id];
     290//                    Tptr_t     bottom_new = bottom_old;
     291
     292                      Tptr_t     nb_elt_old = (prediction_ifetch)?reg_PREDICT_NB_ELT [context_id]:reg_NB_ELT [context_id];
     293                      Tptr_t     nb_elt_new = nb_elt_old;
     294                     
     295                      log_printf(TRACE,Return_Address_Stack,FUNCTION,"    * before");
     296                      if (prediction_ifetch)
     297                        {
     298                          log_printf(TRACE,Return_Address_Stack,FUNCTION,"      * reg_predict_top     : %d",top_old);
     299//                        log_printf(TRACE,Return_Address_Stack,FUNCTION,"      * reg_predict_bottom  : %d",bottom_old);
     300                          log_printf(TRACE,Return_Address_Stack,FUNCTION,"      * reg_predict_nb_elt  : %d",nb_elt_old);
     301                        }
     302                      else
     303                        {
     304                          log_printf(TRACE,Return_Address_Stack,FUNCTION,"      * reg_top     : %d",top_old);
     305//                        log_printf(TRACE,Return_Address_Stack,FUNCTION,"      * reg_bottom  : %d",bottom_old);
     306                          log_printf(TRACE,Return_Address_Stack,FUNCTION,"      * reg_nb_elt  : %d",nb_elt_old);
     307                        }
     308
     309                      // if previous is push, pop the value
     310                      // else is previous is pop, push the poped value
     311                      if (push)
     312                        {
     313                          // previous is push, now must be pop
     314
     315                          // Test if the stack is empty
     316                          if (nb_elt_old>0) // ??
     317                            {
     318                              top_new = (top_old==0)?(_param->_size_queue[context_id]-1):(top_old-1);
     319                              nb_elt_new --;
     320                            }
     321                        }
     322                      else
     323                        {
     324                          // previous is pop, now must be push
     325                          Taddress_t address           = PORT_READ(in_UPDATE_ADDRESS           [i]);
     326
     327                          // push : increase the top (circular)
     328//                        if (nb_elt_old==_param->_size_queue[context_id])
     329//                          bottom_new = (bottom_old+1)%_param->_size_queue[context_id];
     330//                        else
     331//                          nb_elt_new ++;
     332
     333                          if (nb_elt_old!=_param->_size_queue[context_id])
     334                            nb_elt_new ++;
     335
     336                          top_new = index;
     337                         
     338                          reg_stack [context_id][index]._address = address;
     339                        }
     340
     341                      log_printf(TRACE,Return_Address_Stack,FUNCTION,"    * after");
     342
     343                      if (prediction_ifetch)
     344                        {
     345                          log_printf(TRACE,Return_Address_Stack,FUNCTION,"      * reg_predict_top     : %d",top_new);
     346//                        log_printf(TRACE,Return_Address_Stack,FUNCTION,"      * reg_predict_bottom  : %d",bottom_new);
     347                          log_printf(TRACE,Return_Address_Stack,FUNCTION,"      * reg_predict_nb_elt  : %d",nb_elt_new);
     348
     349                          reg_PREDICT_TOP    [context_id] = top_new   ;
     350//                        reg_PREDICT_BOTTOM [context_id] = bottom_new;
     351                          reg_PREDICT_NB_ELT [context_id] = nb_elt_new;
     352                        }
     353                      else
     354                        {
     355                          log_printf(TRACE,Return_Address_Stack,FUNCTION,"      * reg_top     : %d",top_new);
     356//                        log_printf(TRACE,Return_Address_Stack,FUNCTION,"      * reg_bottom  : %d",bottom_new);
     357                          log_printf(TRACE,Return_Address_Stack,FUNCTION,"      * reg_nb_elt  : %d",nb_elt_new);
     358
     359                          reg_TOP            [context_id] = top_new   ;
     360//                        reg_BOTTOM         [context_id] = bottom_new;
     361                          reg_NB_ELT         [context_id] = nb_elt_new;
     362                        }
     363                    }
     364                }
    245365            }
    246366      }
     367
     368#if defined(DEBUG_Return_Address_Stack) and DEBUG>=DEBUG_TRACE
     369    log_printf(TRACE,Return_Address_Stack,FUNCTION,"  * Dump RAS");
     370    for (uint32_t i=0; i<_param->_nb_context; ++i)
     371      {
     372        log_printf(TRACE,Return_Address_Stack,FUNCTION,"    * Return Address Stack [%d]",i);
     373        log_printf(TRACE,Return_Address_Stack,FUNCTION,"      * reg_TOP            : %d",reg_TOP            [i]);
     374//      log_printf(TRACE,Return_Address_Stack,FUNCTION,"      * reg_BOTTOM         : %d",reg_BOTTOM         [i]);
     375        log_printf(TRACE,Return_Address_Stack,FUNCTION,"      * reg_NB_ELT         : %d",reg_NB_ELT         [i]);
     376        log_printf(TRACE,Return_Address_Stack,FUNCTION,"      * reg_PREDICT_TOP    : %d",reg_PREDICT_TOP    [i]);
     377//      log_printf(TRACE,Return_Address_Stack,FUNCTION,"      * reg_PREDICT_BOTTOM : %d",reg_PREDICT_BOTTOM [i]);
     378        log_printf(TRACE,Return_Address_Stack,FUNCTION,"      * reg_PREDICT_NB_ELT : %d",reg_PREDICT_NB_ELT [i]);
     379
     380        for (uint32_t j=0; j<_param->_size_queue[i]; ++j)
     381          log_printf(TRACE,Return_Address_Stack,FUNCTION,"      [%d] %.8x (%.8x)",j,reg_stack [i][j]._address,reg_stack [i][j]._address<<2);
     382      }
     383#endif
    247384
    248385#if defined(STATISTICS) or defined(VHDL_TESTBENCH)
     
    250387#endif
    251388
    252     log_printf(FUNC,Return_Address_Stack,FUNCTION,"End");
     389    log_end(Return_Address_Stack,FUNCTION);
    253390  };
    254391
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Commit_unit/include/Commit_unit.h

    r98 r100  
    220220  private   : Tcounter_t                   ** reg_NB_INST_COMMIT_ALL               ;//[nb_front_end][nb_context]
    221221  private   : Tcounter_t                   ** reg_NB_INST_COMMIT_MEM               ;//[nb_front_end][nb_context]
     222
     223  private   : Tevent_state_t               ** reg_EVENT_STATE                      ;//[nb_front_end][nb_context]
    222224                                                                                   
    223225    // ~~~~~[ Internal ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~         
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Commit_unit/include/Types.h

    r88 r100  
    2727  typedef enum
    2828    {
    29       ROB_EMPTY                     , //
    30       ROB_BRANCH_WAIT_END           , //
    31       ROB_BRANCH_COMPLETE           , //
    32       ROB_STORE_WAIT_HEAD_OK        , //
    33 //    ROB_STORE_WAIT_HEAD_KO        , //
    34       ROB_STORE_HEAD_OK             , //
    35       ROB_STORE_HEAD_KO             , //
    36       ROB_OTHER_WAIT_END            , //
    37       ROB_MISS_WAIT_END             , //
    38       ROB_END_OK_SPECULATIVE        , //
    39       ROB_END_OK                    , //
    40       ROB_END_KO_SPECULATIVE        , //
    41       ROB_END_KO                    , //
    42       ROB_END_MISS                  , //
    43       ROB_END_EXCEPTION_WAIT_HEAD   , //
     29      ROB_EMPTY                      , //
     30      ROB_BRANCH_WAIT_END            , //
     31      ROB_BRANCH_COMPLETE            , //
     32      ROB_STORE_WAIT_HEAD_OK         , //
     33//    ROB_STORE_WAIT_HEAD_KO         , //
     34      ROB_STORE_HEAD_OK              , //
     35      ROB_STORE_HEAD_KO              , //
     36      ROB_OTHER_WAIT_END             , //
     37      ROB_MISS_WAIT_END              , //
     38      ROB_END_OK_SPECULATIVE         , //
     39      ROB_END_OK                     , //
     40      ROB_END_KO_SPECULATIVE         , //
     41      ROB_END_KO                     , //
     42      ROB_END_BRANCH_MISS_SPECULATIVE, //
     43      ROB_END_BRANCH_MISS            , //
     44      ROB_END_MISS                   , //
     45      ROB_END_EXCEPTION_WAIT_HEAD    , //
    4446      ROB_END_EXCEPTION               //
    4547    } rob_state_t;
     
    7981  public  : Tspecial_address_t num_reg_re_phy_new      ;
    8082
    81   public  : Tevent_state_t     event_state             ;
    8283  public  : Texception_t       exception               ;
    8384  public  : Texception_t       exception_use           ;
     
    161162    switch (x)
    162163      {
    163       case morpheo::behavioural::core::multi_ooo_engine::ooo_engine::commit_unit::ROB_EMPTY                     : return "empty"                     ; break;
    164       case morpheo::behavioural::core::multi_ooo_engine::ooo_engine::commit_unit::ROB_BRANCH_WAIT_END           : return "branch_wait_end"           ; break;
    165       case morpheo::behavioural::core::multi_ooo_engine::ooo_engine::commit_unit::ROB_BRANCH_COMPLETE           : return "branch_complete"           ; break;
    166       case morpheo::behavioural::core::multi_ooo_engine::ooo_engine::commit_unit::ROB_STORE_WAIT_HEAD_OK        : return "store_wait_head_ok"        ; break;
    167 //    case morpheo::behavioural::core::multi_ooo_engine::ooo_engine::commit_unit::ROB_STORE_WAIT_HEAD_KO        : return "store_wait_head_ko"        ; break;
    168       case morpheo::behavioural::core::multi_ooo_engine::ooo_engine::commit_unit::ROB_STORE_HEAD_OK             : return "store_head_ok"             ; break;
    169       case morpheo::behavioural::core::multi_ooo_engine::ooo_engine::commit_unit::ROB_STORE_HEAD_KO             : return "store_head_ko"             ; break;
    170       case morpheo::behavioural::core::multi_ooo_engine::ooo_engine::commit_unit::ROB_OTHER_WAIT_END            : return "other_wait_end"            ; break;
    171       case morpheo::behavioural::core::multi_ooo_engine::ooo_engine::commit_unit::ROB_MISS_WAIT_END             : return "miss_wait_end"             ; break;
    172       case morpheo::behavioural::core::multi_ooo_engine::ooo_engine::commit_unit::ROB_END_OK_SPECULATIVE        : return "end_ok_speculative"        ; break;
    173       case morpheo::behavioural::core::multi_ooo_engine::ooo_engine::commit_unit::ROB_END_OK                    : return "end_ok"                    ; break;
    174       case morpheo::behavioural::core::multi_ooo_engine::ooo_engine::commit_unit::ROB_END_KO_SPECULATIVE        : return "end_ko_speculative"        ; break;
    175       case morpheo::behavioural::core::multi_ooo_engine::ooo_engine::commit_unit::ROB_END_KO                    : return "end_ko"                    ; break;
    176       case morpheo::behavioural::core::multi_ooo_engine::ooo_engine::commit_unit::ROB_END_EXCEPTION_WAIT_HEAD   : return "end_exception_wait_head"   ; break;
    177       case morpheo::behavioural::core::multi_ooo_engine::ooo_engine::commit_unit::ROB_END_EXCEPTION             : return "end_exception"             ; break;
     164      case morpheo::behavioural::core::multi_ooo_engine::ooo_engine::commit_unit::ROB_EMPTY                      : return "ROB_EMPTY"                       ; break;
     165      case morpheo::behavioural::core::multi_ooo_engine::ooo_engine::commit_unit::ROB_BRANCH_WAIT_END            : return "ROB_BRANCH_WAIT_END"             ; break;
     166      case morpheo::behavioural::core::multi_ooo_engine::ooo_engine::commit_unit::ROB_BRANCH_COMPLETE            : return "ROB_BRANCH_COMPLETE"             ; break;
     167      case morpheo::behavioural::core::multi_ooo_engine::ooo_engine::commit_unit::ROB_STORE_WAIT_HEAD_OK         : return "ROB_STORE_WAIT_HEAD_OK"          ; break;
     168//    case morpheo::behavioural::core::multi_ooo_engine::ooo_engine::commit_unit::ROB_STORE_WAIT_HEAD_KO         : return "ROB_STORE_WAIT_HEAD_KO"          ; break;
     169      case morpheo::behavioural::core::multi_ooo_engine::ooo_engine::commit_unit::ROB_STORE_HEAD_OK              : return "ROB_STORE_HEAD_OK"               ; break;
     170      case morpheo::behavioural::core::multi_ooo_engine::ooo_engine::commit_unit::ROB_STORE_HEAD_KO              : return "ROB_STORE_HEAD_KO"               ; break;
     171      case morpheo::behavioural::core::multi_ooo_engine::ooo_engine::commit_unit::ROB_OTHER_WAIT_END             : return "ROB_OTHER_WAIT_END"              ; break;
     172      case morpheo::behavioural::core::multi_ooo_engine::ooo_engine::commit_unit::ROB_MISS_WAIT_END              : return "ROB_MISS_WAIT_END"               ; break;
     173      case morpheo::behavioural::core::multi_ooo_engine::ooo_engine::commit_unit::ROB_END_OK_SPECULATIVE         : return "ROB_END_OK_SPECULATIVE"          ; break;
     174      case morpheo::behavioural::core::multi_ooo_engine::ooo_engine::commit_unit::ROB_END_OK                     : return "ROB_END_OK"                      ; break;
     175      case morpheo::behavioural::core::multi_ooo_engine::ooo_engine::commit_unit::ROB_END_KO_SPECULATIVE         : return "ROB_END_KO_SPECULATIVE"          ; break;
     176      case morpheo::behavioural::core::multi_ooo_engine::ooo_engine::commit_unit::ROB_END_KO                     : return "ROB_END_KO"                      ; break;
     177      case morpheo::behavioural::core::multi_ooo_engine::ooo_engine::commit_unit::ROB_END_BRANCH_MISS_SPECULATIVE: return "ROB_END_BRANCH_MISS_SPECULATIVE" ; break;
     178      case morpheo::behavioural::core::multi_ooo_engine::ooo_engine::commit_unit::ROB_END_BRANCH_MISS            : return "ROB_END_BRANCH_MISS"             ; break;
     179      case morpheo::behavioural::core::multi_ooo_engine::ooo_engine::commit_unit::ROB_END_MISS                   : return "ROB_END_MISS"                    ; break;
     180      case morpheo::behavioural::core::multi_ooo_engine::ooo_engine::commit_unit::ROB_END_EXCEPTION_WAIT_HEAD    : return "ROB_END_EXCEPTION_WAIT_HEAD"     ; break;
     181      case morpheo::behavioural::core::multi_ooo_engine::ooo_engine::commit_unit::ROB_END_EXCEPTION              : return "ROB_END_EXCEPTION"               ; break;
     182
    178183      default    : return ""      ; break;
    179184      }
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Commit_unit/src/Commit_unit_allocation.cpp

    r98 r100  
    272272
    273273    // ~~~~~[ Register ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
    274     _rob = new std::list<entry_t*> [_param->_nb_bank];
     274    ALLOC1(_rob                   ,std::list<entry_t*>,_param->_nb_bank);
    275275   
    276     reg_BANK_PTR           = new uint32_t     [_param->_nb_bank];
    277 
    278     reg_NB_INST_COMMIT_ALL = new Tcounter_t * [_param->_nb_front_end];
    279     reg_NB_INST_COMMIT_MEM = new Tcounter_t * [_param->_nb_front_end];
     276    ALLOC1(reg_BANK_PTR           ,uint32_t      ,_param->_nb_bank);
     277
     278    ALLOC2(reg_NB_INST_COMMIT_ALL ,Tcounter_t    ,_param->_nb_front_end,_param->_nb_context [it1]);
     279    ALLOC2(reg_NB_INST_COMMIT_MEM ,Tcounter_t    ,_param->_nb_front_end,_param->_nb_context [it1]);
    280280   
    281     for (uint32_t i=0; i<_param->_nb_front_end; i++)
    282       {
    283         reg_NB_INST_COMMIT_ALL [i] = new Tcounter_t [_param->_nb_context [i]];
    284         reg_NB_INST_COMMIT_MEM [i] = new Tcounter_t [_param->_nb_context [i]];
    285       }
     281    ALLOC2(reg_EVENT_STATE        ,Tevent_state_t,_param->_nb_front_end,_param->_nb_context [it1]);
    286282      }
    287283
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Commit_unit/src/Commit_unit_deallocation.cpp

    r98 r100  
    178178       
    179179        // ~~~~~[ Register ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
    180         for (uint32_t i=0; i<_param->_nb_front_end; i++)
    181           {
    182             delete [] reg_NB_INST_COMMIT_ALL [i];
    183             delete [] reg_NB_INST_COMMIT_MEM [i];
    184           }
    185         delete [] reg_NB_INST_COMMIT_ALL;
    186         delete [] reg_NB_INST_COMMIT_MEM;
    187        
    188         delete [] reg_BANK_PTR;
    189        
    190         delete [] _rob;
     180        DELETE1(_rob                   ,_param->_nb_bank);
     181        DELETE1(reg_BANK_PTR           ,_param->_nb_bank);
     182        DELETE2(reg_NB_INST_COMMIT_ALL ,_param->_nb_front_end,_param->_nb_context [it1]);
     183        DELETE2(reg_NB_INST_COMMIT_MEM ,_param->_nb_front_end,_param->_nb_context [it1]);
     184        DELETE2(reg_EVENT_STATE        ,_param->_nb_front_end,_param->_nb_context [it1]);
    191185      }
    192186
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Commit_unit/src/Commit_unit_genMealy_commit.cpp

    r88 r100  
    3030    uint32_t           bank_nb_access    [_param->_nb_bank];
    3131    Tcontrol_t         commit_ack        [_param->_nb_inst_commit];
     32
    3233    // Initialisation
    3334    for (uint32_t i=0; i<_param->_nb_bank; i++)
     
    3839      }
    3940
    40     // commit interface
     41    // commit interface -> scan all entry (Out of Order)
    4142    for (uint32_t i=0; i<_param->_nb_inst_commit; i++)
    4243      {
    4344        commit_ack        [i] = false;
    4445
    45         // Test if have instruction
     46        // Test if have valid instruction
    4647        if (PORT_READ(in_COMMIT_VAL [i]))
    4748          {
    48             Tpacket_t packet          = (_param->_have_port_rob_ptr  )?PORT_READ(in_COMMIT_PACKET_ID [i]):0;
    49             uint32_t  num_bank        = packet >> _param->_shift_num_bank;
     49            // packet_id number can
     50            Tpacket_t packet_id       = (_param->_have_port_rob_ptr  )?PORT_READ(in_COMMIT_PACKET_ID [i]):0;
     51            uint32_t  num_bank        = packet_id >> _param->_shift_num_bank;
    5052            uint32_t  num_bank_access = bank_nb_access [num_bank];
    5153           
     
    6062                internal_BANK_COMMIT_NUM_INST [num_bank][num_bank_access] = i;
    6163               
    62                 Tpacket_t packet_id = packet & _param->_mask_size_bank;
     64                Tpacket_t num_packet = packet_id & _param->_mask_size_bank;
    6365               
    6466                // find the good entry !!!
     
    6769                     it!=_rob[num_bank].end();
    6870                     it++)
    69                   if ((*it)->ptr == packet_id)
     71                  if ((*it)->ptr == num_packet)
    7072                    {
    7173                      entry = (*it);
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Commit_unit/src/Commit_unit_genMealy_insert.cpp

    r88 r100  
    5454    std::list<generic::priority::select_t> * select_insert = _priority_insert ->select(); // same select for all insert
    5555    std::list<generic::priority::select_t>::iterator it=select_insert ->begin();
    56  
     56
     57    // Scan all bank ...
    5758    for (uint32_t i=0; i<_param->_nb_bank; i++)
    5859      {
     
    6465//      log_printf(TRACE,Commit_unit,FUNCTION,"    * full : %d", bank_full [num_bank]);
    6566
     67        // Scan all insert interface to find a valid transaction
    6668        while (it!=select_insert ->end())
    6769          {
     
    8789                if (not bank_full [num_bank])
    8890                  {
    89                     // find
     91                    // find !!!
    9092                    insert_ack       [num_rename_unit][num_inst_insert] = true;
    9193
     
    112114      }
    113115   
     116    // Write output
    114117    for (uint32_t i=0; i<_param->_nb_rename_unit; i++)
    115118      for (uint32_t j=0; j<_param->_nb_inst_insert[i]; j++)
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Commit_unit/src/Commit_unit_genMealy_retire.cpp

    r88 r100  
    4848          retire_val [i][j] = false;
    4949      }
    50 
    5150    for (uint32_t i=0; i<_param->_nb_front_end; ++i)
    5251      for (uint32_t j=0; j<_param->_nb_context[i]; ++j)
    53         spr_write_val [i][j] = 0;
    54 
     52        {
     53          spr_write_val [i][j] = 0;
     54          spr_write_sr_f_val  [i][j] = 0;
     55          spr_write_sr_cy_val [i][j] = 0;
     56          spr_write_sr_ov_val [i][j] = 0;
     57
     58        }
    5559    // Scan Top of each bank
    5660    for (uint32_t i=0; i<_param->_nb_bank; i++)
     
    6468            uint32_t   x     = entry->rename_unit_id;
    6569            uint32_t   y     = num_inst_retire [x];
    66            
     70       
     71            // test if :
     72            //  * can retire (all previous instruction is retired)
     73            //  * all structure is ok (not busy)
    6774            if (can_retire [x] and // in-order
    6875                (y < _param->_nb_inst_retire [x]) and
     
    7178                rob_state_t state = entry->state;
    7279               
    73                 if ((state == ROB_END_OK  ) or
    74                     (state == ROB_END_KO  ) or
    75                     (state == ROB_END_MISS)//  or
     80                if ((state == ROB_END_OK         ) or
     81                    (state == ROB_END_KO         ) or
     82                    (state == ROB_END_BRANCH_MISS) or
     83                    (state == ROB_END_MISS       )//  or
    7684//                  (state == ROB_END_EXCEPTION)
    7785                    )
     
    8593                    bool spr_write_ack = true;
    8694
     95                    // Write in SR the good flag
    8796                    if ((state == ROB_END_OK  ) and write_re)
     97                      // ROB_END_BRANCH_MISS is a valid branch instruction but don't modify RE
    8898                      {
    8999                        spr_write_ack = PORT_READ(in_SPR_WRITE_ACK [front_end_id][context_id]);
     
    138148                    PORT_WRITE(out_RETIRE_CONTEXT_ID            [x][y], context_id                  );
    139149//                  PORT_WRITE(out_RETIRE_RENAME_UNIT_ID        [x][y], entry->rename_unit_id       );
    140                     PORT_WRITE(out_RETIRE_EVENT_STATE           [x][y], entry->event_state          );
     150                    PORT_WRITE(out_RETIRE_EVENT_STATE           [x][y], reg_EVENT_STATE[front_end_id][context_id]);
    141151                    PORT_WRITE(out_RETIRE_USE_STORE_QUEUE       [x][y], entry->use_store_queue      );
    142152                    PORT_WRITE(out_RETIRE_USE_LOAD_QUEUE        [x][y], entry->use_load_queue       );
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Commit_unit/src/Commit_unit_genMoore.cpp

    r98 r100  
    2828    // ===================================================================
    2929    {
     30      // Store instruction comming Out Of Order in Load Store Unit.
     31      // Must be executed in no speculative mode. Also, send a signal when an Store is in head of ROB
     32
    3033      Tcontrol_t val = false;
    3134
     
    3538          rob_state_t  state = entry->state;
    3639
     40          // Test state
    3741          val   = ((state == ROB_STORE_HEAD_OK) or
    3842                   (state == ROB_STORE_HEAD_KO));
     
    4044          if (val)
    4145            {
     46              // Reexecute store
    4247              if (_param->_have_port_context_id)
    4348              PORT_WRITE(out_REEXECUTE_CONTEXT_ID            [0], entry->context_id           );
     
    6267    // ===================================================================
    6368    {
     69      // Branchement must be send at the prediction unit
    6470      uint32_t nb_scan_bank = 0;
    6571
     72      // for each port, find a valid branchement.
    6673      for (uint32_t i=0; i<_param->_nb_inst_branch_complete; i++)
    6774        {
     
    7279              nb_scan_bank ++;
    7380
     81              // translate bank number
    7482              uint32_t num_bank = (reg_NUM_BANK_HEAD+j)%_param->_nb_bank;
    7583             
     
    124132        }
    125133    }
    126 
    127 //   public    : SC_OUT(Tcontrol_t         )   * out_UPDATE_VAL                        ;
    128 //   public    : SC_IN (Tcontrol_t         )   *  in_UPDATE_ACK                        ;
    129 //   public    : SC_OUT(Tcontext_t         )   * out_UPDATE_CONTEXT_ID                 ;
    130 //   public    : SC_OUT(Tcontext_t         )   * out_UPDATE_FRONT_END_ID               ;
    131 //   public    : SC_OUT(Tdepth_t           )   * out_UPDATE_DEPTH                      ;
    132 //   public    : SC_OUT(Tevent_type_t      )   * out_UPDATE_TYPE                       ;
    133 //   public    : SC_OUT(Tcontrol_t         )   * out_UPDATE_IS_DELAY_SLOT              ;
    134 //   public    : SC_OUT(Taddress_t         )   * out_UPDATE_ADDRESS                    ;
    135 //   public    : SC_OUT(Taddress_t         )   * out_UPDATE_ADDRESS_EPCR               ;
    136 //   public    : SC_OUT(Tcontrol_t         )   * out_UPDATE_ADDRESS_EEAR_VAL           ;
    137 //   public    : SC_OUT(Taddress_t         )   * out_UPDATE_ADDRESS_EEAR               ;
    138134 
    139135    // ===================================================================
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Commit_unit/src/Commit_unit_statistics_allocation.cpp

    r98 r100  
    5757      _stat->create_expr_average_by_cycle("average_inst_retire_ko", sum_nb_inst_retire_ko, "", _("Average instruction retire ko (event, miss) by cycle"));
    5858      _stat->create_expr_average_by_cycle("average_inst_retire"   , "+ "+sum_nb_inst_retire_ok+" "+sum_nb_inst_retire_ko, "", _("Average instruction retire by cycle"));
     59
     60      _stat->create_expr                 ("IPC", "average_inst_retire_ok", TYPE_COUNTER, "inst/cycle", "Instruction Per Cycle");
     61      _stat->create_expr                 ("CPI", "/ 1 IPC"               , TYPE_COUNTER, "cycle/inst", "Cycle Per Instruction");
    5962    }
    6063
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Commit_unit/src/Commit_unit_transition.cpp

    r98 r100  
    2626    if (PORT_READ(in_NRESET) == 0)
    2727      {
     28        // Clear all bank
    2829        for (uint32_t i=0; i<_param->_nb_bank; i++)
    2930          {
     
    3233          }
    3334
     35        // Reset pointer
    3436        reg_NUM_BANK_HEAD = 0;
    3537        reg_NUM_BANK_TAIL = 0;
    3638
     39        // Reset counter
    3740        for (uint32_t i=0; i<_param->_nb_front_end; i++)
    3841          for (uint32_t j=0; j<_param->_nb_context [i]; j++)
     
    4043              reg_NB_INST_COMMIT_ALL [i][j] = 0;
    4144              reg_NB_INST_COMMIT_MEM [i][j] = 0;
     45
     46              reg_EVENT_STATE        [i][j] = EVENT_STATE_NO_EVENT;
    4247            }
    4348
     49        // Reset priority algorithm
    4450        _priority_insert->reset();
    4551      }
    4652    else
    4753      {
    48         // next priority
     54        // Compute next priority
    4955        _priority_insert->transition();
     56
     57        // ===================================================================
     58        // =====[ GARBAGE COLLECTOR ]=========================================
     59        // ===================================================================
     60        for (uint32_t i=0; i<_param->_nb_front_end; i++)
     61          for (uint32_t j=0; j<_param->_nb_context [i]; j++)
     62            switch (reg_EVENT_STATE [i][j])
     63              {
     64              case EVENT_STATE_EVENT    : reg_EVENT_STATE [i][j] = EVENT_STATE_WAITEND ; break;
     65              case EVENT_STATE_END      : reg_EVENT_STATE [i][j] = EVENT_STATE_NO_EVENT; break;
     66//            case EVENT_STATE_NO_EVENT :
     67//            case EVENT_STATE_WAITEND  :
     68              default : break;
     69              }
    5070
    5171        // ===================================================================
     
    5575          if (internal_BANK_INSERT_VAL [i])
    5676            {
     77              // get rename unit source and instruction.
    5778              uint32_t x = internal_BANK_INSERT_NUM_RENAME_UNIT [i];
    5879              uint32_t y = internal_BANK_INSERT_NUM_INST        [i];
     
    6788#endif
    6889
     90                  // get information
    6991                  Tcontext_t   front_end_id = (_param->_have_port_front_end_id)?PORT_READ(in_INSERT_FRONT_END_ID [x][y]):0;
    7092                  Tcontext_t   context_id   = (_param->_have_port_context_id  )?PORT_READ(in_INSERT_CONTEXT_ID   [x][y]):0;
    7193                  Ttype_t      type         = PORT_READ(in_INSERT_TYPE         [x][y]);
    7294                  Toperation_t operation    = PORT_READ(in_INSERT_OPERATION    [x][y]);
     95                  bool         is_store     = is_operation_memory_store(operation);
     96
    7397                  Texception_t exception    = PORT_READ(in_INSERT_EXCEPTION    [x][y]);
    7498
     
    78102                  log_printf(TRACE,Commit_unit,FUNCTION,"    * operation      : %d",operation );
    79103                  log_printf(TRACE,Commit_unit,FUNCTION,"    * exception      : %d",exception );
    80 
     104                 
     105                  // Create new entry.
    81106                  entry_t * entry = new entry_t;
    82107
     
    92117                  entry->exception               = exception;
    93118                  entry->exception_use           = PORT_READ(in_INSERT_EXCEPTION_USE         [x][y]);
    94                   entry->use_store_queue         = (type == TYPE_MEMORY) and (    is_operation_memory_store(operation));
    95                   entry->use_load_queue          = (type == TYPE_MEMORY) and (not is_operation_memory_store(operation));
     119                  entry->use_store_queue         = (type == TYPE_MEMORY) and (    is_store);
     120                  entry->use_load_queue          = (type == TYPE_MEMORY) and (not is_store);
    96121                  entry->store_queue_ptr_write   = PORT_READ(in_INSERT_STORE_QUEUE_PTR_WRITE [x][y]);
    97122                  entry->load_queue_ptr_write    = (_param->_have_port_load_queue_ptr)?PORT_READ(in_INSERT_LOAD_QUEUE_PTR_WRITE [x][y]):0;
     
    114139                  entry->num_reg_re_phy_new      = PORT_READ(in_INSERT_NUM_REG_RE_PHY_NEW    [x][y]);
    115140
     141                  // Test if exception :
     142                  //  * yes : no execute instruction, wait ROB Head
     143                  //  * no  : test type
     144                  //            * BRANCH : l.j   -> branch is ended
     145                  //                       other -> wait the execution end of branchment
     146                  //            * MEMORY : store -> wait store is at head of ROB
     147                  //                       other -> wait end of instruction
     148                  //            * OTHER
    116149                  if (exception == EXCEPTION_NONE)
    117150                    {
     
    124157                        {
    125158                        case TYPE_BRANCH : {entry->state=(no_execute==1)?ROB_BRANCH_COMPLETE:ROB_BRANCH_WAIT_END; break;}
    126                         case TYPE_MEMORY : {entry->state=ROB_STORE_WAIT_HEAD_OK; break;}
     159                        case TYPE_MEMORY : {entry->state=(is_store  ==1)?ROB_STORE_WAIT_HEAD_OK:ROB_OTHER_WAIT_END; break;}
    127160                        default          : {entry->state=(no_execute==1)?ROB_END_OK_SPECULATIVE:ROB_OTHER_WAIT_END; break;}
    128161                        }
     
    130163                  else
    131164                    {
     165                      // Have an exception : wait head of ROB
     166
    132167                      // in_INSERT_NO_EXECUTE [x][y] : l.sys, l.trap
    133168
     
    135170                    }
    136171
     172                  // Push in rob
    137173                  _rob[i].push_back(entry);
    138174
    139                   // Update nb_inst
     175                  // Update counter and pointer
    140176                  reg_NB_INST_COMMIT_ALL [front_end_id][context_id] ++;
    141177                  if (type == TYPE_MEMORY)
     
    160196            if (internal_BANK_COMMIT_VAL [i][j])
    161197              {
     198                // An instruction is executed. Change state of this instruction
     199
    162200                uint32_t x = internal_BANK_COMMIT_NUM_INST [i][j];
    163201
     
    171209#endif
    172210
    173 //                  Tpacket_t packet_id = (_param->_have_port_rob_ptr  )?(PORT_READ(in_COMMIT_PACKET_ID [x])&_param->_mask_size_bank):0;
    174                    
    175211                    log_printf(TRACE,Commit_unit,FUNCTION,"    * num_bank   : %d",i);
    176 //                  log_printf(TRACE,Commit_unit,FUNCTION,"    * packet_id  : %d",(_param->_have_port_rob_ptr  )?(PORT_READ(in_COMMIT_PACKET_ID [x])):0);
    177 //                  log_printf(TRACE,Commit_unit,FUNCTION,"    * num_entry  : %d",packet_id);
    178                    
    179                     // test pandex with ptr_write.
    180 //                  Tpacket_t index     = (packet_id<reg_BANK_PTR [i])?(reg_BANK_PTR [i]-packet_id):(_param->_size_bank+reg_BANK_PTR [i]-packet_id);
    181212
    182213                    // find the good entry !!!
    183                     entry_t *       entry       = internal_BANK_COMMIT_ENTRY [i][j];
    184 
    185                   //Toperation_t    operation   = PORT_READ(in_COMMIT_OPERATION   [x]);
    186                   //Ttype_t         type        = PORT_READ(in_COMMIT_TYPE        [x]);
    187                     Texception_t    exception   = PORT_READ(in_COMMIT_EXCEPTION   [x]);
    188 
    189                     rob_state_t state        = entry->state;
    190                     Tcontext_t  front_end_id = entry->front_end_id;
    191                     Tcontext_t  context_id   = entry->context_id;
    192 
    193                     // change state
     214                    entry_t *       entry        = internal_BANK_COMMIT_ENTRY [i][j];
     215                                                 
     216                  //Toperation_t    operation    = PORT_READ(in_COMMIT_OPERATION   [x]);
     217                  //Ttype_t         type         = PORT_READ(in_COMMIT_TYPE        [x]);
     218                    Texception_t    exception    = PORT_READ(in_COMMIT_EXCEPTION   [x]);
     219
     220                    rob_state_t     state        = entry->state;
     221                    Tcontext_t      front_end_id = entry->front_end_id;
     222                    Tcontext_t      context_id   = entry->context_id;
     223
     224                    // change state : test exception_use
    194225                    //  * test if exception : exception and mask
    195226                   
    196                     bool have_exception = false;
    197                    
     227                    bool have_exception        = false;
     228                    bool have_miss_speculation = false;
     229
    198230                    if (exception != EXCEPTION_NONE)
    199                       switch (entry->exception_use)
    200                         {
    201                         case  EXCEPTION_USE_RANGE                    : {have_exception = ((exception == EXCEPTION_RANGE) and PORT_READ(in_SPR_READ_SR_OVE[front_end_id][context_id])); break;}
    202                         case  EXCEPTION_USE_MEMORY_WITH_ALIGNMENT    : {have_exception = ((exception == EXCEPTION_BUS_ERROR) or
    203                                                                                           (exception == EXCEPTION_DATA_TLB ) or
    204                                                                                           (exception == EXCEPTION_DATA_PAGE) or
    205                                                                                           (exception == EXCEPTION_ALIGNMENT)); break;};
    206                         case  EXCEPTION_USE_MEMORY_WITHOUT_ALIGNMENT : {have_exception = ((exception == EXCEPTION_BUS_ERROR) or
    207                                                                                           (exception == EXCEPTION_DATA_TLB ) or
    208                                                                                           (exception == EXCEPTION_DATA_PAGE)); break;};
    209                         case  EXCEPTION_USE_CUSTOM_0                 : {have_exception = (exception == EXCEPTION_CUSTOM_0); break;};
    210                         case  EXCEPTION_USE_CUSTOM_1                 : {have_exception = (exception == EXCEPTION_CUSTOM_1); break;};
    211                         case  EXCEPTION_USE_CUSTOM_2                 : {have_exception = (exception == EXCEPTION_CUSTOM_2); break;};
    212                         case  EXCEPTION_USE_CUSTOM_3                 : {have_exception = (exception == EXCEPTION_CUSTOM_3); break;};
    213                         case  EXCEPTION_USE_CUSTOM_4                 : {have_exception = (exception == EXCEPTION_CUSTOM_4); break;};
    214                         case  EXCEPTION_USE_CUSTOM_5                 : {have_exception = (exception == EXCEPTION_CUSTOM_5); break;};
    215                         case  EXCEPTION_USE_CUSTOM_6                 : {have_exception = (exception == EXCEPTION_CUSTOM_6); break;};
    216                         case  EXCEPTION_USE_TRAP                     : {have_exception = false; break;};
    217                         case  EXCEPTION_USE_NONE                     : {have_exception = false; break;};
    218                         case  EXCEPTION_USE_ILLEGAL_INSTRUCTION      : {have_exception = false; break;};
    219                         case  EXCEPTION_USE_SYSCALL                  : {have_exception = false; break;};
    220                         default :
    221                           {
    222                             throw ERRORMORPHEO(FUNCTION,_("Commit : invalid exception_use.\n"));
    223                             break;
    224                           }
    225                         }
    226 
    227                     if (not have_exception)
    228                       {
    229                         switch (state)
    230                           {
    231                           case ROB_OTHER_WAIT_END  : {state = ROB_END_OK_SPECULATIVE; break;}
    232                           case ROB_BRANCH_WAIT_END : {state = ROB_BRANCH_COMPLETE   ; break;}
    233                           case ROB_MISS_WAIT_END   : {state = ROB_END_KO_SPECULATIVE; break;}
    234                           default :
    235                             {
    236                               throw ERRORMORPHEO(FUNCTION,toString(_("Commit : invalid state value (%s).\n"),toString(state).c_str()));
    237                               break;
    238                             }
    239                           }
    240                         // can have an exception, but this instruction is not sensible a this exception
    241                         exception = EXCEPTION_NONE;
    242                       }
    243                     else
    244                       {
    245 #ifdef DEBUG_TEST
    246                         if ((entry->type == TYPE_MEMORY) and (exception == EXCEPTION_MEMORY_LOAD_SPECULATIVE))
    247                           throw ERRORMORPHEO(FUNCTION,_("Commit : invalid exception.\n"));
    248 #endif
    249 
    250                         switch (state)
    251                           {
    252                           case ROB_OTHER_WAIT_END  :
    253                           case ROB_BRANCH_WAIT_END : {state = ROB_END_EXCEPTION_WAIT_HEAD; break;}
    254                           case ROB_MISS_WAIT_END   : {state = ROB_END_KO_SPECULATIVE     ; break;}
    255                           default :
    256                             {
    257                               throw ERRORMORPHEO(FUNCTION,_("Commit : invalid state value.\n"));
    258                               break;
    259                             }
    260                           }
    261                       }
     231                      {
     232                        // Test if the instruction is a load and is a miss speculation (load is commit, but they have an dependence with a previous store)
     233                        have_miss_speculation  = (exception == EXCEPTION_MEMORY_MISS_SPECULATION);
     234
     235                        switch (entry->exception_use)
     236                          {
     237                            // Have overflow exception if bit overflow enable is set.
     238                          case  EXCEPTION_USE_RANGE                    : {have_exception = ((exception == EXCEPTION_RANGE) and PORT_READ(in_SPR_READ_SR_OVE[front_end_id][context_id])); break;}
     239                          case  EXCEPTION_USE_MEMORY_WITH_ALIGNMENT    : {have_exception = ((exception == EXCEPTION_BUS_ERROR) or
     240                                                                                            (exception == EXCEPTION_DATA_TLB ) or
     241                                                                                            (exception == EXCEPTION_DATA_PAGE) or
     242                                                                                            (exception == EXCEPTION_ALIGNMENT)); break;};
     243                          case  EXCEPTION_USE_MEMORY_WITHOUT_ALIGNMENT : {have_exception = ((exception == EXCEPTION_BUS_ERROR) or
     244                                                                                            (exception == EXCEPTION_DATA_TLB ) or
     245                                                                                            (exception == EXCEPTION_DATA_PAGE)); break;};
     246                          case  EXCEPTION_USE_CUSTOM_0                 : {have_exception = (exception == EXCEPTION_CUSTOM_0); break;};
     247                          case  EXCEPTION_USE_CUSTOM_1                 : {have_exception = (exception == EXCEPTION_CUSTOM_1); break;};
     248                          case  EXCEPTION_USE_CUSTOM_2                 : {have_exception = (exception == EXCEPTION_CUSTOM_2); break;};
     249                          case  EXCEPTION_USE_CUSTOM_3                 : {have_exception = (exception == EXCEPTION_CUSTOM_3); break;};
     250                          case  EXCEPTION_USE_CUSTOM_4                 : {have_exception = (exception == EXCEPTION_CUSTOM_4); break;};
     251                          case  EXCEPTION_USE_CUSTOM_5                 : {have_exception = (exception == EXCEPTION_CUSTOM_5); break;};
     252                          case  EXCEPTION_USE_CUSTOM_6                 : {have_exception = (exception == EXCEPTION_CUSTOM_6); break;};
     253                            // Case already manage (decod stage -> in insert in ROB)
     254                          case  EXCEPTION_USE_TRAP                     : {have_exception = false; exception = EXCEPTION_NONE; break;};
     255                          case  EXCEPTION_USE_NONE                     : {have_exception = false; exception = EXCEPTION_NONE; break;};
     256                          case  EXCEPTION_USE_ILLEGAL_INSTRUCTION      : {have_exception = false; exception = EXCEPTION_NONE; break;};
     257                          case  EXCEPTION_USE_SYSCALL                  : {have_exception = false; exception = EXCEPTION_NONE; break;};
     258                          default :
     259                            {
     260                              throw ERRORMORPHEO(FUNCTION,_("Commit : invalid exception_use.\n"));
     261                              break;
     262                            }
     263                          }
     264                      }
     265                   
     266                    switch (state)
     267                      {
     268                        // Branch ...
     269                      case ROB_BRANCH_WAIT_END : {state = (have_exception)?ROB_END_EXCEPTION_WAIT_HEAD:ROB_BRANCH_COMPLETE; break;}
     270                        // Store KO
     271                      case ROB_MISS_WAIT_END   : {state = ROB_END_KO_SPECULATIVE; break;}
     272                        // Store OK, Load and other instruction
     273                      case ROB_OTHER_WAIT_END  : {state = (have_exception)?ROB_END_EXCEPTION_WAIT_HEAD:((have_miss_speculation)?ROB_END_MISS:ROB_END_OK_SPECULATIVE); break;}
     274                      default :
     275                        {
     276                          throw ERRORMORPHEO(FUNCTION,toString(_("Commit : invalid state value (%s).\n"),toString(state).c_str()));
     277                          break;
     278                        }
     279                      }
    262280
    263281                    // update Re Order Buffer
     
    287305
    288306              entry_t *  entry        =  _rob [i].front();
     307              rob_state_t state = entry->state;
     308             
    289309#ifdef STATISTICS
    290310              if (usage_is_set(_usage,USE_STATISTICS))
    291311                {
    292                   rob_state_t state = entry->state;
    293                  
    294312                  if (state == ROB_END_OK)
    295313                    (*_stat_nb_inst_retire_ok [x]) ++;
     
    302320              Tcontext_t context_id   = entry->context_id  ;
    303321              Ttype_t    type         = entry->type        ;
     322
     323              if (state == ROB_END_BRANCH_MISS)
     324                {
     325                  reg_EVENT_STATE [front_end_id][context_id] = EVENT_STATE_EVENT;
     326
     327                  // !!!!!!!!!!! Compute address
     328                }
    304329             
    305330              // Update nb_inst
     
    307332              if (type == TYPE_MEMORY)
    308333                reg_NB_INST_COMMIT_MEM [front_end_id][context_id] --;
    309              
     334
     335              if (reg_NB_INST_COMMIT_ALL [front_end_id][context_id] == 0)
     336                reg_EVENT_STATE [front_end_id][context_id] = EVENT_STATE_END;
     337
    310338              reg_NUM_BANK_HEAD = (reg_NUM_BANK_HEAD+1)%_param->_nb_bank;
    311339             
     
    350378#endif
    351379
    352               entry->state = ROB_END_OK_SPECULATIVE;
     380              entry->state = (PORT_READ(in_BRANCH_COMPLETE_MISS_PREDICTION [i]))?ROB_END_OK_SPECULATIVE:ROB_END_BRANCH_MISS_SPECULATIVE;
     381//               entry->state = ROB_END_OK_SPECULATIVE;
    353382            }
    354383
    355384        // ===================================================================
     385        // =====[ UPDATE ]====================================================
     386        // ===================================================================
     387        {
     388          // Not yet implemented
     389        }
     390
     391        // ===================================================================
    356392        // =====[ EVENT ]=====================================================
    357393        // ===================================================================
     394        {
     395          // Not yet implemented
     396        }
    358397
    359398        // ===================================================================
     
    400439                  switch (state)
    401440                    {
    402                     case ROB_BRANCH_WAIT_END           : {state = ROB_MISS_WAIT_END; break;}
    403                     case ROB_BRANCH_COMPLETE           : {state = ROB_END_MISS     ; break;}
    404                     case ROB_STORE_WAIT_HEAD_OK        : {state = ROB_STORE_HEAD_KO; break;}
    405                   //case ROB_STORE_WAIT_HEAD_KO        : {state = ; break;}
    406                     case ROB_OTHER_WAIT_END            : {state = ROB_MISS_WAIT_END; break;}
    407                     case ROB_END_OK_SPECULATIVE        : {state = ROB_END_MISS     ; break;}
    408                     case ROB_END_KO_SPECULATIVE        : {state = ROB_END_MISS     ; break;}
    409                     case ROB_END_EXCEPTION_WAIT_HEAD   : {state = ROB_END_MISS     ; break;}
    410                      
    411                       // don't change
    412                     case ROB_STORE_HEAD_KO             : {break;}
    413                     case ROB_MISS_WAIT_END             : {break;}
    414                     case ROB_END_MISS                  : {break;}
    415                      
    416                       // can't have miss speculation
    417                     case ROB_STORE_HEAD_OK             :
    418                     case ROB_END_OK                    :
    419                     case ROB_END_KO                    :
    420                     case ROB_END_EXCEPTION             :
    421                     default                            :
     441                    case ROB_BRANCH_WAIT_END             : {state = ROB_MISS_WAIT_END; break;}
     442                    case ROB_BRANCH_COMPLETE             : {state = ROB_END_MISS     ; break;}
     443                    case ROB_END_BRANCH_MISS_SPECULATIVE : {state = ROB_END_MISS     ; break;}
     444                    case ROB_STORE_WAIT_HEAD_OK          : {state = ROB_STORE_HEAD_KO; break;}
     445                  //case ROB_STORE_WAIT_HEAD_KO          : {state = ; break;}
     446                    case ROB_OTHER_WAIT_END              : {state = ROB_MISS_WAIT_END; break;}
     447                    case ROB_END_OK_SPECULATIVE          : {state = ROB_END_MISS     ; break;}
     448                    case ROB_END_KO_SPECULATIVE          : {state = ROB_END_MISS     ; break;}
     449                    case ROB_END_EXCEPTION_WAIT_HEAD     : {state = ROB_END_MISS     ; break;}
     450                                                         
     451                      // don't change                   
     452                    case ROB_STORE_HEAD_KO               : {break;}
     453                    case ROB_MISS_WAIT_END               : {break;}
     454                    case ROB_END_MISS                    : {break;}
     455                                                         
     456                      // can't have miss speculation     
     457                    case ROB_STORE_HEAD_OK               :
     458                    case ROB_END_OK                      :
     459                    case ROB_END_KO                      :
     460                    case ROB_END_BRANCH_MISS             :
     461                    case ROB_END_EXCEPTION               :
     462                    default                              :
    422463                      {
    423464                        throw ERRORMORPHEO(FUNCTION,_("Miss Speculation : Invalide state.\n"));
     
    434475                  switch (state)
    435476                    {
    436                     case ROB_END_OK_SPECULATIVE        : {state = ROB_END_OK                 ; break;}
    437                     case ROB_END_KO_SPECULATIVE        : {state = ROB_END_KO                 ; break;}
     477                    case ROB_END_OK_SPECULATIVE          : {state = ROB_END_OK                 ; break;}
     478                    case ROB_END_KO_SPECULATIVE          : {state = ROB_END_KO                 ; break;}
     479                    case ROB_END_BRANCH_MISS_SPECULATIVE : {state = ROB_END_BRANCH_MISS        ; break;}
    438480                    default : {break;}
    439481                  }
     
    519561                       (*it)->num_reg_re_phy_new      );
    520562           
    521             log_printf(TRACE,Commit_unit,FUNCTION,"             %.2d %.2d %.1d %.1d %.8x %s",
     563            log_printf(TRACE,Commit_unit,FUNCTION,"             %.2d %.2d %.1d %.1d %.8x",
    522564                       (*it)->exception     ,
    523565                       (*it)->exception_use ,
    524566                       (*it)->flags         ,
    525567                       (*it)->no_sequence   ,
    526                        (*it)->data_commit   ,
    527                        toString((*it)->event_state).c_str()
     568                       (*it)->data_commit   
    528569                       );
    529570
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Rename_unit/Register_translation_unit/Register_Address_Translation_unit/src/Register_Address_Translation_unit.cpp

    r88 r100  
    113113            sensitive << (*(in_RENAME_CONTEXT_ID     [i]));
    114114           
    115             sensitive << (*(in_RENAME_NUM_REG_RA_LOG [i]))
     115            sensitive << (*(in_RENAME_VAL            [i])) // Not necessary
     116                      << (*(in_RENAME_NUM_REG_RA_LOG [i]))
    116117                      << (*(in_RENAME_NUM_REG_RB_LOG [i]))
    117118                      << (*(in_RENAME_NUM_REG_RC_LOG [i]))
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Rename_unit/Register_translation_unit/Register_Address_Translation_unit/src/Register_Address_Translation_unit_genMealy_rename.cpp

    r97 r100  
    2929      if (PORT_READ(in_RENAME_VAL [i])) // not in sensitive list : it's to have valide value to array access
    3030      {
     31        log_printf(TRACE,Register_Address_Translation_unit,FUNCTION,"  * RENAME [%d]",i);
     32
    3133        Tcontext_t front_end_id = (_param->_have_port_front_end_id)?PORT_READ(in_RENAME_FRONT_END_ID [i]):0;
    3234        Tcontext_t context_id   = (_param->_have_port_context_id  )?PORT_READ(in_RENAME_CONTEXT_ID   [i]):0;
    3335
    34         Tgeneral_address_t num_reg_ra_log = PORT_READ(in_RENAME_NUM_REG_RA_LOG [i]); //%_param->_nb_general_register;
    35         Tgeneral_address_t num_reg_rb_log = PORT_READ(in_RENAME_NUM_REG_RB_LOG [i]); //%_param->_nb_general_register;
    36         Tspecial_address_t num_reg_rc_log = PORT_READ(in_RENAME_NUM_REG_RC_LOG [i]); //%_param->_nb_special_register;
    37         Tgeneral_address_t num_reg_rd_log = PORT_READ(in_RENAME_NUM_REG_RD_LOG [i]); //%_param->_nb_general_register;
    38         Tspecial_address_t num_reg_re_log = PORT_READ(in_RENAME_NUM_REG_RE_LOG [i]); //%_param->_nb_special_register;
     36        log_printf(TRACE,Register_Address_Translation_unit,FUNCTION,"    * front_end_id       : %d",front_end_id);
     37        log_printf(TRACE,Register_Address_Translation_unit,FUNCTION,"    * context_id         : %d",context_id);
    3938
    40         PORT_WRITE(out_RENAME_NUM_REG_RA_PHY     [i], rat_gpr[front_end_id][context_id][num_reg_ra_log]);
    41         PORT_WRITE(out_RENAME_NUM_REG_RB_PHY     [i], rat_gpr[front_end_id][context_id][num_reg_rb_log]);
    42         PORT_WRITE(out_RENAME_NUM_REG_RC_PHY     [i], rat_spr[front_end_id][context_id][num_reg_rc_log]);
    43         PORT_WRITE(out_RENAME_NUM_REG_RD_PHY_OLD [i], rat_gpr[front_end_id][context_id][num_reg_rd_log]);
    44         PORT_WRITE(out_RENAME_NUM_REG_RE_PHY_OLD [i], rat_spr[front_end_id][context_id][num_reg_re_log]);
    45         log_printf(TRACE,Register_Address_Translation_unit,FUNCTION,"yo6");
     39        Tgeneral_address_t num_reg_ra_log    = PORT_READ(in_RENAME_NUM_REG_RA_LOG [i]); //%_param->_nb_general_register;
     40        Tgeneral_address_t num_reg_rb_log    = PORT_READ(in_RENAME_NUM_REG_RB_LOG [i]); //%_param->_nb_general_register;
     41        Tspecial_address_t num_reg_rc_log    = PORT_READ(in_RENAME_NUM_REG_RC_LOG [i]); //%_param->_nb_special_register;
     42        Tgeneral_address_t num_reg_rd_log    = PORT_READ(in_RENAME_NUM_REG_RD_LOG [i]); //%_param->_nb_general_register;
     43        Tspecial_address_t num_reg_re_log    = PORT_READ(in_RENAME_NUM_REG_RE_LOG [i]); //%_param->_nb_special_register;
     44                                           
     45        Tgeneral_address_t num_reg_ra_phy    = rat_gpr[front_end_id][context_id][num_reg_ra_log];
     46        Tgeneral_address_t num_reg_rb_phy    = rat_gpr[front_end_id][context_id][num_reg_rb_log];
     47        Tspecial_address_t num_reg_rc_phy    = rat_spr[front_end_id][context_id][num_reg_rc_log];
     48        Tgeneral_address_t num_reg_rd_phy_old= rat_gpr[front_end_id][context_id][num_reg_rd_log];
     49        Tspecial_address_t num_reg_re_phy_old= rat_spr[front_end_id][context_id][num_reg_re_log];
     50
     51        log_printf(TRACE,Register_Address_Translation_unit,FUNCTION,"    * num_reg_ra         : %d -> %d",num_reg_ra_log,num_reg_ra_phy    );
     52        log_printf(TRACE,Register_Address_Translation_unit,FUNCTION,"    * num_reg_rb         : %d -> %d",num_reg_rb_log,num_reg_rb_phy    );
     53        log_printf(TRACE,Register_Address_Translation_unit,FUNCTION,"    * num_reg_rc         : %d -> %d",num_reg_rc_log,num_reg_rc_phy    );
     54        log_printf(TRACE,Register_Address_Translation_unit,FUNCTION,"    * num_reg_rd         : %d -> %d",num_reg_rd_log,num_reg_rd_phy_old);
     55        log_printf(TRACE,Register_Address_Translation_unit,FUNCTION,"    * num_reg_re         : %d -> %d",num_reg_re_log,num_reg_re_phy_old);
     56       
     57
     58        PORT_WRITE(out_RENAME_NUM_REG_RA_PHY     [i], num_reg_ra_phy    );
     59        PORT_WRITE(out_RENAME_NUM_REG_RB_PHY     [i], num_reg_rb_phy    );
     60        PORT_WRITE(out_RENAME_NUM_REG_RC_PHY     [i], num_reg_rc_phy    );
     61        PORT_WRITE(out_RENAME_NUM_REG_RD_PHY_OLD [i], num_reg_rd_phy_old);
     62        PORT_WRITE(out_RENAME_NUM_REG_RE_PHY_OLD [i], num_reg_re_phy_old);
    4663      }
    4764
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Rename_unit/Register_translation_unit/Register_Address_Translation_unit/src/Register_Address_Translation_unit_transition.cpp

    r98 r100  
    3737
    3838              for (uint32_t k=1; k<_param->_nb_general_register_logic; k++)
    39                 rat_gpr [i][j][k] = gpr++;
     39                {
     40                  rat_gpr             [i][j][k] = gpr++;
     41//                rat_gpr_update_table[i][j][k] = 0;
     42                }
    4043              for (uint32_t k=0; k<_param->_nb_special_register_logic; k++)
    41                 rat_spr [i][j][k] = spr++;
     44                {
     45                  rat_spr             [i][j][k] = spr++;
     46//                rat_spr_update_table[i][j][k] = 0;
     47                }
    4248            }
    4349      }
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Special_Register_unit/src/Special_Register_unit_transition.cpp

    r98 r100  
    9595              if (PORT_READ(in_SPR_COMMIT_VAL [i][j])) // out_SPR_COMMIT_ACK [i][j]
    9696                {
     97                  log_printf(TRACE,Special_Register_unit,FUNCTION,"  * SPR_COMMIT [%d][%d]",i,j);
     98                  log_printf(TRACE,Special_Register_unit,FUNCTION,"    * F            : %d, %d",PORT_READ(in_SPR_COMMIT_SR_F_VAL  [i][j]),PORT_READ(in_SPR_COMMIT_SR_F  [i][j]));
     99                  log_printf(TRACE,Special_Register_unit,FUNCTION,"    * CY           : %d, %d",PORT_READ(in_SPR_COMMIT_SR_CY_VAL [i][j]),PORT_READ(in_SPR_COMMIT_SR_CY [i][j]));
     100                  log_printf(TRACE,Special_Register_unit,FUNCTION,"    * OV           : %d, %d",PORT_READ(in_SPR_COMMIT_SR_OV_VAL [i][j]),PORT_READ(in_SPR_COMMIT_SR_OV [i][j]));
     101
     102                  log_printf(TRACE,Special_Register_unit,FUNCTION,"    * SPR (before) : %.8x",_spr [i][j][GROUP_SYSTEM_AND_CONTROL][SPR_SR]->read());
    97103                  SR * sr = static_cast<SR*>(_spr [i][j][GROUP_SYSTEM_AND_CONTROL][SPR_SR]);
    98104
     
    105111                  if (PORT_READ(in_SPR_COMMIT_SR_OV_VAL [i][j]))
    106112                    sr->ov = PORT_READ(in_SPR_COMMIT_SR_OV [i][j]);
     113
     114                  log_printf(TRACE,Special_Register_unit,FUNCTION,"    * SPR (after)  : %.8x",_spr [i][j][GROUP_SYSTEM_AND_CONTROL][SPR_SR]->read());
     115
    107116                }
    108117
    109118              if (PORT_READ(in_SPR_EVENT_VAL [i][j])) // out_SPR_EVENT_ACK [i][j]
    110119                {
     120                  log_printf(TRACE,Special_Register_unit,FUNCTION,"  * SPR_EVENT [%d][%d]",i,j);
     121                  log_printf(TRACE,Special_Register_unit,FUNCTION,"    * SPR (before) : %.8x",_spr [i][j][GROUP_SYSTEM_AND_CONTROL][SPR_SR]->read());
     122
    111123                  SR * sr = static_cast<SR*>(_spr [i][j][GROUP_SYSTEM_AND_CONTROL][SPR_SR]);
    112124                  sr->dsx = PORT_READ(in_SPR_EVENT_SR_DSX [i][j]);
     
    117129                  if (PORT_READ(in_SPR_EVENT_SR_TO_ESR [i][j]))
    118130                  _spr [i][j][GROUP_SYSTEM_AND_CONTROL][SPR_ESR ]->write(sr->read());
     131
     132                  log_printf(TRACE,Special_Register_unit,FUNCTION,"    * SPR (after)  : %.8x",_spr [i][j][GROUP_SYSTEM_AND_CONTROL][SPR_SR]->read());
    119133                }
    120134            }
Note: See TracChangeset for help on using the changeset viewer.