[111] | 1 | #ifdef SYSTEMC |
---|
| 2 | /* |
---|
| 3 | * $Id: Decod_queue_function_multi_fifo_genMealy_decod_out.cpp 124 2009-06-17 12:11:25Z 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_genMealy_decod_out" |
---|
| 22 | void Decod_queue::function_multi_fifo_genMealy_decod_out (void) |
---|
| 23 | { |
---|
| 24 | log_begin(Decod_queue,FUNCTION); |
---|
| 25 | log_function(Decod_queue,FUNCTION,_name.c_str()); |
---|
[123] | 26 | |
---|
| 27 | if (PORT_READ(in_NRESET)) |
---|
| 28 | { |
---|
| 29 | bool context_val [_param->_nb_context]; |
---|
| 30 | uint32_t nb_inst_event [_param->_nb_context]; |
---|
| 31 | for (uint32_t i=0; i<_param->_nb_context; i++) |
---|
| 32 | { |
---|
| 33 | context_val [i] = true; |
---|
| 34 | nb_inst_event [i] = reg_NB_INST_EVENT [i]; |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | Tcontrol_t val [_param->_nb_inst_decod]; |
---|
[111] | 38 | for (uint32_t i=0; i<_param->_nb_inst_decod; i++) |
---|
| 39 | { |
---|
| 40 | val [i] = 0; |
---|
| 41 | internal_DECOD_OUT_VAL [i] = 0; |
---|
| 42 | internal_DECOD_OUT_ACK [i] = 0; |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | uint32_t num_bank = reg_NUM_BANK_HEAD%_param->_nb_bank; |
---|
| 46 | |
---|
| 47 | for (uint32_t i=0; i<_param->_nb_inst_decod; i++) |
---|
| 48 | { |
---|
| 49 | log_printf(TRACE,Decod_queue,FUNCTION,_(" * num_bank : %d"),num_bank); |
---|
| 50 | |
---|
| 51 | if (not reg_QUEUE[num_bank].empty()) |
---|
| 52 | { |
---|
| 53 | log_printf(TRACE,Decod_queue,FUNCTION,_(" * Queue is not empty, slot [%d] is valid."),i); |
---|
| 54 | |
---|
[124] | 55 | Tcontext_t context = reg_QUEUE[num_bank].front()->_context_id [0]; |
---|
[111] | 56 | |
---|
| 57 | log_printf(TRACE,Decod_queue,FUNCTION," * context : %d",context); |
---|
| 58 | |
---|
[123] | 59 | if (context_val [context]) |
---|
[111] | 60 | { |
---|
[123] | 61 | |
---|
| 62 | // Tdepth_t depth = reg_QUEUE[num_bank].front()->_depth [0]; |
---|
| 63 | // Tdepth_t depth_min = (_param->_have_port_depth)?PORT_READ(in_DEPTH_MIN [context]):0; |
---|
| 64 | // Tdepth_t depth_max = (_param->_have_port_depth)?PORT_READ(in_DEPTH_MAX [context]):0; |
---|
| 65 | // Tcontrol_t depth_full = PORT_READ(in_DEPTH_FULL[context]); |
---|
| 66 | |
---|
| 67 | // is a valid instruction ? |
---|
| 68 | // If DEPTH_CURRENT : |
---|
| 69 | // equal at DEPTH_MIN -> not speculative |
---|
| 70 | // not include ]DEPTH_MIN:DEPTH_MAX] -> previous branch miss |
---|
| 71 | // include ]DEPTH_MIN:DEPTH_MAX] -> speculative |
---|
| 72 | |
---|
| 73 | // All case |
---|
| 74 | // ....... min ...X... max ....... OK |
---|
| 75 | // ....... min ....... max ...X... KO |
---|
| 76 | // ...X... min ....... max ....... KO |
---|
| 77 | // ....... max ....... min ...X... OK |
---|
| 78 | // ...X... max ....... min ....... OK |
---|
| 79 | // ....... max ...X... min ....... KO |
---|
| 80 | |
---|
| 81 | Tcontrol_t is_valid = (nb_inst_event [context] == 0); |
---|
| 82 | |
---|
| 83 | // Tcontrol_t is_valid = ((depth == depth_min) or |
---|
| 84 | // depth_full or |
---|
| 85 | // ((depth_min <= depth_max)? |
---|
| 86 | // ((depth >= depth_min) and (depth <=depth_max)): |
---|
| 87 | // ((depth >= depth_min) or (depth <=depth_max)))); |
---|
| 88 | |
---|
| 89 | log_printf(TRACE,Decod_queue,FUNCTION," * is_valid : %d",is_valid); |
---|
| 90 | log_printf(TRACE,Decod_queue,FUNCTION," * context_val : %d",context_val [context]); |
---|
| 91 | log_printf(TRACE,Decod_queue,FUNCTION," * nb_inst_event: %d",nb_inst_event [context]); |
---|
| 92 | // log_printf(TRACE,Decod_queue,FUNCTION," * depth : %d",depth); |
---|
| 93 | // log_printf(TRACE,Decod_queue,FUNCTION," * depth_min : %d",depth_min); |
---|
| 94 | // log_printf(TRACE,Decod_queue,FUNCTION," * depth_max : %d",depth_max); |
---|
| 95 | // log_printf(TRACE,Decod_queue,FUNCTION," * depth_full : %d",depth_full); |
---|
| 96 | #ifdef DEBUG |
---|
| 97 | log_printf(TRACE,Decod_queue,FUNCTION," * address : 0x%x (0x%x)",reg_QUEUE[num_bank].front()->_address [0],reg_QUEUE[num_bank].front()->_address [0]<<2); |
---|
| 98 | #endif |
---|
| 99 | log_printf(TRACE,Decod_queue,FUNCTION," * address_next : 0x%x (0x%x)",reg_QUEUE[num_bank].front()->_address_next[0],reg_QUEUE[num_bank].front()->_address_next[0]<<2); |
---|
| 100 | |
---|
| 101 | internal_DECOD_OUT_VAL [i] = 1; // in all case, val is set (entry is not empty, and instruction is valid) |
---|
[124] | 102 | |
---|
[123] | 103 | if (is_valid) |
---|
| 104 | { |
---|
| 105 | val [i] = 1; |
---|
| 106 | internal_DECOD_OUT_ACK [i] = PORT_READ(in_DECOD_OUT_ACK [i]); |
---|
| 107 | } |
---|
| 108 | else |
---|
| 109 | { |
---|
| 110 | // Consume the instruction (to erase) |
---|
| 111 | internal_DECOD_OUT_ACK [i] = 1; |
---|
| 112 | |
---|
| 113 | // Have event ? |
---|
| 114 | if (nb_inst_event [context] > 0) |
---|
| 115 | { |
---|
| 116 | nb_inst_event [context] --; |
---|
| 117 | |
---|
| 118 | // Last event ? |
---|
| 119 | if (nb_inst_event [context] == 0) |
---|
| 120 | { |
---|
| 121 | context_val [context] = false; |
---|
| 122 | } |
---|
| 123 | } |
---|
| 124 | } |
---|
[124] | 125 | |
---|
| 126 | log_printf(TRACE,Decod_queue,FUNCTION," * decod_out_ack: %d (%d)",internal_DECOD_OUT_ACK [i],PORT_READ(in_DECOD_OUT_ACK [i])); |
---|
[111] | 127 | } |
---|
| 128 | } |
---|
| 129 | num_bank = (num_bank+1)%_param->_nb_bank; |
---|
| 130 | } |
---|
| 131 | |
---|
| 132 | for (uint32_t i=0; i<_param->_nb_inst_decod; i++) |
---|
| 133 | { |
---|
| 134 | log_printf(TRACE,Decod_queue,FUNCTION," * DECOD_OUT_VAL : %d",val [i]); |
---|
| 135 | |
---|
| 136 | PORT_WRITE(out_DECOD_OUT_VAL [i],val [i]); |
---|
| 137 | } |
---|
[123] | 138 | } |
---|
| 139 | else |
---|
| 140 | { |
---|
| 141 | // Reset |
---|
| 142 | for (uint32_t i=0; i<_param->_nb_inst_decod; i++) |
---|
| 143 | { |
---|
| 144 | internal_DECOD_OUT_VAL [i] = 0; |
---|
| 145 | internal_DECOD_OUT_ACK [i] = 0; |
---|
| 146 | PORT_WRITE(out_DECOD_OUT_VAL [i],0); |
---|
| 147 | } |
---|
| 148 | } |
---|
[111] | 149 | |
---|
| 150 | log_end(Decod_queue,FUNCTION); |
---|
| 151 | }; |
---|
| 152 | |
---|
| 153 | }; // end namespace decod_queue |
---|
| 154 | }; // end namespace decod_unit |
---|
| 155 | }; // end namespace front_end |
---|
| 156 | }; // end namespace multi_front_end |
---|
| 157 | }; // end namespace core |
---|
| 158 | |
---|
| 159 | }; // end namespace behavioural |
---|
| 160 | }; // end namespace morpheo |
---|
| 161 | #endif |
---|