Changeset 81 for trunk/IPs/systemC/Environment/Cache/selftest
- Timestamp:
- Apr 15, 2008, 8:40:01 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/IPs/systemC/Environment/Cache/selftest/main.cpp
-
Property
svn:keywords
set to
Id
r80 r81 1 #include "../include/Cache.h" 1 2 #include <iostream> 2 #include "../include/Cache.h"3 3 4 4 using namespace std; … … 6 6 using namespace environment::cache; 7 7 8 #define TEST(x,y) \ 9 { \ 10 cout << "Line " << __LINE__ << " : "; \ 11 if (x==y) \ 12 { \ 13 cout << "Test OK" << endl; \ 14 } \ 15 else \ 16 { \ 17 cout << "Test KO" << endl; \ 18 exit (EXIT_FAILURE); \ 19 } \ 8 #define TEST(x,y) \ 9 { \ 10 if (x==y) \ 11 { \ 12 cout << "Line " << __LINE__ << " : " << "Test OK" << endl; \ 13 } \ 14 else \ 15 { \ 16 cout << "Line " << __LINE__ << " : " << "Test KO" << endl; \ 17 exit (EXIT_FAILURE); \ 18 } \ 20 19 } while (0) 21 20 22 21 23 22 24 int main (void) 23 #ifdef SYSTEMC 24 int sc_main (int argc, char * argv[]) 25 #else 26 int main (int argc, char * argv[]) 27 #endif 25 28 { 26 29 cout << "<main> Begin" << endl; … … 38 41 ); 39 42 40 cout << *param << endl;43 // cout << *param << endl; 41 44 42 45 cache_onelevel::Cache_OneLevel * cache = new cache_onelevel::Cache_OneLevel ("my_cache",param); 43 46 cache->reset(); 44 47 45 cout << *cache << endl;48 // cout << *cache << endl; 46 49 47 50 cache->transition(); 48 51 cache->transition(); 49 52 50 cout << *cache << endl;53 // cout << *cache << endl; 51 54 52 55 TEST(cache->access(0, 0x100, 0, CACHED, WRITE), MISS); … … 89 92 90 93 cache->transition(); // miss cycle 1 91 cout << *cache << endl;94 // cout << *cache << endl; 92 95 93 96 TEST(cache->access(0, 0x200, 0, CACHED, WRITE), MISS ); … … 99 102 cache->transition(); // miss cycle 2 100 103 cache->transition(); // miss cycle 3 101 cout << *cache << endl;104 // cout << *cache << endl; 102 105 103 106 // line 0 : all way is use … … 113 116 114 117 cache->transition(); 115 cout << *cache << endl;118 // cout << *cache << endl; 116 119 117 120 TEST(cache->access(0, 0x500, 0, CACHED, WRITE), MISS ); … … 141 144 TEST(cache->latence(3), 5); 142 145 143 cout << *cache << endl;146 // cout << *cache << endl; 144 147 145 148 delete cache; … … 174 177 ); 175 178 176 cout << *param << endl;179 // cout << *param << endl; 177 180 178 181 cache_multilevel::Cache_MultiLevel * cache = new cache_multilevel::Cache_MultiLevel ("my_cache",param); 179 182 180 cout << *cache << endl;181 183 cache->reset(); 182 cout << *cache << endl;184 // cout << *cache << endl; 183 185 184 186 cache_multilevel::Access access; … … 202 204 cache->transition(); //11 203 205 cache->transition(); //10 204 cout << *cache << endl;206 // cout << *cache << endl; 205 207 206 208 access = cache->access (0, 0x100, 0, CACHED, WRITE); … … 238 240 TEST(access.latence , 1); 239 241 TEST(access.last_nb_level, 0); 240 cout << *cache << endl;242 // cout << *cache << endl; 241 243 242 244 cache->transition(); … … 303 305 cache->transition(); //11 304 306 cache->transition(); //10 305 cout << *cache << endl;307 // cout << *cache << endl; 306 308 307 309 access = cache->access (0, 0x100, 0, CACHED, WRITE); … … 358 360 359 361 access = cache->access (1, 0x100, 0, CACHED, WRITE); 360 cout << access<< endl;362 // cout << access<< endl; 361 363 362 364 cache->update_access(access); … … 367 369 TEST(access.last_nb_level, 1); 368 370 369 cout << *cache << endl;371 // cout << *cache << endl; 370 372 delete cache; 371 373 delete param; … … 389 391 cache_shared_size_line [0] = 8 ; 390 392 cache_shared_size_word [0] = 4 ; 391 cache_shared_associativity [0] = 4;393 cache_shared_associativity [0] = 8 ; 392 394 cache_shared_hit_latence [0] = 2 ; 393 395 cache_shared_miss_penality [0] = 5 ; … … 467 469 468 470 dcache_nb_level [1] = 2; 469 dcache_nb_port [1] = 2;471 dcache_nb_port [1] = 8; // to test 470 472 dcache_nb_line [1] = new uint32_t [2]; 471 473 dcache_size_line [1] = new uint32_t [2]; … … 519 521 ); 520 522 521 cout << *param << endl;523 // cout << *param << endl; 522 524 523 525 cache::Cache * cache = new cache::Cache ("my_cache",param); 524 526 527 cache->reset(); 528 // cout << *cache << endl; 529 530 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 16); 531 cache->transition(); 532 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 15); 533 cache->transition(); 534 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 14); 535 cache->transition(); 536 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 13); 537 cache->transition(); 538 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 12); 539 cache->transition(); 540 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 11); 541 cache->transition(); 542 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 10); 543 cache->transition(); 544 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 9); 545 cache->transition(); 546 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 8); 547 TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 16); // miss thread != 548 TEST(cache->latence (DATA_CACHE, 0, 0, 0x100, 0, CACHED, WRITE), 6); // miss L1, hit L2 549 cache->transition(); 550 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 7); 551 TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 15); 552 cache->transition(); 553 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 6); 554 TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 14); 555 cache->transition(); 556 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 5); 557 TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 13); 558 cache->transition(); 559 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 4); 560 TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 12); 561 cache->transition(); 562 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 3); 563 TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 11); 564 cache->transition(); 565 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 2); 566 TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 10); 567 cache->transition(); 568 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 1); 569 TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 9); 570 cache->transition(); 571 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 1); 572 TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 8); 573 cache->transition(); 574 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 1); 575 TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 7); 576 cache->transition(); 577 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 1); 578 TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 6); 579 cache->transition(); 580 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 1); 581 TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 5); 582 cache->transition(); 583 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 1); 584 TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 4); 585 cache->transition(); 586 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 1); 587 TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 3); 588 cache->transition(); 589 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 1); 590 TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 2); 591 cache->transition(); 592 593 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 5); // L1 is direct map, hit L2 594 TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 1); // write in L1 595 TEST(cache->latence (DATA_CACHE, 1, 2, 0x100, 2, CACHED, WRITE), 16); 596 TEST(cache->latence (DATA_CACHE, 1, 3, 0x100, 3, CACHED, WRITE), 16); 597 cache->transition(); 598 599 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 4); 600 TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 1); 601 TEST(cache->latence (DATA_CACHE, 1, 2, 0x100, 2, CACHED, WRITE), 15); 602 TEST(cache->latence (DATA_CACHE, 1, 3, 0x100, 3, CACHED, WRITE), 15); 603 cache->transition(); 604 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 3); 605 TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 1); 606 TEST(cache->latence (DATA_CACHE, 1, 2, 0x100, 2, CACHED, WRITE), 14); 607 TEST(cache->latence (DATA_CACHE, 1, 3, 0x100, 3, CACHED, WRITE), 14); 608 TEST(cache->latence (DATA_CACHE, 1, 4, 0x100, 4, CACHED, WRITE), 16); 609 TEST(cache->latence (DATA_CACHE, 1, 5, 0x100, 5, CACHED, WRITE), 16); 610 cache->transition(); 611 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 2); 612 TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 1); 613 TEST(cache->latence (DATA_CACHE, 1, 2, 0x100, 2, CACHED, WRITE), 13); 614 TEST(cache->latence (DATA_CACHE, 1, 3, 0x100, 3, CACHED, WRITE), 13); 615 TEST(cache->latence (DATA_CACHE, 1, 4, 0x100, 4, CACHED, WRITE), 15); 616 TEST(cache->latence (DATA_CACHE, 1, 5, 0x100, 5, CACHED, WRITE), 15); 617 618 619 cache->transition(); 620 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 1); 621 TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 5); 622 TEST(cache->latence (DATA_CACHE, 1, 2, 0x100, 2, CACHED, WRITE), 12); 623 TEST(cache->latence (DATA_CACHE, 1, 3, 0x100, 3, CACHED, WRITE), 12); 624 TEST(cache->latence (DATA_CACHE, 1, 4, 0x100, 4, CACHED, WRITE), 14); 625 TEST(cache->latence (DATA_CACHE, 1, 5, 0x100, 5, CACHED, WRITE), 14); 626 627 628 cache->transition(); 629 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 1); 630 TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 4); 631 TEST(cache->latence (DATA_CACHE, 1, 2, 0x100, 2, CACHED, WRITE), 11); 632 TEST(cache->latence (DATA_CACHE, 1, 3, 0x100, 3, CACHED, WRITE), 11); 633 TEST(cache->latence (DATA_CACHE, 1, 4, 0x100, 4, CACHED, WRITE), 13); 634 TEST(cache->latence (DATA_CACHE, 1, 5, 0x100, 5, CACHED, WRITE), 13); 635 636 // in cache L2 : context 0,1,2,3 637 638 cache->transition(); 639 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 1); 640 TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 3); 641 TEST(cache->latence (DATA_CACHE, 1, 2, 0x100, 2, CACHED, WRITE), 10); 642 TEST(cache->latence (DATA_CACHE, 1, 3, 0x100, 3, CACHED, WRITE), 10); 643 TEST(cache->latence (DATA_CACHE, 1, 4, 0x100, 4, CACHED, WRITE), 12); 644 TEST(cache->latence (DATA_CACHE, 1, 5, 0x100, 5, CACHED, WRITE), 12); 645 646 cache->transition(); 647 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 1); 648 TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 2); 649 TEST(cache->latence (DATA_CACHE, 1, 2, 0x100, 2, CACHED, WRITE), 9); 650 TEST(cache->latence (DATA_CACHE, 1, 3, 0x100, 3, CACHED, WRITE), 9); 651 TEST(cache->latence (DATA_CACHE, 1, 4, 0x100, 4, CACHED, WRITE), 11); 652 TEST(cache->latence (DATA_CACHE, 1, 5, 0x100, 5, CACHED, WRITE), 11); 653 654 cache->transition(); 655 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 5); 656 TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 1); 657 TEST(cache->latence (DATA_CACHE, 1, 2, 0x100, 2, CACHED, WRITE), 8); 658 TEST(cache->latence (DATA_CACHE, 1, 3, 0x100, 3, CACHED, WRITE), 8); 659 TEST(cache->latence (DATA_CACHE, 1, 4, 0x100, 4, CACHED, WRITE), 10); // write in L2 660 TEST(cache->latence (DATA_CACHE, 1, 5, 0x100, 5, CACHED, WRITE), 10); // write in L2 661 662 cache->transition(); 663 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 4); 664 TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 1); 665 TEST(cache->latence (DATA_CACHE, 1, 2, 0x100, 2, CACHED, WRITE), 7); 666 TEST(cache->latence (DATA_CACHE, 1, 3, 0x100, 3, CACHED, WRITE), 7); 667 TEST(cache->latence (DATA_CACHE, 1, 4, 0x100, 4, CACHED, WRITE), 9); 668 TEST(cache->latence (DATA_CACHE, 1, 5, 0x100, 5, CACHED, WRITE), 9); 669 670 cache->transition(); 671 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 3); 672 TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 1); 673 TEST(cache->latence (DATA_CACHE, 1, 2, 0x100, 2, CACHED, WRITE), 6); 674 TEST(cache->latence (DATA_CACHE, 1, 3, 0x100, 3, CACHED, WRITE), 6); 675 TEST(cache->latence (DATA_CACHE, 1, 4, 0x100, 4, CACHED, WRITE), 8); 676 TEST(cache->latence (DATA_CACHE, 1, 5, 0x100, 5, CACHED, WRITE), 8); 677 678 cache->transition(); 679 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 2); 680 TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 1); 681 TEST(cache->latence (DATA_CACHE, 1, 2, 0x100, 2, CACHED, WRITE), 5); 682 TEST(cache->latence (DATA_CACHE, 1, 3, 0x100, 3, CACHED, WRITE), 5); 683 TEST(cache->latence (DATA_CACHE, 1, 4, 0x100, 4, CACHED, WRITE), 7); 684 TEST(cache->latence (DATA_CACHE, 1, 5, 0x100, 5, CACHED, WRITE), 7); 685 686 cache->transition(); 687 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 1); 688 TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 5); 689 TEST(cache->latence (DATA_CACHE, 1, 2, 0x100, 2, CACHED, WRITE), 4); 690 TEST(cache->latence (DATA_CACHE, 1, 3, 0x100, 3, CACHED, WRITE), 4); 691 TEST(cache->latence (DATA_CACHE, 1, 4, 0x100, 4, CACHED, WRITE), 6); 692 TEST(cache->latence (DATA_CACHE, 1, 5, 0x100, 5, CACHED, WRITE), 6); 693 694 cache->transition(); 695 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 1); 696 TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 4); 697 TEST(cache->latence (DATA_CACHE, 1, 2, 0x100, 2, CACHED, WRITE), 3); 698 TEST(cache->latence (DATA_CACHE, 1, 3, 0x100, 3, CACHED, WRITE), 3); 699 TEST(cache->latence (DATA_CACHE, 1, 4, 0x100, 4, CACHED, WRITE), 5); 700 TEST(cache->latence (DATA_CACHE, 1, 5, 0x100, 5, CACHED, WRITE), 5); 701 702 cache->transition(); 703 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 1); 704 TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 3); 705 TEST(cache->latence (DATA_CACHE, 1, 2, 0x100, 2, CACHED, WRITE), 2); 706 TEST(cache->latence (DATA_CACHE, 1, 3, 0x100, 3, CACHED, WRITE), 2); 707 TEST(cache->latence (DATA_CACHE, 1, 4, 0x100, 4, CACHED, WRITE), 4); 708 TEST(cache->latence (DATA_CACHE, 1, 5, 0x100, 5, CACHED, WRITE), 4); 709 525 710 cout << *cache << endl; 526 cache->reset(); 527 cout << *cache << endl; 528 529 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 16); 530 cache->transition(); 531 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 15); 532 cache->transition(); 533 534 cout << *cache << endl; 535 711 712 cache->transition(); 713 // In L2 : context 1,2,4,5 : also context 0 and 3 miss L1 and L2, hit L3 714 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 11); 715 TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 2); 716 TEST(cache->latence (DATA_CACHE, 1, 2, 0x100, 2, CACHED, WRITE), 1); 717 TEST(cache->latence (DATA_CACHE, 1, 3, 0x100, 3, CACHED, WRITE), 11); 718 TEST(cache->latence (DATA_CACHE, 1, 4, 0x100, 4, CACHED, WRITE), 3); 719 TEST(cache->latence (DATA_CACHE, 1, 5, 0x100, 5, CACHED, WRITE), 3); 720 721 cache->transition(); 722 TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 10); 723 TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 1); 724 TEST(cache->latence (DATA_CACHE, 1, 2, 0x100, 2, CACHED, WRITE), 5); 725 TEST(cache->latence (DATA_CACHE, 1, 3, 0x100, 3, CACHED, WRITE), 10); 726 TEST(cache->latence (DATA_CACHE, 1, 4, 0x100, 4, CACHED, WRITE), 2); 727 TEST(cache->latence (DATA_CACHE, 1, 5, 0x100, 5, CACHED, WRITE), 2); 728 729 // // cout << *cache << endl; 536 730 537 731 delete cache; 732 538 733 delete param; 539 734 delete [] cache_shared_nb_line ; -
Property
svn:keywords
set to
Note: See TracChangeset
for help on using the changeset viewer.