1 | #ifdef SYSTEMC |
---|
2 | /* |
---|
3 | * $Id$ |
---|
4 | * |
---|
5 | * [ Description ] |
---|
6 | * |
---|
7 | */ |
---|
8 | |
---|
9 | #include "Behavioural/Stage_1_Ifetch/Predictor/Meta_Predictor/Two_Level_Branch_Predictor/include/Two_Level_Branch_Predictor.h" |
---|
10 | |
---|
11 | namespace morpheo { |
---|
12 | namespace behavioural { |
---|
13 | namespace stage_1_ifetch { |
---|
14 | namespace predictor { |
---|
15 | namespace meta_predictor { |
---|
16 | namespace two_level_branch_predictor { |
---|
17 | |
---|
18 | void Two_Level_Branch_Predictor::allocation (void) |
---|
19 | { |
---|
20 | log_printf(FUNC,Two_Level_Branch_Predictor,"allocation","Begin"); |
---|
21 | |
---|
22 | _component = new Component (); |
---|
23 | |
---|
24 | Entity * entity = _component->set_entity (_name |
---|
25 | ,"Two_Level_Branch_Predictor" |
---|
26 | #ifdef POSITION |
---|
27 | ,MIXTE |
---|
28 | #endif |
---|
29 | ); |
---|
30 | |
---|
31 | _interfaces = entity->set_interfaces(); |
---|
32 | |
---|
33 | // ~~~~~[ Interface : "" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
34 | { |
---|
35 | Interface * interface = _interfaces->set_interface("" |
---|
36 | #ifdef POSITION |
---|
37 | , IN |
---|
38 | , SOUTH |
---|
39 | , "Generalist interface" |
---|
40 | #endif |
---|
41 | ); |
---|
42 | |
---|
43 | in_CLOCK = interface->set_signal_clk ("clock" ,1); |
---|
44 | in_NRESET = interface->set_signal_in <Tcontrol_t> ("nreset",1,RESET_VHDL_YES); |
---|
45 | } |
---|
46 | |
---|
47 | // ~~~~~[ Interface : "predict" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
48 | |
---|
49 | in_PREDICT_VAL = new SC_IN (Tcontrol_t) * [_param._nb_prediction ]; |
---|
50 | out_PREDICT_ACK = new SC_OUT(Tcontrol_t) * [_param._nb_prediction ]; |
---|
51 | in_PREDICT_ADDRESS = new SC_IN (Taddress_t) * [_param._nb_prediction ]; |
---|
52 | if (_param._have_bht) |
---|
53 | out_PREDICT_BHT_HISTORY = new SC_OUT(Tbht_history_t) * [_param._nb_prediction ]; |
---|
54 | if (_param._have_pht) |
---|
55 | out_PREDICT_PHT_HISTORY = new SC_OUT(Tpht_history_t) * [_param._nb_prediction ]; |
---|
56 | |
---|
57 | for (uint32_t i=0; i<_param._nb_prediction; i++) |
---|
58 | { |
---|
59 | Interface_fifo * interface = _interfaces->set_interface("predict_"+toString(i) |
---|
60 | #ifdef POSITION |
---|
61 | , IN |
---|
62 | , WEST |
---|
63 | , "Interface Predict" |
---|
64 | #endif |
---|
65 | ); |
---|
66 | |
---|
67 | in_PREDICT_VAL [i] = interface->set_signal_valack_in ("val" , VAL); |
---|
68 | out_PREDICT_ACK [i] = interface->set_signal_valack_out ("ack" , ACK); |
---|
69 | in_PREDICT_ADDRESS [i] = interface->set_signal_in <Taddress_t> ("address", _param._size_address); |
---|
70 | if (_param._have_bht) |
---|
71 | out_PREDICT_BHT_HISTORY [i] = interface->set_signal_out <Tbht_history_t> ("bht_history", _param._bht_size_shifter); |
---|
72 | if (_param._have_pht) |
---|
73 | out_PREDICT_PHT_HISTORY [i] = interface->set_signal_out <Tpht_history_t> ("pht_history", _param._pht_size_counter); |
---|
74 | } |
---|
75 | |
---|
76 | // ~~~~~[ Interface : "branch_complete" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
77 | |
---|
78 | in_BRANCH_COMPLETE_VAL = new SC_IN (Tcontrol_t) * [_param._nb_branch_complete]; |
---|
79 | out_BRANCH_COMPLETE_ACK = new SC_OUT(Tcontrol_t) * [_param._nb_branch_complete]; |
---|
80 | in_BRANCH_COMPLETE_ADDRESS = new SC_IN (Taddress_t) * [_param._nb_branch_complete]; |
---|
81 | if (_param._have_bht) |
---|
82 | in_BRANCH_COMPLETE_BHT_HISTORY = new SC_IN (Tbht_history_t) * [_param._nb_branch_complete]; |
---|
83 | if (_param._have_pht) |
---|
84 | in_BRANCH_COMPLETE_PHT_HISTORY = new SC_IN (Tpht_history_t) * [_param._nb_branch_complete]; |
---|
85 | in_BRANCH_COMPLETE_DIRECTION = new SC_IN (Tcontrol_t) * [_param._nb_branch_complete]; |
---|
86 | |
---|
87 | for (uint32_t i=0; i<_param._nb_branch_complete; i++) |
---|
88 | { |
---|
89 | Interface_fifo * interface = _interfaces->set_interface("branch_complete_"+toString(i) |
---|
90 | #ifdef POSITION |
---|
91 | , IN |
---|
92 | , EAST |
---|
93 | , "Interface branch complete" |
---|
94 | #endif |
---|
95 | ); |
---|
96 | |
---|
97 | in_BRANCH_COMPLETE_VAL [i] = interface->set_signal_valack_in ("val" , VAL); |
---|
98 | out_BRANCH_COMPLETE_ACK [i] = interface->set_signal_valack_out ("ack" , ACK); |
---|
99 | in_BRANCH_COMPLETE_ADDRESS [i] = interface->set_signal_in <Taddress_t > ("address" , _param._size_address); |
---|
100 | if (_param._have_bht) |
---|
101 | in_BRANCH_COMPLETE_BHT_HISTORY [i] = interface->set_signal_in <Tbht_history_t> ("bht_history", _param._bht_size_shifter); |
---|
102 | if (_param._have_pht) |
---|
103 | in_BRANCH_COMPLETE_PHT_HISTORY [i] = interface->set_signal_in <Tpht_history_t> ("pht_history", _param._pht_size_counter); |
---|
104 | in_BRANCH_COMPLETE_DIRECTION [i] = interface->set_signal_in <Tcontrol_t > ("direction" , 1); |
---|
105 | } |
---|
106 | |
---|
107 | // ~~~~~[ Component ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
108 | string name_component; |
---|
109 | |
---|
110 | // =====[ component_Branch_History_Table ]============================ |
---|
111 | if (_param._have_bht) |
---|
112 | { |
---|
113 | name_component = _name+"_Branch_History_Table"; |
---|
114 | |
---|
115 | component_Branch_History_Table = new morpheo::behavioural::stage_1_ifetch::predictor::meta_predictor::two_level_branch_predictor::branch_history_table ::Branch_History_Table (name_component.c_str() |
---|
116 | #ifdef STATISTICS |
---|
117 | ,_param_statistics |
---|
118 | #endif |
---|
119 | ,*(_param._param_branch_history_table)); |
---|
120 | |
---|
121 | _component->set_component (component_Branch_History_Table->_component |
---|
122 | #ifdef POSITION |
---|
123 | , 75 |
---|
124 | , 25 |
---|
125 | , 10 |
---|
126 | , 10 |
---|
127 | #endif |
---|
128 | ); |
---|
129 | } |
---|
130 | |
---|
131 | // =====[ component_Pattern_History_Table ]=========================== |
---|
132 | if (_param._have_pht) |
---|
133 | { |
---|
134 | name_component = _name+"_Pattern_History_Table"; |
---|
135 | |
---|
136 | component_Pattern_History_Table = new morpheo::behavioural::stage_1_ifetch::predictor::meta_predictor::two_level_branch_predictor::pattern_history_table ::Pattern_History_Table (name_component.c_str() |
---|
137 | #ifdef STATISTICS |
---|
138 | ,_param_statistics |
---|
139 | #endif |
---|
140 | ,*(_param._param_pattern_history_table)); |
---|
141 | |
---|
142 | _component->set_component (component_Pattern_History_Table->_component |
---|
143 | #ifdef POSITION |
---|
144 | , 75 |
---|
145 | , 75 |
---|
146 | , 10 |
---|
147 | , 10 |
---|
148 | #endif |
---|
149 | ); |
---|
150 | } |
---|
151 | |
---|
152 | // =====[ component_Two_Level_Branch_Predictor_Glue ]================= |
---|
153 | |
---|
154 | name_component = _name+"_Two_Level_Branch_Predictor_Glue"; |
---|
155 | |
---|
156 | component_Two_Level_Branch_Predictor_Glue = new morpheo::behavioural::stage_1_ifetch::predictor::meta_predictor::two_level_branch_predictor::two_level_branch_predictor_glue::Two_Level_Branch_Predictor_Glue (name_component.c_str() |
---|
157 | #ifdef STATISTICS |
---|
158 | ,_param_statistics |
---|
159 | #endif |
---|
160 | ,*(_param._param_two_level_branch_predictor_glue)); |
---|
161 | |
---|
162 | _component->set_component (component_Two_Level_Branch_Predictor_Glue->_component |
---|
163 | #ifdef POSITION |
---|
164 | , 50 |
---|
165 | , 75 |
---|
166 | , 10 |
---|
167 | , 10 |
---|
168 | #endif |
---|
169 | ); |
---|
170 | |
---|
171 | // ~~~~~[ Component - Instanciation ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
172 | |
---|
173 | // =====[ component_Branch_History_Table - Instanciation ]============ |
---|
174 | if (_param._have_bht) |
---|
175 | { |
---|
176 | #ifdef POSITION |
---|
177 | _component->interface_map (_name+"_Branch_History_Table","", |
---|
178 | _name ,""); |
---|
179 | #endif |
---|
180 | |
---|
181 | _component->port_map(_name+"_Branch_History_Table", "in_CLOCK" , _name,"in_CLOCK" ); |
---|
182 | _component->port_map(_name+"_Branch_History_Table", "in_NRESET", _name,"in_NRESET"); |
---|
183 | |
---|
184 | for (uint32_t i=0; i<_param._nb_prediction; i++) |
---|
185 | { |
---|
186 | #ifdef POSITION |
---|
187 | _component->interface_map (_name+"_Branch_History_Table","predict_"+toString(i), |
---|
188 | _name ,"predict_"+toString(i)); |
---|
189 | #endif |
---|
190 | _component->port_map(_name+"_Branch_History_Table", "in_PREDICT_"+toString(i)+"_VAL" , _name , "in_PREDICT_"+toString(i)+"_VAL" ); |
---|
191 | _component->port_map(_name+"_Branch_History_Table","out_PREDICT_"+toString(i)+"_ACK" , _name+"_Two_Level_Branch_Predictor_Glue", "in_PREDICT_"+toString(i)+"_BHT_ACK" ); |
---|
192 | _component->port_map(_name+"_Branch_History_Table", "in_PREDICT_"+toString(i)+"_ADDRESS", _name+"_Two_Level_Branch_Predictor_Glue","out_PREDICT_"+toString(i)+"_BHT_ADDRESS"); |
---|
193 | _component->port_map(_name+"_Branch_History_Table","out_PREDICT_"+toString(i)+"_HISTORY", _name ,"out_PREDICT_"+toString(i)+"_BHT_HISTORY"); |
---|
194 | } |
---|
195 | |
---|
196 | for (uint32_t i=0; i<_param._nb_branch_complete; i++) |
---|
197 | { |
---|
198 | #ifdef POSITION |
---|
199 | _component->interface_map (_name+"_Branch_History_Table","branch_complete_"+toString(i), |
---|
200 | _name ,"branch_complete_"+toString(i)); |
---|
201 | #endif |
---|
202 | _component->port_map(_name+"_Branch_History_Table", "in_BRANCH_COMPLETE_"+toString(i)+"_VAL" , _name , "in_BRANCH_COMPLETE_"+toString(i)+"_VAL" ); |
---|
203 | _component->port_map(_name+"_Branch_History_Table","out_BRANCH_COMPLETE_"+toString(i)+"_ACK" , _name+"_Two_Level_Branch_Predictor_Glue", "in_BRANCH_COMPLETE_"+toString(i)+"_BHT_ACK" ); |
---|
204 | _component->port_map(_name+"_Branch_History_Table", "in_BRANCH_COMPLETE_"+toString(i)+"_ADDRESS" , _name+"_Two_Level_Branch_Predictor_Glue","out_BRANCH_COMPLETE_"+toString(i)+"_BHT_ADDRESS" ); |
---|
205 | _component->port_map(_name+"_Branch_History_Table", "in_BRANCH_COMPLETE_"+toString(i)+"_HISTORY" , _name , "in_BRANCH_COMPLETE_"+toString(i)+"_BHT_HISTORY" ); |
---|
206 | _component->port_map(_name+"_Branch_History_Table", "in_BRANCH_COMPLETE_"+toString(i)+"_DIRECTION", _name , "in_BRANCH_COMPLETE_"+toString(i)+"_DIRECTION" ); |
---|
207 | } |
---|
208 | } |
---|
209 | |
---|
210 | // =====[ component_Pattern_History_Table - Instanciation ]=========== |
---|
211 | if (_param._have_pht) |
---|
212 | { |
---|
213 | #ifdef POSITION |
---|
214 | _component->interface_map (_name+"_Pattern_History_Table","", |
---|
215 | _name ,""); |
---|
216 | #endif |
---|
217 | |
---|
218 | _component->port_map(_name+"_Pattern_History_Table", "in_CLOCK" , _name,"in_CLOCK" ); |
---|
219 | _component->port_map(_name+"_Pattern_History_Table", "in_NRESET", _name,"in_NRESET"); |
---|
220 | |
---|
221 | for (uint32_t i=0; i<_param._nb_prediction; i++) |
---|
222 | { |
---|
223 | #ifdef POSITION |
---|
224 | _component->interface_map (_name+"_Pattern_History_Table","predict_"+toString(i), |
---|
225 | _name ,"predict_"+toString(i)); |
---|
226 | #endif |
---|
227 | _component->port_map(_name+"_Pattern_History_Table", "in_PREDICT_"+toString(i)+"_VAL" , _name , "in_PREDICT_"+toString(i)+"_VAL" ); |
---|
228 | _component->port_map(_name+"_Pattern_History_Table","out_PREDICT_"+toString(i)+"_ACK" , _name+"_Two_Level_Branch_Predictor_Glue", "in_PREDICT_"+toString(i)+"_PHT_ACK" ); |
---|
229 | _component->port_map(_name+"_Pattern_History_Table", "in_PREDICT_"+toString(i)+"_ADDRESS", _name+"_Two_Level_Branch_Predictor_Glue","out_PREDICT_"+toString(i)+"_PHT_ADDRESS"); |
---|
230 | _component->port_map(_name+"_Pattern_History_Table","out_PREDICT_"+toString(i)+"_HISTORY", _name ,"out_PREDICT_"+toString(i)+"_PHT_HISTORY"); |
---|
231 | } |
---|
232 | |
---|
233 | for (uint32_t i=0; i<_param._nb_branch_complete; i++) |
---|
234 | { |
---|
235 | #ifdef POSITION |
---|
236 | _component->interface_map (_name+"_Pattern_History_Table","branch_complete_"+toString(i), |
---|
237 | _name ,"branch_complete_"+toString(i)); |
---|
238 | #endif |
---|
239 | _component->port_map(_name+"_Pattern_History_Table", "in_BRANCH_COMPLETE_"+toString(i)+"_VAL" , _name , "in_BRANCH_COMPLETE_"+toString(i)+"_VAL" ); |
---|
240 | _component->port_map(_name+"_Pattern_History_Table","out_BRANCH_COMPLETE_"+toString(i)+"_ACK" , _name+"_Two_Level_Branch_Predictor_Glue", "in_BRANCH_COMPLETE_"+toString(i)+"_PHT_ACK" ); |
---|
241 | _component->port_map(_name+"_Pattern_History_Table", "in_BRANCH_COMPLETE_"+toString(i)+"_ADDRESS" , _name+"_Two_Level_Branch_Predictor_Glue","out_BRANCH_COMPLETE_"+toString(i)+"_PHT_ADDRESS" ); |
---|
242 | _component->port_map(_name+"_Pattern_History_Table", "in_BRANCH_COMPLETE_"+toString(i)+"_HISTORY" , _name , "in_BRANCH_COMPLETE_"+toString(i)+"_PHT_HISTORY" ); |
---|
243 | _component->port_map(_name+"_Pattern_History_Table", "in_BRANCH_COMPLETE_"+toString(i)+"_DIRECTION", _name , "in_BRANCH_COMPLETE_"+toString(i)+"_DIRECTION" ); |
---|
244 | } |
---|
245 | } |
---|
246 | |
---|
247 | // =====[ component_Two_Level_Branch_Predictor_Glue - Instanciation ]= |
---|
248 | #ifdef POSITION |
---|
249 | _component->interface_map (_name+"_Two_Level_Branch_Predictor_Glue","", |
---|
250 | _name ,""); |
---|
251 | #endif |
---|
252 | _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "in_CLOCK" , _name,"in_CLOCK" ); |
---|
253 | _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "in_NRESET", _name,"in_NRESET"); |
---|
254 | |
---|
255 | for (uint32_t i=0; i<_param._nb_prediction; i++) |
---|
256 | { |
---|
257 | if (_param._have_bht) |
---|
258 | { |
---|
259 | _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "in_PREDICT_"+toString(i)+"_BHT_ACK" , _name+"_Branch_History_Table" , "out_PREDICT_"+toString(i)+"_ACK" ); |
---|
260 | _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "out_PREDICT_"+toString(i)+"_BHT_ADDRESS", _name+"_Branch_History_Table" , "in_PREDICT_"+toString(i)+"_ADDRESS"); |
---|
261 | } |
---|
262 | if (_param._have_pht) |
---|
263 | { |
---|
264 | _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "in_PREDICT_"+toString(i)+"_PHT_ACK" , _name+"_Pattern_History_Table", "out_PREDICT_"+toString(i)+"_ACK" ); |
---|
265 | _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "out_PREDICT_"+toString(i)+"_PHT_ADDRESS", _name+"_Pattern_History_Table", "in_PREDICT_"+toString(i)+"_ADDRESS"); |
---|
266 | } |
---|
267 | if (_param._have_bht and _param._have_pht) |
---|
268 | _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "in_PREDICT_"+toString(i)+"_BHT_HISTORY" , _name+"_Branch_History_Table" ,"out_PREDICT_"+toString(i)+"_HISTORY"); |
---|
269 | _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue","out_PREDICT_"+toString(i)+"_ACK" , _name ,"out_PREDICT_"+toString(i)+"_ACK"); |
---|
270 | _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "in_PREDICT_"+toString(i)+"_ADDRESS" , _name , "in_PREDICT_"+toString(i)+"_ADDRESS"); |
---|
271 | } |
---|
272 | |
---|
273 | for (uint32_t i=0; i<_param._nb_branch_complete; i++) |
---|
274 | { |
---|
275 | if (_param._have_bht) |
---|
276 | { |
---|
277 | _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "in_BRANCH_COMPLETE_"+toString(i)+"_BHT_ACK" , _name+"_Branch_History_Table" , "out_BRANCH_COMPLETE_"+toString(i)+"_ACK" ); |
---|
278 | _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "out_BRANCH_COMPLETE_"+toString(i)+"_BHT_ADDRESS", _name+"_Branch_History_Table" , "in_BRANCH_COMPLETE_"+toString(i)+"_ADDRESS"); |
---|
279 | } |
---|
280 | if (_param._have_pht) |
---|
281 | { |
---|
282 | _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "in_BRANCH_COMPLETE_"+toString(i)+"_PHT_ACK" , _name+"_Pattern_History_Table", "out_BRANCH_COMPLETE_"+toString(i)+"_ACK" ); |
---|
283 | _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "out_BRANCH_COMPLETE_"+toString(i)+"_PHT_ADDRESS", _name+"_Pattern_History_Table", "in_BRANCH_COMPLETE_"+toString(i)+"_ADDRESS"); |
---|
284 | } |
---|
285 | if (_param._have_bht and _param._have_pht) |
---|
286 | _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "in_BRANCH_COMPLETE_"+toString(i)+"_BHT_HISTORY" , _name , "in_BRANCH_COMPLETE_"+toString(i)+"_BHT_HISTORY"); |
---|
287 | _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue","out_BRANCH_COMPLETE_"+toString(i)+"_ACK" , _name ,"out_BRANCH_COMPLETE_"+toString(i)+"_ACK"); |
---|
288 | _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "in_BRANCH_COMPLETE_"+toString(i)+"_ADDRESS" , _name , "in_BRANCH_COMPLETE_"+toString(i)+"_ADDRESS"); |
---|
289 | } |
---|
290 | #ifdef POSITION |
---|
291 | _component->generate_file(); |
---|
292 | #endif |
---|
293 | |
---|
294 | log_printf(FUNC,Two_Level_Branch_Predictor,"allocation","End"); |
---|
295 | }; |
---|
296 | |
---|
297 | }; // end namespace two_level_branch_predictor |
---|
298 | }; // end namespace meta_predictor |
---|
299 | }; // end namespace predictor |
---|
300 | }; // end namespace stage_1_ifetch |
---|
301 | }; // end namespace behavioural |
---|
302 | }; // end namespace morpheo |
---|
303 | #endif |
---|