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 @ 115

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

1) Write queue with mealy
2) Network : fix bug
3) leak memory

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