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