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

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

Ajout SystemC read_queue et reservation_station
Ajout port au bloc registerfile_monolithic (à ajouter également au bloc registerfile et registerfile_multi_banked)
Modif param : passage de pointeur (attention, tous les composants n'ont pas été tous modifier)

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