1 | /* |
---|
2 | * $Id$ |
---|
3 | * |
---|
4 | * [ Description ] |
---|
5 | * |
---|
6 | */ |
---|
7 | |
---|
8 | #include "Behavioural/Stage_1_Ifetch/Predictor/Meta_Predictor/Meta_Predictor_Glue/include/Meta_Predictor_Glue.h" |
---|
9 | |
---|
10 | namespace morpheo { |
---|
11 | namespace behavioural { |
---|
12 | namespace stage_1_ifetch { |
---|
13 | namespace predictor { |
---|
14 | namespace meta_predictor { |
---|
15 | namespace meta_predictor_glue { |
---|
16 | |
---|
17 | |
---|
18 | #ifdef SYSTEMC |
---|
19 | Meta_Predictor_Glue::Meta_Predictor_Glue (sc_module_name name, |
---|
20 | #else |
---|
21 | Meta_Predictor_Glue::Meta_Predictor_Glue (string name, |
---|
22 | #endif |
---|
23 | #ifdef STATISTICS |
---|
24 | morpheo::behavioural::Parameters_Statistics param_statistics, |
---|
25 | #endif |
---|
26 | morpheo::behavioural::stage_1_ifetch::predictor::meta_predictor::meta_predictor_glue::Parameters param ): |
---|
27 | _name (name) |
---|
28 | ,_param (param) |
---|
29 | // #ifdef STATISTICS |
---|
30 | // ,_param_statistics (param_statistics) |
---|
31 | // #endif |
---|
32 | { |
---|
33 | log_printf(FUNC,Meta_Predictor_Glue,"Meta_Predictor_Glue","Begin"); |
---|
34 | |
---|
35 | #ifdef STATISTICS |
---|
36 | log_printf(INFO,Meta_Predictor_Glue,"Meta_Predictor_Glue","Allocation of statistics"); |
---|
37 | |
---|
38 | // Allocation of statistics |
---|
39 | _stat = new Statistics (static_cast<string>(_name), |
---|
40 | param_statistics , |
---|
41 | param); |
---|
42 | #endif |
---|
43 | |
---|
44 | #ifdef VHDL_TESTBENCH |
---|
45 | // Creation of a testbench |
---|
46 | // -> port |
---|
47 | // -> clock's signals |
---|
48 | log_printf(INFO,Meta_Predictor_Glue,"Meta_Predictor_Glue","Creation of a testbench"); |
---|
49 | _vhdl_testbench = new Vhdl_Testbench (_name); |
---|
50 | vhdl_testbench_port (); |
---|
51 | _vhdl_testbench->set_clock ("in_CLOCK",false); |
---|
52 | #endif |
---|
53 | |
---|
54 | #ifdef VHDL |
---|
55 | // generate the vhdl |
---|
56 | log_printf(INFO,Meta_Predictor_Glue,"Meta_Predictor_Glue","VHDL's generation"); |
---|
57 | vhdl(); |
---|
58 | #endif |
---|
59 | |
---|
60 | #ifdef SYSTEMC |
---|
61 | log_printf(INFO,Meta_Predictor_Glue,"Meta_Predictor_Glue","Allocation"); |
---|
62 | allocation (); |
---|
63 | |
---|
64 | #if defined(STATISTICS) or defined(VHDL_TESTBENCH) |
---|
65 | log_printf(INFO,Meta_Predictor_Glue,"Meta_Predictor_Glue","method - transition"); |
---|
66 | |
---|
67 | SC_METHOD (transition); |
---|
68 | dont_initialize (); |
---|
69 | sensitive_pos << *(in_CLOCK); |
---|
70 | #endif |
---|
71 | |
---|
72 | log_printf(INFO,Meta_Predictor_Glue,"Meta_Predictor_Glue","method - genMealy_predict_ack"); |
---|
73 | SC_METHOD (genMealy_predict_ack); |
---|
74 | dont_initialize (); |
---|
75 | for (uint32_t i=0; i<_param._nb_prediction; i++) |
---|
76 | { |
---|
77 | sensitive << *(in_PREDICT_PREDICTOR_2_ACK [i]); |
---|
78 | |
---|
79 | if (_param._have_meta_predictor) |
---|
80 | { |
---|
81 | sensitive << *(in_PREDICT_PREDICTOR_0_ACK [i]) |
---|
82 | << *(in_PREDICT_PREDICTOR_1_ACK [i]); |
---|
83 | } |
---|
84 | } |
---|
85 | |
---|
86 | #ifdef SYSTEMCASS_SPECIFIC |
---|
87 | // List dependency information |
---|
88 | for (uint32_t i=0; i<_param._nb_prediction; i++) |
---|
89 | { |
---|
90 | (*(out_PREDICT_ACK [i])) (*(in_PREDICT_PREDICTOR_2_ACK [i])); |
---|
91 | |
---|
92 | if (_param._have_meta_predictor) |
---|
93 | { |
---|
94 | (*(out_PREDICT_ACK [i])) (*(in_PREDICT_PREDICTOR_0_ACK [i])); |
---|
95 | (*(out_PREDICT_ACK [i])) (*(in_PREDICT_PREDICTOR_1_ACK [i])); |
---|
96 | } |
---|
97 | } |
---|
98 | #endif |
---|
99 | |
---|
100 | log_printf(INFO,Meta_Predictor_Glue,"Meta_Predictor_Glue","method - genMealy_predict_history"); |
---|
101 | SC_METHOD (genMealy_predict_history); |
---|
102 | dont_initialize (); |
---|
103 | for (uint32_t i=0; i<_param._nb_prediction; i++) |
---|
104 | { |
---|
105 | if (_param._predictor_2_have_bht) |
---|
106 | sensitive << *(in_PREDICT_PREDICTOR_2_BHT_HISTORY [i]); |
---|
107 | if (_param._predictor_2_have_pht) |
---|
108 | sensitive << *(in_PREDICT_PREDICTOR_2_PHT_HISTORY [i]); |
---|
109 | |
---|
110 | if (_param._have_meta_predictor) |
---|
111 | { |
---|
112 | if (_param._predictor_1_have_bht) |
---|
113 | sensitive << *(in_PREDICT_PREDICTOR_1_BHT_HISTORY [i]); |
---|
114 | if (_param._predictor_1_have_pht) |
---|
115 | sensitive << *(in_PREDICT_PREDICTOR_1_PHT_HISTORY [i]); |
---|
116 | |
---|
117 | if (_param._predictor_0_have_bht) |
---|
118 | sensitive << *(in_PREDICT_PREDICTOR_0_BHT_HISTORY [i]); |
---|
119 | if (_param._predictor_0_have_pht) |
---|
120 | sensitive << *(in_PREDICT_PREDICTOR_0_PHT_HISTORY [i]); |
---|
121 | } |
---|
122 | } |
---|
123 | |
---|
124 | #ifdef SYSTEMCASS_SPECIFIC |
---|
125 | // List dependency information |
---|
126 | for (uint32_t i=0; i<_param._nb_prediction; i++) |
---|
127 | { |
---|
128 | if (_param._predictor_2_have_bht) |
---|
129 | (*(out_PREDICT_HISTORY [i])) (*(in_PREDICT_PREDICTOR_2_BHT_HISTORY [i])); |
---|
130 | if (_param._predictor_2_have_pht) |
---|
131 | (*(out_PREDICT_HISTORY [i])) (*(in_PREDICT_PREDICTOR_2_PHT_HISTORY [i])); |
---|
132 | |
---|
133 | if (_param._have_meta_predictor) |
---|
134 | { |
---|
135 | if (_param._predictor_1_have_bht) |
---|
136 | (*(out_PREDICT_HISTORY [i])) (*(in_PREDICT_PREDICTOR_1_BHT_HISTORY [i])); |
---|
137 | if (_param._predictor_1_have_pht) |
---|
138 | (*(out_PREDICT_HISTORY [i])) (*(in_PREDICT_PREDICTOR_1_PHT_HISTORY [i])); |
---|
139 | |
---|
140 | if (_param._predictor_0_have_bht) |
---|
141 | (*(out_PREDICT_HISTORY [i])) (*(in_PREDICT_PREDICTOR_0_BHT_HISTORY [i])); |
---|
142 | if (_param._predictor_0_have_pht) |
---|
143 | (*(out_PREDICT_HISTORY [i])) (*(in_PREDICT_PREDICTOR_0_PHT_HISTORY [i])); |
---|
144 | } |
---|
145 | |
---|
146 | if (_param._predictor_2_have_bht) |
---|
147 | (*(out_PREDICT_DIRECTION [i])) (*(in_PREDICT_PREDICTOR_2_BHT_HISTORY [i])); |
---|
148 | if (_param._predictor_2_have_pht) |
---|
149 | (*(out_PREDICT_DIRECTION [i])) (*(in_PREDICT_PREDICTOR_2_PHT_HISTORY [i])); |
---|
150 | |
---|
151 | if (_param._have_meta_predictor) |
---|
152 | { |
---|
153 | if (_param._predictor_1_have_bht) |
---|
154 | (*(out_PREDICT_DIRECTION [i])) (*(in_PREDICT_PREDICTOR_1_BHT_HISTORY [i])); |
---|
155 | if (_param._predictor_1_have_pht) |
---|
156 | (*(out_PREDICT_DIRECTION [i])) (*(in_PREDICT_PREDICTOR_1_PHT_HISTORY [i])); |
---|
157 | |
---|
158 | if (_param._predictor_0_have_bht) |
---|
159 | (*(out_PREDICT_DIRECTION [i])) (*(in_PREDICT_PREDICTOR_0_BHT_HISTORY [i])); |
---|
160 | if (_param._predictor_0_have_pht) |
---|
161 | (*(out_PREDICT_DIRECTION [i])) (*(in_PREDICT_PREDICTOR_0_PHT_HISTORY [i])); |
---|
162 | } |
---|
163 | } |
---|
164 | #endif |
---|
165 | |
---|
166 | if (_param._have_meta_predictor) |
---|
167 | { |
---|
168 | log_printf(INFO,Meta_Predictor_Glue,"Meta_Predictor_Glue","method - genMealy_branch_complete_val"); |
---|
169 | SC_METHOD (genMealy_branch_complete_val); |
---|
170 | dont_initialize (); |
---|
171 | for (uint32_t i=0; i<_param._nb_branch_complete; i++) |
---|
172 | { |
---|
173 | sensitive << *(in_BRANCH_COMPLETE_VAL [i]) |
---|
174 | << *(in_BRANCH_COMPLETE_HISTORY [i]) |
---|
175 | << *(in_BRANCH_COMPLETE_DIRECTION [i]); |
---|
176 | } |
---|
177 | |
---|
178 | #ifdef SYSTEMCASS_SPECIFIC |
---|
179 | // List dependency information |
---|
180 | for (uint32_t i=0; i<_param._nb_branch_complete; i++) |
---|
181 | { |
---|
182 | (*(out_BRANCH_COMPLETE_PREDICTOR_2_VAL [i])) (*(in_BRANCH_COMPLETE_VAL [i])); |
---|
183 | (*(out_BRANCH_COMPLETE_PREDICTOR_2_VAL [i])) (*(in_BRANCH_COMPLETE_HISTORY [i])); |
---|
184 | (*(out_BRANCH_COMPLETE_PREDICTOR_2_VAL [i])) (*(in_BRANCH_COMPLETE_DIRECTION [i])); |
---|
185 | |
---|
186 | (*(out_BRANCH_COMPLETE_PREDICTOR_2_DIRECTION [i])) (*(in_BRANCH_COMPLETE_VAL [i])); |
---|
187 | (*(out_BRANCH_COMPLETE_PREDICTOR_2_DIRECTION [i])) (*(in_BRANCH_COMPLETE_HISTORY [i])); |
---|
188 | (*(out_BRANCH_COMPLETE_PREDICTOR_2_DIRECTION [i])) (*(in_BRANCH_COMPLETE_DIRECTION [i])); |
---|
189 | } |
---|
190 | #endif |
---|
191 | } |
---|
192 | |
---|
193 | log_printf(INFO,Meta_Predictor_Glue,"Meta_Predictor_Glue","method - genMealy_branch_complete_ack"); |
---|
194 | SC_METHOD (genMealy_branch_complete_ack); |
---|
195 | dont_initialize (); |
---|
196 | for (uint32_t i=0; i<_param._nb_branch_complete; i++) |
---|
197 | { |
---|
198 | sensitive << *(in_BRANCH_COMPLETE_PREDICTOR_2_ACK [i]); |
---|
199 | |
---|
200 | if (_param._have_meta_predictor) |
---|
201 | { |
---|
202 | sensitive << *(in_BRANCH_COMPLETE_PREDICTOR_0_ACK [i]) |
---|
203 | << *(in_BRANCH_COMPLETE_PREDICTOR_1_ACK [i]); |
---|
204 | } |
---|
205 | } |
---|
206 | |
---|
207 | #ifdef SYSTEMCASS_SPECIFIC |
---|
208 | // List dependency information |
---|
209 | for (uint32_t i=0; i<_param._nb_branch_complete; i++) |
---|
210 | { |
---|
211 | (*(out_BRANCH_COMPLETE_ACK [i])) (*(in_BRANCH_COMPLETE_PREDICTOR_2_ACK [i])); |
---|
212 | |
---|
213 | if (_param._have_meta_predictor) |
---|
214 | { |
---|
215 | (*(out_BRANCH_COMPLETE_ACK [i])) (*(in_BRANCH_COMPLETE_PREDICTOR_0_ACK [i])); |
---|
216 | (*(out_BRANCH_COMPLETE_ACK [i])) (*(in_BRANCH_COMPLETE_PREDICTOR_1_ACK [i])); |
---|
217 | } |
---|
218 | } |
---|
219 | #endif |
---|
220 | |
---|
221 | log_printf(INFO,Meta_Predictor_Glue,"Meta_Predictor_Glue","method - genMealy_branch_complete_history"); |
---|
222 | SC_METHOD (genMealy_branch_complete_history); |
---|
223 | dont_initialize (); |
---|
224 | for (uint32_t i=0; i<_param._nb_branch_complete; i++) |
---|
225 | { |
---|
226 | sensitive << *(in_BRANCH_COMPLETE_HISTORY [i]); |
---|
227 | } |
---|
228 | |
---|
229 | #ifdef SYSTEMCASS_SPECIFIC |
---|
230 | // List dependency information |
---|
231 | for (uint32_t i=0; i<_param._nb_branch_complete; i++) |
---|
232 | { |
---|
233 | if (_param._predictor_2_have_bht) |
---|
234 | (*(out_BRANCH_COMPLETE_PREDICTOR_2_BHT_HISTORY [i])) (*( in_BRANCH_COMPLETE_HISTORY [i])); |
---|
235 | if (_param._predictor_2_have_pht) |
---|
236 | (*(out_BRANCH_COMPLETE_PREDICTOR_2_PHT_HISTORY [i])) (*( in_BRANCH_COMPLETE_HISTORY [i])); |
---|
237 | |
---|
238 | if (_param._have_meta_predictor) |
---|
239 | { |
---|
240 | if (_param._predictor_1_have_bht) |
---|
241 | (*(out_BRANCH_COMPLETE_PREDICTOR_1_BHT_HISTORY [i])) (*( in_BRANCH_COMPLETE_HISTORY [i])); |
---|
242 | if (_param._predictor_1_have_pht) |
---|
243 | (*(out_BRANCH_COMPLETE_PREDICTOR_1_PHT_HISTORY [i])) (*( in_BRANCH_COMPLETE_HISTORY [i])); |
---|
244 | |
---|
245 | if (_param._predictor_0_have_bht) |
---|
246 | (*(out_BRANCH_COMPLETE_PREDICTOR_0_BHT_HISTORY [i])) (*( in_BRANCH_COMPLETE_HISTORY [i])); |
---|
247 | if (_param._predictor_0_have_pht) |
---|
248 | (*(out_BRANCH_COMPLETE_PREDICTOR_0_PHT_HISTORY [i])) (*( in_BRANCH_COMPLETE_HISTORY [i])); |
---|
249 | } |
---|
250 | } |
---|
251 | #endif |
---|
252 | |
---|
253 | #endif |
---|
254 | log_printf(FUNC,Meta_Predictor_Glue,"Meta_Predictor_Glue","End"); |
---|
255 | }; |
---|
256 | |
---|
257 | Meta_Predictor_Glue::~Meta_Predictor_Glue (void) |
---|
258 | { |
---|
259 | log_printf(FUNC,Meta_Predictor_Glue,"~Meta_Predictor_Glue","Begin"); |
---|
260 | |
---|
261 | #ifdef VHDL_TESTBENCH |
---|
262 | log_printf(INFO,Meta_Predictor_Glue,"~Meta_Predictor_Glue","Generate Testbench"); |
---|
263 | // generate the test bench |
---|
264 | _vhdl_testbench->generate_file(); |
---|
265 | delete _vhdl_testbench; |
---|
266 | #endif |
---|
267 | |
---|
268 | #ifdef STATISTICS |
---|
269 | log_printf(INFO,Meta_Predictor_Glue,"~Meta_Predictor_Glue","Generate Statistics"); |
---|
270 | _stat->generate_file(statistics(0)); |
---|
271 | |
---|
272 | delete _stat; |
---|
273 | #endif |
---|
274 | |
---|
275 | #ifdef SYSTEMC |
---|
276 | log_printf(INFO,Meta_Predictor_Glue,"~Meta_Predictor_Glue","Dealocation"); |
---|
277 | deallocation (); |
---|
278 | #endif |
---|
279 | |
---|
280 | log_printf(FUNC,Meta_Predictor_Glue,"~Meta_Predictor_Glue","End"); |
---|
281 | }; |
---|
282 | |
---|
283 | }; // end namespace meta_predictor_glue |
---|
284 | }; // end namespace meta_predictor |
---|
285 | }; // end namespace predictor |
---|
286 | }; // end namespace stage_1_ifetch |
---|
287 | }; // end namespace behavioural |
---|
288 | }; // end namespace morpheo |
---|