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 @ 146

Last change on this file since 146 was 146, checked in by rosiere, 13 years ago

1) Integration of RegisterFile_Internal_Banked in RegisterFile?
2) Erase "read_write" interface in RegisterFile_Monolithic component
3) Add smith predictor parameters in Load_store_pointer_unit.
4) Fix not statistics flags

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