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

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

add two component :

  • Write Queue (in Moore version)
  • Execute Queue

add macro to help the interface allocation : Allocation.h

File size: 5.8 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
70            _execute_operation->_context_id    = context_id   ;
71            _execute_operation->_front_end_id  = front_end_id ;
72            _execute_operation->_ooo_engine_id = ooo_engine_id;
73            _execute_operation->_packet_id     = packet_id    ;
74            _execute_operation->_operation     = operation    ;
75            _execute_operation->_type          = PORT_READ(in_EXECUTE_IN_TYPE        );
76            _execute_operation->_has_immediat  = PORT_READ(in_EXECUTE_IN_HAS_IMMEDIAT);
77            _execute_operation->_immediat      = PORT_READ(in_EXECUTE_IN_IMMEDIAT    );
78            _execute_operation->_data_ra       = PORT_READ(in_EXECUTE_IN_DATA_RA     );
79            _execute_operation->_data_rb       = PORT_READ(in_EXECUTE_IN_DATA_RB     );
80            _execute_operation->_data_rc       = PORT_READ(in_EXECUTE_IN_DATA_RC     );
81            _execute_operation->_write_rd      = PORT_READ(in_EXECUTE_IN_WRITE_RD    );
82            _execute_operation->_num_reg_rd    = PORT_READ(in_EXECUTE_IN_NUM_REG_RD  );
83            _execute_operation->_write_re      = PORT_READ(in_EXECUTE_IN_WRITE_RE    );
84            _execute_operation->_num_reg_re    = PORT_READ(in_EXECUTE_IN_NUM_REG_RE  );
85
86#ifdef DEBUG_TEST
87            if (operation >= MAX_OPERATION)
88              throw ERRORMORPHEO(FUNCTION,"Invalid operation : '"+toString(operation)+"' is higher that MAX_OPERATION");
89#endif
90
91            // execute the operation
92            execute_register = _execute_register[context_id][front_end_id][ooo_engine_id];
93
94            // Test if operation is a custom
95            if ((operation == OPERATION_CUSTOM_L_1) or
96                (operation == OPERATION_CUSTOM_L_2) or
97                (operation == OPERATION_CUSTOM_L_3) or
98                (operation == OPERATION_CUSTOM_L_4) or
99                (operation == OPERATION_CUSTOM_L_5) or
100                (operation == OPERATION_CUSTOM_L_6) or
101                (operation == OPERATION_CUSTOM_L_7) or
102                (operation == OPERATION_CUSTOM_L_8))
103              {
104                uint32_t num_thread = get_num_thread(context_id   ,_param->_size_context_id,
105                                                     front_end_id ,_param->_size_front_end_id,
106                                                     ooo_engine_id,_param->_size_ooo_engine_id);
107
108                (*(_param->_get_custom_information(num_thread)._get_custom_execute_genMoore(operation))) (_execute_operation, execute_register, _execute_param);
109              }
110            else
111              (*(_function_execute[operation])) (_execute_operation, execute_register, _execute_param);
112
113
114#ifdef STATISTICS
115            (*_stat_use_functionnal_unit) ++;
116            (*_stat_sum_delay)   += _execute_operation->_timing._delay;
117            (*_stat_sum_latence) += _execute_operation->_timing._latence;
118#endif
119          }
120       
121        // End cycle
122        {
123          for (uint32_t i=0; i<_param->_nb_context; i++)
124            for (uint32_t j=0; j<_param->_nb_front_end; j++)
125              for (uint32_t k=0; k<_param->_nb_ooo_engine; k++)
126                {
127                  uint32_t num_thread = get_num_thread(i,_param->_size_context_id,
128                                                       j,_param->_size_front_end_id,
129                                                       k,_param->_size_ooo_engine_id);
130
131                  for (uint32_t x=GROUP_CUSTOM_1; x<GROUP_CUSTOM_8; x++)
132                    {
133                      function_execute_end_cycle_t * fct = (_param->_get_custom_information(num_thread)._get_custom_execute_transition(x));
134                     
135                      if (fct != NULL)
136                        (* fct) (_execute_register[i][j][k], _execute_param);
137                    }
138                }
139
140          // Update status
141          if (execute_register != NULL)
142            {
143              // They have an access
144              execute_register->_i_write_spr = false;
145              execute_register->_i_read_spr  = false;
146            }
147        }
148      }
149
150    // each cycle : decrease the latence
151    if (reg_BUSY and (_execute_operation->_timing._latence > 0))
152      _execute_operation->_timing._latence --;
153
154#if defined(STATISTICS) or defined(VHDL_TESTBENCH)
155    end_cycle ();
156#endif
157
158    log_printf(FUNC,Functionnal_unit,FUNCTION,"End");
159  };
160
161}; // end namespace functionnal_unit
162}; // end namespace execute_unit
163}; // end namespace multi_execute_unit
164}; // end namespace execute_loop
165}; // end namespace multi_execute_loop
166}; // end namespace core
167
168}; // end namespace behavioural
169}; // end namespace morpheo             
170#endif
Note: See TracBrowser for help on using the repository browser.