Changeset 477 for branches/RWT/lib/generic_cache_tsar/include
- Timestamp:
- Jul 26, 2013, 5:03:12 PM (11 years ago)
- Location:
- branches/RWT
- Files:
-
- 2 added
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/RWT/lib/generic_cache_tsar/include/generic_cache.h
r393 r477 76 76 { 77 77 CACHE_SLOT_STATE_EMPTY, 78 CACHE_SLOT_STATE_VALID ,78 CACHE_SLOT_STATE_VALID_CC, 79 79 CACHE_SLOT_STATE_ZOMBI, 80 CACHE_SLOT_STATE_VALID_NCC, 80 81 }; 81 82 … … 118 119 return r_lru[(way*m_sets)+set]; 119 120 } 120 121 121 122 ////////////////////////////////////////////// 122 123 inline int &cache_state(size_t way, size_t set) … … 125 126 } 126 127 128 127 129 ///////////////////////////////////////////////// 128 130 inline void cache_set_lru(size_t way, size_t set) … … 218 220 } 219 221 222 inline int get_cache_state(int way, int set) 223 { 224 return cache_state(way,set); 225 } 226 220 227 ///////////////////////////////////////////////////////////////////// 221 228 // Read a single 32 bits word. … … 233 240 { 234 241 if ( (tag == cache_tag(way, set)) 235 && ( cache_state(way, set) == CACHE_SLOT_STATE_VALID) )242 && ( (cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC) or (cache_state(way, set) == CACHE_SLOT_STATE_VALID_NCC)) ) 236 243 { 237 244 *dt = cache_data(way, set, word); … … 262 269 { 263 270 if ( (tag == cache_tag(way, set)) and 264 ( cache_state(way, set) == CACHE_SLOT_STATE_VALID))271 ( (cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC)or (cache_state(way, set) == CACHE_SLOT_STATE_VALID_NCC))) 265 272 { 266 273 *selway = way; … … 308 315 { 309 316 310 if ( cache_state(way, set) == CACHE_SLOT_STATE_VALID )317 if ( cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC ) 311 318 { 312 *state = CACHE_SLOT_STATE_VALID; 319 *state = CACHE_SLOT_STATE_VALID_CC; 320 *selway = way; 321 *selset = set; 322 *selword = word; 323 *dt = cache_data(way, set, word); 324 cache_set_lru(way, set); 325 } 326 else if ( cache_state(way, set) == CACHE_SLOT_STATE_VALID_NCC ) 327 { 328 *state = CACHE_SLOT_STATE_VALID_NCC; 313 329 *selway = way; 314 330 *selset = set; … … 347 363 { 348 364 if ( (tag == cache_tag(way, set)) 349 && ( cache_state(way, set) == CACHE_SLOT_STATE_VALID) )365 && ( (cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC) or (cache_state(way, set) == CACHE_SLOT_STATE_VALID_NCC) ) ) 350 366 { 351 367 *selway = way; … … 382 398 { 383 399 if ( (tag == cache_tag(way, set)) 384 && (cache_state(way, set) == CACHE_SLOT_STATE_VALID) )400 &&( (cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC) ) ) 385 401 { 386 402 *dt = cache_data(way, set, word); … … 433 449 { 434 450 435 if ( cache_state(way, set) == CACHE_SLOT_STATE_VALID )451 if ( cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC ) 436 452 { 437 *state = CACHE_SLOT_STATE_VALID ;453 *state = CACHE_SLOT_STATE_VALID_CC; 438 454 *selway = way; 439 455 *selset = set; … … 446 462 cache_set_lru(way, set); 447 463 } 464 465 else if ( cache_state(way, set) == CACHE_SLOT_STATE_VALID_NCC ) 466 { 467 *state = CACHE_SLOT_STATE_VALID_NCC; 468 *selway = way; 469 *selset = set; 470 *selword = word; 471 *dt = cache_data(way, set, word); 472 if ( word+1 < m_words) 473 { 474 *dt_next = cache_data(way, set, word+1); 475 } 476 cache_set_lru(way, set); 477 } 478 448 479 else if ( cache_state(way, set) == CACHE_SLOT_STATE_ZOMBI ) 449 480 { … … 477 508 { 478 509 if ( (tag == cache_tag(way, set)) 479 && ( cache_state(way, set) == CACHE_SLOT_STATE_VALID) )510 && ( (cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC)or(cache_state(way, set) == CACHE_SLOT_STATE_VALID_NCC) ) ) 480 511 { 481 512 *selway = way; … … 509 540 const size_t ad_set = m_y[ad]; 510 541 const size_t ad_word = m_x[ad]; 511 512 542 for ( size_t _way = 0; _way < m_ways; _way++ ) 513 543 { … … 556 586 data_t data) 557 587 { 588 /**/ //std::cout << "write cache : way = "<<way<<" | set = "<<set<<" | word = "<<word<<" | data = "<<(uint32_t)data << std::endl; 558 589 cache_data(way, set, word) = data; 559 590 cache_set_lru(way, set); … … 584 615 addr_t* nline) 585 616 { 586 if ( cache_state(way,set) == CACHE_SLOT_STATE_VALID )617 if( (cache_state(way,set) == CACHE_SLOT_STATE_VALID_CC) or (cache_state(way,set) == CACHE_SLOT_STATE_VALID_NCC)) 587 618 { 588 619 cache_state(way,set) = CACHE_SLOT_STATE_EMPTY; … … 615 646 for ( size_t _way = 0 ; _way < m_ways && !found ; _way++ ) 616 647 { 617 if ( cache_state(_way, *set) != CACHE_SLOT_STATE_VALID) // empty648 if( ( cache_state(_way, *set) != CACHE_SLOT_STATE_VALID_CC ) and ( cache_state(_way, *set) != CACHE_SLOT_STATE_VALID_NCC )) // empty 618 649 { 619 650 found = true; … … 674 705 } 675 706 } 707 ////////////////////////////////////////////////////////////// 708 /*for ( size_t _way = 0 ; _way < m_ways && !(*found) ; _way++ ) 709 { 710 if ( not cache_lru(_way, _set) and 711 (cache_state(_way, _set) != CACHE_SLOT_STATE_ZOMBI) and 712 (cache_state(_way, _set) == CACHE_SLOT_STATE_VALID_NCC) ) 713 { 714 *found = true; 715 *cleanup = true; 716 *way = _way; 717 *set = m_y[ad]; 718 *victim = (addr_t)((cache_tag(*way,_set) * m_sets) + _set); 719 return; 720 } 721 }*/ 676 722 // Search first not zombi old slot 677 723 for ( size_t _way = 0 ; _way < m_ways && !(*found) ; _way++ ) … … 718 764 719 765 cache_tag(way, set) = tag; 720 cache_state(way, set) = CACHE_SLOT_STATE_VALID ;766 cache_state(way, set) = CACHE_SLOT_STATE_VALID_CC; 721 767 cache_set_lru(way, set); 722 768 } … … 733 779 addr_t tag = m_z[ad]; 734 780 735 assert( ( (state == CACHE_SLOT_STATE_VALID) or 781 assert( ( (state == CACHE_SLOT_STATE_VALID_CC) or 782 (state == CACHE_SLOT_STATE_VALID_NCC) or 736 783 (state == CACHE_SLOT_STATE_ZOMBI) or 737 784 (state == CACHE_SLOT_STATE_EMPTY) ) and … … 747 794 cache_state(way, set) = state; 748 795 749 if ( state == CACHE_SLOT_STATE_VALID) cache_set_lru(way, set);796 if ( (state == CACHE_SLOT_STATE_VALID_CC) or (state == CACHE_SLOT_STATE_VALID_NCC) ) cache_set_lru(way, set); 750 797 } 751 798 … … 759 806 int state) 760 807 { 761 assert( ( (state == CACHE_SLOT_STATE_VALID) or 808 assert( ( (state == CACHE_SLOT_STATE_VALID_CC) or 809 (state == CACHE_SLOT_STATE_VALID_NCC) or 762 810 (state == CACHE_SLOT_STATE_ZOMBI) or 763 811 (state == CACHE_SLOT_STATE_EMPTY) ) and … … 772 820 cache_state(way, set) = state; 773 821 774 if ( state == CACHE_SLOT_STATE_VALID) cache_set_lru(way, set);822 if ( (state == CACHE_SLOT_STATE_VALID_CC) or (state == CACHE_SLOT_STATE_VALID_NCC) ) cache_set_lru(way, set); 775 823 } 776 824 … … 788 836 789 837 cache_tag(way, set) = tag; 790 cache_state(way, set) = CACHE_SLOT_STATE_VALID ;838 cache_state(way, set) = CACHE_SLOT_STATE_VALID_CC; 791 839 cache_set_lru(way, set); 792 840 for ( size_t word = 0 ; word < m_words ; word++ ) … … 835 883 std::cout << " | " << cache_data(way,set,word) ; 836 884 } 837 std::cout << std:: endl ;885 std::cout << std::dec << std::endl ; 838 886 } 839 887 } … … 853 901 { 854 902 if ( (tag == cache_tag(way, set)) and 855 (cache_state(way, set) == CACHE_SLOT_STATE_VALID ) )903 (cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC) ) 856 904 { 857 905 hit = true; … … 878 926 { 879 927 if ( (tag == cache_tag(way, set)) and 880 (cache_state(way, set) == CACHE_SLOT_STATE_VALID ) )928 (cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC) ) 881 929 { 882 930 hit = true; … … 923 971 { 924 972 if ( (tag == cache_tag(way, set)) and 925 (cache_state(way, set) == CACHE_SLOT_STATE_VALID ) )973 (cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC) ) 926 974 { 927 975 cache_data(way, set, word) = dt; … … 948 996 { 949 997 if ( (tag == cache_tag(way, set)) and 950 (cache_state(way, set) == CACHE_SLOT_STATE_VALID ) )998 (cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC) ) 951 999 { 952 1000 data_t mask = be2mask(be); … … 975 1023 { 976 1024 if ( (tag == cache_tag(way, set)) and 977 (cache_state(way, set) == CACHE_SLOT_STATE_VALID ) )1025 (cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC) ) 978 1026 { 979 1027 cache_data(way, set, word) = dt; … … 1002 1050 { 1003 1051 if ( (tag == cache_tag(way, set)) and 1004 (cache_state(way, set) == CACHE_SLOT_STATE_VALID ) )1052 (cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC) ) 1005 1053 { 1006 1054 data_t mask = be2mask(be);
Note: See TracChangeset
for help on using the changeset viewer.