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

Last change on this file since 88 was 88, checked in by rosiere, 16 years ago

Almost complete design
with Test and test platform

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