source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Execute_loop/Execute_loop/Multi_Read_unit/Read_unit/Reservation_station/src/Reservation_station_transition.cpp @ 122

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

Modif for performance :
1) Load Store Unit : store send request to valid exeception
2) Commit_unit : retire can bypass store
3) Commit_unit : add stat to manage store instruction
4) Load Store Unit and Load Store Pointer Manager : add store_queue_ptr_read
5) Fix lot of bug

  • Property svn:keywords set to Id
File size: 15.4 KB
Line 
1#ifdef SYSTEMC
2//#if defined(STATISTICS) or defined(VHDL_TESTBENCH)
3/*
4 * $Id: Reservation_station_transition.cpp 122 2009-06-03 08:15:51Z rosiere $
5 *
6 * [ Description ]
7 *
8 */
9
10#include "Behavioural/Core/Multi_Execute_loop/Execute_loop/Multi_Read_unit/Read_unit/Reservation_station/include/Reservation_station.h"
11
12namespace morpheo                    {
13namespace behavioural {
14namespace core {
15namespace multi_execute_loop {
16namespace execute_loop {
17namespace multi_read_unit {
18namespace read_unit {
19namespace reservation_station {
20
21#ifdef  SYSTEMC_VHDL_COMPATIBILITY
22#define dump_queue()                                                    \
23  do                                                                    \
24    {                                                                   \
25      log_printf(TRACE,Reservation_station,FUNCTION,"  * Dump Reservation Station");  \
26      for (uint32_t it_dump=0;it_dump<_param->_size_queue; it_dump++)   \
27        if (_queue_valid [it_dump])                                     \
28          log_printf(TRACE,Reservation_station,FUNCTION,"    * [%.4d] %.2d %.2d %.2d %.4d, %.2d %.3d, %.2d %.2d %.1d %.2d, %.1d %.8x, %.4d %.1d %.8x, %.4d %.1d %.8x, %.4d %.1d %.2x, %.1d %.4d, %.1d %.4d (%s)", \
29                     it_dump,                                           \
30                     _queue[it_dump]._context_id           ,            \
31                     _queue[it_dump]._front_end_id         ,            \
32                     _queue[it_dump]._ooo_engine_id        ,            \
33                     _queue[it_dump]._rob_id               ,            \
34                     _queue[it_dump]._type                 ,            \
35                     _queue[it_dump]._operation            ,            \
36                     _queue[it_dump]._store_queue_ptr_write,            \
37                     _queue[it_dump]._store_queue_ptr_read ,            \
38                     _queue[it_dump]._store_queue_empty    ,            \
39                     _queue[it_dump]._load_queue_ptr_write ,            \
40                     _queue[it_dump]._has_immediat         ,            \
41                     _queue[it_dump]._immediat             ,            \
42                     _queue[it_dump]._num_reg_ra           ,            \
43                     _queue[it_dump]._data_ra_val          ,            \
44                     _queue[it_dump]._data_ra              ,            \
45                     _queue[it_dump]._num_reg_rb           ,            \
46                     _queue[it_dump]._data_rb_val          ,            \
47                     _queue[it_dump]._data_rb              ,            \
48                     _queue[it_dump]._num_reg_rc           ,            \
49                     _queue[it_dump]._data_rc_val          ,            \
50                     _queue[it_dump]._data_rc              ,            \
51                     _queue[it_dump]._write_rd             ,            \
52                     _queue[it_dump]._num_reg_rd           ,            \
53                     _queue[it_dump]._write_re             ,            \
54                     _queue[it_dump]._num_reg_re           ,            \
55                     toString(_queue[it_dump]._type).c_str());          \
56    } while (0)
57#else
58#define dump_queue()                                                    \
59  do                                                                    \
60    {                                                                   \
61      log_printf(TRACE,Reservation_station,FUNCTION,"  * Dump Reservation Station"); \
62      log_printf(TRACE,Reservation_station,FUNCTION,"    * nb_elt : %d",_queue_control->nb_elt()); \
63      for (uint32_t it_dump=0;it_dump<_param->_size_queue; it_dump++)   \
64        if (it_dump < _queue_control->nb_elt())                         \
65          log_printf(TRACE,Reservation_station,FUNCTION,"    * [%.4d] %.2d %.2d %.2d %.4d, %.2d %.3d, %.2d %.2d %.1d %.2d, %.1d %.8x, %.4d %.1d %.8x, %.4d %.1d %.8x, %.4d %.1d %.2x, %.1d %.4d, %.1d %.4d (%s)", \
66                     (*_queue_control)[it_dump],                        \
67                     _queue[(*_queue_control)[it_dump]]._context_id           , \
68                     _queue[(*_queue_control)[it_dump]]._front_end_id         , \
69                     _queue[(*_queue_control)[it_dump]]._ooo_engine_id        , \
70                     _queue[(*_queue_control)[it_dump]]._rob_id               , \
71                     _queue[(*_queue_control)[it_dump]]._type                 , \
72                     _queue[(*_queue_control)[it_dump]]._operation            , \
73                     _queue[(*_queue_control)[it_dump]]._store_queue_ptr_write, \
74                     _queue[(*_queue_control)[it_dump]]._store_queue_ptr_read , \
75                     _queue[(*_queue_control)[it_dump]]._store_queue_empty    , \
76                     _queue[(*_queue_control)[it_dump]]._load_queue_ptr_write , \
77                     _queue[(*_queue_control)[it_dump]]._has_immediat         , \
78                     _queue[(*_queue_control)[it_dump]]._immediat             , \
79                     _queue[(*_queue_control)[it_dump]]._num_reg_ra           , \
80                     _queue[(*_queue_control)[it_dump]]._data_ra_val          , \
81                     _queue[(*_queue_control)[it_dump]]._data_ra              , \
82                     _queue[(*_queue_control)[it_dump]]._num_reg_rb           , \
83                     _queue[(*_queue_control)[it_dump]]._data_rb_val          , \
84                     _queue[(*_queue_control)[it_dump]]._data_rb              , \
85                     _queue[(*_queue_control)[it_dump]]._num_reg_rc           , \
86                     _queue[(*_queue_control)[it_dump]]._data_rc_val          , \
87                     _queue[(*_queue_control)[it_dump]]._data_rc              , \
88                     _queue[(*_queue_control)[it_dump]]._write_rd             , \
89                     _queue[(*_queue_control)[it_dump]]._num_reg_rd           , \
90                     _queue[(*_queue_control)[it_dump]]._write_re             , \
91                     _queue[(*_queue_control)[it_dump]]._num_reg_re           , \
92                     toString(_queue[(*_queue_control)[it_dump]]._type).c_str()); \
93        else                                                            \
94          log_printf(TRACE,Reservation_station,FUNCTION,"    * [%.4d]", \
95                     (*_queue_control)[it_dump]);                       \
96    } while (0)
97#endif
98
99#undef  FUNCTION
100#define FUNCTION "Reservation_station::transition"
101  void Reservation_station::transition (void)
102  {
103    log_begin(Reservation_station,FUNCTION);
104    log_function(Reservation_station,FUNCTION,_name.c_str());
105
106    if (PORT_READ(in_NRESET) == 0)
107      {
108#ifdef  SYSTEMC_VHDL_COMPATIBILITY
109        for (uint32_t i=0; i<_param->_size_queue; i++)
110          _queue_valid [i] = false;
111#else
112        _queue_control->clear();
113#endif
114      }
115    else
116      {
117        // ***** POP from reservation station
118
119        // scan in reverse order, because when we pop the queue there are an auto reorder
120        //for (int32_t i=(static_cast<int32_t>(_queue_control->nb_elt()))-1;i>=0; i--)
121        for (int32_t i=(static_cast<int32_t>(_param->_nb_inst_retire))-1;i>=0; i--)
122          {
123            if ((    internal_RETIRE_VAL [i]  == 1) and
124                (PORT_READ(in_RETIRE_ACK [i]) == 1))
125              {
126                //uint32_t index = (*_queue_control)[i];
127
128                log_printf(NONE,Reservation_station,FUNCTION,"  * POP  [%d]",i);
129
130                uint32_t index  = internal_RETIRE_SLOT[i];
131
132#ifdef  SYSTEMC_VHDL_COMPATIBILITY
133                _queue_valid [index] = false;
134#else
135                _queue_control->pop(index);
136#endif
137//              cout << "========== Transition : " << endl
138//                   << " * i           : " << i << endl
139//                   << " * index       : " << index << endl;
140
141                log_printf(NONE,Reservation_station,FUNCTION,"    * index         : %d",index);
142              }
143          }
144       
145//      dump_queue();
146
147        // ***** Bypass
148        // Note : we can take this sequence code before the PUSH in the queue, because read_queue make the bypass !!!
149       
150        // scan all entry
151        for (uint32_t i=0; 
152#ifdef  SYSTEMC_VHDL_COMPATIBILITY
153             i<_param->_size_queue;
154#else
155             i<_queue_control->nb_elt();
156#endif
157             i++)
158          {
159            uint32_t index;
160#ifdef  SYSTEMC_VHDL_COMPATIBILITY
161            index = i;
162#else
163            index = (*_queue_control)[i];
164#endif
165
166            // ***** bypass - gpr_write
167            for (uint32_t j=0; j<_param->_nb_gpr_write; j++)
168              {
169                bool cmp;
170                if (_param->_have_port_ooo_engine_id)
171                  cmp = (PORT_READ(in_GPR_WRITE_OOO_ENGINE_ID [j]) == _queue[index]._ooo_engine_id);
172                else
173                  cmp = true;
174
175                if ((PORT_READ(in_GPR_WRITE_VAL        [j]) == 1) and cmp)
176                  {
177                    if (PORT_READ(in_GPR_WRITE_NUM_REG [j]) == _queue[index]._num_reg_ra)
178                      {
179                        log_printf(TRACE,Reservation_station,FUNCTION,"    -> GPR_WRITE     [%d] - Hit queue[%d]-GPR_RA[%d]",i,index,_queue[index]._num_reg_ra);
180                        _queue[index]._data_ra_val = 1;
181                        _queue[index]._data_ra     = PORT_READ(in_GPR_WRITE_DATA [j]);
182                      }
183                    if (PORT_READ(in_GPR_WRITE_NUM_REG [j]) == _queue[index]._num_reg_rb)
184                      {
185                        log_printf(TRACE,Reservation_station,FUNCTION,"    -> GPR_WRITE     [%d] - Hit queue[%d]-GPR_RB[%d]",i,index,_queue[index]._num_reg_rb);
186                        _queue[index]._data_rb_val = 1;
187                        _queue[index]._data_rb     = PORT_READ(in_GPR_WRITE_DATA [j]);
188                      }
189                  }
190              }
191            // ***** bypass - spr_write
192            for (uint32_t j=0; j<_param->_nb_spr_write; j++)
193              {
194                bool cmp;
195                if (_param->_have_port_ooo_engine_id)
196                  cmp = (PORT_READ(in_SPR_WRITE_OOO_ENGINE_ID [j]) == _queue[index]._ooo_engine_id);
197                else
198                  cmp = true;
199               
200                if ((PORT_READ(in_SPR_WRITE_VAL           [j]) == 1) and
201                    cmp and
202                    (PORT_READ(in_SPR_WRITE_NUM_REG       [j]) == _queue[index]._num_reg_rc))
203                  {
204                    log_printf(TRACE,Reservation_station,FUNCTION,"    -> SPR_WRITE     [%d] - Hit queue[%d]-SPR_RC[%d]",i,index,_queue[index]._num_reg_rc);
205                    _queue[index]._data_rc_val = 1;
206                    _queue[index]._data_rc     = PORT_READ(in_SPR_WRITE_DATA [j]);
207                  }
208              }
209            // ***** bypass - bypass_write
210            for (uint32_t j=0; j<_param->_nb_bypass_write; j++)
211              {
212                bool cmp;
213                if (_param->_have_port_ooo_engine_id)
214                  cmp = (PORT_READ(in_BYPASS_WRITE_OOO_ENGINE_ID [j]) == _queue[index]._ooo_engine_id);
215                else
216                  cmp = true;
217
218                if (cmp)
219                  {
220                    if (PORT_READ(in_BYPASS_WRITE_GPR_VAL    [j]) == 1)
221                      {
222                    if (PORT_READ(in_BYPASS_WRITE_GPR_NUM_REG[j]) == _queue[index]._num_reg_ra)
223                      {
224                        log_printf(TRACE,Reservation_station,FUNCTION,"    -> BYPASS_WRITE  [%d] - Hit queue[%d]-GPR_RA[%d]",i,index,_queue[index]._num_reg_ra);
225                        _queue[index]._data_ra_val = 1;
226                        _queue[index]._data_ra     = PORT_READ(in_BYPASS_WRITE_GPR_DATA [j]);
227                      }
228                    if (PORT_READ(in_BYPASS_WRITE_GPR_NUM_REG [j]) == _queue[index]._num_reg_rb)
229                      {
230                        log_printf(TRACE,Reservation_station,FUNCTION,"    -> BYPASS_WRITE  [%d] - Hit queue[%d]-GPR_RB[%d]",i,index,_queue[index]._num_reg_rb);
231                        _queue[index]._data_rb_val = 1;
232                        _queue[index]._data_rb     = PORT_READ(in_BYPASS_WRITE_GPR_DATA [j]);
233                      }
234                      }
235                    if ((PORT_READ(in_BYPASS_WRITE_SPR_VAL    [j]) == 1) and
236                        (PORT_READ(in_BYPASS_WRITE_SPR_NUM_REG[j]) == _queue[index]._num_reg_rc))
237                      {
238                        log_printf(TRACE,Reservation_station,FUNCTION,"    -> BYPASS_WRITE  [%d] - Hit queue[%d]-SPR_RC[%d]",i,index,_queue[index]._num_reg_rc);
239                        _queue[index]._data_rc_val = 1;
240                        _queue[index]._data_rc     = PORT_READ(in_BYPASS_WRITE_SPR_DATA [j]);
241                      }
242                  }
243              }
244            // ***** bypass - bypass_memory
245            for (uint32_t j=0; j<_param->_nb_bypass_memory; j++)
246              {
247                bool cmp;
248                if (_param->_have_port_ooo_engine_id)
249                  cmp = (PORT_READ(in_BYPASS_MEMORY_OOO_ENGINE_ID [j]) == _queue[index]._ooo_engine_id);
250                else
251                  cmp = true;
252
253                if ((PORT_READ(in_BYPASS_MEMORY_VAL           [j]) == 1) and cmp)
254                  {
255                    if (PORT_READ(in_BYPASS_MEMORY_NUM_REG [j]) == _queue[index]._num_reg_ra)
256                      {
257                        log_printf(TRACE,Reservation_station,FUNCTION,"    -> BYPASS_MEMORY [%d] - Hit queue[%d]-GPR_RA[%d]",i,index,_queue[index]._num_reg_ra);
258                        _queue[index]._data_ra_val = 1;
259                        _queue[index]._data_ra     = PORT_READ(in_BYPASS_MEMORY_DATA [j]);
260                      }
261                    if (PORT_READ(in_BYPASS_MEMORY_NUM_REG [j]) == _queue[index]._num_reg_rb)
262                      {
263                        log_printf(TRACE,Reservation_station,FUNCTION,"    -> BYPASS_MEMORY [%d] - Hit queue[%d]-GPR_RB[%d]",i,index,_queue[index]._num_reg_rb);
264                        _queue[index]._data_rb_val = 1;
265                        _queue[index]._data_rb     = PORT_READ(in_BYPASS_MEMORY_DATA [j]);
266                      }
267                  }
268              }
269          }
270        // ***** PUSH to reservation station
271        if ((PORT_READ(in_INSERT_VAL) == 1) and
272            (    internal_INSERT_ACK  == 1))
273          {
274            log_printf(TRACE,Reservation_station,FUNCTION,"  * PUSH");
275
276            // Write in reservation station
277            uint32_t index;
278
279#ifdef  SYSTEMC_VHDL_COMPATIBILITY
280            index = internal_INSERT_SLOT;
281            _queue_valid [internal_INSERT_SLOT] = true;
282#else
283            index = _queue_control->push();
284#endif
285            log_printf(TRACE,Reservation_station,FUNCTION,"    * index         : %d",index);
286
287            if (_param->_have_port_context_id)
288            _queue[index]._context_id      = PORT_READ(in_INSERT_CONTEXT_ID     );
289            if (_param->_have_port_front_end_id)
290            _queue[index]._front_end_id    = PORT_READ(in_INSERT_FRONT_END_ID   );
291            if (_param->_have_port_ooo_engine_id)
292            _queue[index]._ooo_engine_id   = PORT_READ(in_INSERT_OOO_ENGINE_ID  );
293            if (_param->_have_port_rob_ptr)
294            _queue[index]._rob_id          = PORT_READ(in_INSERT_ROB_ID         );
295            _queue[index]._operation       = PORT_READ(in_INSERT_OPERATION      );
296            _queue[index]._type            = PORT_READ(in_INSERT_TYPE           );
297            _queue[index]._store_queue_ptr_write = PORT_READ(in_INSERT_STORE_QUEUE_PTR_WRITE);
298            _queue[index]._store_queue_ptr_read  = PORT_READ(in_INSERT_STORE_QUEUE_PTR_READ );
299            _queue[index]._store_queue_empty     = PORT_READ(in_INSERT_STORE_QUEUE_EMPTY    );
300            if (_param->_have_port_load_queue_ptr)
301            _queue[index]._load_queue_ptr_write  = PORT_READ(in_INSERT_LOAD_QUEUE_PTR_WRITE );
302            _queue[index]._has_immediat    = PORT_READ(in_INSERT_HAS_IMMEDIAT   );
303            _queue[index]._immediat        = PORT_READ(in_INSERT_IMMEDIAT       );
304//          _queue[index]._read_ra         = PORT_READ(in_INSERT_READ_RA        );
305            _queue[index]._num_reg_ra      = PORT_READ(in_INSERT_NUM_REG_RA     );
306            _queue[index]._data_ra_val     = PORT_READ(in_INSERT_DATA_RA_VAL    );
307            _queue[index]._data_ra         = PORT_READ(in_INSERT_DATA_RA        );
308//          _queue[index]._read_rb         = PORT_READ(in_INSERT_READ_RB        );
309            _queue[index]._num_reg_rb      = PORT_READ(in_INSERT_NUM_REG_RB     );
310            _queue[index]._data_rb_val     = PORT_READ(in_INSERT_DATA_RB_VAL    );
311            _queue[index]._data_rb         = PORT_READ(in_INSERT_DATA_RB        );
312//          _queue[index]._read_rc         = PORT_READ(in_INSERT_READ_RC        );
313            _queue[index]._num_reg_rc      = PORT_READ(in_INSERT_NUM_REG_RC     );
314            _queue[index]._data_rc_val     = PORT_READ(in_INSERT_DATA_RC_VAL    );
315            _queue[index]._data_rc         = PORT_READ(in_INSERT_DATA_RC        );
316            _queue[index]._write_rd        = PORT_READ(in_INSERT_WRITE_RD       );
317            _queue[index]._num_reg_rd      = PORT_READ(in_INSERT_NUM_REG_RD     );
318            _queue[index]._write_re        = PORT_READ(in_INSERT_WRITE_RE       );
319            _queue[index]._num_reg_re      = PORT_READ(in_INSERT_NUM_REG_RE     );
320//          dump_queue();
321          }
322      }
323
324    dump_queue();
325
326    end_cycle ();
327
328    log_end(Reservation_station,FUNCTION);
329  };
330
331}; // end namespace reservation_station
332}; // end namespace read_unit
333}; // end namespace multi_read_unit
334}; // end namespace execute_loop
335}; // end namespace multi_execute_loop
336}; // end namespace core
337
338}; // end namespace behavioural
339}; // end namespace morpheo             
340#endif
341//#endif
Note: See TracBrowser for help on using the repository browser.