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

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