[88] | 1 | /* |
---|
| 2 | * $Id: Parameters.cpp 88 2008-12-10 18:31:39Z rosiere $ |
---|
| 3 | * |
---|
| 4 | * [ Description ] |
---|
| 5 | * |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | #include "Behavioural/Core/Dcache_Access/include/Parameters.h" |
---|
| 9 | #include "Common/include/Max.h" |
---|
| 10 | #include "Common/include/BitManipulation.h" |
---|
| 11 | |
---|
| 12 | namespace morpheo { |
---|
| 13 | namespace behavioural { |
---|
| 14 | namespace core { |
---|
| 15 | namespace dcache_access { |
---|
| 16 | |
---|
| 17 | |
---|
| 18 | #undef FUNCTION |
---|
| 19 | #define FUNCTION "Dcache_Access::Parameters" |
---|
| 20 | Parameters::Parameters (uint32_t nb_thread , |
---|
| 21 | uint32_t nb_execute_loop , |
---|
| 22 | uint32_t * nb_load_store_unit , |
---|
| 23 | uint32_t * nb_context , |
---|
| 24 | uint32_t ** nb_cache_access , |
---|
| 25 | uint32_t nb_dcache_port , |
---|
| 26 | uint32_t size_address , |
---|
| 27 | uint32_t size_data , |
---|
| 28 | uint32_t size_dcache_thread_id , |
---|
| 29 | uint32_t size_dcache_packet_id , |
---|
| 30 | uint32_t ** size_thread_id , |
---|
| 31 | uint32_t ** size_packet_id , |
---|
| 32 | uint32_t *** table_routing , |
---|
| 33 | Tpriority_t priority , |
---|
| 34 | Tload_balancing_t load_balancing , |
---|
| 35 | uint32_t *** translate_load_store_unit_to_thread, |
---|
| 36 | bool is_toplevel ) |
---|
| 37 | { |
---|
| 38 | log_begin(Dcache_Access,FUNCTION); |
---|
| 39 | |
---|
| 40 | _nb_thread = nb_thread ; |
---|
| 41 | _nb_execute_loop = nb_execute_loop ; |
---|
| 42 | _nb_load_store_unit = nb_load_store_unit; |
---|
| 43 | _nb_context = nb_context ; |
---|
| 44 | _nb_cache_access = nb_cache_access ; |
---|
| 45 | _nb_dcache_port = nb_dcache_port ; |
---|
| 46 | _size_address = size_address ; |
---|
| 47 | _size_data = size_data ; |
---|
| 48 | _size_dcache_thread_id = size_dcache_thread_id; |
---|
| 49 | _size_dcache_packet_id = size_dcache_packet_id; |
---|
| 50 | _size_thread_id = size_thread_id ; |
---|
| 51 | _size_packet_id = size_packet_id ; |
---|
| 52 | _table_routing = table_routing ; |
---|
| 53 | _priority = priority ; |
---|
| 54 | _load_balancing = load_balancing ; |
---|
| 55 | _translate_load_store_unit_to_thread = translate_load_store_unit_to_thread; |
---|
| 56 | |
---|
| 57 | test(); |
---|
| 58 | |
---|
| 59 | _max_nb_load_store_unit = max<uint32_t>(_nb_load_store_unit, nb_execute_loop); |
---|
| 60 | _max_nb_cache_access = max<uint32_t>(_nb_cache_access , _nb_execute_loop, _nb_load_store_unit); |
---|
| 61 | |
---|
| 62 | // _size_dcache_thread_id = (log2(_nb_execute_loop) + |
---|
| 63 | // log2(_max_nb_load_store_unit) + |
---|
| 64 | // log2(_max_nb_cache_access) + |
---|
| 65 | // _max_size_thread_id); |
---|
| 66 | |
---|
| 67 | uint32_t max_size_packet_id= max<uint32_t>(_size_packet_id , _nb_execute_loop, _nb_load_store_unit); |
---|
| 68 | |
---|
| 69 | _shift_num_cache_access = max_size_packet_id; |
---|
| 70 | _mask_num_cache_access = gen_mask<Tpacket_t>(log2(_max_nb_cache_access)); |
---|
| 71 | _mask_num_lsq_packet = gen_mask<Tpacket_t>(max_size_packet_id); |
---|
| 72 | |
---|
| 73 | _have_port_dcache_thread_id= _size_dcache_thread_id > 0; |
---|
| 74 | _have_port_dcache_packet_id= _size_dcache_packet_id > 0; |
---|
| 75 | |
---|
| 76 | _have_port_lsq_thread_id = new bool * [_nb_execute_loop]; |
---|
| 77 | _have_port_lsq_packet_id = new bool * [_nb_execute_loop]; |
---|
| 78 | |
---|
| 79 | for (uint32_t i=0; i<_nb_execute_loop; ++i) |
---|
| 80 | { |
---|
| 81 | _have_port_lsq_thread_id [i] = new bool [_nb_load_store_unit [i]]; |
---|
| 82 | _have_port_lsq_packet_id [i] = new bool [_nb_load_store_unit [i]]; |
---|
| 83 | |
---|
| 84 | for (uint32_t j=0; j<_nb_load_store_unit [i]; ++j) |
---|
| 85 | { |
---|
| 86 | _have_port_lsq_thread_id [i][j] = _size_thread_id[i][j] > 0; |
---|
| 87 | _have_port_lsq_packet_id [i][j] = _size_packet_id[i][j] > 0; |
---|
| 88 | } |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | _translate_thread_to_execute_loop = new uint32_t [nb_thread]; |
---|
| 92 | _translate_thread_to_load_store_unit = new uint32_t [nb_thread]; |
---|
| 93 | _translate_thread_to_context = new uint32_t [nb_thread]; |
---|
| 94 | |
---|
| 95 | for (uint32_t i=0; i<_nb_execute_loop; ++i) |
---|
| 96 | for (uint32_t j=0; j<_nb_load_store_unit [i]; ++j) |
---|
| 97 | for (uint32_t k=0; k<_nb_context[i]; ++k) |
---|
| 98 | { |
---|
| 99 | uint32_t num_thread = _translate_load_store_unit_to_thread [i][j][k]; |
---|
| 100 | |
---|
| 101 | _translate_thread_to_execute_loop [num_thread] = i; |
---|
| 102 | _translate_thread_to_load_store_unit [num_thread] = j; |
---|
| 103 | _translate_thread_to_context [num_thread] = k; |
---|
| 104 | } |
---|
| 105 | |
---|
| 106 | if (is_toplevel) |
---|
| 107 | { |
---|
| 108 | copy(); |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | log_end(Dcache_Access,FUNCTION); |
---|
| 112 | }; |
---|
| 113 | |
---|
| 114 | // #undef FUNCTION |
---|
| 115 | // #define FUNCTION "Dcache_Access::Parameters (copy)" |
---|
| 116 | // Parameters::Parameters (Parameters & param) |
---|
| 117 | // { |
---|
| 118 | // log_begin(Dcache_Access,FUNCTION); |
---|
| 119 | // test(); |
---|
| 120 | // log_end(Dcache_Access,FUNCTION); |
---|
| 121 | // }; |
---|
| 122 | |
---|
| 123 | #undef FUNCTION |
---|
| 124 | #define FUNCTION "Dcache_Access::~Parameters" |
---|
| 125 | Parameters::~Parameters (void) |
---|
| 126 | { |
---|
| 127 | log_begin(Dcache_Access,FUNCTION); |
---|
| 128 | |
---|
| 129 | delete [] _translate_thread_to_context ; |
---|
| 130 | delete [] _translate_thread_to_load_store_unit; |
---|
| 131 | delete [] _translate_thread_to_execute_loop ; |
---|
| 132 | |
---|
| 133 | for (uint32_t i=0; i<_nb_execute_loop; ++i) |
---|
| 134 | { |
---|
| 135 | delete [] _have_port_lsq_thread_id [i]; |
---|
| 136 | delete [] _have_port_lsq_packet_id [i]; |
---|
| 137 | } |
---|
| 138 | delete [] _have_port_lsq_thread_id; |
---|
| 139 | delete [] _have_port_lsq_packet_id; |
---|
| 140 | |
---|
| 141 | log_end(Dcache_Access,FUNCTION); |
---|
| 142 | }; |
---|
| 143 | |
---|
| 144 | #undef FUNCTION |
---|
| 145 | #define FUNCTION "Dcache_Access::copy" |
---|
| 146 | void Parameters::copy (void) |
---|
| 147 | { |
---|
| 148 | log_begin(Dcache_Access,FUNCTION); |
---|
| 149 | log_end(Dcache_Access,FUNCTION); |
---|
| 150 | }; |
---|
| 151 | |
---|
| 152 | }; // end namespace dcache_access |
---|
| 153 | }; // end namespace core |
---|
| 154 | |
---|
| 155 | }; // end namespace behavioural |
---|
| 156 | }; // end namespace morpheo |
---|