1 | #ifdef SYSTEMC |
---|
2 | //#if defined(STATISTICS) or defined(VHDL_TESTBENCH) |
---|
3 | /* |
---|
4 | * $Id: Read_queue_transition.cpp 128 2009-06-26 08:43:23Z rosiere $ |
---|
5 | * |
---|
6 | * [ Description ] |
---|
7 | * |
---|
8 | */ |
---|
9 | |
---|
10 | #include "Behavioural/Core/Multi_Execute_loop/Execute_loop/Multi_Read_unit/Read_unit/Read_queue/include/Read_queue.h" |
---|
11 | |
---|
12 | namespace morpheo { |
---|
13 | namespace behavioural { |
---|
14 | namespace core { |
---|
15 | namespace multi_execute_loop { |
---|
16 | namespace execute_loop { |
---|
17 | namespace multi_read_unit { |
---|
18 | namespace read_unit { |
---|
19 | namespace read_queue { |
---|
20 | |
---|
21 | |
---|
22 | #undef FUNCTION |
---|
23 | #define FUNCTION "Read_queue::transition" |
---|
24 | void Read_queue::transition (void) |
---|
25 | { |
---|
26 | log_begin(Read_queue,FUNCTION); |
---|
27 | log_function(Read_queue,FUNCTION,_name.c_str()); |
---|
28 | |
---|
29 | if (PORT_READ(in_NRESET) == 0) |
---|
30 | { |
---|
31 | // Flush queue |
---|
32 | // FIXME "queue reset" |
---|
33 | // > 1) flush one slot by cycle |
---|
34 | // > 2) flush all slot in one cycle |
---|
35 | |
---|
36 | while (_queue->empty() == false) |
---|
37 | { |
---|
38 | delete _queue->front(); |
---|
39 | _queue->pop_front(); |
---|
40 | } |
---|
41 | // _queue->clear(); |
---|
42 | |
---|
43 | // Init, else error in registerfile |
---|
44 | _queue_head->_context_id = 0;// not necessary |
---|
45 | _queue_head->_front_end_id = 0;// not necessary |
---|
46 | _queue_head->_ooo_engine_id = 0;// not necessary |
---|
47 | |
---|
48 | _queue_head->_rob_id = 0;// not necessary |
---|
49 | _queue_head->_operation = 0;// not necessary |
---|
50 | _queue_head->_type = 0;// not necessary |
---|
51 | _queue_head->_store_queue_ptr_write = 0;// not necessary |
---|
52 | _queue_head->_store_queue_ptr_read = 0;// not necessary |
---|
53 | _queue_head->_store_queue_empty = 0;// not necessary |
---|
54 | _queue_head->_load_queue_ptr_write = 0;// not necessary |
---|
55 | _queue_head->_has_immediat = 0;// not necessary |
---|
56 | _queue_head->_immediat = 0;// not necessary |
---|
57 | |
---|
58 | _queue_head->_read_ra = 0;// not necessary |
---|
59 | _queue_head->_read_rb = 0;// not necessary |
---|
60 | _queue_head->_read_rc = 0;// not necessary |
---|
61 | _queue_head->_write_rd = 0;// not necessary |
---|
62 | _queue_head->_write_re = 0;// not necessary |
---|
63 | |
---|
64 | _queue_head->_read_ra_val = false; |
---|
65 | _queue_head->_read_rb_val = false; |
---|
66 | _queue_head->_read_rc_val = false; |
---|
67 | |
---|
68 | _queue_head->_data_ra_val = false; |
---|
69 | _queue_head->_data_rb_val = false; |
---|
70 | _queue_head->_data_rc_val = false; |
---|
71 | |
---|
72 | _queue_head->_num_reg_ra = 0;// not necessary |
---|
73 | _queue_head->_num_reg_rb = 0;// not necessary |
---|
74 | _queue_head->_num_reg_rc = 0;// not necessary |
---|
75 | _queue_head->_num_reg_rd = 0;// not necessary |
---|
76 | _queue_head->_num_reg_re = 0;// not necessary |
---|
77 | } |
---|
78 | else |
---|
79 | { |
---|
80 | // cout << "Transition Begin : Print queue_head" << endl; |
---|
81 | // if (_queue->empty ()) |
---|
82 | // cout << "queue is empty !!!" << endl; |
---|
83 | // else |
---|
84 | // cout << (*_queue_head) << endl; |
---|
85 | |
---|
86 | log_printf(TRACE,Read_queue,FUNCTION," * Read_queue size (begin) : %d",(int)_queue->size()); |
---|
87 | // Write to read_queue |
---|
88 | |
---|
89 | bool not_full = not (_queue->size() == _param->_size_queue); |
---|
90 | bool empty = _queue->empty(); |
---|
91 | bool need_new_head = false; |
---|
92 | |
---|
93 | log_printf(TRACE,Read_queue,FUNCTION," * test transaction READ_QUEUE_IN : %d,%d",PORT_READ(in_READ_QUEUE_IN_VAL), not_full); |
---|
94 | if ((PORT_READ(in_READ_QUEUE_IN_VAL) == 1) and not_full) |
---|
95 | { |
---|
96 | Tread_queue_entry_t * entry = new Tread_queue_entry_t; |
---|
97 | |
---|
98 | entry->_context_id = (_param->_have_port_context_id )?PORT_READ(in_READ_QUEUE_IN_CONTEXT_ID ):0; |
---|
99 | entry->_front_end_id = (_param->_have_port_front_end_id )?PORT_READ(in_READ_QUEUE_IN_FRONT_END_ID ):0; |
---|
100 | entry->_ooo_engine_id = (_param->_have_port_ooo_engine_id )?PORT_READ(in_READ_QUEUE_IN_OOO_ENGINE_ID):0; |
---|
101 | entry->_rob_id = (_param->_have_port_rob_ptr )?PORT_READ(in_READ_QUEUE_IN_ROB_ID ):0; |
---|
102 | entry->_operation = PORT_READ(in_READ_QUEUE_IN_OPERATION ); |
---|
103 | entry->_type = PORT_READ(in_READ_QUEUE_IN_TYPE ); |
---|
104 | entry->_store_queue_ptr_write = PORT_READ(in_READ_QUEUE_IN_STORE_QUEUE_PTR_WRITE); |
---|
105 | entry->_store_queue_ptr_read = PORT_READ(in_READ_QUEUE_IN_STORE_QUEUE_PTR_READ ); |
---|
106 | entry->_store_queue_empty = PORT_READ(in_READ_QUEUE_IN_STORE_QUEUE_EMPTY ); |
---|
107 | entry->_load_queue_ptr_write = (_param->_have_port_load_queue_ptr)?PORT_READ(in_READ_QUEUE_IN_LOAD_QUEUE_PTR_WRITE ):0; |
---|
108 | entry->_has_immediat = PORT_READ(in_READ_QUEUE_IN_HAS_IMMEDIAT); |
---|
109 | entry->_immediat = PORT_READ(in_READ_QUEUE_IN_IMMEDIAT ); |
---|
110 | entry->_read_ra = PORT_READ(in_READ_QUEUE_IN_READ_RA ); |
---|
111 | entry->_num_reg_ra = PORT_READ(in_READ_QUEUE_IN_NUM_REG_RA ); |
---|
112 | entry->_read_rb = PORT_READ(in_READ_QUEUE_IN_READ_RB ); |
---|
113 | entry->_num_reg_rb = PORT_READ(in_READ_QUEUE_IN_NUM_REG_RB ); |
---|
114 | entry->_read_rc = PORT_READ(in_READ_QUEUE_IN_READ_RC ); |
---|
115 | entry->_num_reg_rc = PORT_READ(in_READ_QUEUE_IN_NUM_REG_RC ); |
---|
116 | entry->_write_rd = PORT_READ(in_READ_QUEUE_IN_WRITE_RD ); |
---|
117 | entry->_num_reg_rd = PORT_READ(in_READ_QUEUE_IN_NUM_REG_RD ); |
---|
118 | entry->_write_re = PORT_READ(in_READ_QUEUE_IN_WRITE_RE ); |
---|
119 | entry->_num_reg_re = PORT_READ(in_READ_QUEUE_IN_NUM_REG_RE ); |
---|
120 | |
---|
121 | log_printf(TRACE,Read_queue,FUNCTION," * push (id : %d-%d)",entry->_context_id, entry->_rob_id); |
---|
122 | _queue->push_back(entry); |
---|
123 | |
---|
124 | // read next new head |
---|
125 | if (empty) |
---|
126 | { |
---|
127 | log_printf(TRACE,Read_queue,FUNCTION," * queue was empty"); |
---|
128 | need_new_head = true; |
---|
129 | } |
---|
130 | } |
---|
131 | |
---|
132 | // Read from read_queue |
---|
133 | log_printf(TRACE,Read_queue,FUNCTION," * test transaction READ_QUEUE_OUT : %d,%d",internal_READ_QUEUE_OUT_VAL, PORT_READ(in_READ_QUEUE_OUT_ACK)); |
---|
134 | if (( internal_READ_QUEUE_OUT_VAL == 1) and |
---|
135 | (PORT_READ(in_READ_QUEUE_OUT_ACK) == 1)) |
---|
136 | { |
---|
137 | // Pop the entry |
---|
138 | log_printf(TRACE,Read_queue,FUNCTION," * pop (id : %d-%d)",_queue->front()->_context_id, _queue->front()->_rob_id); |
---|
139 | delete _queue->front(); |
---|
140 | _queue->pop_front(); |
---|
141 | |
---|
142 | // read next new head |
---|
143 | if (_queue->empty() == false) |
---|
144 | { |
---|
145 | log_printf(TRACE,Read_queue,FUNCTION," * queue was not empty"); |
---|
146 | need_new_head = true; |
---|
147 | } |
---|
148 | } |
---|
149 | else |
---|
150 | { |
---|
151 | // no transaction, update queue_head |
---|
152 | _queue_head->_read_ra_val = internal_READ_QUEUE_OUT_READ_RA_VAL ; |
---|
153 | _queue_head->_data_ra_val = internal_READ_QUEUE_OUT_DATA_RA_VAL ; |
---|
154 | _queue_head->_data_ra = internal_READ_QUEUE_OUT_DATA_RA ; |
---|
155 | |
---|
156 | _queue_head->_read_rb_val = internal_READ_QUEUE_OUT_READ_RB_VAL ; |
---|
157 | _queue_head->_data_rb_val = internal_READ_QUEUE_OUT_DATA_RB_VAL ; |
---|
158 | _queue_head->_data_rb = internal_READ_QUEUE_OUT_DATA_RB ; |
---|
159 | |
---|
160 | _queue_head->_read_rc_val = internal_READ_QUEUE_OUT_READ_RC_VAL ; |
---|
161 | _queue_head->_data_rc_val = internal_READ_QUEUE_OUT_DATA_RC_VAL ; |
---|
162 | _queue_head->_data_rc = internal_READ_QUEUE_OUT_DATA_RC ; |
---|
163 | } |
---|
164 | |
---|
165 | if (need_new_head == true) |
---|
166 | { |
---|
167 | log_printf(TRACE,Read_queue,FUNCTION," * new head"); |
---|
168 | (*_queue_head) = (*_queue->front()); |
---|
169 | } |
---|
170 | |
---|
171 | // cout << "Transition End : Print queue_head" << endl; |
---|
172 | // if (_queue->empty ()) |
---|
173 | // cout << "queue is empty !!!" << endl; |
---|
174 | // else |
---|
175 | // cout << (*_queue_head) << endl; |
---|
176 | |
---|
177 | #if (DEBUG >= DEBUG_TRACE) and (DEBUG_Read_queue == true) |
---|
178 | log_printf(TRACE,Read_queue,FUNCTION," * Dump Read_queue"); |
---|
179 | log_printf(TRACE,Read_queue,FUNCTION," * size : %d / %d",(int)_queue->size(),_param->_size_queue); |
---|
180 | |
---|
181 | if (_queue->size()>0) |
---|
182 | { |
---|
183 | log_printf(TRACE,Read_queue,FUNCTION," * [%.4d] %.2d %.2d %.2d %.4d, %.2d %.3d, %.2d %.2d %.1d %.2d, %.1d %.8x, %.1d %.1d %.4d %.1d %.8x, %.1d %.1d %.4d %.1d %.8x, %.1d %.1d %.4d %.1d %.2x, %.1d %.4d, %.1d %.4d (%s)", |
---|
184 | 0, |
---|
185 | |
---|
186 | _queue_head->_context_id , |
---|
187 | _queue_head->_front_end_id , |
---|
188 | _queue_head->_ooo_engine_id , |
---|
189 | _queue_head->_rob_id , |
---|
190 | |
---|
191 | _queue_head->_type , |
---|
192 | _queue_head->_operation , |
---|
193 | |
---|
194 | _queue_head->_store_queue_ptr_write, |
---|
195 | _queue_head->_store_queue_ptr_read , |
---|
196 | _queue_head->_store_queue_empty , |
---|
197 | _queue_head->_load_queue_ptr_write , |
---|
198 | |
---|
199 | _queue_head->_has_immediat , |
---|
200 | _queue_head->_immediat , |
---|
201 | |
---|
202 | _queue_head->_read_ra , |
---|
203 | _queue_head->_read_ra_val , |
---|
204 | _queue_head->_num_reg_ra , |
---|
205 | _queue_head->_data_ra_val , |
---|
206 | _queue_head->_data_ra , |
---|
207 | |
---|
208 | _queue_head->_read_rb , |
---|
209 | _queue_head->_read_rb_val , |
---|
210 | _queue_head->_num_reg_rb , |
---|
211 | _queue_head->_data_rb_val , |
---|
212 | _queue_head->_data_rb , |
---|
213 | |
---|
214 | _queue_head->_read_rc , |
---|
215 | _queue_head->_read_rc_val , |
---|
216 | _queue_head->_num_reg_rc , |
---|
217 | _queue_head->_data_rc_val , |
---|
218 | _queue_head->_data_rc , |
---|
219 | |
---|
220 | _queue_head->_write_rd , |
---|
221 | _queue_head->_num_reg_rd , |
---|
222 | |
---|
223 | _queue_head->_write_re , |
---|
224 | _queue_head->_num_reg_re , |
---|
225 | |
---|
226 | toString(_queue_head->_type).c_str()); |
---|
227 | |
---|
228 | |
---|
229 | std::list<Tread_queue_entry_t *>::iterator it=_queue->begin(); |
---|
230 | ++it; // first is already printed |
---|
231 | uint32_t i=1; |
---|
232 | |
---|
233 | for (;it!=_queue->end(); ++it) |
---|
234 | { |
---|
235 | log_printf(TRACE,Read_queue,FUNCTION," * [%.4d] %.2d %.2d %.2d %.4d, %.2d %.3d, %.2d %.2d %.1d %.2d, %.1d %.8x, %.1d %.4d , %.1d %.4d , %.1d %.4d , %.1d %.4d, %.1d %.4d (%s)", |
---|
236 | i, |
---|
237 | |
---|
238 | (*it)->_context_id , |
---|
239 | (*it)->_front_end_id , |
---|
240 | (*it)->_ooo_engine_id , |
---|
241 | (*it)->_rob_id , |
---|
242 | |
---|
243 | (*it)->_type , |
---|
244 | (*it)->_operation , |
---|
245 | |
---|
246 | (*it)->_store_queue_ptr_write, |
---|
247 | (*it)->_store_queue_ptr_read , |
---|
248 | (*it)->_store_queue_empty , |
---|
249 | (*it)->_load_queue_ptr_write , |
---|
250 | |
---|
251 | (*it)->_has_immediat , |
---|
252 | (*it)->_immediat , |
---|
253 | |
---|
254 | (*it)->_read_ra , |
---|
255 | // (*it)->_read_ra_val , |
---|
256 | (*it)->_num_reg_ra , |
---|
257 | // (*it)->_data_ra_val , |
---|
258 | // (*it)->_data_ra , |
---|
259 | |
---|
260 | (*it)->_read_rb , |
---|
261 | // (*it)->_read_rb_val , |
---|
262 | (*it)->_num_reg_rb , |
---|
263 | // (*it)->_data_rb_val , |
---|
264 | // (*it)->_data_rb , |
---|
265 | |
---|
266 | (*it)->_read_rc , |
---|
267 | // (*it)->_read_rc_val , |
---|
268 | (*it)->_num_reg_rc , |
---|
269 | // (*it)->_data_rc_val , |
---|
270 | // (*it)->_data_rc , |
---|
271 | |
---|
272 | (*it)->_write_rd , |
---|
273 | (*it)->_num_reg_rd , |
---|
274 | |
---|
275 | (*it)->_write_re , |
---|
276 | (*it)->_num_reg_re , |
---|
277 | |
---|
278 | toString((*it)->_type).c_str()); |
---|
279 | |
---|
280 | ++i; |
---|
281 | } |
---|
282 | } |
---|
283 | #endif |
---|
284 | } |
---|
285 | |
---|
286 | #if defined(STATISTICS) or defined(VHDL_TESTBENCH) |
---|
287 | end_cycle (); |
---|
288 | #endif |
---|
289 | |
---|
290 | log_end(Read_queue,FUNCTION); |
---|
291 | }; |
---|
292 | |
---|
293 | }; // end namespace read_queue |
---|
294 | }; // end namespace read_unit |
---|
295 | }; // end namespace multi_read_unit |
---|
296 | }; // end namespace execute_loop |
---|
297 | }; // end namespace multi_execute_loop |
---|
298 | }; // end namespace core |
---|
299 | |
---|
300 | }; // end namespace behavioural |
---|
301 | }; // end namespace morpheo |
---|
302 | #endif |
---|
303 | //#endif |
---|