[111] | 1 | #ifdef SYSTEMC |
---|
| 2 | /* |
---|
| 3 | * $Id: Decod_queue_function_multi_fifo_transition.cpp 112 2009-03-18 22:36:26Z rosiere $ |
---|
| 4 | * |
---|
| 5 | * [ Description ] |
---|
| 6 | * |
---|
| 7 | */ |
---|
| 8 | |
---|
| 9 | #include "Behavioural/Core/Multi_Front_end/Front_end/Decod_unit/Decod_queue/include/Decod_queue.h" |
---|
| 10 | |
---|
| 11 | namespace morpheo { |
---|
| 12 | namespace behavioural { |
---|
| 13 | namespace core { |
---|
| 14 | namespace multi_front_end { |
---|
| 15 | namespace front_end { |
---|
| 16 | namespace decod_unit { |
---|
| 17 | namespace decod_queue { |
---|
| 18 | |
---|
| 19 | |
---|
| 20 | #undef FUNCTION |
---|
| 21 | #define FUNCTION "Decod_queue::function_multi_fifo_transition" |
---|
| 22 | void Decod_queue::function_multi_fifo_transition (void) |
---|
| 23 | { |
---|
| 24 | log_begin(Decod_queue,FUNCTION); |
---|
| 25 | log_function(Decod_queue,FUNCTION,_name.c_str()); |
---|
| 26 | |
---|
| 27 | if (PORT_READ(in_NRESET) == 0) |
---|
| 28 | { |
---|
| 29 | for (uint32_t i=0; i<_param->_nb_bank; ++i) |
---|
[112] | 30 | while (not reg_QUEUE[i].empty()) |
---|
| 31 | { |
---|
| 32 | delete reg_QUEUE[i].front(); |
---|
| 33 | reg_QUEUE[i].pop_front(); |
---|
| 34 | } |
---|
[111] | 35 | |
---|
| 36 | for (uint32_t i=0; i<_param->_nb_context; i++) |
---|
| 37 | reg_NB_INST [i]=0; |
---|
| 38 | |
---|
| 39 | reg_NUM_BANK_HEAD = 0; |
---|
| 40 | reg_NUM_BANK_TAIL = 0; |
---|
| 41 | } |
---|
| 42 | else |
---|
| 43 | { |
---|
| 44 | //-------------------------------------------------------------------- |
---|
| 45 | //-----[ DECOD_IN ]--------------------------------------------------- |
---|
| 46 | //-------------------------------------------------------------------- |
---|
| 47 | |
---|
| 48 | { |
---|
| 49 | #ifdef STATISTICS |
---|
| 50 | bool find = false; |
---|
| 51 | #endif |
---|
| 52 | for (uint32_t i=0; i<_param->_nb_inst_decod; i++) |
---|
| 53 | if (PORT_READ(in_DECOD_IN_VAL [i]) and internal_DECOD_IN_ACK[i]) |
---|
| 54 | { |
---|
| 55 | log_printf(TRACE,Decod_queue,FUNCTION,_(" * DECOD_IN [%d]"),i); |
---|
| 56 | |
---|
| 57 | // Create entry |
---|
| 58 | decod_queue_entry_t * entry = new decod_queue_entry_t (1); |
---|
| 59 | reg_QUEUE[reg_NUM_BANK_TAIL].push_back(entry); |
---|
| 60 | |
---|
| 61 | #ifdef STATISTICS |
---|
| 62 | find = true; |
---|
| 63 | if (usage_is_set(_usage,USE_STATISTICS)) |
---|
| 64 | (*_stat_sum_inst_enable) ++; |
---|
| 65 | #endif |
---|
| 66 | |
---|
| 67 | Tcontext_t context = (_param->_have_port_context_id)?PORT_READ(in_DECOD_IN_CONTEXT_ID [i]):0; |
---|
| 68 | |
---|
| 69 | log_printf(TRACE,Decod_queue,FUNCTION,_(" * context : %d"),context); |
---|
| 70 | |
---|
| 71 | // entry->_val [0] = 1; |
---|
| 72 | entry->_context_id [0] = context; |
---|
| 73 | entry->_depth [0] = (_param->_have_port_depth)?PORT_READ(in_DECOD_IN_DEPTH [i]):0; |
---|
| 74 | entry->_type [0] = PORT_READ(in_DECOD_IN_TYPE [i]); |
---|
| 75 | entry->_operation [0] = PORT_READ(in_DECOD_IN_OPERATION [i]); |
---|
| 76 | entry->_no_execute [0] = PORT_READ(in_DECOD_IN_NO_EXECUTE [i]); |
---|
| 77 | entry->_is_delay_slot [0] = PORT_READ(in_DECOD_IN_IS_DELAY_SLOT [i]); |
---|
| 78 | #ifdef DEBUG |
---|
| 79 | entry->_address [0] = PORT_READ(in_DECOD_IN_ADDRESS [i]); |
---|
| 80 | #endif |
---|
| 81 | entry->_address_next [0] = PORT_READ(in_DECOD_IN_ADDRESS_NEXT [i]); |
---|
| 82 | entry->_has_immediat [0] = PORT_READ(in_DECOD_IN_HAS_IMMEDIAT [i]); |
---|
| 83 | entry->_immediat [0] = PORT_READ(in_DECOD_IN_IMMEDIAT [i]); |
---|
| 84 | entry->_read_ra [0] = PORT_READ(in_DECOD_IN_READ_RA [i]); |
---|
| 85 | entry->_num_reg_ra [0] = PORT_READ(in_DECOD_IN_NUM_REG_RA [i]); |
---|
| 86 | entry->_read_rb [0] = PORT_READ(in_DECOD_IN_READ_RB [i]); |
---|
| 87 | entry->_num_reg_rb [0] = PORT_READ(in_DECOD_IN_NUM_REG_RB [i]); |
---|
| 88 | entry->_read_rc [0] = PORT_READ(in_DECOD_IN_READ_RC [i]); |
---|
| 89 | entry->_num_reg_rc [0] = PORT_READ(in_DECOD_IN_NUM_REG_RC [i]); |
---|
| 90 | entry->_write_rd [0] = PORT_READ(in_DECOD_IN_WRITE_RD [i]); |
---|
| 91 | entry->_num_reg_rd [0] = PORT_READ(in_DECOD_IN_NUM_REG_RD [i]); |
---|
| 92 | entry->_write_re [0] = PORT_READ(in_DECOD_IN_WRITE_RE [i]); |
---|
| 93 | entry->_num_reg_re [0] = PORT_READ(in_DECOD_IN_NUM_REG_RE [i]); |
---|
| 94 | entry->_exception_use [0] = PORT_READ(in_DECOD_IN_EXCEPTION_USE [i]); |
---|
| 95 | entry->_exception [0] = PORT_READ(in_DECOD_IN_EXCEPTION [i]); |
---|
| 96 | |
---|
| 97 | // Update pointer |
---|
| 98 | reg_NUM_BANK_TAIL = (reg_NUM_BANK_TAIL+1)%_param->_nb_bank; |
---|
| 99 | reg_NB_INST [context] ++; |
---|
| 100 | |
---|
| 101 | log_printf(TRACE,Decod_queue,FUNCTION,_(" * nb_inst : %d"),reg_NB_INST [context]); |
---|
| 102 | log_printf(TRACE,Decod_queue,FUNCTION,_(" * PUSH queue")); |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | #ifdef STATISTICS |
---|
| 106 | if (usage_is_set(_usage,USE_STATISTICS)) |
---|
| 107 | if (find) |
---|
| 108 | (*_stat_sum_transaction_decod_in) ++; |
---|
| 109 | #endif |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | //-------------------------------------------------------------------- |
---|
| 113 | //-----[ DECOD_OUT ]-------------------------------------------------- |
---|
| 114 | //-------------------------------------------------------------------- |
---|
| 115 | { |
---|
| 116 | for (uint32_t i=0; i<_param->_nb_inst_decod; i++) |
---|
| 117 | if (internal_DECOD_OUT_VAL [i] and internal_DECOD_OUT_ACK[i]) |
---|
| 118 | { |
---|
| 119 | log_printf(TRACE,Decod_queue,FUNCTION,_(" * DECOD_OUT [%d]"),i); |
---|
| 120 | |
---|
| 121 | uint32_t num_bank = reg_NUM_BANK_HEAD; |
---|
| 122 | |
---|
| 123 | Tcontext_t context = reg_QUEUE[num_bank].front()->_context_id [0]; |
---|
| 124 | |
---|
| 125 | log_printf(TRACE,Decod_queue,FUNCTION,_(" * context : %d"),context); |
---|
| 126 | |
---|
| 127 | // Pop the slot |
---|
| 128 | delete reg_QUEUE[num_bank].front(); |
---|
| 129 | reg_QUEUE[num_bank].pop_front(); |
---|
| 130 | |
---|
| 131 | // Update pointer |
---|
| 132 | reg_NUM_BANK_HEAD = (reg_NUM_BANK_HEAD+1)%_param->_nb_bank; |
---|
| 133 | reg_NB_INST [context] --; |
---|
| 134 | } |
---|
| 135 | } |
---|
| 136 | |
---|
| 137 | //-------------------------------------------------------------------- |
---|
| 138 | //-----[ OTHERS ]----------------------------------------------------- |
---|
| 139 | //-------------------------------------------------------------------- |
---|
| 140 | |
---|
| 141 | #if defined(DEBUG) and defined(DEBUG_Decod_queue) and (DEBUG >= DEBUG_TRACE) |
---|
| 142 | log_printf(TRACE,Decod_queue,FUNCTION," * Dump decod_queue"); |
---|
| 143 | log_printf(TRACE,Decod_queue,FUNCTION," * reg_NUM_BANK_HEAD : %d",reg_NUM_BANK_HEAD); |
---|
| 144 | log_printf(TRACE,Decod_queue,FUNCTION," * reg_NUM_BANK_TAIL : %d",reg_NUM_BANK_TAIL); |
---|
| 145 | for (uint32_t i=0; i<_param->_nb_context; i++) |
---|
| 146 | log_printf(TRACE,Decod_queue,FUNCTION," * reg_NB_INST [%d] : %d",i,reg_NB_INST [i]); |
---|
| 147 | |
---|
| 148 | for (uint32_t i=0; i<_param->_nb_bank; ++i) |
---|
| 149 | { |
---|
| 150 | uint32_t x=0; |
---|
| 151 | uint32_t num_bank = (reg_NUM_BANK_HEAD+i)%_param->_nb_bank; |
---|
| 152 | for (std::list<decod_queue_entry_t*>::iterator it=reg_QUEUE[num_bank].begin(); |
---|
| 153 | it!=reg_QUEUE[num_bank].end(); |
---|
| 154 | it++) |
---|
| 155 | { |
---|
| 156 | log_printf(TRACE,Decod_queue,FUNCTION," * [%.4d][%.4d] %.3d %.2d, %.2d %.3d %.1d %.1d, 0x%.8x (0x%.8x), %.1d 0x%.8x, %.1d %.2d, %.1d %.2d, %.1d %.2d, %.1d %.2d, %.1d %.2d, %.1d %.2d" |
---|
| 157 | ,i |
---|
| 158 | ,x |
---|
| 159 | ,(*it)->_context_id [0] |
---|
| 160 | ,(*it)->_depth [0] |
---|
| 161 | ,(*it)->_type [0] |
---|
| 162 | ,(*it)->_operation [0] |
---|
| 163 | ,(*it)->_no_execute [0] |
---|
| 164 | ,(*it)->_is_delay_slot [0] |
---|
| 165 | ,(*it)->_address [0] |
---|
| 166 | ,(*it)->_address [0]<<2 |
---|
| 167 | ,(*it)->_has_immediat [0] |
---|
| 168 | ,(*it)->_immediat [0] |
---|
| 169 | ,(*it)->_read_ra [0] |
---|
| 170 | ,(*it)->_num_reg_ra [0] |
---|
| 171 | ,(*it)->_read_rb [0] |
---|
| 172 | ,(*it)->_num_reg_rb [0] |
---|
| 173 | ,(*it)->_read_rc [0] |
---|
| 174 | ,(*it)->_num_reg_rc [0] |
---|
| 175 | ,(*it)->_write_rd [0] |
---|
| 176 | ,(*it)->_num_reg_rd [0] |
---|
| 177 | ,(*it)->_write_re [0] |
---|
| 178 | ,(*it)->_num_reg_re [0] |
---|
| 179 | ,(*it)->_exception_use [0] |
---|
| 180 | ,(*it)->_exception [0] |
---|
| 181 | ); |
---|
| 182 | x++; |
---|
| 183 | } |
---|
| 184 | } |
---|
| 185 | #endif |
---|
| 186 | |
---|
| 187 | #ifdef STATISTICS |
---|
| 188 | if (usage_is_set(_usage,USE_STATISTICS)) |
---|
| 189 | { |
---|
| 190 | for (uint32_t i=0; i<_param->_nb_bank; ++i) |
---|
| 191 | *(_stat_use_queue) += reg_QUEUE[i].size(); |
---|
| 192 | for (uint32_t i=0; i<_param->_nb_context; i++) |
---|
| 193 | *(_stat_nb_inst [i]) += reg_NB_INST [i]; |
---|
| 194 | } |
---|
| 195 | #endif |
---|
| 196 | } |
---|
| 197 | |
---|
| 198 | log_end(Decod_queue,FUNCTION); |
---|
| 199 | }; |
---|
| 200 | |
---|
| 201 | }; // end namespace decod_queue |
---|
| 202 | }; // end namespace decod_unit |
---|
| 203 | }; // end namespace front_end |
---|
| 204 | }; // end namespace multi_front_end |
---|
| 205 | }; // end namespace core |
---|
| 206 | |
---|
| 207 | }; // end namespace behavioural |
---|
| 208 | }; // end namespace morpheo |
---|
| 209 | #endif |
---|