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