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