[88] | 1 | /* |
---|
| 2 | * $Id: Parameters.cpp 88 2008-12-10 18:31:39Z rosiere $ |
---|
| 3 | * |
---|
| 4 | * [ Description ] |
---|
| 5 | * |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | #include "Behavioural/Core/Icache_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 icache_access { |
---|
| 16 | |
---|
| 17 | |
---|
| 18 | #undef FUNCTION |
---|
| 19 | #define FUNCTION "Icache_Access::Parameters" |
---|
| 20 | Parameters::Parameters (uint32_t nb_thread , |
---|
| 21 | uint32_t nb_front_end , |
---|
| 22 | uint32_t * nb_context , |
---|
| 23 | uint32_t nb_icache_port , |
---|
| 24 | uint32_t size_address , |
---|
| 25 | uint32_t size_icache_thread_id , |
---|
| 26 | uint32_t size_icache_packet_id , |
---|
| 27 | uint32_t ** nb_instruction , |
---|
| 28 | uint32_t ** size_packet_id , |
---|
| 29 | uint32_t ** table_routing , |
---|
| 30 | Tpriority_t priority , |
---|
| 31 | Tload_balancing_t load_balancing , |
---|
| 32 | uint32_t ** translate_context_to_thread, |
---|
| 33 | bool is_toplevel ) |
---|
| 34 | { |
---|
| 35 | log_begin(Icache_Access,FUNCTION); |
---|
| 36 | |
---|
| 37 | _nb_thread = nb_thread ; |
---|
| 38 | _nb_front_end = nb_front_end ; |
---|
| 39 | _nb_context = nb_context ; |
---|
| 40 | _nb_icache_port = nb_icache_port; |
---|
| 41 | _size_address = size_address ; |
---|
| 42 | _size_icache_thread_id = size_icache_thread_id; |
---|
| 43 | _size_icache_packet_id = size_icache_packet_id; |
---|
| 44 | _nb_instruction = nb_instruction; |
---|
| 45 | _size_packet_id = size_packet_id; |
---|
| 46 | _table_routing = table_routing ; |
---|
| 47 | _priority = priority ; |
---|
| 48 | _load_balancing = load_balancing; |
---|
| 49 | _translate_context_to_thread = translate_context_to_thread; |
---|
| 50 | |
---|
| 51 | test(); |
---|
| 52 | |
---|
| 53 | _have_port_icache_thread_id = _size_icache_thread_id>0; |
---|
| 54 | _have_port_icache_packet_id = _size_icache_packet_id>0; |
---|
| 55 | |
---|
| 56 | |
---|
| 57 | _translate_thread_to_context = new Tcontext_t [_nb_thread]; |
---|
| 58 | _translate_thread_to_front_end = new Tcontext_t [_nb_thread]; |
---|
| 59 | |
---|
| 60 | for (uint32_t i=0; i<_nb_front_end; ++i) |
---|
| 61 | for (uint32_t j=0; j<_nb_context[i]; ++j) |
---|
| 62 | { |
---|
| 63 | uint32_t num_thread = translate_context_to_thread[i][j]; |
---|
| 64 | |
---|
| 65 | _translate_thread_to_context [num_thread] = i; |
---|
| 66 | _translate_thread_to_front_end [num_thread] = j; |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | _icache_nb_instruction = new uint32_t [_nb_icache_port]; |
---|
| 70 | for (uint32_t i=0; i<_nb_icache_port; ++i) |
---|
| 71 | _icache_nb_instruction [i] = 0; |
---|
| 72 | for (uint32_t i=0; i<_nb_front_end; i++) |
---|
| 73 | for (uint32_t j=0; j<_nb_context[i]; j++) |
---|
| 74 | { |
---|
| 75 | uint32_t port = _table_routing [i][j]; |
---|
| 76 | |
---|
| 77 | // Take the greater |
---|
| 78 | if (_icache_nb_instruction[port] < _nb_instruction [i][j]) |
---|
| 79 | _icache_nb_instruction[port] = _nb_instruction [i][j]; |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | _have_port_packet_id = new bool * [_nb_front_end]; |
---|
| 83 | for (uint32_t i=0; i<_nb_front_end; i++) |
---|
| 84 | { |
---|
| 85 | _have_port_packet_id [i] = new bool [_nb_context [i]]; |
---|
| 86 | |
---|
| 87 | for (uint32_t j=0; j<_nb_context[i]; j++) |
---|
| 88 | _have_port_packet_id [i][j] = _size_packet_id [i][j] > 0; |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | _max_nb_context = max<uint32_t>(_nb_context,_nb_front_end); |
---|
| 92 | _max_nb_instruction = max<uint32_t>(_nb_instruction,_nb_front_end,_nb_context); |
---|
| 93 | _size_thread_id = log2(_nb_front_end) + log2(_max_nb_context); |
---|
| 94 | _max_size_packet_id = max<uint32_t>(_size_packet_id,_nb_front_end, _nb_context); |
---|
| 95 | |
---|
| 96 | _shift_num_front_end = log2(_max_nb_context); |
---|
| 97 | _mask_size_context = gen_mask<Tcontext_t>(log2(_max_nb_context)); |
---|
| 98 | |
---|
| 99 | if (is_toplevel) |
---|
| 100 | { |
---|
| 101 | copy (); |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | log_end(Icache_Access,FUNCTION); |
---|
| 105 | }; |
---|
| 106 | |
---|
| 107 | // #undef FUNCTION |
---|
| 108 | // #define FUNCTION "Icache_Access::Parameters (copy)" |
---|
| 109 | // Parameters::Parameters (Parameters & param) |
---|
| 110 | // { |
---|
| 111 | // log_begin(Icache_Access,FUNCTION); |
---|
| 112 | // test(); |
---|
| 113 | // log_end(Icache_Access,FUNCTION); |
---|
| 114 | // }; |
---|
| 115 | |
---|
| 116 | #undef FUNCTION |
---|
| 117 | #define FUNCTION "Icache_Access::~Parameters" |
---|
| 118 | Parameters::~Parameters (void) |
---|
| 119 | { |
---|
| 120 | log_begin(Icache_Access,FUNCTION); |
---|
| 121 | |
---|
| 122 | for (uint32_t i=0; i<_nb_front_end; i++) |
---|
| 123 | delete [] _have_port_packet_id [i]; |
---|
| 124 | delete [] _have_port_packet_id; |
---|
| 125 | delete [] _icache_nb_instruction; |
---|
| 126 | |
---|
| 127 | delete [] _translate_thread_to_front_end; |
---|
| 128 | delete [] _translate_thread_to_context ; |
---|
| 129 | |
---|
| 130 | log_end(Icache_Access,FUNCTION); |
---|
| 131 | }; |
---|
| 132 | |
---|
| 133 | #undef FUNCTION |
---|
| 134 | #define FUNCTION "Icache_Access::copy" |
---|
| 135 | void Parameters::copy (void) |
---|
| 136 | { |
---|
| 137 | log_begin(Icache_Access,FUNCTION); |
---|
| 138 | log_end(Icache_Access,FUNCTION); |
---|
| 139 | }; |
---|
| 140 | |
---|
| 141 | }; // end namespace icache_access |
---|
| 142 | }; // end namespace core |
---|
| 143 | |
---|
| 144 | }; // end namespace behavioural |
---|
| 145 | }; // end namespace morpheo |
---|