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

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

1) Add test and configuration
2) Fix Bug
3) Add log file in load store unit
4) Fix Bug in environment

  • Property svn:keywords set to Id
File size: 4.3 KB
Line 
1
2#ifdef SYSTEMC
3/*
4 * $Id: Two_Level_Branch_Predictor_genMealy_predict.cpp 124 2009-06-17 12:11:25Z 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    if (PORT_READ(in_NRESET))
32      {
33    // ===================================================================
34    // =====[ PREDICT ]===================================================
35    // ===================================================================
36
37    for (uint32_t i=0; i<_param->_nb_inst_predict; ++i)
38//       if (PORT_READ(in_PREDICT_VAL[i]))
39        {
40          log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * PREDICT [%d]",i);
41
42          Taddress_t address     = PORT_READ(in_PREDICT_ADDRESS   [i]);
43          Thistory_t history     = 0;
44          Tcontrol_t direction   = 0;
45
46          log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * address          : 0x%.8x",address);
47
48          Thistory_t pht_bht_history = 0;
49          if (_param->_have_bht)
50            {
51              Thistory_t bht_num_reg = address & _param->_bht_address_mask;
52
53// #ifdef DEBUG_TEST
54//               assert(bht_num_reg < _param->_bht_nb_shifter);
55// #endif
56
57              Thistory_t bht_history = reg_BHT [bht_num_reg];
58              pht_bht_history = bht_history;
59
60              log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * bht_history      : 0x%llx",bht_history);
61              log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * bht_num_reg      : %lld",bht_num_reg);
62
63              history   = (bht_history << _param->_bht_history_shift )&_param->_bht_history_mask ;
64              direction = (bht_history >> (_param->_bht_size_shifter-1))&1;
65
66              if (_param->_update_on_prediction)
67              internal_PREDICT_BHT_NUM_REG [i] = bht_num_reg;
68            }
69
70          if (_param->_have_pht)
71            {
72              Thistory_t pht_num_bank= (address>>_param->_pht_address_bank_shift )&_param->_pht_address_bank_mask;
73              Thistory_t pht_num_reg = (pht_bht_history xor ((address&_param->_pht_address_share_mask)<<_param->_pht_address_share_shift));
74
75              log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * bht_history      : 0x%llx",pht_bht_history);
76              log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * pht_num_reg      : %lld",pht_num_reg);
77              log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * pht_num_bank     : %lld",pht_num_bank);
78
79              Thistory_t pht_history = reg_PHT [pht_num_bank][pht_num_reg];
80             
81              log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * pht_history      : 0x%llx",pht_history);
82             
83              history  |= (pht_history << _param->_pht_history_shift )&_param->_pht_history_mask;
84              direction = (pht_history >> (_param->_pht_size_counter-1))&1;
85
86              if (_param->_update_on_prediction)
87                {
88              internal_PREDICT_PHT_NUM_REG [i] = pht_num_reg;
89              internal_PREDICT_PHT_NUM_BANK[i] = pht_num_bank;
90                }
91            }
92
93          log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * direction        : %d",direction);
94          log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * history          : 0x%llx",history);
95
96          PORT_WRITE(out_PREDICT_DIRECTION [i],direction);
97          PORT_WRITE(out_PREDICT_HISTORY   [i],history  );
98        }
99      }
100
101    log_end(Two_Level_Branch_Predictor,FUNCTION);
102  };
103
104}; // end namespace two_level_branch_predictor
105}; // end namespace meta_predictor
106}; // end namespace direction
107}; // end namespace prediction_unit
108}; // end namespace front_end
109}; // end namespace multi_front_end
110}; // end namespace core
111
112}; // end namespace behavioural
113}; // end namespace morpheo             
114#endif
Note: See TracBrowser for help on using the repository browser.