source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/src/Two_Level_Branch_Predictor_genMealy_predict.cpp @ 119

Last change on this file since 119 was 119, checked in by rosiere, 15 years ago

1) Prediction unit : static prediction not blocking

  • Property svn:keywords set to Id
File size: 4.2 KB
Line 
1
2#ifdef SYSTEMC
3/*
4 * $Id: Two_Level_Branch_Predictor_genMealy_predict.cpp 119 2009-05-25 17:40:26Z rosiere $
5 *
6 * [ Description ]
7 *
8 */
9
10#include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/include/Two_Level_Branch_Predictor.h"
11// #include <assert.h>
12
13namespace morpheo                    {
14namespace behavioural {
15namespace core {
16namespace multi_front_end {
17namespace front_end {
18namespace prediction_unit {
19namespace direction {
20namespace meta_predictor {
21namespace two_level_branch_predictor {
22
23
24#undef  FUNCTION
25#define FUNCTION "Two_Level_Branch_Predictor::genMealy_predict"
26  void Two_Level_Branch_Predictor::genMealy_predict (void)
27  {
28    log_begin(Two_Level_Branch_Predictor,FUNCTION);
29    log_function(Two_Level_Branch_Predictor,FUNCTION,_name.c_str());
30
31    // ===================================================================
32    // =====[ PREDICT ]===================================================
33    // ===================================================================
34
35    for (uint32_t i=0; i<_param->_nb_inst_predict; ++i)
36//       if (PORT_READ(in_PREDICT_VAL[i]))
37        {
38          log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * PREDICT [%d]",i);
39
40          Taddress_t address     = PORT_READ(in_PREDICT_ADDRESS   [i]);
41          Thistory_t history     = 0;
42          Tcontrol_t direction;
43
44          log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * address          : 0x%.8x",address);
45
46          Thistory_t pht_bht_history = 0;
47          if (_param->_have_bht)
48            {
49              Thistory_t bht_num_reg = address & _param->_bht_address_mask;
50
51// #ifdef DEBUG_TEST
52//               assert(bht_num_reg < _param->_bht_nb_shifter);
53// #endif
54
55              Thistory_t bht_history = reg_BHT [bht_num_reg];
56              pht_bht_history = bht_history;
57
58              log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * bht_history      : 0x%x",bht_history);
59              log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * bht_num_reg      : %d",bht_num_reg);
60
61              history   = (bht_history << _param->_bht_history_shift )&_param->_bht_history_mask ;
62              direction = (bht_history >> (_param->_bht_size_shifter-1))&1;
63
64              if (_param->_update_on_prediction)
65              internal_PREDICT_BHT_NUM_REG [i] = bht_num_reg;
66            }
67
68          if (_param->_have_pht)
69            {
70              Thistory_t pht_num_bank= (address>>_param->_pht_address_bank_shift )&_param->_pht_address_bank_mask;
71              Thistory_t pht_num_reg = (pht_bht_history xor ((address&_param->_pht_address_share_mask)<<_param->_pht_address_share_shift));
72
73              log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * bht_history      : 0x%x",pht_bht_history);
74              log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * pht_num_reg      : %d",pht_num_reg);
75              log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * pht_num_bank     : %d",pht_num_bank);
76
77              Thistory_t pht_history = reg_PHT [pht_num_bank][pht_num_reg];
78             
79              log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * pht_history      : 0x%x",pht_history);
80             
81              history  |= (pht_history << _param->_pht_history_shift )&_param->_pht_history_mask;
82              direction = (pht_history >> (_param->_pht_size_counter-1))&1;
83
84              if (_param->_update_on_prediction)
85                {
86              internal_PREDICT_PHT_NUM_REG [i] = pht_num_reg;
87              internal_PREDICT_PHT_NUM_BANK[i] = pht_num_bank;
88                }
89            }
90
91          log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * direction        : %d",direction);
92          log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * history          : 0x%x",history);
93
94          PORT_WRITE(out_PREDICT_DIRECTION [i],direction);
95          PORT_WRITE(out_PREDICT_HISTORY   [i],history  );
96        }
97
98    log_end(Two_Level_Branch_Predictor,FUNCTION);
99  };
100
101}; // end namespace two_level_branch_predictor
102}; // end namespace meta_predictor
103}; // end namespace direction
104}; // end namespace prediction_unit
105}; // end namespace front_end
106}; // end namespace multi_front_end
107}; // end namespace core
108
109}; // end namespace behavioural
110}; // end namespace morpheo             
111#endif
Note: See TracBrowser for help on using the repository browser.