[88] | 1 | #ifdef SYSTEMC |
---|
| 2 | /* |
---|
| 3 | * $Id: Dcache_Access_genMealy_req.cpp 128 2009-06-26 08:43:23Z rosiere $ |
---|
| 4 | * |
---|
| 5 | * [ Description ] |
---|
| 6 | * |
---|
| 7 | */ |
---|
| 8 | |
---|
| 9 | #include "Behavioural/Core/Dcache_Access/include/Dcache_Access.h" |
---|
| 10 | |
---|
| 11 | namespace morpheo { |
---|
| 12 | namespace behavioural { |
---|
| 13 | namespace core { |
---|
| 14 | namespace dcache_access { |
---|
| 15 | |
---|
| 16 | |
---|
| 17 | #undef FUNCTION |
---|
| 18 | #define FUNCTION "Dcache_Access::genMealy_req" |
---|
| 19 | void Dcache_Access::genMealy_req (void) |
---|
| 20 | { |
---|
| 21 | log_begin(Dcache_Access,FUNCTION); |
---|
[128] | 22 | log_function(Dcache_Access,FUNCTION,_name.c_str()); |
---|
[88] | 23 | |
---|
[123] | 24 | if (PORT_READ(in_NRESET)) |
---|
| 25 | { |
---|
[88] | 26 | Tcontrol_t dcache_req_val [_param->_nb_dcache_port]; |
---|
| 27 | for (uint32_t i=0; i<_param->_nb_dcache_port; ++i) |
---|
| 28 | { |
---|
| 29 | dcache_req_val [i] = 0; |
---|
| 30 | |
---|
| 31 | #ifdef STATISTICS |
---|
| 32 | _internal_DCACHE_REQ_NB_ACCESS [i] = 0; |
---|
| 33 | _internal_DCACHE_REQ_NB_ACCESS_CONFLIT [i] = 0; |
---|
| 34 | #endif |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | Tcontrol_t lsq_req_ack [_param->_nb_execute_loop][_param->_max_nb_load_store_unit][_param->_max_nb_cache_access]; |
---|
| 38 | for (uint32_t i=0; i<_param->_nb_execute_loop; ++i) |
---|
| 39 | for (uint32_t j=0; j<_param->_nb_load_store_unit[i]; ++j) |
---|
| 40 | for (uint32_t k=0; k<_param->_nb_cache_access [i][j]; ++k) |
---|
| 41 | lsq_req_ack [i][j][k] = 0; |
---|
| 42 | |
---|
| 43 | std::list<generic::priority::select_t> * select = _priority ->select(); |
---|
| 44 | for (std::list<generic::priority::select_t>::iterator it=select ->begin(); |
---|
| 45 | it!=select->end(); |
---|
| 46 | ++it) |
---|
| 47 | { |
---|
| 48 | uint32_t num_execute_loop = it->grp; |
---|
| 49 | uint32_t num_load_store_unit = it->elt; |
---|
| 50 | |
---|
| 51 | for (uint32_t num_cache_access = 0; num_cache_access<_param->_nb_cache_access [num_execute_loop][num_load_store_unit]; ++num_cache_access) |
---|
| 52 | { |
---|
| 53 | if (PORT_READ(in_LSQ_REQ_VAL [num_execute_loop][num_load_store_unit][num_cache_access])) |
---|
| 54 | { |
---|
| 55 | uint32_t num_port = _param->_table_routing[num_execute_loop][num_load_store_unit][num_cache_access]; |
---|
[128] | 56 | |
---|
| 57 | log_printf(TRACE,Dcache_Access,FUNCTION," * LSQ_REQ [%d][%d][%d] <-> DCACHE_REQ [%d]",num_execute_loop,num_load_store_unit,num_cache_access,num_port); |
---|
| 58 | |
---|
[88] | 59 | Tcontrol_t dcache_req_ack = PORT_READ(in_DCACHE_REQ_ACK [num_port]); |
---|
[117] | 60 | |
---|
[88] | 61 | #ifdef STATISTICS |
---|
| 62 | if (dcache_req_ack) |
---|
| 63 | { |
---|
| 64 | _internal_DCACHE_REQ_NB_ACCESS [num_port] ++; |
---|
| 65 | if (dcache_req_val [num_port]) |
---|
| 66 | _internal_DCACHE_REQ_NB_ACCESS_CONFLIT [num_port] ++; |
---|
| 67 | } |
---|
| 68 | #endif |
---|
| 69 | if (not dcache_req_val [num_port]) |
---|
| 70 | { |
---|
[128] | 71 | log_printf(TRACE,Dcache_Access,FUNCTION," * is valid !!!"); |
---|
| 72 | |
---|
[88] | 73 | dcache_req_val [num_port] = 1; |
---|
| 74 | lsq_req_ack [num_execute_loop][num_load_store_unit][num_cache_access] = dcache_req_ack; |
---|
| 75 | |
---|
| 76 | if (_param->_have_port_dcache_thread_id) |
---|
| 77 | { |
---|
| 78 | Tcontext_t num_context = (_param->_have_port_lsq_thread_id [num_execute_loop][num_load_store_unit])?PORT_READ(in_LSQ_REQ_THREAD_ID [num_execute_loop][num_load_store_unit][num_cache_access]):0; |
---|
[117] | 79 | Tcontext_t num_thread = _param->_translate_load_store_unit_to_thread[num_execute_loop][num_load_store_unit][num_context]; |
---|
| 80 | log_printf(TRACE,Dcache_Access,FUNCTION," * num_context : %d",num_context); |
---|
| 81 | log_printf(TRACE,Dcache_Access,FUNCTION," * num_thread : %d",num_thread ); |
---|
| 82 | |
---|
[128] | 83 | #ifdef DEBUG_TEST |
---|
| 84 | if (num_thread >= _param->_nb_thread) |
---|
| 85 | throw ERRORMORPHEO(FUNCTION,toString(_("Invalid thread number : %d\n"),num_thread)); |
---|
| 86 | #endif |
---|
[117] | 87 | |
---|
| 88 | PORT_WRITE(out_DCACHE_REQ_THREAD_ID [num_port], num_thread); |
---|
[88] | 89 | } |
---|
| 90 | // PORT_WRITE(out_DCACHE_REQ_THREAD_ID [num_port], ((num_execute_loop << _param->_shift_num_execute_loop )+ |
---|
| 91 | // (num_load_store_unit << _param->_shift_num_load_store_unit)+ |
---|
| 92 | // (num_cache_access << _param->_shift_num_cache_access )+ |
---|
| 93 | // num_context)); |
---|
| 94 | if (_param->_have_port_dcache_packet_id) |
---|
| 95 | { |
---|
[128] | 96 | Tpacket_t packet_id = ((num_cache_access << _param->_shift_num_cache_access)+ |
---|
| 97 | ((_param->_have_port_lsq_packet_id [num_execute_loop][num_load_store_unit])?PORT_READ(in_LSQ_REQ_PACKET_ID [num_execute_loop][num_load_store_unit][num_cache_access]):0)); |
---|
| 98 | |
---|
| 99 | log_printf(TRACE,Dcache_Access,FUNCTION," * packet_id : %d",packet_id); |
---|
| 100 | |
---|
| 101 | PORT_WRITE(out_DCACHE_REQ_PACKET_ID [num_port], packet_id); |
---|
[88] | 102 | } |
---|
| 103 | PORT_WRITE(out_DCACHE_REQ_ADDRESS [num_port], PORT_READ(in_LSQ_REQ_ADDRESS [num_execute_loop][num_load_store_unit][num_cache_access])); |
---|
| 104 | PORT_WRITE(out_DCACHE_REQ_WDATA [num_port], PORT_READ(in_LSQ_REQ_WDATA [num_execute_loop][num_load_store_unit][num_cache_access])); |
---|
| 105 | PORT_WRITE(out_DCACHE_REQ_TYPE [num_port], PORT_READ(in_LSQ_REQ_TYPE [num_execute_loop][num_load_store_unit][num_cache_access])); |
---|
| 106 | } |
---|
| 107 | } |
---|
| 108 | } |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | for (uint32_t i=0; i<_param->_nb_dcache_port; ++i) |
---|
| 112 | PORT_WRITE(out_DCACHE_REQ_VAL [i], dcache_req_val [i]); |
---|
| 113 | |
---|
| 114 | for (uint32_t i=0; i<_param->_nb_execute_loop; ++i) |
---|
| 115 | for (uint32_t j=0; j<_param->_nb_load_store_unit[i]; ++j) |
---|
| 116 | for (uint32_t k=0; k<_param->_nb_cache_access [i][j]; ++k) |
---|
| 117 | PORT_WRITE(out_LSQ_REQ_ACK [i][j][k], lsq_req_ack [i][j][k]); |
---|
[123] | 118 | } |
---|
[88] | 119 | |
---|
[123] | 120 | else |
---|
| 121 | { |
---|
| 122 | for (uint32_t i=0; i<_param->_nb_dcache_port; ++i) |
---|
| 123 | PORT_WRITE(out_DCACHE_REQ_VAL [i], 0); |
---|
| 124 | |
---|
| 125 | for (uint32_t i=0; i<_param->_nb_execute_loop; ++i) |
---|
| 126 | for (uint32_t j=0; j<_param->_nb_load_store_unit[i]; ++j) |
---|
| 127 | for (uint32_t k=0; k<_param->_nb_cache_access [i][j]; ++k) |
---|
| 128 | PORT_WRITE(out_LSQ_REQ_ACK [i][j][k], 0); |
---|
| 129 | } |
---|
| 130 | |
---|
[88] | 131 | log_end(Dcache_Access,FUNCTION); |
---|
| 132 | }; |
---|
| 133 | |
---|
| 134 | }; // end namespace dcache_access |
---|
| 135 | }; // end namespace core |
---|
| 136 | |
---|
| 137 | }; // end namespace behavioural |
---|
| 138 | }; // end namespace morpheo |
---|
| 139 | #endif |
---|