1 | /* |
---|
2 | * $Id: Direction_Glue.cpp 132 2009-07-11 16:39:35Z rosiere $ |
---|
3 | * |
---|
4 | * [ Description ] |
---|
5 | * |
---|
6 | */ |
---|
7 | |
---|
8 | #include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Direction_Glue/include/Direction_Glue.h" |
---|
9 | |
---|
10 | namespace morpheo { |
---|
11 | namespace behavioural { |
---|
12 | namespace core { |
---|
13 | namespace multi_front_end { |
---|
14 | namespace front_end { |
---|
15 | namespace prediction_unit { |
---|
16 | namespace direction { |
---|
17 | namespace direction_glue { |
---|
18 | |
---|
19 | |
---|
20 | #undef FUNCTION |
---|
21 | #define FUNCTION "Direction_Glue::Direction_Glue" |
---|
22 | Direction_Glue::Direction_Glue |
---|
23 | ( |
---|
24 | #ifdef SYSTEMC |
---|
25 | sc_module_name name, |
---|
26 | #else |
---|
27 | string name, |
---|
28 | #endif |
---|
29 | #ifdef STATISTICS |
---|
30 | morpheo::behavioural::Parameters_Statistics * param_statistics, |
---|
31 | #endif |
---|
32 | morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::direction::direction_glue::Parameters * param, |
---|
33 | morpheo::behavioural::Tusage_t usage |
---|
34 | ): |
---|
35 | _name (name) |
---|
36 | ,_param (param) |
---|
37 | ,_usage (usage) |
---|
38 | { |
---|
39 | log_printf(FUNC,Direction_Glue,FUNCTION,"Begin"); |
---|
40 | |
---|
41 | |
---|
42 | // #if DEBUG_Direction_Glue == true |
---|
43 | // log_printf(INFO,Direction_Glue,FUNCTION,_("<%s> Parameters"),_name.c_str()); |
---|
44 | |
---|
45 | // std::cout << *param << std::endl; |
---|
46 | // #endif |
---|
47 | |
---|
48 | log_printf(INFO,Direction_Glue,FUNCTION,"Allocation"); |
---|
49 | |
---|
50 | allocation ( |
---|
51 | #ifdef STATISTICS |
---|
52 | param_statistics |
---|
53 | #endif |
---|
54 | ); |
---|
55 | |
---|
56 | #ifdef STATISTICS |
---|
57 | if (usage_is_set(_usage,USE_STATISTICS)) |
---|
58 | { |
---|
59 | log_printf(INFO,Direction_Glue,FUNCTION,"Allocation of statistics"); |
---|
60 | |
---|
61 | statistics_allocation(param_statistics); |
---|
62 | } |
---|
63 | #endif |
---|
64 | |
---|
65 | #ifdef VHDL |
---|
66 | if (usage_is_set(_usage,USE_VHDL)) |
---|
67 | { |
---|
68 | // generate the vhdl |
---|
69 | log_printf(INFO,Direction_Glue,FUNCTION,"Generate the vhdl"); |
---|
70 | |
---|
71 | vhdl(); |
---|
72 | } |
---|
73 | #endif |
---|
74 | |
---|
75 | #ifdef SYSTEMC |
---|
76 | if (usage_is_set(_usage,USE_SYSTEMC)) |
---|
77 | { |
---|
78 | bool need_genmealy_predict = true; |
---|
79 | bool need_genmealy_update = true; |
---|
80 | |
---|
81 | // Constant |
---|
82 | if (not _param->_have_component_meta_predictor) |
---|
83 | { |
---|
84 | // no need update |
---|
85 | need_genmealy_update = false; |
---|
86 | |
---|
87 | // always ack |
---|
88 | for (uint32_t i=0; i<_param->_nb_inst_predict; i++) |
---|
89 | { |
---|
90 | // constant direction : never / always |
---|
91 | switch (_param->_predictor_scheme) |
---|
92 | { |
---|
93 | case PREDICTOR_NEVER_TAKE : |
---|
94 | { |
---|
95 | need_genmealy_predict = false; |
---|
96 | break; |
---|
97 | } |
---|
98 | case PREDICTOR_ALWAYS_TAKE : |
---|
99 | { |
---|
100 | need_genmealy_predict = false; |
---|
101 | break; |
---|
102 | } |
---|
103 | default : break; |
---|
104 | } |
---|
105 | } |
---|
106 | } |
---|
107 | |
---|
108 | #ifdef SYSTEMCASS_SPECIFIC |
---|
109 | constant(); |
---|
110 | #else |
---|
111 | log_printf(INFO,Direction_Glue,FUNCTION,"Method - constant"); |
---|
112 | |
---|
113 | SC_METHOD (constant); |
---|
114 | // dont_initialize (); |
---|
115 | |
---|
116 | # ifdef SYSTEMCASS_SPECIFIC |
---|
117 | // List dependency information |
---|
118 | # endif |
---|
119 | #endif |
---|
120 | |
---|
121 | # if defined(STATISTICS) or defined(VHDL_TESTBENCH) |
---|
122 | log_printf(INFO,Direction_Glue,FUNCTION,"Method - transition"); |
---|
123 | |
---|
124 | SC_METHOD (transition); |
---|
125 | dont_initialize (); |
---|
126 | sensitive << (*(in_CLOCK)).pos(); |
---|
127 | |
---|
128 | # ifdef SYSTEMCASS_SPECIFIC |
---|
129 | // List dependency information |
---|
130 | # endif |
---|
131 | # endif |
---|
132 | |
---|
133 | if (need_genmealy_predict) |
---|
134 | { |
---|
135 | log_printf(INFO,Direction_Glue,FUNCTION,"Method - genMealy_predict"); |
---|
136 | |
---|
137 | SC_METHOD (genMealy_predict); |
---|
138 | dont_initialize (); |
---|
139 | // sensitive << (*(in_CLOCK)).neg(); // don't use internal register |
---|
140 | sensitive << (*(in_NRESET)); |
---|
141 | for (uint32_t i=0; i<_param->_nb_inst_predict; i++) |
---|
142 | { |
---|
143 | switch (_param->_predictor_scheme) |
---|
144 | { |
---|
145 | case PREDICTOR_STATIC : |
---|
146 | { |
---|
147 | sensitive << (*(in_PREDICT_STATIC [i])); |
---|
148 | break; |
---|
149 | } |
---|
150 | case PREDICTOR_LAST_TAKE : |
---|
151 | { |
---|
152 | sensitive << (*(in_PREDICT_LAST_TAKE [i])); |
---|
153 | break; |
---|
154 | } |
---|
155 | case PREDICTOR_COUNTER : |
---|
156 | case PREDICTOR_LOCAL : |
---|
157 | case PREDICTOR_GLOBAL : |
---|
158 | case PREDICTOR_META : |
---|
159 | case PREDICTOR_CUSTOM : |
---|
160 | { |
---|
161 | sensitive << (*(in_PREDICT_VAL [i])) |
---|
162 | << (*(in_PREDICT_ADDRESS_SRC [i])) |
---|
163 | << (*(in_PREDICT_PREDICTOR_ACK [i])) |
---|
164 | << (*(in_PREDICT_PREDICTOR_HISTORY [i])) |
---|
165 | << (*(in_PREDICT_PREDICTOR_DIRECTION [i])); |
---|
166 | break; |
---|
167 | } |
---|
168 | default : |
---|
169 | { |
---|
170 | break; |
---|
171 | } |
---|
172 | } |
---|
173 | } |
---|
174 | |
---|
175 | # ifdef SYSTEMCASS_SPECIFIC |
---|
176 | // // List dependency information |
---|
177 | // for (uint32_t i=0; i<_param->_nb_inst_predict; i++) |
---|
178 | // { |
---|
179 | |
---|
180 | // switch (_param->_predictor_scheme) |
---|
181 | // { |
---|
182 | // case PREDICTOR_STATIC : |
---|
183 | // { |
---|
184 | // (*(out_PREDICT_DIRECTION [i])) (*(in_PREDICT_STATIC [i])); |
---|
185 | |
---|
186 | // break; |
---|
187 | // } |
---|
188 | // case PREDICTOR_LAST_TAKE : |
---|
189 | // { |
---|
190 | // (*(out_PREDICT_DIRECTION [i])) (*(in_PREDICT_LAST_TAKE [i])); |
---|
191 | |
---|
192 | // break; |
---|
193 | // } |
---|
194 | // case PREDICTOR_COUNTER : |
---|
195 | // case PREDICTOR_LOCAL : |
---|
196 | // case PREDICTOR_GLOBAL : |
---|
197 | // case PREDICTOR_META : |
---|
198 | // case PREDICTOR_CUSTOM : |
---|
199 | // { |
---|
200 | // (*(out_PREDICT_ACK [i])) (*(in_PREDICT_PREDICTOR_ACK [i])); |
---|
201 | // (*(out_PREDICT_HISTORY [i])) (*(in_PREDICT_PREDICTOR_HISTORY [i])); |
---|
202 | // (*(out_PREDICT_DIRECTION [i])) (*(in_PREDICT_PREDICTOR_DIRECTION [i])); |
---|
203 | // (*(out_PREDICT_PREDICTOR_VAL [i])) (*(in_PREDICT_VAL [i])); |
---|
204 | // (*(out_PREDICT_PREDICTOR_ADDRESS_SRC [i])) (*(in_PREDICT_ADDRESS_SRC [i])); |
---|
205 | |
---|
206 | // break; |
---|
207 | // } |
---|
208 | // default : |
---|
209 | // { |
---|
210 | // break; |
---|
211 | // } |
---|
212 | // } |
---|
213 | // } |
---|
214 | # endif |
---|
215 | } |
---|
216 | |
---|
217 | if (need_genmealy_update) |
---|
218 | { |
---|
219 | log_printf(INFO,Direction_Glue,FUNCTION,"Method - genMealy_update"); |
---|
220 | |
---|
221 | SC_METHOD (genMealy_update); |
---|
222 | dont_initialize (); |
---|
223 | // sensitive << (*(in_CLOCK)).neg(); // don't use internal register |
---|
224 | sensitive << (*(in_NRESET)); |
---|
225 | for (uint32_t i=0; i<_param->_nb_inst_update; i++) |
---|
226 | sensitive << (*(in_UPDATE_VAL [i])) |
---|
227 | << (*(in_UPDATE_PREDICTOR_ACK [i])) |
---|
228 | << (*(in_UPDATE_ADDRESS [i])) |
---|
229 | << (*(in_UPDATE_HISTORY [i])) |
---|
230 | << (*(in_UPDATE_DIRECTION [i])) |
---|
231 | << (*(in_UPDATE_PREDICTION_IFETCH [i])) |
---|
232 | ; |
---|
233 | |
---|
234 | # ifdef SYSTEMCASS_SPECIFIC |
---|
235 | // // List dependency information |
---|
236 | // for (uint32_t i=0; i<_param->_nb_inst_update; i++) |
---|
237 | // { |
---|
238 | // (*(out_UPDATE_PREDICTOR_VAL [i])) (*(in_UPDATE_VAL [i])); |
---|
239 | // (*(out_UPDATE_ACK [i])) (*(in_UPDATE_PREDICTOR_ACK [i])); |
---|
240 | // (*(out_UPDATE_PREDICTOR_ADDRESS [i])) (*(in_UPDATE_ADDRESS [i])); |
---|
241 | // (*(out_UPDATE_PREDICTOR_HISTORY [i])) (*(in_UPDATE_HISTORY [i])); |
---|
242 | // (*(out_UPDATE_PREDICTOR_DIRECTION [i])) (*(in_UPDATE_DIRECTION [i])); |
---|
243 | // } |
---|
244 | # endif |
---|
245 | } |
---|
246 | #endif |
---|
247 | } |
---|
248 | log_printf(FUNC,Direction_Glue,FUNCTION,"End"); |
---|
249 | }; |
---|
250 | |
---|
251 | #undef FUNCTION |
---|
252 | #define FUNCTION "Direction_Glue::~Direction_Glue" |
---|
253 | Direction_Glue::~Direction_Glue (void) |
---|
254 | { |
---|
255 | log_printf(FUNC,Direction_Glue,FUNCTION,"Begin"); |
---|
256 | |
---|
257 | #ifdef STATISTICS |
---|
258 | if (usage_is_set(_usage,USE_STATISTICS)) |
---|
259 | { |
---|
260 | statistics_deallocation(); |
---|
261 | } |
---|
262 | #endif |
---|
263 | |
---|
264 | log_printf(INFO,Direction_Glue,FUNCTION,"Deallocation"); |
---|
265 | deallocation (); |
---|
266 | |
---|
267 | log_printf(FUNC,Direction_Glue,FUNCTION,"End"); |
---|
268 | }; |
---|
269 | |
---|
270 | }; // end namespace direction_glue |
---|
271 | }; // end namespace direction |
---|
272 | }; // end namespace prediction_unit |
---|
273 | }; // end namespace front_end |
---|
274 | }; // end namespace multi_front_end |
---|
275 | }; // end namespace core |
---|
276 | |
---|
277 | }; // end namespace behavioural |
---|
278 | }; // end namespace morpheo |
---|