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

Last change on this file since 56 was 56, checked in by rosiere, 17 years ago

Factorisation du contrôle de file d'attente dans une classe "Queue_Control"

File size: 8.9 KB
Line 
1#ifdef SYSTEMC
2//#if defined(STATISTICS) or defined(VHDL_TESTBENCH)
3/*
4 * $Id$
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#define dump_queue() \
22  do\
23  {\
24   log_printf(TRACE,Reservation_station,FUNCTION," * dump queue");\
25   log_printf(TRACE,Reservation_station,FUNCTION,"   * nb_elt : %d",_queue_nb_elt);\
26   for (uint32_t j=0;j<_param->_size_queue; j++)\
27   {\
28     cout << "\t"\
29          << "[" << (*_queue_control)[j] << "] "\
30          << "{" << _queue[(*_queue_control)[j]]._packet_id << " - "<< _queue[(*_queue_control)[j]]._context_id << "} "\
31          << _queue[(*_queue_control)[j]]._data_ra_val << ", "\
32          << _queue[(*_queue_control)[j]]._num_reg_ra  << " - "\
33          << _queue[(*_queue_control)[j]]._data_rb_val << ","\
34          << _queue[(*_queue_control)[j]]._num_reg_rb  << " - "\
35          << _queue[(*_queue_control)[j]]._data_rc_val << ","\
36          << _queue[(*_queue_control)[j]]._num_reg_rc  \
37          << endl;\
38    }\
39  } while (0)
40
41#undef  FUNCTION
42#define FUNCTION "Reservation_station::transition"
43  void Reservation_station::transition (void)
44  {
45    log_printf(FUNC,Reservation_station,FUNCTION,"Begin");
46
47    if (PORT_READ(in_NRESET) == 0)
48      {
49        _queue_control->clear();
50      }
51    else
52      {
53        // ***** PUSH to reservation station
54        if ((PORT_READ(in_RESERVATION_STATION_IN_VAL) == 1) and
55            (    internal_RESERVATION_STATION_IN_ACK  == 1))
56          {
57            log_printf(TRACE,Reservation_station,FUNCTION,"PUSH");
58
59            // Write in reservation station
60            uint32_t index = _queue_control->push();
61
62            log_printf(TRACE,Reservation_station,FUNCTION," * index         : %d",index);
63
64            _queue[index]._context_id   = PORT_READ(in_RESERVATION_STATION_IN_CONTEXT_ID  );
65            _queue[index]._packet_id    = PORT_READ(in_RESERVATION_STATION_IN_PACKET_ID   );
66            _queue[index]._operation    = PORT_READ(in_RESERVATION_STATION_IN_OPERATION   );
67            _queue[index]._type         = PORT_READ(in_RESERVATION_STATION_IN_TYPE        );
68            _queue[index]._has_immediat = PORT_READ(in_RESERVATION_STATION_IN_HAS_IMMEDIAT);
69            _queue[index]._immediat     = PORT_READ(in_RESERVATION_STATION_IN_IMMEDIAT    );
70//          _queue[index]._read_ra      = PORT_READ(in_RESERVATION_STATION_IN_READ_RA     );
71            _queue[index]._num_reg_ra   = PORT_READ(in_RESERVATION_STATION_IN_NUM_REG_RA  );
72            _queue[index]._data_ra_val  = PORT_READ(in_RESERVATION_STATION_IN_DATA_RA_VAL );
73            _queue[index]._data_ra      = PORT_READ(in_RESERVATION_STATION_IN_DATA_RA     );
74//          _queue[index]._read_rb      = PORT_READ(in_RESERVATION_STATION_IN_READ_RB     );
75            _queue[index]._num_reg_rb   = PORT_READ(in_RESERVATION_STATION_IN_NUM_REG_RB  );
76            _queue[index]._data_rb_val  = PORT_READ(in_RESERVATION_STATION_IN_DATA_RB_VAL );
77            _queue[index]._data_rb      = PORT_READ(in_RESERVATION_STATION_IN_DATA_RB     );
78//          _queue[index]._read_rc      = PORT_READ(in_RESERVATION_STATION_IN_READ_RC     );
79            _queue[index]._num_reg_rc   = PORT_READ(in_RESERVATION_STATION_IN_NUM_REG_RC  );
80            _queue[index]._data_rc_val  = PORT_READ(in_RESERVATION_STATION_IN_DATA_RC_VAL );
81            _queue[index]._data_rc      = PORT_READ(in_RESERVATION_STATION_IN_DATA_RC     );
82            _queue[index]._write_rd     = PORT_READ(in_RESERVATION_STATION_IN_WRITE_RD    );
83            _queue[index]._num_reg_rd   = PORT_READ(in_RESERVATION_STATION_IN_NUM_REG_RD  );
84            _queue[index]._write_re     = PORT_READ(in_RESERVATION_STATION_IN_WRITE_RE    );
85            _queue[index]._num_reg_re   = PORT_READ(in_RESERVATION_STATION_IN_NUM_REG_RE  );
86//          dump_queue();
87          }
88
89        // ***** POP from reservation station
90
91        // scan in reverse order, because when we pop the queue there are an auto reorder
92        for (int32_t i=(static_cast<int32_t>(_queue_control->nb_elt()))-1;i>=0; i--)
93          {
94            uint32_t index = (*_queue_control)[i];
95           
96            if ((    internal_RESERVATION_STATION_OUT_VAL [index]  == 1) and
97                (PORT_READ(in_RESERVATION_STATION_OUT_ACK [index]) == 1))
98              {
99                log_printf(TRACE,Reservation_station,FUNCTION,"POP  [%d]",i);
100
101                _queue_control->pop(i);
102
103                log_printf(TRACE,Reservation_station,FUNCTION," * index         : %d",index);
104//              dump_queue();
105              }
106          }
107
108        // ***** Bypass
109        // Note : we can take this sequence code before the PUSH in the queue, because read_queue make the bypass !!!
110       
111        // scan all entry
112        for (uint32_t i=0; i<_queue_control->nb_elt(); i++)
113          {
114            uint32_t index = (*_queue_control)[i];
115
116            // ***** bypass - gpr_write
117            for (uint32_t j=0; j<_param->_nb_gpr_write; j++)
118              {
119                if ((PORT_READ(in_GPR_WRITE_VAL        [j]) == 1) and
120                    (PORT_READ(in_GPR_WRITE_CONTEXT_ID [j]) == _queue[index]._context_id))
121                  {
122                    if (PORT_READ(in_GPR_WRITE_NUM_REG [j]) == _queue[index]._num_reg_ra)
123                      {
124                        log_printf(TRACE,Reservation_station,FUNCTION," -> GPR_WRITE     [%d] - Hit queue[%d]-GPR_RA[%d]",i,index,_queue[index]._num_reg_ra);
125                        _queue[index]._data_ra_val = 1;
126                        _queue[index]._data_ra     = PORT_READ(in_GPR_WRITE_DATA [j]);
127                      }
128                    if (PORT_READ(in_GPR_WRITE_NUM_REG [j]) == _queue[index]._num_reg_rb)
129                      {
130                        log_printf(TRACE,Reservation_station,FUNCTION," -> GPR_WRITE     [%d] - Hit queue[%d]-GPR_RB[%d]",i,index,_queue[index]._num_reg_rb);
131                        _queue[index]._data_rb_val = 1;
132                        _queue[index]._data_rb     = PORT_READ(in_GPR_WRITE_DATA [j]);
133                      }
134                  }
135              }
136            // ***** bypass - spr_write
137            for (uint32_t j=0; j<_param->_nb_spr_write; j++)
138              {
139                if ((PORT_READ(in_SPR_WRITE_VAL        [j]) == 1)                         and
140                    (PORT_READ(in_SPR_WRITE_CONTEXT_ID [j]) == _queue[index]._context_id) and
141                    (PORT_READ(in_SPR_WRITE_NUM_REG    [j]) == _queue[index]._num_reg_rc))
142                  {
143                    log_printf(TRACE,Reservation_station,FUNCTION," -> SPR_WRITE     [%d] - Hit queue[%d]-SPR_RC[%d]",i,index,_queue[index]._num_reg_rc);
144                    _queue[index]._data_rc_val = 1;
145                    _queue[index]._data_rc     = PORT_READ(in_SPR_WRITE_DATA [j]);
146                  }
147              }
148            // ***** bypass - bypass_write
149            for (uint32_t j=0; j<_param->_nb_bypass_write; j++)
150              {
151                if (PORT_READ(in_BYPASS_WRITE_CONTEXT_ID [j]) == _queue[index]._context_id)
152                  {
153                    if (PORT_READ(in_BYPASS_WRITE_GPR_VAL    [j]) == 1)
154                      {
155                    if (PORT_READ(in_BYPASS_WRITE_GPR_NUM_REG[j]) == _queue[index]._num_reg_ra)
156                      {
157                        log_printf(TRACE,Reservation_station,FUNCTION," -> BYPASS_WRITE  [%d] - Hit queue[%d]-GPR_RA[%d]",i,index,_queue[index]._num_reg_ra);
158                        _queue[index]._data_ra_val = 1;
159                        _queue[index]._data_ra     = PORT_READ(in_BYPASS_WRITE_GPR_DATA [j]);
160                      }
161                    if (PORT_READ(in_BYPASS_WRITE_GPR_NUM_REG [j]) == _queue[index]._num_reg_rb)
162                      {
163                        log_printf(TRACE,Reservation_station,FUNCTION," -> BYPASS_WRITE  [%d] - Hit queue[%d]-GPR_RB[%d]",i,index,_queue[index]._num_reg_rb);
164                        _queue[index]._data_rb_val = 1;
165                        _queue[index]._data_rb     = PORT_READ(in_BYPASS_WRITE_GPR_DATA [j]);
166                      }
167                      }
168                    if ((PORT_READ(in_BYPASS_WRITE_SPR_VAL    [j]) == 1) and
169                        (PORT_READ(in_BYPASS_WRITE_SPR_NUM_REG[j]) == _queue[index]._num_reg_rc))
170                      {
171                        log_printf(TRACE,Reservation_station,FUNCTION," -> BYPASS_WRITE  [%d] - Hit queue[%d]-SPR_RC[%d]",i,index,_queue[index]._num_reg_rc);
172                        _queue[index]._data_rc_val = 1;
173                        _queue[index]._data_rc     = PORT_READ(in_BYPASS_WRITE_SPR_DATA [j]);
174                      }
175                  }
176              }
177            // ***** bypass - bypass_memory
178            for (uint32_t j=0; j<_param->_nb_bypass_memory; j++)
179              {
180                if ((PORT_READ(in_BYPASS_MEMORY_VAL        [j]) == 1) and
181                    (PORT_READ(in_BYPASS_MEMORY_CONTEXT_ID [j]) == _queue[index]._context_id))
182                  {
183                    if (PORT_READ(in_BYPASS_MEMORY_NUM_REG [j]) == _queue[index]._num_reg_ra)
184                      {
185                        log_printf(TRACE,Reservation_station,FUNCTION," -> BYPASS_MEMORY [%d] - Hit queue[%d]-GPR_RA[%d]",i,index,_queue[index]._num_reg_ra);
186                        _queue[index]._data_ra_val = 1;
187                        _queue[index]._data_ra     = PORT_READ(in_BYPASS_MEMORY_DATA [j]);
188                      }
189                    if (PORT_READ(in_BYPASS_MEMORY_NUM_REG [j]) == _queue[index]._num_reg_rb)
190                      {
191                        log_printf(TRACE,Reservation_station,FUNCTION," -> BYPASS_MEMORY [%d] - Hit queue[%d]-GPR_RB[%d]",i,index,_queue[index]._num_reg_rb);
192                        _queue[index]._data_rb_val = 1;
193                        _queue[index]._data_rb     = PORT_READ(in_BYPASS_MEMORY_DATA [j]);
194                      }
195                  }
196              }
197          }
198      }
199
200#ifdef STATISTICS
201    _stat->add();
202#endif   
203
204#ifdef VHDL_TESTBENCH
205    vhdl_testbench_transition ();
206#endif
207
208    log_printf(FUNC,Reservation_station,FUNCTION,"End");
209  };
210
211}; // end namespace reservation_station
212}; // end namespace read_unit
213}; // end namespace multi_read_unit
214}; // end namespace execute_loop
215}; // end namespace multi_execute_loop
216}; // end namespace core
217
218}; // end namespace behavioural
219}; // end namespace morpheo             
220#endif
221//#endif
Note: See TracBrowser for help on using the repository browser.