1 | /* |
---|
2 | * $Id: Direction_Glue.cpp 81 2008-04-15 18:40:01Z 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 | log_printf(INFO,Direction_Glue,FUNCTION,"Allocation"); |
---|
42 | |
---|
43 | allocation ( |
---|
44 | #ifdef STATISTICS |
---|
45 | param_statistics |
---|
46 | #endif |
---|
47 | ); |
---|
48 | |
---|
49 | #ifdef STATISTICS |
---|
50 | if (_usage & USE_STATISTICS) |
---|
51 | { |
---|
52 | log_printf(INFO,Direction_Glue,FUNCTION,"Allocation of statistics"); |
---|
53 | |
---|
54 | statistics_allocation(param_statistics); |
---|
55 | } |
---|
56 | #endif |
---|
57 | |
---|
58 | #ifdef VHDL |
---|
59 | if (_usage & USE_VHDL) |
---|
60 | { |
---|
61 | // generate the vhdl |
---|
62 | log_printf(INFO,Direction_Glue,FUNCTION,"Generate the vhdl"); |
---|
63 | |
---|
64 | vhdl(); |
---|
65 | } |
---|
66 | #endif |
---|
67 | |
---|
68 | #ifdef SYSTEMC |
---|
69 | if (_usage & USE_SYSTEMC) |
---|
70 | { |
---|
71 | bool need_genmealy_predict = true; |
---|
72 | bool need_genmealy_update = true; |
---|
73 | |
---|
74 | // Constant |
---|
75 | if (not _param->_have_component_meta_predictor) |
---|
76 | { |
---|
77 | // no need update |
---|
78 | need_genmealy_update = false; |
---|
79 | for (uint32_t i=0; i<_param->_nb_inst_update; i++) |
---|
80 | PORT_WRITE(out_UPDATE_ACK [i], 1); |
---|
81 | |
---|
82 | // always ack |
---|
83 | for (uint32_t i=0; i<_param->_nb_inst_predict; i++) |
---|
84 | { |
---|
85 | PORT_WRITE(out_PREDICT_ACK [i], 1); |
---|
86 | |
---|
87 | // constant direction : never / always |
---|
88 | switch (_param->_predictor_scheme) |
---|
89 | { |
---|
90 | case PREDICTOR_NEVER_TAKE : |
---|
91 | { |
---|
92 | need_genmealy_predict = false; |
---|
93 | PORT_WRITE(out_PREDICT_DIRECTION [i], 0); |
---|
94 | break; |
---|
95 | } |
---|
96 | case PREDICTOR_ALWAYS_TAKE : |
---|
97 | { |
---|
98 | need_genmealy_predict = false; |
---|
99 | PORT_WRITE(out_PREDICT_DIRECTION [i], 1); |
---|
100 | break; |
---|
101 | } |
---|
102 | default : break; |
---|
103 | } |
---|
104 | } |
---|
105 | } |
---|
106 | |
---|
107 | # if defined(STATISTICS) or defined(VHDL_TESTBENCH) |
---|
108 | log_printf(INFO,Direction_Glue,FUNCTION,"Method - transition"); |
---|
109 | |
---|
110 | SC_METHOD (transition); |
---|
111 | dont_initialize (); |
---|
112 | sensitive << (*(in_CLOCK)).pos(); |
---|
113 | |
---|
114 | # ifdef SYSTEMCASS_SPECIFIC |
---|
115 | // List dependency information |
---|
116 | # endif |
---|
117 | # endif |
---|
118 | |
---|
119 | if (need_genmealy_predict) |
---|
120 | { |
---|
121 | log_printf(INFO,Direction_Glue,FUNCTION,"Method - genMealy_predict"); |
---|
122 | |
---|
123 | SC_METHOD (genMealy_predict); |
---|
124 | dont_initialize (); |
---|
125 | // sensitive << (*(in_CLOCK)).neg(); // don't use internal register |
---|
126 | for (uint32_t i=0; i<_param->_nb_inst_predict; i++) |
---|
127 | { |
---|
128 | switch (_param->_predictor_scheme) |
---|
129 | { |
---|
130 | case PREDICTOR_STATIC : |
---|
131 | { |
---|
132 | sensitive << (*(in_PREDICT_STATIC [i])); |
---|
133 | break; |
---|
134 | } |
---|
135 | case PREDICTOR_LAST_TAKE : |
---|
136 | { |
---|
137 | sensitive << (*(in_PREDICT_LAST_TAKE [i])); |
---|
138 | break; |
---|
139 | } |
---|
140 | case PREDICTOR_COUNTER : |
---|
141 | case PREDICTOR_LOCAL : |
---|
142 | case PREDICTOR_GLOBAL : |
---|
143 | case PREDICTOR_META : |
---|
144 | case PREDICTOR_CUSTOM : |
---|
145 | { |
---|
146 | sensitive << (*(in_PREDICT_VAL [i])) |
---|
147 | << (*(in_PREDICT_ADDRESS_SRC [i])) |
---|
148 | << (*(in_PREDICT_PREDICTOR_ACK [i])) |
---|
149 | << (*(in_PREDICT_PREDICTOR_HISTORY [i])) |
---|
150 | << (*(in_PREDICT_PREDICTOR_DIRECTION [i])); |
---|
151 | break; |
---|
152 | } |
---|
153 | default : |
---|
154 | { |
---|
155 | break; |
---|
156 | } |
---|
157 | } |
---|
158 | } |
---|
159 | |
---|
160 | # ifdef SYSTEMCASS_SPECIFIC |
---|
161 | // List dependency information |
---|
162 | for (uint32_t i=0; i<_param->_nb_inst_predict; i++) |
---|
163 | { |
---|
164 | |
---|
165 | switch (_param->_predictor_scheme) |
---|
166 | { |
---|
167 | case PREDICTOR_STATIC : |
---|
168 | { |
---|
169 | (*(out_PREDICT_DIRECTION [i])) (*(in_PREDICT_STATIC [i])); |
---|
170 | |
---|
171 | break; |
---|
172 | } |
---|
173 | case PREDICTOR_LAST_TAKE : |
---|
174 | { |
---|
175 | (*(out_PREDICT_DIRECTION [i])) (*(in_PREDICT_LAST_TAKE [i])); |
---|
176 | |
---|
177 | break; |
---|
178 | } |
---|
179 | case PREDICTOR_COUNTER : |
---|
180 | case PREDICTOR_LOCAL : |
---|
181 | case PREDICTOR_GLOBAL : |
---|
182 | case PREDICTOR_META : |
---|
183 | case PREDICTOR_CUSTOM : |
---|
184 | { |
---|
185 | (*(out_PREDICT_ACK [i])) (*(in_PREDICT_PREDICTOR_ACK [i])); |
---|
186 | (*(out_PREDICT_HISTORY [i])) (*(in_PREDICT_PREDICTOR_HISTORY [i])); |
---|
187 | (*(out_PREDICT_DIRECTION [i])) (*(in_PREDICT_PREDICTOR_DIRECTION [i])); |
---|
188 | (*(out_PREDICT_PREDICTOR_VAL [i])) (*(in_PREDICT_VAL [i])); |
---|
189 | (*(out_PREDICT_PREDICTOR_ADDRESS_SRC [i])) (*(in_PREDICT_ADDRESS_SRC [i])); |
---|
190 | |
---|
191 | break; |
---|
192 | } |
---|
193 | default : |
---|
194 | { |
---|
195 | break; |
---|
196 | } |
---|
197 | } |
---|
198 | } |
---|
199 | # endif |
---|
200 | } |
---|
201 | |
---|
202 | if (need_genmealy_update) |
---|
203 | { |
---|
204 | log_printf(INFO,Direction_Glue,FUNCTION,"Method - genMealy_update"); |
---|
205 | |
---|
206 | SC_METHOD (genMealy_update); |
---|
207 | dont_initialize (); |
---|
208 | // sensitive << (*(in_CLOCK)).neg(); // don't use internal register |
---|
209 | for (uint32_t i=0; i<_param->_nb_inst_update; i++) |
---|
210 | sensitive << (*(in_UPDATE_VAL [i])) |
---|
211 | << (*(in_UPDATE_PREDICTOR_ACK [i])) |
---|
212 | << (*(in_UPDATE_ADDRESS [i])) |
---|
213 | << (*(in_UPDATE_HISTORY [i])) |
---|
214 | << (*(in_UPDATE_DIRECTION [i])); |
---|
215 | |
---|
216 | # ifdef SYSTEMCASS_SPECIFIC |
---|
217 | // List dependency information |
---|
218 | for (uint32_t i=0; i<_param->_nb_inst_update; i++) |
---|
219 | { |
---|
220 | (*(out_UPDATE_PREDICTOR_VAL [i])) (*(in_UPDATE_VAL [i])); |
---|
221 | (*(out_UPDATE_ACK [i])) (*(in_UPDATE_PREDICTOR_ACK [i])); |
---|
222 | (*(out_UPDATE_PREDICTOR_ADDRESS [i])) (*(in_UPDATE_ADDRESS [i])); |
---|
223 | (*(out_UPDATE_PREDICTOR_HISTORY [i])) (*(in_UPDATE_HISTORY [i])); |
---|
224 | (*(out_UPDATE_PREDICTOR_DIRECTION [i])) (*(in_UPDATE_DIRECTION [i])); |
---|
225 | } |
---|
226 | # endif |
---|
227 | } |
---|
228 | #endif |
---|
229 | } |
---|
230 | log_printf(FUNC,Direction_Glue,FUNCTION,"End"); |
---|
231 | }; |
---|
232 | |
---|
233 | #undef FUNCTION |
---|
234 | #define FUNCTION "Direction_Glue::~Direction_Glue" |
---|
235 | Direction_Glue::~Direction_Glue (void) |
---|
236 | { |
---|
237 | log_printf(FUNC,Direction_Glue,FUNCTION,"Begin"); |
---|
238 | |
---|
239 | #ifdef STATISTICS |
---|
240 | if (_usage & USE_STATISTICS) |
---|
241 | { |
---|
242 | statistics_deallocation(); |
---|
243 | } |
---|
244 | #endif |
---|
245 | |
---|
246 | log_printf(INFO,Direction_Glue,FUNCTION,"Deallocation"); |
---|
247 | deallocation (); |
---|
248 | |
---|
249 | log_printf(FUNC,Direction_Glue,FUNCTION,"End"); |
---|
250 | }; |
---|
251 | |
---|
252 | }; // end namespace direction_glue |
---|
253 | }; // end namespace direction |
---|
254 | }; // end namespace prediction_unit |
---|
255 | }; // end namespace front_end |
---|
256 | }; // end namespace multi_front_end |
---|
257 | }; // end namespace core |
---|
258 | |
---|
259 | }; // end namespace behavioural |
---|
260 | }; // end namespace morpheo |
---|