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

Last change on this file since 72 was 72, checked in by rosiere, 16 years ago
  • SystemC de l'unite fonctionnelle.
  • gestion des groupes / instructions custom
File size: 5.4 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 = 0;
36               
37                for (uint32_t x=GROUP_CUSTOM_1; x<GROUP_CUSTOM_8; x++)
38                  {
39                    function_execute_end_cycle_t * fct = (_param->_get_custom_information(num_thread)._get_custom_execute_reset(x));
40                   
41                    if (fct != NULL)
42                      (* fct) (_execute_register[i][j][k], _execute_param);
43                  }
44              }
45      }
46    else
47      {
48        // Test if pop
49        if (internal_EXECUTE_OUT_VAL and PORT_READ(in_EXECUTE_OUT_ACK))
50          {
51            // transaction
52            reg_BUSY = false;
53          }
54       
55        // Test if push
56        execute_register_t * execute_register = NULL;
57
58        if (PORT_READ(in_EXECUTE_IN_VAL) and internal_EXECUTE_IN_ACK)
59          {
60            reg_BUSY = true;
61
62            Tcontext_t context_id    = (_param->_have_port_context_id   )?PORT_READ(in_EXECUTE_IN_CONTEXT_ID   ):0;
63            Tcontext_t front_end_id  = (_param->_have_port_front_end_id )?PORT_READ(in_EXECUTE_IN_FRONT_END_ID ):0;
64            Tcontext_t ooo_engine_id = (_param->_have_port_ooo_engine_id)?PORT_READ(in_EXECUTE_IN_OOO_ENGINE_ID):0;
65            Tcontext_t packet_id     = (_param->_have_port_packet_id    )?PORT_READ(in_EXECUTE_IN_PACKET_ID    ):0;
66            Toperation_t operation = PORT_READ(in_EXECUTE_IN_OPERATION);
67
68            _execute_operation->_context_id    = context_id   ;
69            _execute_operation->_front_end_id  = front_end_id ;
70            _execute_operation->_ooo_engine_id = ooo_engine_id;
71            _execute_operation->_packet_id     = packet_id    ;
72            _execute_operation->_operation     = operation    ;
73            _execute_operation->_type          = PORT_READ(in_EXECUTE_IN_TYPE        );
74            _execute_operation->_has_immediat  = PORT_READ(in_EXECUTE_IN_HAS_IMMEDIAT);
75            _execute_operation->_immediat      = PORT_READ(in_EXECUTE_IN_IMMEDIAT    );
76            _execute_operation->_data_ra       = PORT_READ(in_EXECUTE_IN_DATA_RA     );
77            _execute_operation->_data_rb       = PORT_READ(in_EXECUTE_IN_DATA_RB     );
78            _execute_operation->_data_rc       = PORT_READ(in_EXECUTE_IN_DATA_RC     );
79            _execute_operation->_write_rd      = PORT_READ(in_EXECUTE_IN_WRITE_RD    );
80            _execute_operation->_num_reg_rd    = PORT_READ(in_EXECUTE_IN_NUM_REG_RD  );
81            _execute_operation->_write_re      = PORT_READ(in_EXECUTE_IN_WRITE_RE    );
82            _execute_operation->_num_reg_re    = PORT_READ(in_EXECUTE_IN_NUM_REG_RE  );
83
84#ifdef DEBUG_TEST
85            if (operation >= MAX_OPERATION)
86              throw ERRORMORPHEO(FUNCTION,"Invalid operation : '"+toString(operation)+"' is higher that MAX_OPERATION");
87#endif
88
89            // execute the operation
90            execute_register = _execute_register[context_id][front_end_id][ooo_engine_id];
91
92            // Test if operation is a custom
93            if ((operation == OPERATION_CUSTOM_L_1) or
94                (operation == OPERATION_CUSTOM_L_2) or
95                (operation == OPERATION_CUSTOM_L_3) or
96                (operation == OPERATION_CUSTOM_L_4) or
97                (operation == OPERATION_CUSTOM_L_5) or
98                (operation == OPERATION_CUSTOM_L_6) or
99                (operation == OPERATION_CUSTOM_L_7) or
100                (operation == OPERATION_CUSTOM_L_8))
101              {
102                uint32_t num_thread = 0;
103
104                (*(_param->_get_custom_information(num_thread)._get_custom_execute_genMoore(operation))) (_execute_operation, execute_register, _execute_param);
105              }
106            else
107              (*(_function_execute[operation])) (_execute_operation, execute_register, _execute_param);
108
109
110#ifdef STATISTICS
111            (*_stat_use_functionnal_unit) ++;
112            (*_stat_sum_delay)   += _execute_operation->_timing._delay;
113            (*_stat_sum_latence) += _execute_operation->_timing._latence;
114#endif
115          }
116       
117        // End cycle
118        {
119          for (uint32_t i=0; i<_param->_nb_context; i++)
120            for (uint32_t j=0; j<_param->_nb_front_end; j++)
121              for (uint32_t k=0; k<_param->_nb_ooo_engine; k++)
122                {
123                  uint32_t num_thread = 0;
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.