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

Last change on this file was 146, checked in by rosiere, 13 years ago

1) Integration of RegisterFile_Internal_Banked in RegisterFile?
2) Erase "read_write" interface in RegisterFile_Monolithic component
3) Add smith predictor parameters in Load_store_pointer_unit.
4) Fix not statistics flags

  • Property svn:keywords set to Id
File size: 7.5 KB
Line 
1/*
2 * $Id: Parameters.cpp 146 2011-02-01 20:57:54Z rosiere $
3 *
4 * [ Description ]
5 *
6 */
7
8#include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/include/Parameters.h"
9#include "Common/include/BitManipulation.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::Parameters"
24  Parameters::Parameters (uint32_t      nb_inst_predict       ,
25                          uint32_t      nb_inst_update        ,
26                          uint32_t      size_address          ,
27                          bool          have_bht              ,
28                          uint32_t      bht_size_shifter      ,
29                          uint32_t      bht_nb_shifter        ,
30                          bool          have_pht              ,
31                          uint32_t      pht_size_counter      ,
32                          uint32_t      pht_nb_counter        ,
33                          uint32_t      pht_size_address_share,
34                          Tpht_scheme_t pht_scheme            ,
35                          bool          update_on_prediction  ,
36                          bool          is_toplevel)
37  {
38    log_begin(Two_Level_Branch_Predictor,FUNCTION);
39
40    _nb_inst_predict         = nb_inst_predict       ;
41    _nb_inst_update          = nb_inst_update        ;
42    _size_address            = size_address          ;
43    _have_bht                = have_bht              ;
44    _bht_size_shifter        = (have_bht)?(bht_size_shifter):0;
45    _bht_nb_shifter          = (have_bht)?(bht_nb_shifter  ):0;
46    _have_pht                = have_pht              ;
47    _pht_size_counter        = (have_pht)?(pht_size_counter):0;
48    _pht_nb_counter          = (have_pht)?(pht_nb_counter  ):0;
49    _pht_size_address_share  = (have_bht and have_pht)?(pht_size_address_share):0;
50    _pht_scheme              = pht_scheme            ;
51    _update_on_prediction    = update_on_prediction  ;
52                             
53    _bht_size_address        = (_have_bht)?log2(_bht_nb_shifter):0;
54    _pht_size_address        = (_have_pht)?log2(_pht_nb_counter):0;
55                             
56    test();                 
57
58    // history to update_prediction_table :
59    //  MSB : pht_history
60    //  LSB : bht_history
61    log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * _have_bht                 : %d",_have_bht        );
62    log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * _bht_size_shifter         : %d",_bht_size_shifter);
63    log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * _bht_nb_shifter           : %d",_bht_nb_shifter  );
64
65    log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * _have_pht                 : %d",_have_pht        );
66    log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * _pht_size_counter         : %d",_pht_size_counter);
67    log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * _pht_nb_counter           : %d",_pht_nb_counter  );
68                       
69    _size_history            = _bht_size_shifter + _pht_size_counter;
70    _bht_history_mask        = gen_mask<Thistory_t>(_bht_size_shifter);
71    _bht_history_shift       = 0;
72    _pht_history_mask        = gen_mask<Thistory_t>(_pht_size_counter);
73    _pht_history_shift       = _bht_size_shifter;
74                             
75    log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * _size_history             : %d",_size_history  );
76    log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * _bht_history_mask         : 0x%llx",_bht_history_mask  );
77    log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * _bht_history_shift        : %lld",_bht_history_shift );
78    log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * _pht_history_mask         : 0x%llx",_pht_history_mask  );
79    log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * _pht_history_shift        : %lld",_pht_history_shift );
80
81    _bht_init_take           = static_cast<Thistory_t>(-1)&_bht_history_mask;
82    _bht_init_ntake          = 0;
83    _pht_init_take           = (1<<(_pht_size_counter-1)); // size = 4 : 1000/2
84    _pht_init_ntake          = _pht_init_take-1;           // size = 4 : 0111/2
85
86    log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * _bht_init_take            : 0x%llx",_bht_init_take );
87    log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * _bht_init_ntake           : 0x%llx",_bht_init_ntake);
88    log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * _pht_init_take            : 0x%llx",_pht_init_take );
89    log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * _pht_init_ntake           : 0x%llx",_pht_init_ntake);
90   
91    if (_have_bht)
92      {
93        _bht_address_mask        = gen_mask<Taddress_t>(_bht_size_address);
94
95        log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * _bht_address_mask         : 0x%x",_bht_address_mask  );
96      }
97
98    if (_have_pht)
99      {
100        _pht_counter_max         = (1<<_pht_size_counter)-1;
101        _pht_threshold_up        = (1<<(_pht_size_counter-1))+1;
102        _pht_threshold_down      = (1<<(_pht_size_counter-1))-1;
103
104        _pht_size_bank           = (_have_bht)?(1<<_bht_size_shifter):1;
105        _pht_nb_bank             = _pht_nb_counter / _pht_size_bank;
106
107        // -------->|
108        //   +---+  |
109        //   |   |  |--->
110        // ---> --->|
111        //   |   |  |
112        //   +---+
113        //
114
115        _pht_address_share_mask  = gen_mask<Taddress_t>(_pht_size_address_share);
116        _pht_address_share_shift = _bht_size_shifter-_pht_size_address_share;
117        _pht_address_bank_mask   = gen_mask<Taddress_t>(log2(_pht_nb_bank));
118        _pht_address_bank_shift  = _pht_size_address_share;
119
120        log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * _pht_nb_bank              : %d"  ,_pht_nb_bank   );
121        log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * _pht_size_bank            : %d"  ,_pht_size_bank );
122        log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * _pht_address_share_mask   : 0x%x",_pht_address_share_mask  );
123        log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * _pht_address_share_shift  : %d"  ,_pht_address_share_shift );
124        log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * _pht_address_bank_mask    : 0x%x",_pht_address_bank_mask   );
125        log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * _pht_address_bank_shift   : %d"  ,_pht_address_bank_shift  );
126      }
127
128    if (is_toplevel)
129      copy();
130
131    log_end(Two_Level_Branch_Predictor,FUNCTION);
132  };
133 
134// #undef  FUNCTION
135// #define FUNCTION "Two_Level_Branch_Predictor::Parameters (copy)"
136//   Parameters::Parameters (Parameters & param)
137//   {
138//     log_begin(Two_Level_Branch_Predictor,FUNCTION);
139//     test();
140//     log_end(Two_Level_Branch_Predictor,FUNCTION);
141//   };
142
143#undef  FUNCTION
144#define FUNCTION "Two_Level_Branch_Predictor::~Parameters"
145  Parameters::~Parameters (void) 
146  {
147    log_begin(Two_Level_Branch_Predictor,FUNCTION);
148    log_end(Two_Level_Branch_Predictor,FUNCTION);
149  };
150
151#undef  FUNCTION
152#define FUNCTION "Two_Level_Branch_Predictor::copy"
153  void Parameters::copy (void) 
154  {
155    log_begin(Two_Level_Branch_Predictor,FUNCTION);
156    log_end(Two_Level_Branch_Predictor,FUNCTION);
157  };
158
159}; // end namespace two_level_branch_predictor
160}; // end namespace meta_predictor
161}; // end namespace direction
162}; // end namespace prediction_unit
163}; // end namespace front_end
164}; // end namespace multi_front_end
165}; // end namespace core
166
167}; // end namespace behavioural
168}; // end namespace morpheo             
Note: See TracBrowser for help on using the repository browser.