1 | /* |
---|
2 | * $Id: Direction_Glue.cpp 112 2009-03-18 22:36:26Z 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 | for (uint32_t i=0; i<_param->_nb_inst_update; i++) |
---|
87 | PORT_WRITE(out_UPDATE_ACK [i], 1); |
---|
88 | |
---|
89 | // always ack |
---|
90 | for (uint32_t i=0; i<_param->_nb_inst_predict; i++) |
---|
91 | { |
---|
92 | PORT_WRITE(out_PREDICT_ACK [i], 1); |
---|
93 | |
---|
94 | // constant direction : never / always |
---|
95 | switch (_param->_predictor_scheme) |
---|
96 | { |
---|
97 | case PREDICTOR_NEVER_TAKE : |
---|
98 | { |
---|
99 | need_genmealy_predict = false; |
---|
100 | PORT_WRITE(out_PREDICT_DIRECTION [i], 0); |
---|
101 | break; |
---|
102 | } |
---|
103 | case PREDICTOR_ALWAYS_TAKE : |
---|
104 | { |
---|
105 | need_genmealy_predict = false; |
---|
106 | PORT_WRITE(out_PREDICT_DIRECTION [i], 1); |
---|
107 | break; |
---|
108 | } |
---|
109 | default : break; |
---|
110 | } |
---|
111 | } |
---|
112 | } |
---|
113 | |
---|
114 | # if defined(STATISTICS) or defined(VHDL_TESTBENCH) |
---|
115 | log_printf(INFO,Direction_Glue,FUNCTION,"Method - transition"); |
---|
116 | |
---|
117 | SC_METHOD (transition); |
---|
118 | dont_initialize (); |
---|
119 | sensitive << (*(in_CLOCK)).pos(); |
---|
120 | |
---|
121 | # ifdef SYSTEMCASS_SPECIFIC |
---|
122 | // List dependency information |
---|
123 | # endif |
---|
124 | # endif |
---|
125 | |
---|
126 | if (need_genmealy_predict) |
---|
127 | { |
---|
128 | log_printf(INFO,Direction_Glue,FUNCTION,"Method - genMealy_predict"); |
---|
129 | |
---|
130 | SC_METHOD (genMealy_predict); |
---|
131 | dont_initialize (); |
---|
132 | // sensitive << (*(in_CLOCK)).neg(); // don't use internal register |
---|
133 | for (uint32_t i=0; i<_param->_nb_inst_predict; i++) |
---|
134 | { |
---|
135 | switch (_param->_predictor_scheme) |
---|
136 | { |
---|
137 | case PREDICTOR_STATIC : |
---|
138 | { |
---|
139 | sensitive << (*(in_PREDICT_STATIC [i])); |
---|
140 | break; |
---|
141 | } |
---|
142 | case PREDICTOR_LAST_TAKE : |
---|
143 | { |
---|
144 | sensitive << (*(in_PREDICT_LAST_TAKE [i])); |
---|
145 | break; |
---|
146 | } |
---|
147 | case PREDICTOR_COUNTER : |
---|
148 | case PREDICTOR_LOCAL : |
---|
149 | case PREDICTOR_GLOBAL : |
---|
150 | case PREDICTOR_META : |
---|
151 | case PREDICTOR_CUSTOM : |
---|
152 | { |
---|
153 | sensitive << (*(in_PREDICT_VAL [i])) |
---|
154 | << (*(in_PREDICT_ADDRESS_SRC [i])) |
---|
155 | << (*(in_PREDICT_PREDICTOR_ACK [i])) |
---|
156 | << (*(in_PREDICT_PREDICTOR_HISTORY [i])) |
---|
157 | << (*(in_PREDICT_PREDICTOR_DIRECTION [i])); |
---|
158 | break; |
---|
159 | } |
---|
160 | default : |
---|
161 | { |
---|
162 | break; |
---|
163 | } |
---|
164 | } |
---|
165 | } |
---|
166 | |
---|
167 | # ifdef SYSTEMCASS_SPECIFIC |
---|
168 | // // List dependency information |
---|
169 | // for (uint32_t i=0; i<_param->_nb_inst_predict; i++) |
---|
170 | // { |
---|
171 | |
---|
172 | // switch (_param->_predictor_scheme) |
---|
173 | // { |
---|
174 | // case PREDICTOR_STATIC : |
---|
175 | // { |
---|
176 | // (*(out_PREDICT_DIRECTION [i])) (*(in_PREDICT_STATIC [i])); |
---|
177 | |
---|
178 | // break; |
---|
179 | // } |
---|
180 | // case PREDICTOR_LAST_TAKE : |
---|
181 | // { |
---|
182 | // (*(out_PREDICT_DIRECTION [i])) (*(in_PREDICT_LAST_TAKE [i])); |
---|
183 | |
---|
184 | // break; |
---|
185 | // } |
---|
186 | // case PREDICTOR_COUNTER : |
---|
187 | // case PREDICTOR_LOCAL : |
---|
188 | // case PREDICTOR_GLOBAL : |
---|
189 | // case PREDICTOR_META : |
---|
190 | // case PREDICTOR_CUSTOM : |
---|
191 | // { |
---|
192 | // (*(out_PREDICT_ACK [i])) (*(in_PREDICT_PREDICTOR_ACK [i])); |
---|
193 | // (*(out_PREDICT_HISTORY [i])) (*(in_PREDICT_PREDICTOR_HISTORY [i])); |
---|
194 | // (*(out_PREDICT_DIRECTION [i])) (*(in_PREDICT_PREDICTOR_DIRECTION [i])); |
---|
195 | // (*(out_PREDICT_PREDICTOR_VAL [i])) (*(in_PREDICT_VAL [i])); |
---|
196 | // (*(out_PREDICT_PREDICTOR_ADDRESS_SRC [i])) (*(in_PREDICT_ADDRESS_SRC [i])); |
---|
197 | |
---|
198 | // break; |
---|
199 | // } |
---|
200 | // default : |
---|
201 | // { |
---|
202 | // break; |
---|
203 | // } |
---|
204 | // } |
---|
205 | // } |
---|
206 | # endif |
---|
207 | } |
---|
208 | |
---|
209 | if (need_genmealy_update) |
---|
210 | { |
---|
211 | log_printf(INFO,Direction_Glue,FUNCTION,"Method - genMealy_update"); |
---|
212 | |
---|
213 | SC_METHOD (genMealy_update); |
---|
214 | dont_initialize (); |
---|
215 | // sensitive << (*(in_CLOCK)).neg(); // don't use internal register |
---|
216 | for (uint32_t i=0; i<_param->_nb_inst_update; i++) |
---|
217 | sensitive << (*(in_UPDATE_VAL [i])) |
---|
218 | << (*(in_UPDATE_PREDICTOR_ACK [i])) |
---|
219 | << (*(in_UPDATE_ADDRESS [i])) |
---|
220 | << (*(in_UPDATE_HISTORY [i])) |
---|
221 | << (*(in_UPDATE_DIRECTION [i])) |
---|
222 | << (*(in_UPDATE_PREDICTION_IFETCH [i])) |
---|
223 | ; |
---|
224 | |
---|
225 | # ifdef SYSTEMCASS_SPECIFIC |
---|
226 | // // List dependency information |
---|
227 | // for (uint32_t i=0; i<_param->_nb_inst_update; i++) |
---|
228 | // { |
---|
229 | // (*(out_UPDATE_PREDICTOR_VAL [i])) (*(in_UPDATE_VAL [i])); |
---|
230 | // (*(out_UPDATE_ACK [i])) (*(in_UPDATE_PREDICTOR_ACK [i])); |
---|
231 | // (*(out_UPDATE_PREDICTOR_ADDRESS [i])) (*(in_UPDATE_ADDRESS [i])); |
---|
232 | // (*(out_UPDATE_PREDICTOR_HISTORY [i])) (*(in_UPDATE_HISTORY [i])); |
---|
233 | // (*(out_UPDATE_PREDICTOR_DIRECTION [i])) (*(in_UPDATE_DIRECTION [i])); |
---|
234 | // } |
---|
235 | # endif |
---|
236 | } |
---|
237 | #endif |
---|
238 | } |
---|
239 | log_printf(FUNC,Direction_Glue,FUNCTION,"End"); |
---|
240 | }; |
---|
241 | |
---|
242 | #undef FUNCTION |
---|
243 | #define FUNCTION "Direction_Glue::~Direction_Glue" |
---|
244 | Direction_Glue::~Direction_Glue (void) |
---|
245 | { |
---|
246 | log_printf(FUNC,Direction_Glue,FUNCTION,"Begin"); |
---|
247 | |
---|
248 | #ifdef STATISTICS |
---|
249 | if (usage_is_set(_usage,USE_STATISTICS)) |
---|
250 | { |
---|
251 | statistics_deallocation(); |
---|
252 | } |
---|
253 | #endif |
---|
254 | |
---|
255 | log_printf(INFO,Direction_Glue,FUNCTION,"Deallocation"); |
---|
256 | deallocation (); |
---|
257 | |
---|
258 | log_printf(FUNC,Direction_Glue,FUNCTION,"End"); |
---|
259 | }; |
---|
260 | |
---|
261 | }; // end namespace direction_glue |
---|
262 | }; // end namespace direction |
---|
263 | }; // end namespace prediction_unit |
---|
264 | }; // end namespace front_end |
---|
265 | }; // end namespace multi_front_end |
---|
266 | }; // end namespace core |
---|
267 | |
---|
268 | }; // end namespace behavioural |
---|
269 | }; // end namespace morpheo |
---|