Changeset 62 for trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Execute_loop/Execute_loop/Multi_Execute_unit/Execute_unit/Load_store_unit/SelfTest/src/test.cpp
- Timestamp:
- Dec 4, 2007, 2:31:54 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Execute_loop/Execute_loop/Multi_Execute_unit/Execute_unit/Load_store_unit/SelfTest/src/test.cpp
r59 r62 10 10 #include "Behavioural/Core/Multi_Execute_loop/Execute_loop/Multi_Execute_unit/Execute_unit/Load_store_unit/SelfTest/include/test.h" 11 11 #include "Common/include/Test.h" 12 #include "Common/include/BitManipulation.h" 12 13 13 14 #define NB_ITERATION 1 … … 43 44 44 45 46 //========================================================={MemoryRequest_t} 45 47 class MemoryRequest_t 46 48 { … … 146 148 return os << "<" << toString(x._cycle) << "> : " 147 149 << "{" << toString(static_cast<uint32_t>(x._packet_id)) << "}" << endl 148 << "\t * " << toString(static_cast<uint32_t>(x._context_id)) << endl149 << "\t * " << toString(static_cast<uint32_t>(x._operation)) << " " << toString(static_cast<uint32_t>(x._type)) << " " << toString(static_cast<uint32_t>(x._write_spec_ko)) << endl150 << "\t * " << toString(static_cast<uint32_t>(x._store_queue_ptr_write)) << " " << toString(static_cast<uint32_t>(x._load_queue_ptr_write)) << endl151 << "\t * " << toString(static_cast<uint32_t>(x._immediat)) << " - " << toString(static_cast<uint32_t>(x._data_ra)) << " - " << toString(static_cast<uint32_t>(x._data_rb)) << endl152 << "\t * " << toString(static_cast<uint32_t>(x._write_rd)) << " " << toString(static_cast<uint32_t>(x._num_reg_rd)) << endl;150 << "\t * context_id : " << toString(static_cast<uint32_t>(x._context_id)) << endl 151 << "\t * operation / type / write_spec_ko : " << toString(static_cast<uint32_t>(x._operation)) << " " << toString(static_cast<uint32_t>(x._type)) << " " << toString(static_cast<uint32_t>(x._write_spec_ko)) << endl 152 << "\t * ptr_write store/load : " << toString(static_cast<uint32_t>(x._store_queue_ptr_write)) << " " << toString(static_cast<uint32_t>(x._load_queue_ptr_write)) << endl 153 << "\t * immediat / data_ra / data_rb : " << toString(static_cast<uint32_t>(x._immediat)) << " - " << toString(static_cast<uint32_t>(x._data_ra)) << " - " << toString(static_cast<uint32_t>(x._data_rb)) << endl 154 << "\t * write_rd / num_reg_rd : " << toString(static_cast<uint32_t>(x._write_rd)) << " " << toString(static_cast<uint32_t>(x._num_reg_rd)) << endl; 153 155 } 154 156 157 //================================================================{Memory_t} 158 class Memory_t 159 { 160 private : const uint32_t _nb_context; 161 private : const uint32_t _nb_word ; 162 private : const uint32_t _size_data ; 163 private : const Tdcache_address_t _mask_addr ; 164 private : Tdcache_data_t ** _data; 165 166 public : Memory_t (uint32_t nb_context, 167 uint32_t nb_word, 168 uint32_t size_data): 169 _nb_context (nb_context), 170 _nb_word (nb_word ), 171 _size_data (size_data ), 172 _mask_addr (gen_mask<Tdcache_address_t>(static_cast<uint32_t>(log2(ceil(static_cast<double>(size_data)))))) 173 { 174 _data = new Tdcache_data_t * [nb_context]; 175 176 for (uint32_t i=0; i<nb_context; i++) 177 { 178 _data [i] = new Tdcache_data_t [nb_word]; 179 180 for (uint32_t j=0; j<nb_word; j++) 181 _data [i][j] = rand()%(size_data); 182 } 183 } 184 185 public : ~Memory_t (void) 186 { 187 delete [] _data; 188 } 189 190 public : Tdcache_data_t access (uint32_t context, 191 Tdcache_address_t address, 192 Tdcache_type_t type, 193 Tdcache_data_t data) 194 { 195 return 0; 196 } 197 198 public : Tdcache_data_t read (uint32_t context, 199 Tdcache_address_t address, 200 Tdcache_type_t type) 201 { 202 // Address's Read must be aligned 203 204 if ((address & _mask_addr) != 0) 205 TEST_KO("<Memory_t::read> Address is not aligned"); 206 207 if (context>_nb_context) 208 TEST_KO("<Memory_t::read> nb context is too high"); 209 210 if (address>_nb_word) 211 TEST_KO("<Memory_t::read> address is too high"); 212 213 return _data [context][address]; 214 } 215 216 public : void write (uint32_t context, 217 Tdcache_address_t address, 218 Tdcache_type_t type, 219 Tdcache_data_t data) 220 { 221 if (context>_nb_context) 222 TEST_KO("<Memory_t::read> nb context is too high"); 223 224 if (address>_nb_word) 225 TEST_KO("<Memory_t::read> address is too high"); 226 227 Tdcache_address_t LSB = address & _mask; 228 Tdcache_address_t MSB = address & ~_mask; 229 230 Tdcache_data_t write_data = data; 231 Tdcache_data_t read_data = _data [context][MSB]; 232 233 // exemple to size_data = 32b 234 // LSB index_min 235 // 0 0 236 // 1 8 237 // 2 16 238 // 3 24 239 uint32_t index_min = LSB<<3; 240 uint32_t index_max = index_min; 241 // index max, dependant of access's size 242 243 switch (type) 244 { 245 246 247 } 248 } 249 }; 250 251 //===================================================================={test} 155 252 void test (string name, 156 253 morpheo::behavioural::core::multi_execute_loop::execute_loop::multi_execute_unit::execute_unit::load_store_unit::Parameters * _param) … … 252 349 (*(_Load_store_unit-> in_MEMORY_IN_PACKET_ID ))(*( in_MEMORY_IN_PACKET_ID )); 253 350 (*(_Load_store_unit-> in_MEMORY_IN_OPERATION ))(*( in_MEMORY_IN_OPERATION )); 254 (*(_Load_store_unit-> in_MEMORY_IN_TYPE ))(*( in_MEMORY_IN_TYPE ));255 351 (*(_Load_store_unit-> in_MEMORY_IN_STORE_QUEUE_PTR_WRITE))(*( in_MEMORY_IN_STORE_QUEUE_PTR_WRITE)); 256 352 (*(_Load_store_unit-> in_MEMORY_IN_LOAD_QUEUE_PTR_WRITE ))(*( in_MEMORY_IN_LOAD_QUEUE_PTR_WRITE )); … … 269 365 (*(_Load_store_unit->out_MEMORY_OUT_CONTEXT_ID ))(*(out_MEMORY_OUT_CONTEXT_ID )); 270 366 (*(_Load_store_unit->out_MEMORY_OUT_PACKET_ID ))(*(out_MEMORY_OUT_PACKET_ID )); 271 (*(_Load_store_unit->out_MEMORY_OUT_OPERATION ))(*(out_MEMORY_OUT_OPERATION ));272 (*(_Load_store_unit->out_MEMORY_OUT_TYPE ))(*(out_MEMORY_OUT_TYPE ));273 367 (*(_Load_store_unit->out_MEMORY_OUT_WRITE_RD ))(*(out_MEMORY_OUT_WRITE_RD )); 274 368 (*(_Load_store_unit->out_MEMORY_OUT_NUM_REG_RD ))(*(out_MEMORY_OUT_NUM_REG_RD )); … … 322 416 const uint32_t nb_word = nb_request; 323 417 324 const uint32_t cst_max_cycle = 2; 325 326 const int32_t percent_transaction_memory_in = 100; 418 //const int32_t percent_transaction_memory_in = 100; 327 419 const int32_t percent_transaction_memory_out = 100; 328 420 const int32_t percent_transaction_dcache = 100; … … 331 423 const int32_t percent_type_load = 0; 332 424 const int32_t percent_type_store = 100; 333 const int32_t percent_miss_spec = 100;425 const int32_t percent_miss_spec = 0; 334 426 335 427 if ((percent_type_load + … … 337 429 TEST_KO("sum of percent_type > 100"); 338 430 339 const int32_t seuil_type_load = seuil_type_load;340 const int32_t seuil_type_store = seuil_type_store+percent_type_load;431 const int32_t seuil_type_load = percent_type_load; 432 const int32_t seuil_type_store = percent_type_store+percent_type_load; 341 433 342 434 uint32_t nb_request_memory_in ; … … 347 439 priority_queue<MemoryRequest_t> fifo_request; 348 440 441 // emulation of cache 349 442 Tdcache_data_t cache_data [_param->_nb_context][nb_word]; 350 443 … … 371 464 for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++) 372 465 { 466 LABEL("Iteration "+toString(iteration)); 467 468 LABEL("Structure's initialisation"); 469 373 470 nb_request_memory_in = 0; 374 471 nb_request_memory_out = 0; 375 472 nb_request_dcache = 0; 376 473 377 LABEL("Iteration "+toString(iteration));378 379 474 // Fill the request_queue 380 475 … … 390 485 load_queue_use [i] = false; 391 486 392 double store_queue_cycle [_param->_size_store_queue];393 double load_queue_cycle [_param->_size_load_queue ];394 487 double current_cycle = sc_simulation_time(); 395 396 for (uint32_t i=0; i<_param->_size_store_queue; i++) 397 store_queue_cycle [i] = current_cycle; 398 for (uint32_t i=0; i<_param->_size_load_queue ; i++) 399 load_queue_cycle [i] = current_cycle; 400 488 double cycle_min = current_cycle; 489 490 LABEL("Fifo request initialisation"); 401 491 // Init fifo_request 402 492 for (uint32_t i=0; i<nb_request; i++) 403 493 { 404 double cycle = current_cycle+(rand()%(cst_max_cycle*nb_request));494 double cycle; 405 495 Tcontext_t context_id = rand () % _param->_nb_context; 406 496 Tpacket_t packet_id = i; … … 411 501 int32_t percent = rand()%100; 412 502 413 if (percent < seuil_type_load) 503 uint32_t size_queue; 504 505 if (percent <= seuil_type_load) 414 506 { 415 operation = OPERATION_MEMORY_LOAD_16_S; 416 load_queue_ptr_write = (load_queue_ptr_write+1) % (_param->_size_load_queue); 417 } 418 else 419 if (percent < seuil_type_store) 420 { 421 operation = OPERATION_MEMORY_STORE_16; 422 store_queue_ptr_write = (store_queue_ptr_write+1) % (_param->_size_store_queue); 423 } 424 else 425 { 426 operation = OPERATION_MEMORY_PREFETCH; 427 load_queue_ptr_write = (load_queue_ptr_write+1) % (_param->_size_load_queue); 428 } 429 430 // Valid nb cycle ? 431 if (is_operation_memory_store(operation)) 432 { 433 if (cycle <= store_queue_cycle[packet_id]) 434 cycle = store_queue_cycle[packet_id]+1; 507 // LABEL(" * LOAD"); 508 operation = OPERATION_MEMORY_LOAD_16_S; 509 size_queue = _param->_size_load_queue; 510 load_queue_ptr_write = (load_queue_ptr_write+1) % (size_queue); 435 511 } 436 512 else 437 513 { 438 if (cycle <= load_queue_cycle[packet_id]) 439 cycle = load_queue_cycle[packet_id]+1; 514 if (percent <= seuil_type_store) 515 { 516 // LABEL(" * STORE"); 517 operation = OPERATION_MEMORY_STORE_16; 518 size_queue = _param->_size_store_queue; 519 store_queue_ptr_write = (store_queue_ptr_write+1) % (size_queue); 520 } 521 else 522 { 523 // LABEL(" * OTHERS"); 524 operation = OPERATION_MEMORY_PREFETCH; 525 size_queue = _param->_size_load_queue; 526 load_queue_ptr_write = (load_queue_ptr_write+1) % (size_queue); 527 } 440 528 } 441 529 530 cycle = cycle_min; 531 cycle_min ++; 532 442 533 Ttype_t type = TYPE_MEMORY; 443 444 Tgeneral_data_t address = rand()%(1<<_param->_size_general_data); 445 Tgeneral_data_t offset = rand()%(1<<_param->_size_general_data); 534 Tgeneral_data_t address = rand()%(nb_word); 535 Tgeneral_data_t offset = rand()%(nb_word); 446 536 447 537 percent = rand()%100; … … 474 564 ); 475 565 566 cout << tab_request [i] << endl; 567 476 568 fifo_request.push(tab_request [i]); 477 569 570 double cycle_head = 0; 571 478 572 if (is_operation_memory_store(operation)) 479 573 { 480 cycle = cycle+((rand()%(10))-4); 481 482 if (cycle <= store_queue_cycle[packet_id]) 483 cycle = store_queue_cycle[packet_id]+1; 484 485 fifo_request.push(MemoryRequest_t(cycle, 574 cycle_head = cycle_min; 575 cycle_min ++; 576 577 cout << " * Write head : " << toString(cycle_head) 578 << endl 579 << endl; 580 581 fifo_request.push(MemoryRequest_t(cycle_head, 486 582 context_id, 487 583 packet_id, … … 497 593 write_spec_ko)); 498 594 } 499 500 // update nb cycle ? 501 if (is_operation_memory_store(operation)) 502 { 503 store_queue_cycle[packet_id] = cycle; 504 } 505 else 506 { 507 load_queue_cycle [packet_id] = cycle; 508 } 509 } 510 595 } 596 597 LABEL("Simulation of this iteration ..."); 598 511 599 while (nb_request_memory_out < nb_request) 512 600 { 601 // ***** MEMORY_IN ***** 602 603 // memory_in_val depends of three factors : 604 // 1) request's fifo is not empty ? 605 // 2) the slot destination is free ? 606 // 3) The head of request's fifo can be issue : the number of cycle is more than current cycle 607 513 608 bool can_execute = false; 514 609 … … 535 630 536 631 in_MEMORY_OUT_ACK->write((rand()%100)<percent_transaction_memory_out); 537 632 633 // ***** DCACHE_REQ ***** 634 in_DCACHE_REQ_ACK->write((rand()%100)<percent_transaction_dcache); 635 538 636 SC_START(0); 539 637 … … 541 639 542 640 LABEL("MEMORY_IN : "+toString(in_MEMORY_IN_VAL ->read())+" - "+toString(out_MEMORY_IN_ACK ->read())); 641 LABEL(" * fifo_request.empty : "+toString(fifo_request.empty())); 642 LABEL(" * fifo_request.top.cycle : "+toString(fifo_request.top()._cycle)); 643 LABEL(" * fifo_request.top.store_queue_ptr_write : "+toString(static_cast<uint32_t>(fifo_request.top()._store_queue_ptr_write))); 644 LABEL(" * fifo_request.top.load_queue_ptr_write : "+toString(static_cast<uint32_t>(fifo_request.top()._load_queue_ptr_write))); 645 LABEL(" * fifo_request.top.operation : "+toString(static_cast<uint32_t>(fifo_request.top()._operation ))); 646 LABEL(" * can_execute : "+toString(can_execute)); 647 543 648 if ( in_MEMORY_IN_VAL ->read() and out_MEMORY_IN_ACK ->read()) 544 649 { … … 562 667 if (out_MEMORY_OUT_VAL->read() and in_MEMORY_OUT_ACK->read()) 563 668 { 564 LABEL(" * Accepted MEMORY_OUT : " + toString( out_MEMORY_OUT_PACKET_ID->read()));669 LABEL(" * Accepted MEMORY_OUT : " + toString(static_cast<uint32_t>(out_MEMORY_OUT_PACKET_ID->read()))); 565 670 566 671 if (is_operation_memory_store(tab_request[out_MEMORY_OUT_PACKET_ID->read()]._operation)) … … 571 676 nb_request_memory_out ++; 572 677 } 678 679 LABEL("DCACHE_REQ : "+toString(out_DCACHE_REQ_VAL->read())+" - "+toString(in_DCACHE_REQ_ACK ->read())); 680 if (out_DCACHE_REQ_VAL->read() and in_DCACHE_REQ_ACK->read()) 681 { 682 LABEL(" * Accepted DCACHE_REQ : " + toString(static_cast<uint32_t>(out_DCACHE_REQ_PACKET_ID->read()))); 683 684 // test type : send or not a respons ! 685 } 686 573 687 } 574 688 }
Note: See TracChangeset
for help on using the changeset viewer.