1 | /* |
---|
2 | * $Id: Parameters.cpp 111 2009-02-27 18:37:40Z 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 | |
---|
11 | namespace morpheo { |
---|
12 | namespace behavioural { |
---|
13 | namespace core { |
---|
14 | namespace multi_front_end { |
---|
15 | namespace front_end { |
---|
16 | namespace prediction_unit { |
---|
17 | namespace direction { |
---|
18 | namespace meta_predictor { |
---|
19 | namespace 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 | _size_history = _bht_size_shifter + _pht_size_counter; |
---|
57 | |
---|
58 | _bht_history_mask = gen_mask<Thistory_t>(_bht_size_shifter); |
---|
59 | _bht_history_rshift = 0; |
---|
60 | _pht_history_mask = gen_mask<Thistory_t>(_pht_size_counter); |
---|
61 | _pht_history_rshift = _bht_size_shifter; |
---|
62 | |
---|
63 | log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * _size_history : %d",_size_history ); |
---|
64 | log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * _bht_history_mask : 0x%x",_bht_history_mask ); |
---|
65 | log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * _bht_history_rshift : %d",_bht_history_rshift); |
---|
66 | log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * _pht_history_mask : 0x%x",_pht_history_mask ); |
---|
67 | log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * _pht_history_rshift : %d",_pht_history_rshift); |
---|
68 | |
---|
69 | if (_have_bht) |
---|
70 | { |
---|
71 | _bht_address_mask = gen_mask<Taddress_t>(_bht_size_address); |
---|
72 | |
---|
73 | log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * _bht_address_mask : 0x%x",_bht_address_mask ); |
---|
74 | } |
---|
75 | |
---|
76 | if (_have_pht) |
---|
77 | { |
---|
78 | _pht_counter_max = (1<<_pht_size_counter)-1; |
---|
79 | |
---|
80 | _pht_nb_bank = (_pht_nb_counter - (1<<_bht_size_shifter))+1; |
---|
81 | _pht_size_bank = _pht_nb_counter / _pht_nb_bank; |
---|
82 | |
---|
83 | _pht_address_share_mask = gen_mask<Taddress_t>(_pht_size_address_share); |
---|
84 | _pht_address_share_lshift= _bht_size_shifter-_pht_size_address_share; |
---|
85 | _pht_address_bank_mask = gen_mask<Taddress_t>(log2(_pht_nb_bank)); |
---|
86 | _pht_address_bank_rshift = _pht_size_address_share; |
---|
87 | |
---|
88 | log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * _pht_nb_bank : %d" ,_pht_nb_bank ); |
---|
89 | log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * _pht_size_bank : %d" ,_pht_size_bank ); |
---|
90 | log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * _pht_address_share_mask : 0x%x",_pht_address_share_mask ); |
---|
91 | log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * _pht_address_share_lshift : %d" ,_pht_address_share_lshift); |
---|
92 | log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * _pht_address_bank_mask : 0x%x",_pht_address_bank_mask ); |
---|
93 | log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * _pht_address_bank_rshift : %d" ,_pht_address_bank_rshift ); |
---|
94 | } |
---|
95 | |
---|
96 | if (is_toplevel) |
---|
97 | copy(); |
---|
98 | |
---|
99 | log_end(Two_Level_Branch_Predictor,FUNCTION); |
---|
100 | }; |
---|
101 | |
---|
102 | // #undef FUNCTION |
---|
103 | // #define FUNCTION "Two_Level_Branch_Predictor::Parameters (copy)" |
---|
104 | // Parameters::Parameters (Parameters & param) |
---|
105 | // { |
---|
106 | // log_begin(Two_Level_Branch_Predictor,FUNCTION); |
---|
107 | // test(); |
---|
108 | // log_end(Two_Level_Branch_Predictor,FUNCTION); |
---|
109 | // }; |
---|
110 | |
---|
111 | #undef FUNCTION |
---|
112 | #define FUNCTION "Two_Level_Branch_Predictor::~Parameters" |
---|
113 | Parameters::~Parameters (void) |
---|
114 | { |
---|
115 | log_begin(Two_Level_Branch_Predictor,FUNCTION); |
---|
116 | log_end(Two_Level_Branch_Predictor,FUNCTION); |
---|
117 | }; |
---|
118 | |
---|
119 | #undef FUNCTION |
---|
120 | #define FUNCTION "Two_Level_Branch_Predictor::copy" |
---|
121 | void Parameters::copy (void) |
---|
122 | { |
---|
123 | log_begin(Two_Level_Branch_Predictor,FUNCTION); |
---|
124 | log_end(Two_Level_Branch_Predictor,FUNCTION); |
---|
125 | }; |
---|
126 | |
---|
127 | }; // end namespace two_level_branch_predictor |
---|
128 | }; // end namespace meta_predictor |
---|
129 | }; // end namespace direction |
---|
130 | }; // end namespace prediction_unit |
---|
131 | }; // end namespace front_end |
---|
132 | }; // end namespace multi_front_end |
---|
133 | }; // end namespace core |
---|
134 | |
---|
135 | }; // end namespace behavioural |
---|
136 | }; // end namespace morpheo |
---|