1 | /* |
---|
2 | * $Id: Parameters.cpp 95 2008-12-16 16:24:26Z rosiere $ |
---|
3 | * |
---|
4 | * [ Description ] |
---|
5 | * |
---|
6 | */ |
---|
7 | |
---|
8 | #include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/include/Parameters.h" |
---|
9 | #include "Common/include/Max.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 | |
---|
18 | |
---|
19 | #undef FUNCTION |
---|
20 | #define FUNCTION "Prediction_unit::Parameters" |
---|
21 | Parameters::Parameters (uint32_t nb_context , |
---|
22 | uint32_t nb_decod_unit , |
---|
23 | uint32_t size_address , |
---|
24 | uint32_t * nb_instruction ,//[nb_context] |
---|
25 | uint32_t * nb_inst_decod ,//[nb_decod_unit] |
---|
26 | uint32_t nb_inst_branch_predict , |
---|
27 | uint32_t nb_inst_branch_decod , |
---|
28 | uint32_t nb_inst_branch_update , |
---|
29 | uint32_t nb_inst_branch_complete , |
---|
30 | uint32_t btb_size_queue , |
---|
31 | uint32_t btb_associativity , |
---|
32 | uint32_t btb_size_counter , |
---|
33 | Tvictim_t btb_victim_scheme , |
---|
34 | Tpredictor_t dir_predictor_scheme , |
---|
35 | bool dir_have_bht [3], |
---|
36 | uint32_t dir_bht_size_shifter [3], |
---|
37 | uint32_t dir_bht_nb_shifter [3], |
---|
38 | bool dir_have_pht [3], |
---|
39 | uint32_t dir_pht_size_counter [3], |
---|
40 | uint32_t dir_pht_nb_counter [3], |
---|
41 | uint32_t dir_pht_size_address_share [3], |
---|
42 | uint32_t * ras_size_queue ,//[nb_context] |
---|
43 | uint32_t * upt_size_queue ,//[nb_context] |
---|
44 | uint32_t * ufpt_size_queue ,//[nb_context] |
---|
45 | bool is_toplevel |
---|
46 | ) |
---|
47 | { |
---|
48 | log_printf(FUNC,Prediction_unit,FUNCTION,"Begin"); |
---|
49 | |
---|
50 | _nb_context = nb_context ; |
---|
51 | _nb_decod_unit = nb_decod_unit ; |
---|
52 | _size_address = size_address ; |
---|
53 | _nb_instruction = nb_instruction ; |
---|
54 | _nb_inst_decod = nb_inst_decod ; |
---|
55 | _nb_inst_branch_predict = nb_inst_branch_predict ; |
---|
56 | _nb_inst_branch_decod = nb_inst_branch_decod ; |
---|
57 | _nb_inst_branch_update = nb_inst_branch_update ; |
---|
58 | _nb_inst_branch_complete = nb_inst_branch_complete ; |
---|
59 | _btb_size_queue = btb_size_queue ; |
---|
60 | _btb_associativity = btb_associativity ; |
---|
61 | _btb_size_counter = btb_size_counter ; |
---|
62 | _btb_victim_scheme = btb_victim_scheme ; |
---|
63 | _dir_predictor_scheme = dir_predictor_scheme ; |
---|
64 | for (uint32_t i=0; i<3; i++) |
---|
65 | { |
---|
66 | _dir_have_bht [i] = dir_have_bht [i]; |
---|
67 | _dir_bht_size_shifter [i] = dir_bht_size_shifter [i]; |
---|
68 | _dir_bht_nb_shifter [i] = dir_bht_nb_shifter [i]; |
---|
69 | _dir_have_pht [i] = dir_have_pht [i]; |
---|
70 | _dir_pht_size_counter [i] = dir_pht_size_counter [i]; |
---|
71 | _dir_pht_nb_counter [i] = dir_pht_nb_counter [i]; |
---|
72 | _dir_pht_size_address_share [i] = dir_pht_size_address_share [i]; |
---|
73 | } |
---|
74 | _ras_size_queue = ras_size_queue ; |
---|
75 | _upt_size_queue = upt_size_queue ; |
---|
76 | _ufpt_size_queue = ufpt_size_queue ; |
---|
77 | |
---|
78 | _array_size_depth = new uint32_t [_nb_context]; |
---|
79 | _size_ras_index = new uint32_t [_nb_context]; |
---|
80 | |
---|
81 | for (uint32_t i=0; i<_nb_context; i++) |
---|
82 | { |
---|
83 | _array_size_depth [i] = log2(_upt_size_queue [i]); |
---|
84 | _size_ras_index [i] = log2(_ras_size_queue [i]); |
---|
85 | } |
---|
86 | |
---|
87 | _param_glue = new morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::prediction_unit_glue ::Parameters |
---|
88 | (_nb_context , |
---|
89 | _nb_decod_unit , |
---|
90 | _size_address , |
---|
91 | _nb_instruction , |
---|
92 | _array_size_depth , |
---|
93 | _nb_inst_decod , |
---|
94 | _nb_inst_branch_predict, |
---|
95 | _nb_inst_branch_decod , |
---|
96 | _nb_inst_branch_update ); |
---|
97 | |
---|
98 | _param_btb = new morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::branch_target_buffer ::Parameters |
---|
99 | (_nb_context , |
---|
100 | _nb_instruction , |
---|
101 | _btb_size_queue , |
---|
102 | _btb_associativity , |
---|
103 | _size_address , |
---|
104 | _btb_size_counter , |
---|
105 | _nb_inst_branch_predict, |
---|
106 | _nb_inst_branch_decod , |
---|
107 | _nb_inst_branch_update , |
---|
108 | _btb_victim_scheme ); |
---|
109 | |
---|
110 | _param_dir = new morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::direction ::Parameters |
---|
111 | (_dir_predictor_scheme , |
---|
112 | _nb_inst_branch_predict , |
---|
113 | _nb_inst_branch_update , |
---|
114 | _size_address , |
---|
115 | _dir_have_bht , |
---|
116 | _dir_bht_size_shifter , |
---|
117 | _dir_bht_nb_shifter , |
---|
118 | _dir_have_pht , |
---|
119 | _dir_pht_size_counter , |
---|
120 | _dir_pht_nb_counter , |
---|
121 | _dir_pht_size_address_share); |
---|
122 | |
---|
123 | _size_history = _param_dir->_size_history; |
---|
124 | _have_port_history = (_size_history > 0); |
---|
125 | |
---|
126 | _param_ras = new morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::return_address_stack ::Parameters |
---|
127 | (_nb_context , |
---|
128 | _ras_size_queue , |
---|
129 | _size_address , |
---|
130 | _nb_inst_branch_predict, |
---|
131 | _nb_inst_branch_decod , |
---|
132 | _nb_inst_branch_update ); |
---|
133 | |
---|
134 | _param_upt = new morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::Parameters |
---|
135 | (_nb_context , |
---|
136 | _upt_size_queue , |
---|
137 | _ufpt_size_queue , |
---|
138 | _size_address , |
---|
139 | _nb_inst_branch_predict , |
---|
140 | _nb_inst_branch_decod , |
---|
141 | _nb_inst_branch_complete, |
---|
142 | _nb_inst_branch_update , |
---|
143 | _size_history , |
---|
144 | _size_ras_index ); |
---|
145 | |
---|
146 | |
---|
147 | if (is_toplevel) |
---|
148 | { |
---|
149 | _size_context_id = log2(_nb_context); |
---|
150 | _size_depth = max<uint32_t>(_array_size_depth,_nb_context); |
---|
151 | _size_inst_ifetch_ptr = log2(max<uint32_t>(_nb_instruction,_nb_context)); |
---|
152 | _size_instruction_address = size_address; |
---|
153 | // _size_nb_inst_decod = ; |
---|
154 | // _size_nb_inst_commit = ; |
---|
155 | // _size_ifetch_queue_ptr = ; |
---|
156 | |
---|
157 | _have_port_context_id = (_size_context_id > 0); |
---|
158 | _have_port_depth = (_size_depth > 0); |
---|
159 | _have_port_inst_ifetch_ptr = _size_inst_ifetch_ptr > 0; |
---|
160 | // _have_port_ifetch_queue_ptr= _size_ifetch_queue_ptr > 0; |
---|
161 | |
---|
162 | copy (); |
---|
163 | } |
---|
164 | |
---|
165 | test(); |
---|
166 | log_printf(FUNC,Prediction_unit,FUNCTION,"End"); |
---|
167 | }; |
---|
168 | |
---|
169 | // #undef FUNCTION |
---|
170 | // #define FUNCTION "Prediction_unit::Parameters (copy)" |
---|
171 | // Parameters::Parameters (Parameters & param) |
---|
172 | // { |
---|
173 | // log_printf(FUNC,Prediction_unit,FUNCTION,"Begin"); |
---|
174 | // test(); |
---|
175 | // log_printf(FUNC,Prediction_unit,FUNCTION,"End"); |
---|
176 | // }; |
---|
177 | |
---|
178 | #undef FUNCTION |
---|
179 | #define FUNCTION "Prediction_unit::~Parameters" |
---|
180 | Parameters::~Parameters () |
---|
181 | { |
---|
182 | log_printf(FUNC,Prediction_unit,FUNCTION,"Begin"); |
---|
183 | |
---|
184 | delete _param_btb; |
---|
185 | delete _param_dir; |
---|
186 | delete _param_ras; |
---|
187 | delete _param_upt; |
---|
188 | delete _param_glue; |
---|
189 | |
---|
190 | delete [] _array_size_depth; |
---|
191 | delete [] _size_ras_index; |
---|
192 | |
---|
193 | log_printf(FUNC,Prediction_unit,FUNCTION,"End"); |
---|
194 | }; |
---|
195 | |
---|
196 | #undef FUNCTION |
---|
197 | #define FUNCTION "Prediction_unit::copy" |
---|
198 | void Parameters::copy (void) |
---|
199 | { |
---|
200 | log_printf(FUNC,Prediction_unit,FUNCTION,"Begin"); |
---|
201 | |
---|
202 | COPY(_param_btb ); |
---|
203 | COPY(_param_dir ); |
---|
204 | COPY(_param_ras ); |
---|
205 | COPY(_param_upt ); |
---|
206 | COPY(_param_glue); |
---|
207 | |
---|
208 | log_printf(FUNC,Prediction_unit,FUNCTION,"End"); |
---|
209 | }; |
---|
210 | |
---|
211 | }; // end namespace prediction_unit |
---|
212 | }; // end namespace front_end |
---|
213 | }; // end namespace multi_front_end |
---|
214 | }; // end namespace core |
---|
215 | |
---|
216 | }; // end namespace behavioural |
---|
217 | }; // end namespace morpheo |
---|