Changeset 289 for trunk/modules/vci_mem_cache_v4/caba/source/include
- Timestamp:
- Jan 20, 2013, 7:09:37 PM (12 years ago)
- Location:
- trunk/modules/vci_mem_cache_v4/caba/source/include
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/vci_mem_cache_v4/caba/source/include/mem_cache_directory_v4.h
r284 r289 620 620 }; // end class HeapDirectory 621 621 622 //////////////////////////////////////////////////////////////////////// 623 // Cache Data 624 //////////////////////////////////////////////////////////////////////// 625 class CacheData { 626 private: 627 const uint32_t m_sets; 628 const uint32_t m_ways; 629 const uint32_t m_words; 630 631 uint32_t *** m_cache_data; 632 633 public: 634 635 CacheData(uint32_t ways, uint32_t sets, uint32_t words) 636 : m_sets(sets), m_ways(ways), m_words(words) { 637 638 m_cache_data = new uint32_t ** [ways]; 639 for ( size_t i=0 ; i < ways ; i++ ) { 640 m_cache_data[i] = new uint32_t * [sets]; 641 } 642 for ( size_t i=0; i<ways; i++ ) { 643 for ( size_t j=0; j<sets; j++ ) { 644 m_cache_data[i][j] = new uint32_t [words]; 645 } 646 } 647 } 648 649 ~CacheData() { 650 for(size_t i=0; i<m_ways ; i++){ 651 for(size_t j=0; j<m_sets ; j++){ 652 delete [] m_cache_data[i][j]; 653 } 654 } 655 for(size_t i=0; i<m_ways ; i++){ 656 delete [] m_cache_data[i]; 657 } 658 delete [] m_cache_data; 659 } 660 661 uint32_t read ( 662 const uint32_t &way, 663 const uint32_t &set, 664 const uint32_t &word) const { 665 666 assert((set < m_sets ) && "Cache data error: Trying to read a wrong set" ); 667 assert((way < m_ways ) && "Cache data error: Trying to read a wrong way" ); 668 assert((word < m_words) && "Cache data error: Trying to read a wrong word"); 669 670 return m_cache_data[way][set][word]; 671 } 672 673 void read_line( 674 const uint32_t &way, 675 const uint32_t &set, 676 sc_core::sc_signal<uint32_t> * cache_line) 677 { 678 assert((set < m_sets ) && "Cache data error: Trying to read a wrong set" ); 679 assert((way < m_ways ) && "Cache data error: Trying to read a wrong way" ); 680 681 for (uint32_t word=0; word<m_words; word++) 682 cache_line[word].write(m_cache_data[way][set][word]); 683 } 684 685 void write ( 686 const uint32_t &way, 687 const uint32_t &set, 688 const uint32_t &word, 689 const uint32_t &data, 690 const uint32_t &be = 0xF) { 691 692 assert((set < m_sets ) && "Cache data error: Trying to write a wrong set" ); 693 assert((way < m_ways ) && "Cache data error: Trying to write a wrong way" ); 694 assert((word < m_words) && "Cache data error: Trying to write a wrong word"); 695 assert((be <= 0xF ) && "Cache data error: Trying to write a wrong word cell"); 696 697 if (be == 0x0) return; 698 699 if (be == 0xF) { 700 m_cache_data[way][set][word] = data; 701 return; 702 } 703 704 uint32_t mask = 0; 705 if (be & 0x1) mask = mask | 0x000000FF; 706 if (be & 0x2) mask = mask | 0x0000FF00; 707 if (be & 0x4) mask = mask | 0x00FF0000; 708 if (be & 0x8) mask = mask | 0xFF000000; 709 710 m_cache_data[way][set][word] = 711 (data & mask) | (m_cache_data[way][set][word] & ~mask); 712 } 713 }; // end class CacheData 622 714 623 715 }} // end namespaces -
trunk/modules/vci_mem_cache_v4/caba/source/include/vci_mem_cache_v4.h
r284 r289 420 420 UpdateTab m_update_tab; // pending update & invalidate 421 421 CacheDirectory m_cache_directory; // data cache directory 422 CacheData m_cache_data; // data array[set][way][word] 422 423 HeapDirectory m_heap; // heap for copies 423 424 data_t *** m_cache_data; // data array[set][way][word]425 424 426 425 // adress masks
Note: See TracChangeset
for help on using the changeset viewer.