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

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

1) Correct bug in link two signal
2) Fix error detected with valgrind
3) modif distexe script

  • Property svn:keywords set to Id
File size: 5.5 KB
Line 
1/*
2 * $Id: Parameters.cpp 128 2009-06-26 08:43:23Z rosiere $
3 *
4 * [ Description ]
5 *
6 */
7
8#include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/include/Parameters.h"
9#include "Behavioural/include/Allocation.h"
10
11namespace morpheo {
12namespace behavioural {
13namespace core {
14namespace multi_front_end {
15namespace front_end {
16namespace prediction_unit {
17namespace direction {
18namespace meta_predictor {
19
20
21#undef  FUNCTION
22#define FUNCTION "Meta_Predictor::Parameters"
23  Parameters::Parameters (uint32_t nb_inst_predict           ,
24                          uint32_t nb_inst_update            ,
25                          uint32_t size_address              ,
26                          bool     have_bht               [3],
27                          uint32_t bht_size_shifter       [3],
28                          uint32_t bht_nb_shifter         [3],
29                          bool     have_pht               [3],
30                          uint32_t pht_size_counter       [3],
31                          uint32_t pht_nb_counter         [3],
32                          uint32_t pht_size_address_share [3],
33                          bool     is_toplevel)
34  {
35    log_begin(Meta_Predictor,FUNCTION);
36
37    _nb_inst_predict            = nb_inst_predict           ;
38    _nb_inst_update             = nb_inst_update            ;
39    _size_address               = size_address              ;
40    for (uint32_t i=0; i<3; ++i)
41      {
42    _have_bht               [i] =                 have_bht               [i];
43    _bht_size_shifter       [i] = (_have_bht [i])?bht_size_shifter       [i]:0;
44    _bht_nb_shifter         [i] = (_have_bht [i])?bht_nb_shifter         [i]:0;
45    _have_pht               [i] =                 have_pht               [i];
46    _pht_size_counter       [i] = (_have_pht [i])?pht_size_counter       [i]:0;
47    _pht_nb_counter         [i] = (_have_pht [i])?pht_nb_counter         [i]:0;
48    _pht_size_address_share [i] = (_have_bht[i] and _have_pht [i])?pht_size_address_share [i]:0;
49      }
50
51    test();
52
53    _have_meta_predictor        = (_have_bht [2] or _have_pht [2]);
54    _nb_predictor               = (_have_meta_predictor)?3:1;
55   
56    ALLOC1(_predictor_update_on_prediction,bool    , _nb_predictor);
57    ALLOC1(_predictor_size_history        ,uint32_t, _nb_predictor);
58   
59    // All predictor can update on prediction ....
60    for (uint32_t i=0; i<_nb_predictor; ++i)
61      _predictor_update_on_prediction [i] = true;
62
63    // ... But the selector prediction can't
64    if (_have_meta_predictor)
65      _predictor_update_on_prediction [_nb_predictor-1] = false;
66
67//     // All predictor can't update on prediction ....
68//     for (uint32_t i=0; i<_nb_predictor; ++i)
69//       _predictor_update_on_prediction [i] = false;
70
71    _param_two_level_branch_predictor = new morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::direction::meta_predictor::two_level_branch_predictor::Parameters * [_nb_predictor];
72    for (uint32_t i=0; i<_nb_predictor; ++i)
73      {
74        _param_two_level_branch_predictor [i] = new morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::direction::meta_predictor::two_level_branch_predictor::Parameters
75          (_nb_inst_predict                   ,
76           _nb_inst_update                    ,
77           _size_address                      ,
78           _have_bht                       [i],
79           _bht_size_shifter               [i],
80           _bht_nb_shifter                 [i],
81           _have_pht                       [i],
82           _pht_size_counter               [i],
83           _pht_nb_counter                 [i],
84           _pht_size_address_share         [i],
85           _predictor_update_on_prediction [i]
86           );
87
88        _predictor_size_history [i] = _param_two_level_branch_predictor [i]->_size_history;
89      }
90
91    _param_glue = new morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::direction::meta_predictor::meta_predictor_glue::Parameters 
92      (
93       _nb_inst_predict               ,
94       _nb_inst_update                ,
95       _nb_predictor                  ,
96       _predictor_size_history        ,
97       _predictor_update_on_prediction
98       );
99    _size_history = _param_glue->_size_history;
100   
101    if (is_toplevel)
102      {
103        copy();
104      }
105
106    log_end(Meta_Predictor,FUNCTION);
107  };
108 
109// #undef  FUNCTION
110// #define FUNCTION "Meta_Predictor::Parameters (copy)"
111//   Parameters::Parameters (Parameters & param)
112//   {
113//     log_begin(Meta_Predictor,FUNCTION);
114//     test();
115//     log_end(Meta_Predictor,FUNCTION);
116//   };
117
118#undef  FUNCTION
119#define FUNCTION "Meta_Predictor::~Parameters"
120  Parameters::~Parameters (void) 
121  {
122    log_begin(Meta_Predictor,FUNCTION);
123
124    delete    _param_glue;
125    for (uint32_t i=0; i<_nb_predictor; ++i)
126    delete    _param_two_level_branch_predictor [i];
127    delete [] _param_two_level_branch_predictor;
128
129    DELETE1(_predictor_size_history          , _nb_predictor);
130    DELETE1(_predictor_update_on_prediction  , _nb_predictor);
131
132    log_end(Meta_Predictor,FUNCTION);
133  };
134
135#undef  FUNCTION
136#define FUNCTION "Meta_Predictor::copy"
137  void Parameters::copy (void) 
138  {
139    log_begin(Meta_Predictor,FUNCTION);
140
141    COPY(_param_glue);
142    for (uint32_t i=0; i<_nb_predictor; ++i)
143      COPY(_param_two_level_branch_predictor [i]);
144
145    log_end(Meta_Predictor,FUNCTION);
146  };
147
148}; // end namespace meta_predictor
149}; // end namespace direction
150}; // end namespace prediction_unit
151}; // end namespace front_end
152}; // end namespace multi_front_end
153}; // end namespace core
154
155}; // end namespace behavioural
156}; // end namespace morpheo             
Note: See TracBrowser for help on using the repository browser.