[55] | 1 | #ifdef SYSTEMC |
---|
| 2 | //#if defined(STATISTICS) or defined(VHDL_TESTBENCH) |
---|
| 3 | /* |
---|
| 4 | * $Id: Reservation_station_transition.cpp 98 2008-12-31 10:18:08Z rosiere $ |
---|
| 5 | * |
---|
| 6 | * [ Description ] |
---|
| 7 | * |
---|
| 8 | */ |
---|
| 9 | |
---|
| 10 | #include "Behavioural/Core/Multi_Execute_loop/Execute_loop/Multi_Read_unit/Read_unit/Reservation_station/include/Reservation_station.h" |
---|
| 11 | |
---|
| 12 | namespace morpheo { |
---|
| 13 | namespace behavioural { |
---|
| 14 | namespace core { |
---|
| 15 | namespace multi_execute_loop { |
---|
| 16 | namespace execute_loop { |
---|
| 17 | namespace multi_read_unit { |
---|
| 18 | namespace read_unit { |
---|
| 19 | namespace reservation_station { |
---|
| 20 | |
---|
[69] | 21 | #ifdef SYSTEMC_VHDL_COMPATIBILITY |
---|
[88] | 22 | #define dump_queue() \ |
---|
| 23 | do \ |
---|
| 24 | { \ |
---|
| 25 | log_printf(TRACE,Reservation_station,FUNCTION," * Dump Reservation Station"); \ |
---|
| 26 | for (uint32_t it_dump=0;it_dump<_param->_size_queue; it_dump++) \ |
---|
[98] | 27 | if (_queue_valid [it_dump]) \ |
---|
| 28 | log_printf(TRACE,Reservation_station,FUNCTION," * [%.4d] %.2d %.2d %.2d %.4d, %.2d %.3d, %.2d %.2d, %.1d %.8x, %.4d %.1d %.8x, %.4d %.1d %.8x, %.4d %.1d %.2x, %.1d %.4d, %.1d %.4d (%s)", \ |
---|
| 29 | it_dump, \ |
---|
| 30 | _queue[it_dump]._context_id , \ |
---|
| 31 | _queue[it_dump]._front_end_id , \ |
---|
| 32 | _queue[it_dump]._ooo_engine_id , \ |
---|
| 33 | _queue[it_dump]._rob_id , \ |
---|
| 34 | _queue[it_dump]._type , \ |
---|
| 35 | _queue[it_dump]._operation , \ |
---|
| 36 | _queue[it_dump]._store_queue_ptr_write, \ |
---|
| 37 | _queue[it_dump]._load_queue_ptr_write , \ |
---|
| 38 | _queue[it_dump]._has_immediat , \ |
---|
| 39 | _queue[it_dump]._immediat , \ |
---|
| 40 | _queue[it_dump]._num_reg_ra , \ |
---|
| 41 | _queue[it_dump]._data_ra_val , \ |
---|
| 42 | _queue[it_dump]._data_ra , \ |
---|
| 43 | _queue[it_dump]._num_reg_rb , \ |
---|
| 44 | _queue[it_dump]._data_rb_val , \ |
---|
| 45 | _queue[it_dump]._data_rb , \ |
---|
| 46 | _queue[it_dump]._num_reg_rc , \ |
---|
| 47 | _queue[it_dump]._data_rc_val , \ |
---|
| 48 | _queue[it_dump]._data_rc , \ |
---|
| 49 | _queue[it_dump]._write_rd , \ |
---|
| 50 | _queue[it_dump]._num_reg_rd , \ |
---|
| 51 | _queue[it_dump]._write_re , \ |
---|
| 52 | _queue[it_dump]._num_reg_re , \ |
---|
| 53 | toString(_queue[it_dump]._type).c_str()); \ |
---|
[88] | 54 | } while (0) |
---|
[69] | 55 | #else |
---|
[88] | 56 | #define dump_queue() \ |
---|
| 57 | do \ |
---|
| 58 | { \ |
---|
| 59 | log_printf(TRACE,Reservation_station,FUNCTION," * Dump Reservation Station"); \ |
---|
| 60 | log_printf(TRACE,Reservation_station,FUNCTION," * nb_elt : %d",_queue_control->nb_elt()); \ |
---|
| 61 | for (uint32_t it_dump=0;it_dump<_param->_size_queue; it_dump++) \ |
---|
| 62 | log_printf(TRACE,Reservation_station,FUNCTION," * [%.4d] %.2d %.2d %.2d %.4d, %.2d %.3d, %.2d %.2d, %.1d %.8x, %.4d %.1d %.8x, %.4d %.1d %.8x, %.4d %.1d %.2x, %.1d %.4d, %.1d %.4d (%s)", \ |
---|
| 63 | (*_queue_control)[it_dump], \ |
---|
| 64 | _queue[(*_queue_control)[it_dump]]._context_id , \ |
---|
| 65 | _queue[(*_queue_control)[it_dump]]._front_end_id , \ |
---|
| 66 | _queue[(*_queue_control)[it_dump]]._ooo_engine_id , \ |
---|
| 67 | _queue[(*_queue_control)[it_dump]]._rob_id , \ |
---|
| 68 | _queue[(*_queue_control)[it_dump]]._type , \ |
---|
| 69 | _queue[(*_queue_control)[it_dump]]._operation , \ |
---|
| 70 | _queue[(*_queue_control)[it_dump]]._store_queue_ptr_write, \ |
---|
| 71 | _queue[(*_queue_control)[it_dump]]._load_queue_ptr_write , \ |
---|
| 72 | _queue[(*_queue_control)[it_dump]]._has_immediat , \ |
---|
| 73 | _queue[(*_queue_control)[it_dump]]._immediat , \ |
---|
| 74 | _queue[(*_queue_control)[it_dump]]._num_reg_ra , \ |
---|
| 75 | _queue[(*_queue_control)[it_dump]]._data_ra_val , \ |
---|
| 76 | _queue[(*_queue_control)[it_dump]]._data_ra , \ |
---|
| 77 | _queue[(*_queue_control)[it_dump]]._num_reg_rb , \ |
---|
| 78 | _queue[(*_queue_control)[it_dump]]._data_rb_val , \ |
---|
| 79 | _queue[(*_queue_control)[it_dump]]._data_rb , \ |
---|
| 80 | _queue[(*_queue_control)[it_dump]]._num_reg_rc , \ |
---|
| 81 | _queue[(*_queue_control)[it_dump]]._data_rc_val , \ |
---|
| 82 | _queue[(*_queue_control)[it_dump]]._data_rc , \ |
---|
| 83 | _queue[(*_queue_control)[it_dump]]._write_rd , \ |
---|
| 84 | _queue[(*_queue_control)[it_dump]]._num_reg_rd , \ |
---|
| 85 | _queue[(*_queue_control)[it_dump]]._write_re , \ |
---|
| 86 | _queue[(*_queue_control)[it_dump]]._num_reg_re , \ |
---|
[97] | 87 | toString(_queue[(*_queue_control)[it_dump]]._type).c_str()); \ |
---|
[88] | 88 | } while (0) |
---|
[69] | 89 | #endif |
---|
[55] | 90 | |
---|
| 91 | #undef FUNCTION |
---|
| 92 | #define FUNCTION "Reservation_station::transition" |
---|
| 93 | void Reservation_station::transition (void) |
---|
| 94 | { |
---|
[88] | 95 | log_begin(Reservation_station,FUNCTION); |
---|
| 96 | log_function(Reservation_station,FUNCTION,_name.c_str()); |
---|
[55] | 97 | |
---|
| 98 | if (PORT_READ(in_NRESET) == 0) |
---|
| 99 | { |
---|
[69] | 100 | #ifdef SYSTEMC_VHDL_COMPATIBILITY |
---|
| 101 | for (uint32_t i=0; i<_param->_size_queue; i++) |
---|
| 102 | _queue_valid [i] = false; |
---|
| 103 | #else |
---|
[55] | 104 | _queue_control->clear(); |
---|
[69] | 105 | #endif |
---|
[55] | 106 | } |
---|
| 107 | else |
---|
| 108 | { |
---|
| 109 | // ***** POP from reservation station |
---|
| 110 | |
---|
| 111 | // scan in reverse order, because when we pop the queue there are an auto reorder |
---|
[69] | 112 | //for (int32_t i=(static_cast<int32_t>(_queue_control->nb_elt()))-1;i>=0; i--) |
---|
| 113 | for (int32_t i=(static_cast<int32_t>(_param->_nb_inst_retire))-1;i>=0; i--) |
---|
[55] | 114 | { |
---|
[69] | 115 | if (( internal_RETIRE_VAL [i] == 1) and |
---|
| 116 | (PORT_READ(in_RETIRE_ACK [i]) == 1)) |
---|
[55] | 117 | { |
---|
[69] | 118 | //uint32_t index = (*_queue_control)[i]; |
---|
| 119 | |
---|
[88] | 120 | log_printf(NONE,Reservation_station,FUNCTION," * POP [%d]",i); |
---|
[55] | 121 | |
---|
[69] | 122 | uint32_t index = internal_RETIRE_SLOT[i]; |
---|
[55] | 123 | |
---|
[69] | 124 | #ifdef SYSTEMC_VHDL_COMPATIBILITY |
---|
| 125 | _queue_valid [index] = false; |
---|
| 126 | #else |
---|
| 127 | _queue_control->pop(index); |
---|
| 128 | #endif |
---|
[70] | 129 | // cout << "========== Transition : " << endl |
---|
| 130 | // << " * i : " << i << endl |
---|
| 131 | // << " * index : " << index << endl; |
---|
| 132 | |
---|
[88] | 133 | log_printf(NONE,Reservation_station,FUNCTION," * index : %d",index); |
---|
[55] | 134 | } |
---|
| 135 | } |
---|
[70] | 136 | |
---|
| 137 | // dump_queue(); |
---|
[55] | 138 | |
---|
| 139 | // ***** Bypass |
---|
| 140 | // Note : we can take this sequence code before the PUSH in the queue, because read_queue make the bypass !!! |
---|
| 141 | |
---|
| 142 | // scan all entry |
---|
[69] | 143 | for (uint32_t i=0; |
---|
| 144 | #ifdef SYSTEMC_VHDL_COMPATIBILITY |
---|
| 145 | i<_param->_size_queue; |
---|
| 146 | #else |
---|
| 147 | i<_queue_control->nb_elt(); |
---|
| 148 | #endif |
---|
| 149 | i++) |
---|
[55] | 150 | { |
---|
[69] | 151 | uint32_t index; |
---|
| 152 | #ifdef SYSTEMC_VHDL_COMPATIBILITY |
---|
| 153 | index = i; |
---|
| 154 | #else |
---|
| 155 | index = (*_queue_control)[i]; |
---|
| 156 | #endif |
---|
[55] | 157 | |
---|
| 158 | // ***** bypass - gpr_write |
---|
| 159 | for (uint32_t j=0; j<_param->_nb_gpr_write; j++) |
---|
| 160 | { |
---|
[69] | 161 | bool cmp; |
---|
| 162 | if (_param->_have_port_ooo_engine_id) |
---|
| 163 | cmp = (PORT_READ(in_GPR_WRITE_OOO_ENGINE_ID [j]) == _queue[index]._ooo_engine_id); |
---|
| 164 | else |
---|
| 165 | cmp = true; |
---|
| 166 | |
---|
| 167 | if ((PORT_READ(in_GPR_WRITE_VAL [j]) == 1) and cmp) |
---|
[55] | 168 | { |
---|
| 169 | if (PORT_READ(in_GPR_WRITE_NUM_REG [j]) == _queue[index]._num_reg_ra) |
---|
| 170 | { |
---|
[88] | 171 | log_printf(TRACE,Reservation_station,FUNCTION," -> GPR_WRITE [%d] - Hit queue[%d]-GPR_RA[%d]",i,index,_queue[index]._num_reg_ra); |
---|
[55] | 172 | _queue[index]._data_ra_val = 1; |
---|
| 173 | _queue[index]._data_ra = PORT_READ(in_GPR_WRITE_DATA [j]); |
---|
| 174 | } |
---|
| 175 | if (PORT_READ(in_GPR_WRITE_NUM_REG [j]) == _queue[index]._num_reg_rb) |
---|
| 176 | { |
---|
[88] | 177 | log_printf(TRACE,Reservation_station,FUNCTION," -> GPR_WRITE [%d] - Hit queue[%d]-GPR_RB[%d]",i,index,_queue[index]._num_reg_rb); |
---|
[55] | 178 | _queue[index]._data_rb_val = 1; |
---|
| 179 | _queue[index]._data_rb = PORT_READ(in_GPR_WRITE_DATA [j]); |
---|
| 180 | } |
---|
| 181 | } |
---|
| 182 | } |
---|
| 183 | // ***** bypass - spr_write |
---|
| 184 | for (uint32_t j=0; j<_param->_nb_spr_write; j++) |
---|
| 185 | { |
---|
[69] | 186 | bool cmp; |
---|
| 187 | if (_param->_have_port_ooo_engine_id) |
---|
| 188 | cmp = (PORT_READ(in_SPR_WRITE_OOO_ENGINE_ID [j]) == _queue[index]._ooo_engine_id); |
---|
| 189 | else |
---|
| 190 | cmp = true; |
---|
| 191 | |
---|
| 192 | if ((PORT_READ(in_SPR_WRITE_VAL [j]) == 1) and |
---|
| 193 | cmp and |
---|
| 194 | (PORT_READ(in_SPR_WRITE_NUM_REG [j]) == _queue[index]._num_reg_rc)) |
---|
[55] | 195 | { |
---|
[88] | 196 | log_printf(TRACE,Reservation_station,FUNCTION," -> SPR_WRITE [%d] - Hit queue[%d]-SPR_RC[%d]",i,index,_queue[index]._num_reg_rc); |
---|
[55] | 197 | _queue[index]._data_rc_val = 1; |
---|
| 198 | _queue[index]._data_rc = PORT_READ(in_SPR_WRITE_DATA [j]); |
---|
| 199 | } |
---|
| 200 | } |
---|
| 201 | // ***** bypass - bypass_write |
---|
| 202 | for (uint32_t j=0; j<_param->_nb_bypass_write; j++) |
---|
| 203 | { |
---|
[69] | 204 | bool cmp; |
---|
| 205 | if (_param->_have_port_ooo_engine_id) |
---|
| 206 | cmp = (PORT_READ(in_BYPASS_WRITE_OOO_ENGINE_ID [j]) == _queue[index]._ooo_engine_id); |
---|
| 207 | else |
---|
| 208 | cmp = true; |
---|
| 209 | |
---|
| 210 | if (cmp) |
---|
[55] | 211 | { |
---|
| 212 | if (PORT_READ(in_BYPASS_WRITE_GPR_VAL [j]) == 1) |
---|
| 213 | { |
---|
| 214 | if (PORT_READ(in_BYPASS_WRITE_GPR_NUM_REG[j]) == _queue[index]._num_reg_ra) |
---|
| 215 | { |
---|
[88] | 216 | log_printf(TRACE,Reservation_station,FUNCTION," -> BYPASS_WRITE [%d] - Hit queue[%d]-GPR_RA[%d]",i,index,_queue[index]._num_reg_ra); |
---|
[55] | 217 | _queue[index]._data_ra_val = 1; |
---|
| 218 | _queue[index]._data_ra = PORT_READ(in_BYPASS_WRITE_GPR_DATA [j]); |
---|
| 219 | } |
---|
| 220 | if (PORT_READ(in_BYPASS_WRITE_GPR_NUM_REG [j]) == _queue[index]._num_reg_rb) |
---|
| 221 | { |
---|
[88] | 222 | log_printf(TRACE,Reservation_station,FUNCTION," -> BYPASS_WRITE [%d] - Hit queue[%d]-GPR_RB[%d]",i,index,_queue[index]._num_reg_rb); |
---|
[55] | 223 | _queue[index]._data_rb_val = 1; |
---|
| 224 | _queue[index]._data_rb = PORT_READ(in_BYPASS_WRITE_GPR_DATA [j]); |
---|
| 225 | } |
---|
| 226 | } |
---|
| 227 | if ((PORT_READ(in_BYPASS_WRITE_SPR_VAL [j]) == 1) and |
---|
| 228 | (PORT_READ(in_BYPASS_WRITE_SPR_NUM_REG[j]) == _queue[index]._num_reg_rc)) |
---|
| 229 | { |
---|
[88] | 230 | log_printf(TRACE,Reservation_station,FUNCTION," -> BYPASS_WRITE [%d] - Hit queue[%d]-SPR_RC[%d]",i,index,_queue[index]._num_reg_rc); |
---|
[55] | 231 | _queue[index]._data_rc_val = 1; |
---|
| 232 | _queue[index]._data_rc = PORT_READ(in_BYPASS_WRITE_SPR_DATA [j]); |
---|
| 233 | } |
---|
| 234 | } |
---|
| 235 | } |
---|
| 236 | // ***** bypass - bypass_memory |
---|
| 237 | for (uint32_t j=0; j<_param->_nb_bypass_memory; j++) |
---|
| 238 | { |
---|
[69] | 239 | bool cmp; |
---|
| 240 | if (_param->_have_port_ooo_engine_id) |
---|
| 241 | cmp = (PORT_READ(in_BYPASS_MEMORY_OOO_ENGINE_ID [j]) == _queue[index]._ooo_engine_id); |
---|
| 242 | else |
---|
| 243 | cmp = true; |
---|
| 244 | |
---|
| 245 | if ((PORT_READ(in_BYPASS_MEMORY_VAL [j]) == 1) and cmp) |
---|
[55] | 246 | { |
---|
| 247 | if (PORT_READ(in_BYPASS_MEMORY_NUM_REG [j]) == _queue[index]._num_reg_ra) |
---|
| 248 | { |
---|
[88] | 249 | log_printf(TRACE,Reservation_station,FUNCTION," -> BYPASS_MEMORY [%d] - Hit queue[%d]-GPR_RA[%d]",i,index,_queue[index]._num_reg_ra); |
---|
[55] | 250 | _queue[index]._data_ra_val = 1; |
---|
| 251 | _queue[index]._data_ra = PORT_READ(in_BYPASS_MEMORY_DATA [j]); |
---|
| 252 | } |
---|
| 253 | if (PORT_READ(in_BYPASS_MEMORY_NUM_REG [j]) == _queue[index]._num_reg_rb) |
---|
| 254 | { |
---|
[88] | 255 | log_printf(TRACE,Reservation_station,FUNCTION," -> BYPASS_MEMORY [%d] - Hit queue[%d]-GPR_RB[%d]",i,index,_queue[index]._num_reg_rb); |
---|
[55] | 256 | _queue[index]._data_rb_val = 1; |
---|
| 257 | _queue[index]._data_rb = PORT_READ(in_BYPASS_MEMORY_DATA [j]); |
---|
| 258 | } |
---|
| 259 | } |
---|
| 260 | } |
---|
| 261 | } |
---|
[69] | 262 | // ***** PUSH to reservation station |
---|
| 263 | if ((PORT_READ(in_INSERT_VAL) == 1) and |
---|
| 264 | ( internal_INSERT_ACK == 1)) |
---|
| 265 | { |
---|
[88] | 266 | log_printf(TRACE,Reservation_station,FUNCTION," * PUSH"); |
---|
[55] | 267 | |
---|
[69] | 268 | // Write in reservation station |
---|
| 269 | uint32_t index; |
---|
[55] | 270 | |
---|
[69] | 271 | #ifdef SYSTEMC_VHDL_COMPATIBILITY |
---|
| 272 | index = internal_INSERT_SLOT; |
---|
| 273 | _queue_valid [internal_INSERT_SLOT] = true; |
---|
| 274 | #else |
---|
| 275 | index = _queue_control->push(); |
---|
[55] | 276 | #endif |
---|
[88] | 277 | log_printf(TRACE,Reservation_station,FUNCTION," * index : %d",index); |
---|
[55] | 278 | |
---|
[69] | 279 | if (_param->_have_port_context_id) |
---|
| 280 | _queue[index]._context_id = PORT_READ(in_INSERT_CONTEXT_ID ); |
---|
| 281 | if (_param->_have_port_front_end_id) |
---|
| 282 | _queue[index]._front_end_id = PORT_READ(in_INSERT_FRONT_END_ID ); |
---|
| 283 | if (_param->_have_port_ooo_engine_id) |
---|
| 284 | _queue[index]._ooo_engine_id = PORT_READ(in_INSERT_OOO_ENGINE_ID ); |
---|
[88] | 285 | if (_param->_have_port_rob_ptr) |
---|
[69] | 286 | _queue[index]._rob_id = PORT_READ(in_INSERT_ROB_ID ); |
---|
| 287 | _queue[index]._operation = PORT_READ(in_INSERT_OPERATION ); |
---|
| 288 | _queue[index]._type = PORT_READ(in_INSERT_TYPE ); |
---|
[76] | 289 | _queue[index]._store_queue_ptr_write = PORT_READ(in_INSERT_STORE_QUEUE_PTR_WRITE); |
---|
[78] | 290 | if (_param->_have_port_load_queue_ptr) |
---|
[76] | 291 | _queue[index]._load_queue_ptr_write = PORT_READ(in_INSERT_LOAD_QUEUE_PTR_WRITE ); |
---|
[69] | 292 | _queue[index]._has_immediat = PORT_READ(in_INSERT_HAS_IMMEDIAT ); |
---|
| 293 | _queue[index]._immediat = PORT_READ(in_INSERT_IMMEDIAT ); |
---|
| 294 | // _queue[index]._read_ra = PORT_READ(in_INSERT_READ_RA ); |
---|
| 295 | _queue[index]._num_reg_ra = PORT_READ(in_INSERT_NUM_REG_RA ); |
---|
| 296 | _queue[index]._data_ra_val = PORT_READ(in_INSERT_DATA_RA_VAL ); |
---|
| 297 | _queue[index]._data_ra = PORT_READ(in_INSERT_DATA_RA ); |
---|
| 298 | // _queue[index]._read_rb = PORT_READ(in_INSERT_READ_RB ); |
---|
| 299 | _queue[index]._num_reg_rb = PORT_READ(in_INSERT_NUM_REG_RB ); |
---|
| 300 | _queue[index]._data_rb_val = PORT_READ(in_INSERT_DATA_RB_VAL ); |
---|
| 301 | _queue[index]._data_rb = PORT_READ(in_INSERT_DATA_RB ); |
---|
| 302 | // _queue[index]._read_rc = PORT_READ(in_INSERT_READ_RC ); |
---|
| 303 | _queue[index]._num_reg_rc = PORT_READ(in_INSERT_NUM_REG_RC ); |
---|
| 304 | _queue[index]._data_rc_val = PORT_READ(in_INSERT_DATA_RC_VAL ); |
---|
| 305 | _queue[index]._data_rc = PORT_READ(in_INSERT_DATA_RC ); |
---|
| 306 | _queue[index]._write_rd = PORT_READ(in_INSERT_WRITE_RD ); |
---|
| 307 | _queue[index]._num_reg_rd = PORT_READ(in_INSERT_NUM_REG_RD ); |
---|
| 308 | _queue[index]._write_re = PORT_READ(in_INSERT_WRITE_RE ); |
---|
| 309 | _queue[index]._num_reg_re = PORT_READ(in_INSERT_NUM_REG_RE ); |
---|
| 310 | // dump_queue(); |
---|
| 311 | } |
---|
| 312 | } |
---|
| 313 | |
---|
[88] | 314 | dump_queue(); |
---|
| 315 | |
---|
[69] | 316 | end_cycle (); |
---|
| 317 | |
---|
[88] | 318 | log_end(Reservation_station,FUNCTION); |
---|
[55] | 319 | }; |
---|
| 320 | |
---|
| 321 | }; // end namespace reservation_station |
---|
| 322 | }; // end namespace read_unit |
---|
| 323 | }; // end namespace multi_read_unit |
---|
| 324 | }; // end namespace execute_loop |
---|
| 325 | }; // end namespace multi_execute_loop |
---|
| 326 | }; // end namespace core |
---|
| 327 | |
---|
| 328 | }; // end namespace behavioural |
---|
| 329 | }; // end namespace morpheo |
---|
| 330 | #endif |
---|
| 331 | //#endif |
---|