Ignore:
Timestamp:
Mar 9, 2007, 7:16:58 PM (17 years ago)
Author:
rosiere
Message:

Ajout du composant Meta_Predictor

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Stage_1_Ifetch/Predictor/Meta_Predictor/Meta_Predictor_Glue/SelfTest/src/test.cpp

    r4 r5  
    4545
    4646    // Interface Branch_complete
     47  sc_signal<Tcontrol_t>           ** BRANCH_COMPLETE_VAL                    ;
     48  sc_signal<Tcontrol_t>           ** BRANCH_COMPLETE_PREDICTOR_2_VAL        ;
     49
    4750  sc_signal<Tcontrol_t>           ** BRANCH_COMPLETE_PREDICTOR_0_ACK        ;
    4851  sc_signal<Tcontrol_t>           ** BRANCH_COMPLETE_PREDICTOR_1_ACK        ;
     
    5760  sc_signal<Tpht_history_t>       ** BRANCH_COMPLETE_PREDICTOR_2_PHT_HISTORY;
    5861  sc_signal<Thistory_t>           ** BRANCH_COMPLETE_HISTORY                ;
    59 
     62  sc_signal<Tcontrol_t>           ** BRANCH_COMPLETE_DIRECTION              ;
     63  sc_signal<Tcontrol_t>           ** BRANCH_COMPLETE_PREDICTOR_2_DIRECTION  ;
    6064  string rename;
    6165
     
    108112
    109113    // Interface Branch_complete
    110    
     114    BRANCH_COMPLETE_VAL                     = new sc_signal<Tcontrol_t>     * [_param._nb_branch_complete     ];
     115    BRANCH_COMPLETE_PREDICTOR_2_VAL         = new sc_signal<Tcontrol_t>     * [_param._nb_branch_complete     ];
    111116    BRANCH_COMPLETE_PREDICTOR_0_ACK         = new sc_signal<Tcontrol_t>     * [_param._nb_branch_complete     ];
    112117    BRANCH_COMPLETE_PREDICTOR_1_ACK         = new sc_signal<Tcontrol_t>     * [_param._nb_branch_complete     ];
     
    120125    BRANCH_COMPLETE_PREDICTOR_2_PHT_HISTORY = new sc_signal<Tpht_history_t> * [_param._nb_branch_complete     ];
    121126    BRANCH_COMPLETE_HISTORY                 = new sc_signal<Thistory_t>     * [_param._nb_branch_complete     ];
     127    BRANCH_COMPLETE_DIRECTION               = new sc_signal<Tcontrol_t>     * [_param._nb_branch_complete     ];
     128    BRANCH_COMPLETE_PREDICTOR_2_DIRECTION   = new sc_signal<Tcontrol_t>     * [_param._nb_branch_complete     ];
    122129
    123130    for (uint32_t i=0; i<_param._nb_branch_complete; i++)
    124131      {
     132        rename = "BRANCH_COMPLETE_VAL_"                      +toString(i);
     133        BRANCH_COMPLETE_VAL                               [i] = new sc_signal<Tcontrol_t>     (rename.c_str());
     134        rename = "BRANCH_COMPLETE_PREDICTOR_2_VAL_"          +toString(i);
     135        BRANCH_COMPLETE_PREDICTOR_2_VAL                   [i] = new sc_signal<Tcontrol_t>     (rename.c_str());
    125136        rename = "BRANCH_COMPLETE_PREDICTOR_0_ACK_"          +toString(i);
    126137        BRANCH_COMPLETE_PREDICTOR_0_ACK                   [i] = new sc_signal<Tcontrol_t>     (rename.c_str());
     
    145156        rename = "BRANCH_COMPLETE_HISTORY_"                +toString(i);
    146157        BRANCH_COMPLETE_HISTORY                           [i] = new sc_signal<Thistory_t>     (rename.c_str());
     158        rename = "BRANCH_COMPLETE_DIRECTION_"              +toString(i);
     159        BRANCH_COMPLETE_DIRECTION                         [i] = new sc_signal<Tcontrol_t>     (rename.c_str());
     160        rename = "BRANCH_COMPLETE_PREDICTOR_2_DIRECTION_"  +toString(i);
     161        BRANCH_COMPLETE_PREDICTOR_2_DIRECTION             [i] = new sc_signal<Tcontrol_t>     (rename.c_str());
    147162      }
    148163
     
    192207        if (_param._have_meta_predictor)
    193208          {
     209        (*(_Meta_Predictor_Glue-> in_BRANCH_COMPLETE_VAL                     [i])) (*(BRANCH_COMPLETE_VAL                     [i]));
     210        (*(_Meta_Predictor_Glue->out_BRANCH_COMPLETE_PREDICTOR_2_VAL         [i])) (*(BRANCH_COMPLETE_PREDICTOR_2_VAL         [i]));
     211
    194212        (*(_Meta_Predictor_Glue-> in_BRANCH_COMPLETE_PREDICTOR_0_ACK         [i])) (*(BRANCH_COMPLETE_PREDICTOR_0_ACK         [i]));
    195213        (*(_Meta_Predictor_Glue-> in_BRANCH_COMPLETE_PREDICTOR_1_ACK         [i])) (*(BRANCH_COMPLETE_PREDICTOR_1_ACK         [i]));
     
    214232        (*(_Meta_Predictor_Glue->out_BRANCH_COMPLETE_PREDICTOR_2_PHT_HISTORY [i])) (*(BRANCH_COMPLETE_PREDICTOR_2_PHT_HISTORY [i]));
    215233        (*(_Meta_Predictor_Glue-> in_BRANCH_COMPLETE_HISTORY                 [i])) (*(BRANCH_COMPLETE_HISTORY                 [i]));
     234        if (_param._have_meta_predictor)       
     235          {
     236        (*(_Meta_Predictor_Glue-> in_BRANCH_COMPLETE_DIRECTION               [i])) (*(BRANCH_COMPLETE_DIRECTION               [i]));
     237        (*(_Meta_Predictor_Glue->out_BRANCH_COMPLETE_PREDICTOR_2_DIRECTION   [i])) (*(BRANCH_COMPLETE_PREDICTOR_2_DIRECTION   [i]));
     238          }
    216239      }
    217240
     
    241264  Tcontrol_t     predict_direction                       [_param._nb_prediction];
    242265               
     266  Tcontrol_t     branch_complete_predictor_2_val         [_param._nb_branch_complete];
    243267  Tcontrol_t     branch_complete_ack                     [_param._nb_branch_complete];
    244268  Tbht_history_t branch_complete_predictor_0_bht_history [_param._nb_branch_complete];
     
    248272  Tbht_history_t branch_complete_predictor_2_bht_history [_param._nb_branch_complete];
    249273  Tpht_history_t branch_complete_predictor_2_pht_history [_param._nb_branch_complete];
     274  Tcontrol_t     branch_complete_predictor_2_direction   [_param._nb_branch_complete];
    250275
    251276  uint32_t shift_0 = 0;
     
    255280  uint32_t shift_4 = shift_3 + _param._predictor_1_pht_size_counter;
    256281  uint32_t shift_5 = shift_4 + _param._predictor_2_bht_size_shifter;
    257 //uint32_t shift_5 = shift_5 + _param._predictor_2_pht_size_counter;
     282//uint32_t shift_6 = shift_5 + _param._predictor_2_pht_size_counter;
    258283
    259284  for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++)
     
    353378                                                             (branch_complete_predictor_2_bht_history [i] << shift_4) |
    354379                                                             (branch_complete_predictor_2_pht_history [i] << shift_5) );
     380
     381          Tcontrol_t direction_0 = ((_param._predictor_0_have_pht)?(branch_complete_predictor_0_pht_history [i] >> (_param._predictor_0_pht_size_counter-1)):(branch_complete_predictor_0_bht_history [i] >> (_param._predictor_0_bht_size_shifter-1)))&1;
     382          Tcontrol_t direction_1 = ((_param._predictor_1_have_pht)?(branch_complete_predictor_1_pht_history [i] >> (_param._predictor_1_pht_size_counter-1)):(branch_complete_predictor_1_bht_history [i] >> (_param._predictor_1_bht_size_shifter-1)))&1;
     383          Tcontrol_t direction_2 = ((_param._predictor_2_have_pht)?(branch_complete_predictor_2_pht_history [i] >> (_param._predictor_2_pht_size_counter-1)):(branch_complete_predictor_2_bht_history [i] >> (_param._predictor_2_bht_size_shifter-1)))&1;
     384
     385          Tcontrol_t direction   = ((rand()%2) != 0);
     386          Tcontrol_t val         = ((rand()%2) != 0);
     387
     388          cout << "{"+toString(static_cast<uint32_t>(sc_simulation_time()))+"} " << endl
     389               << "  * val             : " << val << endl
     390               << "  * direction_good  : " << direction << endl
     391               << "    * direction_0   : " << direction_0 << endl
     392               << "    * direction_1   : " << direction_1 << endl
     393               << "    * direction_2   : " << direction_2 << endl;
     394         
     395          BRANCH_COMPLETE_VAL       [i] ->write (val);
     396          BRANCH_COMPLETE_DIRECTION [i] ->write (direction);
     397         
     398          if (val == 0)
     399            {
     400              branch_complete_predictor_2_val [i] = val;
     401            }
     402          else
     403            {
     404              branch_complete_predictor_2_val [i] = (direction_0 xor direction_1);
     405              if (direction_2 == 0)
     406                if (direction_0 == direction)
     407                  branch_complete_predictor_2_direction [i] = 0;
     408                else
     409                  branch_complete_predictor_2_direction [i] = 1;
     410              else
     411                if (direction_1 == direction)
     412                  branch_complete_predictor_2_direction [i] = 1;
     413                else
     414                  branch_complete_predictor_2_direction [i] = 0;
     415            }
    355416        }
    356417
     
    370431        if (_param._have_meta_predictor)       
    371432          {                                     
     433          TEST(Tcontrol_t    , BRANCH_COMPLETE_PREDICTOR_2_VAL         [i]->read(), branch_complete_predictor_2_val         [i]);
     434
     435          if (branch_complete_predictor_2_val         [i])
     436          TEST(Tcontrol_t    , BRANCH_COMPLETE_PREDICTOR_2_DIRECTION   [i]->read(), branch_complete_predictor_2_direction   [i]); 
     437
    372438        if (_param._predictor_0_have_bht)
    373439          TEST(Tbht_history_t, BRANCH_COMPLETE_PREDICTOR_0_BHT_HISTORY [i]->read(), branch_complete_predictor_0_bht_history [i]);
Note: See TracChangeset for help on using the changeset viewer.