[78] | 1 | #ifdef SYSTEMC |
---|
| 2 | /* |
---|
| 3 | * $Id: Load_Store_pointer_unit_transition.cpp 122 2009-06-03 08:15:51Z rosiere $ |
---|
| 4 | * |
---|
| 5 | * [ Description ] |
---|
| 6 | * |
---|
| 7 | */ |
---|
| 8 | |
---|
| 9 | #include "Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Rename_unit/Load_Store_pointer_unit/include/Load_Store_pointer_unit.h" |
---|
| 10 | |
---|
| 11 | namespace morpheo { |
---|
| 12 | namespace behavioural { |
---|
| 13 | namespace core { |
---|
| 14 | namespace multi_ooo_engine { |
---|
| 15 | namespace ooo_engine { |
---|
| 16 | namespace rename_unit { |
---|
| 17 | namespace load_store_pointer_unit { |
---|
| 18 | |
---|
| 19 | |
---|
| 20 | #undef FUNCTION |
---|
| 21 | #define FUNCTION "Load_Store_pointer_unit::transition" |
---|
| 22 | void Load_Store_pointer_unit::transition (void) |
---|
| 23 | { |
---|
[110] | 24 | log_begin(Load_Store_pointer_unit,FUNCTION); |
---|
| 25 | log_function(Load_Store_pointer_unit,FUNCTION,_name.c_str()); |
---|
[78] | 26 | |
---|
| 27 | if (PORT_READ(in_NRESET) == 0) |
---|
| 28 | { |
---|
| 29 | for (uint32_t i=0; i<_param->_nb_load_store_queue; i++) |
---|
| 30 | { |
---|
| 31 | reg_STORE_QUEUE_PTR_WRITE [i] = 0; |
---|
| 32 | reg_STORE_QUEUE_NB_USE [i] = 0; |
---|
| 33 | reg_LOAD_QUEUE_PTR_WRITE [i] = 0; |
---|
| 34 | |
---|
| 35 | for (uint32_t j=0; j<_param->_size_store_queue[i]; j++) |
---|
| 36 | reg_STORE_QUEUE_USE [i][j] = false; |
---|
| 37 | for (uint32_t j=0; j<_param->_size_load_queue[i]; j++) |
---|
| 38 | reg_LOAD_QUEUE_USE [i][j] = false; |
---|
| 39 | } |
---|
[122] | 40 | for (uint32_t i=0; i<_param->_nb_front_end; ++i) |
---|
| 41 | for (uint32_t j=0; j<_param->_nb_context[i]; ++j) |
---|
| 42 | { |
---|
| 43 | reg_STORE_QUEUE_PTR_READ [i][j] = 0; |
---|
| 44 | reg_STORE_QUEUE_EMPTY [i][j] = true; |
---|
| 45 | } |
---|
[78] | 46 | } |
---|
| 47 | else |
---|
| 48 | { |
---|
| 49 | // ===================================================== |
---|
| 50 | // =====[ INSERT ]====================================== |
---|
| 51 | // ===================================================== |
---|
| 52 | |
---|
| 53 | for (uint32_t i=0; i<_param->_nb_inst_insert; i++) |
---|
| 54 | if (PORT_READ(in_INSERT_VAL [i]) and internal_INSERT_ACK [i]) |
---|
| 55 | { |
---|
[110] | 56 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," * INSERT [%d]",i); |
---|
[78] | 57 | |
---|
| 58 | switch (internal_INSERT_OPERATION_USE [i]) |
---|
| 59 | { |
---|
| 60 | case OPERATION_USE_STORE_QUEUE : |
---|
| 61 | { |
---|
[110] | 62 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," * use STORE_QUEUE"); |
---|
[78] | 63 | |
---|
[122] | 64 | Tcontext_t front_end_id = (_param->_have_port_front_end_id)?PORT_READ(in_INSERT_FRONT_END_ID [i]):0; |
---|
| 65 | Tcontext_t context_id = (_param->_have_port_context_id )?PORT_READ(in_INSERT_CONTEXT_ID [i]):0; |
---|
[78] | 66 | uint32_t lsq = internal_INSERT_LSQ [i]; |
---|
| 67 | Tlsq_ptr_t ptr = internal_INSERT_PTR [i]; |
---|
| 68 | |
---|
[110] | 69 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," * lsq : %d",lsq); |
---|
| 70 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," * ptr : %d",ptr); |
---|
[78] | 71 | |
---|
[122] | 72 | reg_STORE_QUEUE_EMPTY [front_end_id][context_id] = false; // new element |
---|
[78] | 73 | reg_STORE_QUEUE_PTR_WRITE [lsq] = (ptr+1)%_param->_size_store_queue[lsq]; |
---|
| 74 | reg_STORE_QUEUE_NB_USE [lsq] ++; |
---|
| 75 | reg_STORE_QUEUE_USE [lsq][ptr] = true; |
---|
| 76 | |
---|
| 77 | break; |
---|
| 78 | } |
---|
| 79 | case OPERATION_USE_LOAD_QUEUE : |
---|
| 80 | { |
---|
[110] | 81 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," * use LOAD_QUEUE"); |
---|
[78] | 82 | |
---|
| 83 | uint32_t lsq = internal_INSERT_LSQ [i]; |
---|
| 84 | Tlsq_ptr_t ptr = internal_INSERT_PTR [i]; |
---|
| 85 | |
---|
[110] | 86 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," * lsq : %d",lsq); |
---|
| 87 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," * ptr : %d",ptr); |
---|
[78] | 88 | |
---|
| 89 | reg_LOAD_QUEUE_PTR_WRITE [lsq] = (ptr+1)%_param->_size_load_queue[lsq]; |
---|
| 90 | reg_LOAD_QUEUE_USE [lsq][ptr] = true; |
---|
| 91 | |
---|
| 92 | break; |
---|
| 93 | } |
---|
| 94 | default : |
---|
| 95 | { |
---|
| 96 | break; |
---|
| 97 | } |
---|
| 98 | } |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | // ===================================================== |
---|
| 102 | // =====[ RETIRE ]====================================== |
---|
| 103 | // ===================================================== |
---|
| 104 | for (uint32_t i=0; i<_param->_nb_inst_retire; i++) |
---|
| 105 | if (PORT_READ(in_RETIRE_VAL [i]) and internal_RETIRE_ACK [i]) |
---|
| 106 | { |
---|
[110] | 107 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," * RETIRE [%d]",i); |
---|
[78] | 108 | |
---|
| 109 | switch (internal_RETIRE_OPERATION_USE [i]) |
---|
| 110 | { |
---|
| 111 | case OPERATION_USE_STORE_QUEUE : |
---|
| 112 | { |
---|
[110] | 113 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," * use STORE_QUEUE"); |
---|
[78] | 114 | |
---|
| 115 | uint32_t lsq = internal_RETIRE_LSQ [i]; |
---|
| 116 | Tlsq_ptr_t ptr = internal_RETIRE_PTR [i]; |
---|
| 117 | |
---|
[110] | 118 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," * lsq : %d",lsq); |
---|
| 119 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," * ptr : %d",ptr); |
---|
[122] | 120 | |
---|
| 121 | // TODO : if ROB retire ooo context, can retire store ooo. |
---|
| 122 | |
---|
[78] | 123 | // reg_STORE_QUEUE_PTR_WRITE [lsq] = ((ptr==0)?_param->_size_store_queue[lsq]:ptr)-1; |
---|
| 124 | reg_STORE_QUEUE_NB_USE [lsq] --; |
---|
| 125 | reg_STORE_QUEUE_USE [lsq][ptr] = false; |
---|
| 126 | |
---|
| 127 | break; |
---|
| 128 | } |
---|
| 129 | case OPERATION_USE_LOAD_QUEUE : |
---|
| 130 | { |
---|
[110] | 131 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," * use LOAD_QUEUE"); |
---|
[78] | 132 | |
---|
| 133 | uint32_t lsq = internal_RETIRE_LSQ [i]; |
---|
| 134 | Tlsq_ptr_t ptr = internal_RETIRE_PTR [i]; |
---|
| 135 | |
---|
[110] | 136 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," * lsq : %d",lsq); |
---|
| 137 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," * ptr : %d",ptr); |
---|
[78] | 138 | |
---|
| 139 | // reg_LOAD_QUEUE_PTR_WRITE [lsq] = ((ptr==0)?_param->_size_load_queue[lsq]:ptr)-1; |
---|
| 140 | reg_LOAD_QUEUE_USE [lsq][ptr] = false; |
---|
| 141 | |
---|
| 142 | break; |
---|
| 143 | } |
---|
| 144 | default : |
---|
| 145 | { |
---|
| 146 | break; |
---|
| 147 | } |
---|
| 148 | } |
---|
| 149 | } |
---|
[122] | 150 | |
---|
| 151 | for (uint32_t i=0; i<_param->_nb_front_end; ++i) |
---|
| 152 | for (uint32_t j=0; j<_param->_nb_context[i]; ++j) |
---|
| 153 | { |
---|
| 154 | uint32_t lsq = _param->_link_load_store_unit_with_thread[i][j]; |
---|
| 155 | |
---|
| 156 | if (PORT_READ(in_RETIRE_EVENT_STATE [i][j]) == EVENT_STATE_NO_EVENT) |
---|
| 157 | { |
---|
| 158 | uint32_t ptr_old = reg_STORE_QUEUE_PTR_READ[i][j]; |
---|
| 159 | uint32_t ptr_new = (reg_STORE_QUEUE_PTR_READ[i][j]+1)%_param->_size_store_queue[lsq]; |
---|
| 160 | |
---|
| 161 | if ((reg_STORE_QUEUE_USE [lsq][ptr_old] == false) and |
---|
| 162 | (reg_STORE_QUEUE_EMPTY [i][j] == false)) |
---|
| 163 | { |
---|
| 164 | reg_STORE_QUEUE_PTR_READ [i][j] = ptr_new; |
---|
| 165 | if (ptr_new == reg_STORE_QUEUE_PTR_WRITE [lsq]) |
---|
| 166 | reg_STORE_QUEUE_EMPTY [i][j] = true; |
---|
| 167 | } |
---|
| 168 | } |
---|
| 169 | |
---|
| 170 | if (PORT_READ(in_RETIRE_EVENT_VAL[i][j]) and internal_RETIRE_EVENT_ACK [i][j]) |
---|
| 171 | if (PORT_READ(in_RETIRE_EVENT_STATE [i][j]) == EVENT_STATE_EVENT) |
---|
| 172 | { |
---|
| 173 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," * EVENT [%d][%d]",i,j); |
---|
| 174 | |
---|
| 175 | // reset ptr_read |
---|
| 176 | reg_STORE_QUEUE_PTR_READ [i][j] = reg_STORE_QUEUE_PTR_WRITE [lsq]; |
---|
| 177 | reg_STORE_QUEUE_EMPTY [i][j] = true; |
---|
| 178 | } |
---|
| 179 | } |
---|
[78] | 180 | } |
---|
[122] | 181 | |
---|
[110] | 182 | // =================================================================== |
---|
| 183 | // =====[ OTHER ]===================================================== |
---|
| 184 | // =================================================================== |
---|
[78] | 185 | |
---|
[110] | 186 | #if (DEBUG >= DEBUG_TRACE) and (DEBUG_Commit_unit == true) |
---|
| 187 | { |
---|
| 188 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," * Dump Load_Store_pointer Unit"); |
---|
| 189 | |
---|
| 190 | for (uint32_t i=0; i<_param->_nb_load_store_queue; ++i) |
---|
| 191 | { |
---|
| 192 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," * Load_Store_unit [%d]",i); |
---|
[122] | 193 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," * reg_LOAD_QUEUE_PTR_WRITE : %d", reg_LOAD_QUEUE_PTR_WRITE [i]); |
---|
| 194 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," * reg_LOAD_QUEUE_USE :"); |
---|
| 195 | for (uint32_t j=0; j<_param->_size_load_queue [i]; ++j) |
---|
| 196 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," [%d] %d",j,reg_LOAD_QUEUE_USE [i][j]); |
---|
[110] | 197 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," * reg_STORE_QUEUE_NB_USE : %d", reg_STORE_QUEUE_NB_USE [i]); |
---|
| 198 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," * reg_STORE_QUEUE_PTR_WRITE : %d", reg_STORE_QUEUE_PTR_WRITE[i]); |
---|
| 199 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," * reg_STORE_QUEUE_USE :"); |
---|
| 200 | for (uint32_t j=0; j<_param->_size_store_queue [i]; ++j) |
---|
| 201 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," [%d] %d",j,reg_STORE_QUEUE_USE [i][j]); |
---|
| 202 | } |
---|
[122] | 203 | for (uint32_t i=0; i<_param->_nb_front_end; ++i) |
---|
| 204 | for (uint32_t j=0; j<_param->_nb_context[i]; ++j) |
---|
| 205 | { |
---|
| 206 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," * reg_STORE_QUEUE_PTR_READ [%d][%d] : %d",i,j,reg_STORE_QUEUE_PTR_READ [i][j]); |
---|
| 207 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," * reg_STORE_QUEUE_EMPTY [%d][%d] : %d",i,j,reg_STORE_QUEUE_EMPTY [i][j]); |
---|
| 208 | } |
---|
[110] | 209 | } |
---|
| 210 | #endif |
---|
[78] | 211 | |
---|
| 212 | #if defined(STATISTICS) or defined(VHDL_TESTBENCH) |
---|
| 213 | end_cycle (); |
---|
| 214 | #endif |
---|
| 215 | |
---|
[110] | 216 | log_end(Load_Store_pointer_unit,FUNCTION); |
---|
[78] | 217 | }; |
---|
| 218 | |
---|
| 219 | }; // end namespace load_store_pointer_unit |
---|
| 220 | }; // end namespace rename_unit |
---|
| 221 | }; // end namespace ooo_engine |
---|
| 222 | }; // end namespace multi_ooo_engine |
---|
| 223 | }; // end namespace core |
---|
| 224 | |
---|
| 225 | }; // end namespace behavioural |
---|
| 226 | }; // end namespace morpheo |
---|
| 227 | #endif |
---|