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

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

Add new component : Read_unit (no tested)
Change functionnal_unit : now use type and operation to execute the good function
Change New_Component's script

File size: 5.6 KB
Line 
1#ifdef SYSTEMC
2/*
3 * $Id$
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_printf(FUNC,Functionnal_unit,FUNCTION,"Begin");
26
27    if (PORT_READ(in_NRESET) == 0)
28      {
29        reg_BUSY = false;
30       
31        for (uint32_t i=0; i<_param->_nb_context; i++)
32          for (uint32_t j=0; j<_param->_nb_front_end; j++)
33            for (uint32_t k=0; k<_param->_nb_ooo_engine; k++)
34              {
35                uint32_t num_thread = get_num_thread(i,_param->_size_context_id,
36                                                     j,_param->_size_front_end_id,
37                                                     k,_param->_size_ooo_engine_id);
38               
39                for (uint32_t x=GROUP_CUSTOM_1; x<GROUP_CUSTOM_8; x++)
40                  {
41                    function_execute_end_cycle_t * fct = (_param->_get_custom_information(num_thread)._get_custom_execute_reset(x));
42                   
43                    if (fct != NULL)
44                      (* fct) (_execute_register[i][j][k], _execute_param);
45                  }
46              }
47      }
48    else
49      {
50        // Test if pop
51        if (internal_EXECUTE_OUT_VAL and PORT_READ(in_EXECUTE_OUT_ACK))
52          {
53            // transaction
54            reg_BUSY = false;
55          }
56       
57        // Test if push
58        execute_register_t * execute_register = NULL;
59
60        if (PORT_READ(in_EXECUTE_IN_VAL) and internal_EXECUTE_IN_ACK)
61          {
62            reg_BUSY = true;
63
64            Tcontext_t   context_id    = (_param->_have_port_context_id   )?PORT_READ(in_EXECUTE_IN_CONTEXT_ID   ):0;
65            Tcontext_t   front_end_id  = (_param->_have_port_front_end_id )?PORT_READ(in_EXECUTE_IN_FRONT_END_ID ):0;
66            Tcontext_t   ooo_engine_id = (_param->_have_port_ooo_engine_id)?PORT_READ(in_EXECUTE_IN_OOO_ENGINE_ID):0;
67            Tcontext_t   packet_id     = (_param->_have_port_packet_id    )?PORT_READ(in_EXECUTE_IN_PACKET_ID    ):0;
68            Toperation_t operation     = PORT_READ(in_EXECUTE_IN_OPERATION);
69            Ttype_t      type          = PORT_READ(in_EXECUTE_IN_TYPE);
70           
71            _execute_operation->_context_id    = context_id   ;
72            _execute_operation->_front_end_id  = front_end_id ;
73            _execute_operation->_ooo_engine_id = ooo_engine_id;
74            _execute_operation->_packet_id     = packet_id    ;
75            _execute_operation->_operation     = operation    ;
76            _execute_operation->_type          = type         ;
77            _execute_operation->_has_immediat  = PORT_READ(in_EXECUTE_IN_HAS_IMMEDIAT);
78            _execute_operation->_immediat      = PORT_READ(in_EXECUTE_IN_IMMEDIAT    );
79            _execute_operation->_data_ra       = PORT_READ(in_EXECUTE_IN_DATA_RA     );
80            _execute_operation->_data_rb       = PORT_READ(in_EXECUTE_IN_DATA_RB     );
81            _execute_operation->_data_rc       = PORT_READ(in_EXECUTE_IN_DATA_RC     );
82            _execute_operation->_write_rd      = PORT_READ(in_EXECUTE_IN_WRITE_RD    );
83            _execute_operation->_num_reg_rd    = PORT_READ(in_EXECUTE_IN_NUM_REG_RD  );
84            _execute_operation->_write_re      = PORT_READ(in_EXECUTE_IN_WRITE_RE    );
85            _execute_operation->_num_reg_re    = PORT_READ(in_EXECUTE_IN_NUM_REG_RE  );
86
87#ifdef DEBUG_TEST
88            if (operation >= MAX_OPERATION)
89              throw ERRORMORPHEO(FUNCTION,"Invalid operation : '"+toString(operation)+"' is higher that MAX_OPERATION");
90#endif
91
92            // execute the operation
93            execute_register = _execute_register[context_id][front_end_id][ooo_engine_id];
94
95            // Test if operation is a custom
96            if (type == TYPE_CUSTOM)
97              {
98                uint32_t num_thread = get_num_thread(context_id   ,_param->_size_context_id,
99                                                     front_end_id ,_param->_size_front_end_id,
100                                                     ooo_engine_id,_param->_size_ooo_engine_id);
101
102                (*(_param->_get_custom_information(num_thread)._get_custom_execute_genMoore(operation))) (_execute_operation, execute_register, _execute_param);
103              }
104            else
105              (*(_function_execute[type][operation])) (_execute_operation, execute_register, _execute_param);
106
107
108#ifdef STATISTICS
109            (*_stat_use_functionnal_unit) ++;
110            (*_stat_sum_delay)   += _execute_operation->_timing._delay;
111            (*_stat_sum_latence) += _execute_operation->_timing._latence;
112#endif
113          }
114       
115        // End cycle
116        {
117          for (uint32_t i=0; i<_param->_nb_context; i++)
118            for (uint32_t j=0; j<_param->_nb_front_end; j++)
119              for (uint32_t k=0; k<_param->_nb_ooo_engine; k++)
120                {
121                  uint32_t num_thread = get_num_thread(i,_param->_size_context_id,
122                                                       j,_param->_size_front_end_id,
123                                                       k,_param->_size_ooo_engine_id);
124
125                  for (uint32_t x=GROUP_CUSTOM_1; x<GROUP_CUSTOM_8; x++)
126                    {
127                      function_execute_end_cycle_t * fct = (_param->_get_custom_information(num_thread)._get_custom_execute_transition(x));
128                     
129                      if (fct != NULL)
130                        (* fct) (_execute_register[i][j][k], _execute_param);
131                    }
132                }
133
134          // Update status
135          if (execute_register != NULL)
136            {
137              // They have an access
138              execute_register->_i_write_spr = false;
139              execute_register->_i_read_spr  = false;
140            }
141        }
142      }
143
144    // each cycle : decrease the latence
145    if (reg_BUSY and (_execute_operation->_timing._latence > 0))
146      _execute_operation->_timing._latence --;
147
148#if defined(STATISTICS) or defined(VHDL_TESTBENCH)
149    end_cycle ();
150#endif
151
152    log_printf(FUNC,Functionnal_unit,FUNCTION,"End");
153  };
154
155}; // end namespace functionnal_unit
156}; // end namespace execute_unit
157}; // end namespace multi_execute_unit
158}; // end namespace execute_loop
159}; // end namespace multi_execute_loop
160}; // end namespace core
161
162}; // end namespace behavioural
163}; // end namespace morpheo             
164#endif
Note: See TracBrowser for help on using the repository browser.