[88] | 1 | #ifdef SYSTEMC |
---|
| 2 | /* |
---|
| 3 | * $Id: Icache_Access_genMealy_rsp.cpp 124 2009-06-17 12:11:25Z rosiere $ |
---|
| 4 | * |
---|
| 5 | * [ Description ] |
---|
| 6 | * |
---|
| 7 | */ |
---|
| 8 | |
---|
| 9 | #include "Behavioural/Core/Icache_Access/include/Icache_Access.h" |
---|
| 10 | |
---|
| 11 | namespace morpheo { |
---|
| 12 | namespace behavioural { |
---|
| 13 | namespace core { |
---|
| 14 | namespace icache_access { |
---|
| 15 | |
---|
| 16 | |
---|
| 17 | #undef FUNCTION |
---|
| 18 | #define FUNCTION "Icache_Access::genMealy_rsp" |
---|
| 19 | void Icache_Access::genMealy_rsp (void) |
---|
| 20 | { |
---|
[124] | 21 | log_begin(Icache_Access,FUNCTION); |
---|
| 22 | log_function(Icache_Access,FUNCTION,_name.c_str()); |
---|
[88] | 23 | |
---|
| 24 | Tcontrol_t context_rsp_val [_param->_nb_front_end][_param->_max_nb_context]; |
---|
| 25 | for (uint32_t i=0; i<_param->_nb_front_end; ++i) |
---|
| 26 | for (uint32_t j=0; j<_param->_nb_context[i]; ++j) |
---|
| 27 | context_rsp_val [i][j] = 0; |
---|
| 28 | |
---|
[123] | 29 | if (PORT_READ(in_NRESET)) |
---|
| 30 | { |
---|
[88] | 31 | for (uint32_t i=0; i<_param->_nb_icache_port; ++i) |
---|
| 32 | { |
---|
[124] | 33 | log_printf(TRACE,Icache_Access,FUNCTION," * ICACHE_RSP [%d]",i); |
---|
| 34 | |
---|
[88] | 35 | Tcontrol_t val = PORT_READ(in_ICACHE_RSP_VAL [i]); |
---|
| 36 | Tcontrol_t ack; |
---|
| 37 | |
---|
| 38 | Tcontext_t thread_id = (_param->_have_port_icache_thread_id)?PORT_READ(in_ICACHE_RSP_THREAD_ID [i]):0; |
---|
| 39 | |
---|
[124] | 40 | log_printf(TRACE,Icache_Access,FUNCTION," * val : %d",val); |
---|
| 41 | log_printf(TRACE,Icache_Access,FUNCTION," * thread_id : %d",thread_id); |
---|
| 42 | |
---|
[88] | 43 | #ifdef DEBUG_TEST |
---|
| 44 | if (thread_id > _param->_nb_thread) |
---|
| 45 | throw ERRORMORPHEO(FUNCTION,_("invalid thread_id.\n")); |
---|
| 46 | #endif |
---|
| 47 | |
---|
| 48 | if (val) |
---|
| 49 | { |
---|
| 50 | Tcontext_t front_end_id = _param->_translate_thread_to_context [thread_id]; |
---|
| 51 | Tcontext_t context_id = _param->_translate_thread_to_front_end[thread_id]; |
---|
[124] | 52 | |
---|
| 53 | log_printf(TRACE,Icache_Access,FUNCTION," * front_end_id : %d",front_end_id); |
---|
| 54 | log_printf(TRACE,Icache_Access,FUNCTION," * context_id : %d",context_id ); |
---|
[88] | 55 | |
---|
| 56 | // log_printf(TRACE,Icache_Access,FUNCTION,"thread_id : %d",thread_id); |
---|
| 57 | // log_printf(TRACE,Icache_Access,FUNCTION,"front_end_id : %d",front_end_id); |
---|
| 58 | // log_printf(TRACE,Icache_Access,FUNCTION,"context_id : %d",context_id); |
---|
| 59 | |
---|
| 60 | #ifdef DEBUG_TEST |
---|
| 61 | if (front_end_id > _param->_nb_front_end) |
---|
| 62 | throw ERRORMORPHEO(FUNCTION,_("invalid front_end_id.\n")); |
---|
| 63 | |
---|
| 64 | if (context_id > _param->_nb_context[front_end_id]) |
---|
| 65 | throw ERRORMORPHEO(FUNCTION,_("invalid context_id.\n")); |
---|
| 66 | |
---|
| 67 | if (_param->_table_routing [front_end_id][context_id] != i) |
---|
| 68 | throw ERRORMORPHEO(FUNCTION,_("invalid route.\n")); |
---|
| 69 | #endif |
---|
| 70 | |
---|
| 71 | ack = PORT_READ(in_CONTEXT_RSP_ACK [front_end_id][context_id]); |
---|
| 72 | |
---|
| 73 | context_rsp_val [front_end_id][context_id] = 1; |
---|
| 74 | // if (_param->_have_port_icache_packet_id) |
---|
| 75 | if (_param->_have_port_packet_id [front_end_id][context_id]) |
---|
| 76 | PORT_WRITE(out_CONTEXT_RSP_PACKET_ID [front_end_id][context_id], PORT_READ(in_ICACHE_RSP_PACKET_ID [i])); |
---|
| 77 | PORT_WRITE(out_CONTEXT_RSP_ERROR [front_end_id][context_id], PORT_READ(in_ICACHE_RSP_ERROR [i])); |
---|
| 78 | |
---|
| 79 | for (uint32_t j=0; j<_param->_nb_instruction [front_end_id][context_id]; ++j) |
---|
| 80 | PORT_WRITE(out_CONTEXT_RSP_INSTRUCTION [front_end_id][context_id][j], PORT_READ(in_ICACHE_RSP_INSTRUCTION [i][j])); |
---|
| 81 | } |
---|
| 82 | else |
---|
| 83 | ack = 0; |
---|
| 84 | |
---|
| 85 | PORT_WRITE(out_ICACHE_RSP_ACK [i],ack); |
---|
| 86 | } |
---|
| 87 | |
---|
[123] | 88 | } |
---|
| 89 | else |
---|
| 90 | for (uint32_t i=0; i<_param->_nb_icache_port; ++i) |
---|
| 91 | PORT_WRITE(out_ICACHE_RSP_ACK [i],0); |
---|
| 92 | |
---|
[88] | 93 | for (uint32_t i=0; i<_param->_nb_front_end; ++i) |
---|
| 94 | for (uint32_t j=0; j<_param->_nb_context[i]; ++j) |
---|
[124] | 95 | { |
---|
| 96 | log_printf(TRACE,Icache_Access,FUNCTION," * CONTEXT_RSP_VAL [%d][%d] : %d",i,j,context_rsp_val [i][j]); |
---|
[88] | 97 | |
---|
[124] | 98 | PORT_WRITE(out_CONTEXT_RSP_VAL [i][j], context_rsp_val [i][j]); |
---|
| 99 | } |
---|
| 100 | |
---|
[88] | 101 | log_end(Icache_Access,FUNCTION); |
---|
| 102 | }; |
---|
| 103 | |
---|
| 104 | }; // end namespace icache_access |
---|
| 105 | }; // end namespace core |
---|
| 106 | |
---|
| 107 | }; // end namespace behavioural |
---|
| 108 | }; // end namespace morpheo |
---|
| 109 | #endif |
---|