source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Execute_loop/Execute_loop/Multi_Execute_unit/Execute_unit/Functionnal_unit/src/Functionnal_unit_transition.cpp @ 134

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

1) valgrind fix
2) debug file on/off

  • Property svn:keywords set to Id
File size: 12.8 KB
Line 
1#ifdef SYSTEMC
2/*
3 * $Id: Functionnal_unit_transition.cpp 134 2009-07-15 08:41:01Z rosiere $
4 *
5 * [ Description ]
6 *
7 */
8
9#include "Behavioural/Core/Multi_Execute_loop/Execute_loop/Multi_Execute_unit/Execute_unit/Functionnal_unit/include/Functionnal_unit.h"
10
11namespace morpheo                    {
12namespace behavioural {
13namespace core {
14namespace multi_execute_loop {
15namespace execute_loop {
16namespace multi_execute_unit {
17namespace execute_unit {
18namespace functionnal_unit {
19
20
21#undef  FUNCTION
22#define FUNCTION "Functionnal_unit::transition"
23  void Functionnal_unit::transition (void)
24  {
25    log_begin(Functionnal_unit,FUNCTION);
26    log_function(Functionnal_unit,FUNCTION,_name.c_str());
27
28    if (PORT_READ(in_NRESET) == 0)
29      {
30        if (_param->_have_pipeline_in)
31        reg_BUSY_IN  = false;
32        reg_BUSY_OUT = false;
33       
34        for (uint32_t i=0; i<_param->_nb_context; i++)
35          for (uint32_t j=0; j<_param->_nb_front_end; j++)
36            for (uint32_t k=0; k<_param->_nb_ooo_engine; k++)
37              {
38//              uint32_t num_thread = get_num_thread(i,_param->_size_context_id,
39//                                                   j,_param->_size_front_end_id,
40//                                                   k,_param->_size_ooo_engine_id);
41               
42                for (uint32_t x=GROUP_CUSTOM_1; x<GROUP_CUSTOM_8; x++)
43                  {
44                    function_execute_end_cycle_t * fct = (_param->_get_custom_information()._get_custom_execute_reset(x));
45                   
46                    if (fct != NULL)
47                      (* fct) (_execute_register[i][j][k], _execute_param);
48                  }
49              }
50
51        _execute_operation_out->_context_id    = 0; // not necessary
52        _execute_operation_out->_front_end_id  = 0; // not necessary
53        _execute_operation_out->_ooo_engine_id = 0; // not necessary
54        _execute_operation_out->_packet_id     = 0; // not necessary
55  //    _execute_operation_out->_operation     = 0; // not necessary
56  //    _execute_operation_out->_type          = 0; // not necessary
57        _execute_operation_out->_write_rd      = 0; // not necessary
58        _execute_operation_out->_num_reg_rd    = 0; // not necessary
59        _execute_operation_out->_data_rd       = 0; // not necessary
60        _execute_operation_out->_write_re      = 0; // not necessary
61        _execute_operation_out->_num_reg_re    = 0; // not necessary
62        _execute_operation_out->_data_re       = 0; // not necessary
63        _execute_operation_out->_exception     = 0; // not necessary
64        _execute_operation_out->_no_sequence   = 0; // not necessary
65        _execute_operation_out->_address       = 0; // not necessary
66      }
67    else
68      {
69        // Test if pop an instruction
70        if (internal_EXECUTE_OUT_VAL and PORT_READ(in_EXECUTE_OUT_ACK))
71          {
72            log_printf(TRACE,Functionnal_unit,FUNCTION,"  * EXECUTE_OUT : Transaction Accepted");
73            reg_BUSY_OUT = false;
74          }
75       
76        // Test if can move instruction in pipeline in to pipeline out
77        if (_param->_have_pipeline_in)
78        if (reg_BUSY_IN and not reg_BUSY_OUT)
79          {
80            reg_BUSY_OUT = reg_BUSY_IN;
81            reg_BUSY_IN  = false;
82
83            _execute_operation_out->_timing        = _execute_operation_in->_timing       ;
84            _execute_operation_out->_context_id    = _execute_operation_in->_context_id   ;
85            _execute_operation_out->_front_end_id  = _execute_operation_in->_front_end_id ;
86            _execute_operation_out->_ooo_engine_id = _execute_operation_in->_ooo_engine_id;
87            _execute_operation_out->_packet_id     = _execute_operation_in->_packet_id    ;
88            _execute_operation_out->_operation     = _execute_operation_in->_operation    ;
89            _execute_operation_out->_type          = _execute_operation_in->_type         ;
90            _execute_operation_out->_has_immediat  = _execute_operation_in->_has_immediat ;
91            _execute_operation_out->_immediat      = _execute_operation_in->_immediat     ;
92            _execute_operation_out->_data_ra       = _execute_operation_in->_data_ra      ;
93            _execute_operation_out->_data_rb       = _execute_operation_in->_data_rb      ;
94            _execute_operation_out->_data_rc       = _execute_operation_in->_data_rc      ;
95            _execute_operation_out->_data_rd       = _execute_operation_in->_data_rd      ;
96            _execute_operation_out->_data_re       = _execute_operation_in->_data_re      ;
97            _execute_operation_out->_write_rd      = _execute_operation_in->_write_rd     ;
98            _execute_operation_out->_num_reg_rd    = _execute_operation_in->_num_reg_rd   ;
99            _execute_operation_out->_write_re      = _execute_operation_in->_write_re     ;
100            _execute_operation_out->_num_reg_re    = _execute_operation_in->_num_reg_re   ;
101            _execute_operation_out->_exception     = _execute_operation_in->_exception    ;
102            _execute_operation_out->_no_sequence   = _execute_operation_in->_no_sequence  ;
103            _execute_operation_out->_address       = _execute_operation_in->_address      ;
104          }
105
106        // Test if push
107        execute_register_t * execute_register = NULL;
108
109        if (PORT_READ(in_EXECUTE_IN_VAL) and internal_EXECUTE_IN_ACK)
110          {
111            log_printf(TRACE,Functionnal_unit,FUNCTION,"  * EXECUTE_IN : Transaction Accepted");
112
113            execute_operation_t * execute_operation;
114
115            if (_param->_have_pipeline_in)
116              {
117            reg_BUSY_IN       = true;
118            execute_operation = _execute_operation_in;
119              }
120            else
121              {
122            reg_BUSY_OUT      = true;
123            execute_operation = _execute_operation_out;
124              }
125
126            Tcontext_t   context_id    = (_param->_have_port_context_id   )?PORT_READ(in_EXECUTE_IN_CONTEXT_ID   ):0;
127            Tcontext_t   front_end_id  = (_param->_have_port_front_end_id )?PORT_READ(in_EXECUTE_IN_FRONT_END_ID ):0;
128            Tcontext_t   ooo_engine_id = (_param->_have_port_ooo_engine_id)?PORT_READ(in_EXECUTE_IN_OOO_ENGINE_ID):0;
129            Tcontext_t   packet_id     = (_param->_have_port_rob_ptr      )?PORT_READ(in_EXECUTE_IN_PACKET_ID    ):0;
130            Toperation_t operation     = PORT_READ(in_EXECUTE_IN_OPERATION);
131            Ttype_t      type          = PORT_READ(in_EXECUTE_IN_TYPE);
132
133            execute_operation->_context_id    = context_id   ;
134            execute_operation->_front_end_id  = front_end_id ;
135            execute_operation->_ooo_engine_id = ooo_engine_id;
136            execute_operation->_packet_id     = packet_id    ;
137            execute_operation->_operation     = operation    ;
138            execute_operation->_type          = type         ;
139            execute_operation->_has_immediat  = PORT_READ(in_EXECUTE_IN_HAS_IMMEDIAT);
140            execute_operation->_immediat      = PORT_READ(in_EXECUTE_IN_IMMEDIAT    );
141            execute_operation->_data_ra       = PORT_READ(in_EXECUTE_IN_DATA_RA     );
142            execute_operation->_data_rb       = PORT_READ(in_EXECUTE_IN_DATA_RB     );
143            execute_operation->_data_rc       = PORT_READ(in_EXECUTE_IN_DATA_RC     );
144            execute_operation->_write_rd      = PORT_READ(in_EXECUTE_IN_WRITE_RD    );
145            execute_operation->_num_reg_rd    = PORT_READ(in_EXECUTE_IN_NUM_REG_RD  );
146            execute_operation->_data_rd       = 0; // no necessaray
147            execute_operation->_write_re      = PORT_READ(in_EXECUTE_IN_WRITE_RE    );
148            execute_operation->_num_reg_re    = PORT_READ(in_EXECUTE_IN_NUM_REG_RE  );
149            execute_operation->_data_re       = 0; // no necessaray
150            execute_operation->_exception     = 0; // no necessaray
151            execute_operation->_no_sequence   = 0; // no necessaray
152            execute_operation->_address       = 0; // no necessaray
153
154            log_printf(TRACE,Functionnal_unit,FUNCTION,"    * context_id    : %d",execute_operation->_context_id   );
155            log_printf(TRACE,Functionnal_unit,FUNCTION,"    * front_end_id  : %d",execute_operation->_front_end_id );
156            log_printf(TRACE,Functionnal_unit,FUNCTION,"    * ooo_engine_id : %d",execute_operation->_ooo_engine_id);
157            log_printf(TRACE,Functionnal_unit,FUNCTION,"    * packet_id     : %d",execute_operation->_packet_id    );
158            log_printf(TRACE,Functionnal_unit,FUNCTION,"    * operation     : %d",execute_operation->_operation    );
159            log_printf(TRACE,Functionnal_unit,FUNCTION,"    * type          : %s",toString(execute_operation->_type).c_str());
160            log_printf(TRACE,Functionnal_unit,FUNCTION,"    * has_immediat  : %d",execute_operation->_has_immediat );
161            log_printf(TRACE,Functionnal_unit,FUNCTION,"    * immediat      : %.8x",execute_operation->_immediat     );
162            log_printf(TRACE,Functionnal_unit,FUNCTION,"    * data_ra       : %.8x",execute_operation->_data_ra      );
163            log_printf(TRACE,Functionnal_unit,FUNCTION,"    * data_rb       : %.8x",execute_operation->_data_rb      );
164            log_printf(TRACE,Functionnal_unit,FUNCTION,"    * data_rc       : %.8x",execute_operation->_data_rc      );
165            log_printf(TRACE,Functionnal_unit,FUNCTION,"    * write_rd      : %d"  ,execute_operation->_write_rd     );
166            log_printf(TRACE,Functionnal_unit,FUNCTION,"    * num_reg_rd    : %d"  ,execute_operation->_num_reg_rd   );
167            log_printf(TRACE,Functionnal_unit,FUNCTION,"    * write_re      : %d"  ,execute_operation->_write_re     );
168            log_printf(TRACE,Functionnal_unit,FUNCTION,"    * num_reg_re    : %d"  ,execute_operation->_num_reg_re   );
169           
170#ifdef DEBUG_TEST
171            if (type >= _param->_nb_type)
172              throw ERRORMORPHEO(FUNCTION,"Invalid type : '"+toString(type)+"' is higher that _nb_type");
173            if (operation >= _param->_nb_operation)
174              throw ERRORMORPHEO(FUNCTION,"Invalid operation : '"+toString(operation)+"' is higher that _nb_operation");
175#endif
176
177            // execute the operation
178            execute_register = _execute_register[context_id][front_end_id][ooo_engine_id];
179
180            // Test if operation is a custom
181            if (type == TYPE_CUSTOM)
182              {
183//              uint32_t num_thread = get_num_thread(context_id   ,_param->_size_context_id,
184//                                                   front_end_id ,_param->_size_front_end_id,
185//                                                   ooo_engine_id,_param->_size_ooo_engine_id);
186
187                (*(_param->_get_custom_information()._get_custom_execute_genMoore(operation))) (execute_operation, execute_register, _execute_param);
188              }
189            else
190              (*(_function_execute[type][operation])) (execute_operation, execute_register, _execute_param);
191
192
193            log_printf(TRACE,Functionnal_unit,FUNCTION,"    -----------------");
194            log_printf(TRACE,Functionnal_unit,FUNCTION,"    * latence       : %.8x",execute_operation->_timing._latence);
195            log_printf(TRACE,Functionnal_unit,FUNCTION,"    * delay         : %.8x",execute_operation->_timing._delay);
196            log_printf(TRACE,Functionnal_unit,FUNCTION,"    * data_rd       : %.8x",execute_operation->_data_rd    );
197            log_printf(TRACE,Functionnal_unit,FUNCTION,"    * data_re       : %.8x",execute_operation->_data_re    );
198            log_printf(TRACE,Functionnal_unit,FUNCTION,"    * exception     : %d"  ,execute_operation->_exception  );
199            log_printf(TRACE,Functionnal_unit,FUNCTION,"    * no_sequence   : %d"  ,execute_operation->_no_sequence);
200            log_printf(TRACE,Functionnal_unit,FUNCTION,"    * address       : %.8x (%.8x)",execute_operation->_address,execute_operation->_address<<2);
201
202#ifdef STATISTICS
203            if (usage_is_set(_usage,USE_STATISTICS))
204              {
205                (*_stat_use_functionnal_unit) ++;
206                (*_stat_sum_delay)   += execute_operation->_timing._delay;
207                (*_stat_sum_latence) += execute_operation->_timing._latence;
208              }
209#endif
210          }
211       
212        // End cycle
213        {
214          for (uint32_t i=0; i<_param->_nb_context; i++)
215            for (uint32_t j=0; j<_param->_nb_front_end; j++)
216              for (uint32_t k=0; k<_param->_nb_ooo_engine; k++)
217                {
218//                uint32_t num_thread = get_num_thread(i,_param->_size_context_id,
219//                                                     j,_param->_size_front_end_id,
220//                                                     k,_param->_size_ooo_engine_id);
221
222                  for (uint32_t x=GROUP_CUSTOM_1; x<GROUP_CUSTOM_8; x++)
223                    {
224                      function_execute_end_cycle_t * fct = (_param->_get_custom_information()._get_custom_execute_transition(x));
225                     
226                      if (fct != NULL)
227                        (* fct) (_execute_register[i][j][k], _execute_param);
228                    }
229                }
230
231          // Update status
232          if (execute_register != NULL)
233            {
234              // They have an access
235              execute_register->_i_write_spr = false;
236              execute_register->_i_read_spr  = false;
237            }
238        }
239
240       
241        // each cycle : decrease the latence
242        if (reg_BUSY_OUT and (_execute_operation_out->_timing._latence > 0))
243          _execute_operation_out->_timing._latence --;
244
245#if defined(DEBUG) and DEBUG_Functionnal_unit and (DEBUG >= DEBUG_TRACE)
246        {
247          log_printf(TRACE,Functionnal_unit,FUNCTION,"  * Dump ALU (Functionnal_unit)");
248
249          if (_param->_have_pipeline_in)
250          log_printf(TRACE,Functionnal_unit,FUNCTION,"    * reg_BUSY_IN  : %d",reg_BUSY_IN );
251          log_printf(TRACE,Functionnal_unit,FUNCTION,"    * reg_BUSY_OUT : %d",reg_BUSY_OUT);
252        }
253#endif
254      }
255   
256#if defined(STATISTICS) or defined(VHDL_TESTBENCH)
257    end_cycle ();
258#endif
259
260    log_end(Functionnal_unit,FUNCTION);
261  };
262
263}; // end namespace functionnal_unit
264}; // end namespace execute_unit
265}; // end namespace multi_execute_unit
266}; // end namespace execute_loop
267}; // end namespace multi_execute_loop
268}; // end namespace core
269
270}; // end namespace behavioural
271}; // end namespace morpheo             
272#endif
Note: See TracBrowser for help on using the repository browser.