source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Execute_loop/Execute_loop/Multi_Read_unit/Read_unit/Read_queue/src/Read_queue_transition.cpp @ 136

Last change on this file since 136 was 136, checked in by rosiere, 15 years ago

1) Add new algo in ifetch queue
2) Add Cancel bit
3) new config

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