Changeset 192 for trunk/modules
- Timestamp:
- Feb 10, 2012, 9:52:27 AM (13 years ago)
- Location:
- trunk/modules/vci_mem_cache_v1/caba/source
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/vci_mem_cache_v1/caba/source/include/vci_mem_cache_v1.h
r32 r192 50 50 #define TRANSACTION_TAB_LINES 4 // Number of lines in the transaction tab 51 51 #define UPDATE_TAB_LINES 4 // Number of lines in the update tab 52 #define BROADCAST_ADDR 0x0000000003 // Address to send the broadcast invalidate52 //#define BROADCAST_ADDR 0x0000000003 // Address to send the broadcast invalidate 53 53 54 54 namespace soclib { namespace caba { … … 150 150 WRITE_INVAL, 151 151 WRITE_XRAM_SEND, 152 WRITE_RESET 152 153 }; 153 154 … … 303 304 UpdateTab m_update_tab; // pending update & invalidate 304 305 CacheDirectory m_cache_directory; // data cache directory 306 vci_addr_t m_broadcast_address; // broadcast address 305 307 306 308 data_t ***m_cache_data; // data array[set][way][word] -
trunk/modules/vci_mem_cache_v1/caba/source/src/vci_mem_cache_v1.cpp
r32 r192 29 29 #include "../include/vci_mem_cache_v1.h" 30 30 31 #define VHDL_ACCURATE32 33 31 //#define IDEBUG 34 32 //#define DEBUG_VCI_MEM_CACHE 2 35 33 #define RANDOMIZE_SC 34 #define VHDL_ACCURATE 35 //#define DEBUG_CLEANUP 36 36 37 37 namespace soclib { namespace caba { … … 109 109 "WRITE_DIR_INVAL", 110 110 "WRITE_INVAL", 111 "WRITE_XRAM_SEND", 111 "WRITE_XRAM_SEND" 112 #ifdef VHDL_ACCURATE 113 , "WRITE_RESET" 114 #endif 112 115 }; 113 116 const char *ixr_rsp_fsm_str[] = { … … 282 285 assert(nways <= 32); 283 286 287 m_broadcast_address = 0x3 | (0x7C1F << (vci_param::N-20)); 284 288 285 289 // Get the segments associated to the MemCache … … 422 426 r_init_rsp_fsm = INIT_RSP_IDLE; 423 427 r_read_fsm = READ_IDLE; 428 429 #ifdef VHDL_ACCURATE 430 r_write_fsm = WRITE_RESET; 431 r_alloc_dir_fsm = ALLOC_DIR_WRITE; 432 #else 424 433 r_write_fsm = WRITE_IDLE; 434 r_alloc_dir_fsm = ALLOC_DIR_READ; 435 #endif 436 425 437 r_llsc_fsm = LLSC_IDLE; 426 r_cleanup_fsm = CLEANUP_IDLE;427 r_alloc_dir_fsm = ALLOC_DIR_READ; 438 r_cleanup_fsm = CLEANUP_IDLE; 439 428 440 r_alloc_trt_fsm = ALLOC_TRT_READ; 429 441 r_alloc_upt_fsm = ALLOC_UPT_WRITE; … … 433 445 434 446 // Initializing Tables 447 // The Directory is initialized in the WRITE RESET state 448 // in the VHDL ACCURATE model 449 #ifndef VHDL_ACCURATE 435 450 m_cache_directory.init(); 451 #endif 436 452 m_atomic_tab.init(); 437 453 m_transaction_tab.init(); … … 486 502 487 503 r_copies_limit = 3; 504 505 // Initialize WRITE FSM registers 506 r_write_way = 0; 507 r_write_address = 0; 488 508 489 509 // Activity counters … … 912 932 if ( r_alloc_trt_fsm.read() == ALLOC_TRT_READ ) { 913 933 #ifdef IDEBUG 914 934 std::cout << sc_time_stamp() << " " << name() << " READ_TRT_LOCK " << std::endl; 915 935 #endif 916 936 size_t index = 0; … … 943 963 std::vector<data_t>(m_words,0)); 944 964 #ifdef IDEBUG 945 946 947 965 std::cout << sc_time_stamp() << " " << name() << " READ_TRT_SET transaction table : " << std::endl; 966 for(size_t i = 0 ; i < m_transaction_tab.size() ; i++) 967 m_transaction_tab.print(i); 948 968 #endif 949 969 … … 995 1015 996 1016 switch ( r_write_fsm.read() ) { 997 1017 #ifdef VHDL_ACCURATE 1018 case WRITE_RESET: 1019 { 1020 r_write_word_index = 0; 1021 r_write_word_count = 0; 1022 1023 for (int i=0; i < m_words ; i++) { 1024 r_write_data[i] = 0; 1025 } 1026 1027 r_write_srcid = 0; 1028 r_write_trdid = 0; 1029 r_write_pktid = 0; 1030 r_write_is_cnt = false; 1031 r_write_lock = false; 1032 r_write_d_copies = 0; 1033 r_write_i_copies = 0; 1034 r_write_count = 0; 1035 r_write_tag = 0; 1036 1037 if ( r_alloc_dir_fsm.read() == ALLOC_DIR_WRITE ) { 1038 1039 r_write_way = (r_write_way.read()+1); 1040 if(r_write_way.read() == (m_ways-1)) { 1041 r_write_way = 0; 1042 1043 #define L2 soclib::common::uint32_log2 1044 r_write_address = r_write_address.read() + (1<<(L2(m_words)+2)); 1045 #undef L2 1046 } 1047 1048 1049 DirectoryEntry entry; 1050 entry.valid = false; 1051 entry.dirty = false; 1052 entry.tag = 0; 1053 entry.is_cnt = false; 1054 entry.lock = false; 1055 entry.d_copies = 0; 1056 entry.i_copies = 0; 1057 entry.count = 0; 1058 1059 size_t set = m_y[(vci_addr_t)(r_write_address.read())]; 1060 size_t way = r_write_way.read(); 1061 1062 m_cache_directory.write(set, way, entry); 1063 1064 #ifdef IDEBUG 1065 std::cout << "Initialize directory entry: " << std::endl 1066 << "WRITE FSM: Way = " << way << std::endl 1067 << "WRITE FSM: Set = " << set << std::endl 1068 << "WRITE FSM: Address = " << r_write_address.read() 1069 << std::endl; 1070 #endif 1071 1072 1073 if((set == (m_sets-1)) && (way == (m_ways-1))) { 1074 r_write_fsm = WRITE_IDLE; 1075 } 1076 } 1077 break; 1078 } 1079 #endif 998 1080 //////////////// 999 1081 case WRITE_IDLE: // copy first word of a write burst in local buffer … … 1772 1854 TransactionTabEntry trt_entry(m_transaction_tab.read(index)); 1773 1855 1856 #ifdef IDEBUG 1857 std::cout << "TRANSACTION ENTRY DEBUG" << std::endl; 1858 trt_entry.print(); 1859 #endif 1860 1774 1861 r_xram_rsp_trt_buf.copy(trt_entry); // TRT entry local buffer 1775 1862 … … 2044 2131 /////////////////// 2045 2132 case CLEANUP_IDLE: 2046 { 2047 2133 { 2048 2134 if ( p_vci_tgt_cleanup.cmdval.read() ) { 2135 2049 2136 assert( (p_vci_tgt_cleanup.srcid.read() < m_initiators) && 2050 2137 "VCI_MEM_CACHE error in VCI_MEM_CACHE in the CLEANUP network : The received SRCID is larger than 31"); 2138 2139 addr_t nline_addr = ( ((addr_t) p_vci_tgt_cleanup.be.read()) << 32) 2140 | ((addr_t) p_vci_tgt_cleanup.wdata.read()); 2141 2051 2142 bool reached = false; 2052 2143 for ( size_t index = 0 ; index < ncseg && !reached ; index++ ){ … … 2056 2147 } 2057 2148 if ( (p_vci_tgt_cleanup.cmd.read() == vci_param::CMD_WRITE) && 2058 (((addr_t)(p_vci_tgt_cleanup.address.read())) != BROADCAST_ADDR) &&2149 (((addr_t)(p_vci_tgt_cleanup.address.read())) != m_broadcast_address) && 2059 2150 reached) { 2060 2151 2061 2152 m_cpt_cleanup++; 2062 2153 2063 r_cleanup_nline = (addr_t)(m_nline[(vci_addr_t)(p_vci_tgt_cleanup.address.read())]);2154 r_cleanup_nline = nline_addr; 2064 2155 r_cleanup_srcid = p_vci_tgt_cleanup.srcid.read(); 2065 2156 r_cleanup_trdid = p_vci_tgt_cleanup.trdid.read(); … … 2070 2161 #endif 2071 2162 r_cleanup_fsm = CLEANUP_DIR_LOCK; 2163 2164 #ifdef DEBUG_CLEANUP 2165 std::cout << "Cleanup Received" << std::endl; 2166 std::cout << "MemCache address: "; 2167 std::cout << std::hex << p_vci_tgt_cleanup.address.read(); 2168 std::cout << std::endl; 2169 std::cout << "SrcId: "; 2170 std::cout << std::hex << p_vci_tgt_cleanup.srcid.read(); 2171 std::cout << std::endl; 2172 std::cout << "Cache Line Address: "; 2173 std::cout << std::hex << nline_addr; 2174 std::cout << std::endl; 2175 #endif 2072 2176 } 2073 2177 } … … 2083 2187 // Read the directory 2084 2188 size_t way = 0; 2085 2189 addr_t cleanup_address = r_cleanup_nline.read() * m_words * 4; 2086 2190 DirectoryEntry entry = m_cache_directory.read(cleanup_address , way); 2087 2191 #ifdef IDEBUG … … 2426 2530 cmd_llsc_fifo_get = true; 2427 2531 r_llsc_to_tgt_rsp_req = true; 2428 r_llsc_to_tgt_rsp_data = 1; 2532 //r_llsc_to_tgt_rsp_data = 1; 2533 r_llsc_to_tgt_rsp_data = 1; // FIXME: SC done inverted 2429 2534 r_llsc_to_tgt_rsp_srcid = m_cmd_llsc_srcid_fifo.read(); 2430 2535 r_llsc_to_tgt_rsp_trdid = m_cmd_llsc_trdid_fifo.read(); … … 2440 2545 cmd_llsc_fifo_get = true; 2441 2546 r_llsc_to_tgt_rsp_req = true; 2442 r_llsc_to_tgt_rsp_data = 0; 2547 //r_llsc_to_tgt_rsp_data = 0; 2548 r_llsc_to_tgt_rsp_data = 0; // FIXME: SC done inverted 2443 2549 r_llsc_to_tgt_rsp_srcid = m_cmd_llsc_srcid_fifo.read(); 2444 2550 r_llsc_to_tgt_rsp_trdid = m_cmd_llsc_trdid_fifo.read(); … … 2998 3104 ///////////////////// 2999 3105 case ALLOC_DIR_WRITE: 3000 if ( ( (r_write_fsm.read() != WRITE_DIR_LOCK) && 3106 if (( 3107 #ifdef VHDL_ACCURATE 3108 (r_write_fsm.read() != WRITE_RESET) && 3109 #endif 3110 (r_write_fsm.read() != WRITE_DIR_LOCK) && 3001 3111 (r_write_fsm.read() != WRITE_TRT_LOCK) && 3002 3112 (r_write_fsm.read() != WRITE_DIR_HIT_READ) && … … 3464 3574 p_vci_ini.cmdval = true; 3465 3575 if(r_xram_rsp_to_init_cmd_brdcast.read()) 3466 p_vci_ini.address = BROADCAST_ADDR;3576 p_vci_ini.address = m_broadcast_address; 3467 3577 else { 3468 3578 if(r_init_cmd_inst.read()) { 3469 p_vci_ini.address = (addr_t)(m_coherence_table[r_init_cmd_target.read()]+8); 3579 #define L2 soclib::common::uint32_log2 3580 p_vci_ini.address = (addr_t)((r_init_cmd_target.read()<<(vci_param::N - L2(m_initiators))) + 8); 3581 //p_vci_ini.address = (addr_t)(m_coherence_table[r_init_cmd_target.read()]+8); 3470 3582 } else { 3471 p_vci_ini.address = (addr_t)(m_coherence_table[r_init_cmd_target.read()]); 3472 } 3473 } 3583 #define L2 soclib::common::uint32_log2 3584 p_vci_ini.address = (addr_t)((r_init_cmd_target.read()<<(vci_param::N - L2(m_initiators)))); 3585 //p_vci_ini.address = (addr_t)(m_coherence_table[r_init_cmd_target.read()]); 3586 } 3587 } 3588 3474 3589 p_vci_ini.wdata = (uint32_t)r_xram_rsp_to_init_cmd_nline.read(); 3475 3590 p_vci_ini.be = ((r_xram_rsp_to_init_cmd_nline.read() >> 32) & 0x3); … … 3479 3594 break; 3480 3595 case INIT_CMD_BRDCAST: 3596 3481 3597 p_vci_ini.cmdval = true; 3482 p_vci_ini.address = BROADCAST_ADDR;3598 p_vci_ini.address = m_broadcast_address; 3483 3599 p_vci_ini.wdata = (addr_t)r_write_to_init_cmd_nline.read(); 3484 3600 p_vci_ini.be = ((r_write_to_init_cmd_nline.read() >> 32) & 0x3); … … 3490 3606 p_vci_ini.cmdval = true; 3491 3607 if(r_init_cmd_inst.read()){ 3492 p_vci_ini.address = (addr_t)(m_coherence_table[r_init_cmd_target.read()] + 12); 3608 #define L2 soclib::common::uint32_log2 3609 p_vci_ini.address = (addr_t)((r_init_cmd_target.read()<<(vci_param::N - L2(m_initiators))) + 12); 3610 #undef L2 3611 //p_vci_ini.address = (addr_t)(m_coherence_table[r_init_cmd_target.read()] + 12); 3493 3612 } else { 3494 p_vci_ini.address = (addr_t)(m_coherence_table[r_init_cmd_target.read()] + 4); 3495 } 3613 #define L2 soclib::common::uint32_log2 3614 p_vci_ini.address = (addr_t)((r_init_cmd_target.read()<<(vci_param::N - L2(m_initiators))) + 4); 3615 #undef L2 3616 //p_vci_ini.address = (addr_t)(m_coherence_table[r_init_cmd_target.read()] + 4); 3617 } 3618 3496 3619 p_vci_ini.wdata = (uint32_t)r_write_to_init_cmd_nline.read(); 3497 3620 p_vci_ini.be = ((r_write_to_init_cmd_nline.read() >> 32 ) & 0x3); … … 3503 3626 p_vci_ini.cmdval = true; 3504 3627 if(r_init_cmd_inst.read()){ 3505 p_vci_ini.address = (addr_t)(m_coherence_table[r_init_cmd_target.read()] + 12); 3628 #define L2 soclib::common::uint32_log2 3629 p_vci_ini.address = (addr_t)((r_init_cmd_target.read()<<(vci_param::N - L2(m_initiators))) + 12); 3630 #undef L2 3631 //p_vci_ini.address = (addr_t)(m_coherence_table[r_init_cmd_target.read()] + 12); 3506 3632 } else { 3507 p_vci_ini.address = (addr_t)(m_coherence_table[r_init_cmd_target.read()] + 4); 3508 } 3633 #define L2 soclib::common::uint32_log2 3634 p_vci_ini.address = (addr_t)((r_init_cmd_target.read()<<(vci_param::N - L2(m_initiators))) + 4); 3635 #undef L2 3636 //p_vci_ini.address = (addr_t)(m_coherence_table[r_init_cmd_target.read()] + 4); 3637 } 3638 3509 3639 p_vci_ini.wdata = r_write_to_init_cmd_index.read(); 3510 3640 p_vci_ini.be = 0xF; … … 3516 3646 p_vci_ini.cmdval = true; 3517 3647 if(r_init_cmd_inst.read()){ 3518 p_vci_ini.address = (addr_t)(m_coherence_table[r_init_cmd_target.read()] + 12); 3648 #define L2 soclib::common::uint32_log2 3649 p_vci_ini.address = (addr_t)((r_init_cmd_target.read()<<(vci_param::N - L2(m_initiators))) + 12); 3650 #undef L2 3651 //p_vci_ini.address = (addr_t)(m_coherence_table[r_init_cmd_target.read()] + 12); 3519 3652 } else { 3520 p_vci_ini.address = (addr_t)(m_coherence_table[r_init_cmd_target.read()] + 4); 3521 } 3653 #define L2 soclib::common::uint32_log2 3654 p_vci_ini.address = (addr_t)((r_init_cmd_target.read()<<(vci_param::N - L2(m_initiators))) + 4); 3655 #undef L2 3656 //p_vci_ini.address = (addr_t)(m_coherence_table[r_init_cmd_target.read()] + 4); 3657 } 3658 3522 3659 p_vci_ini.wdata = r_write_to_init_cmd_data[r_init_cmd_cpt.read() + 3523 3660 r_write_to_init_cmd_index.read()].read(); … … 3586 3723 // End: 3587 3724 3588 // vim: filetype=cpp:expandtab:shiftwidth= 4:tabstop=4:softtabstop=43589 3725 // vim: filetype=cpp:expandtab:shiftwidth=2:tabstop=2 3726
Note: See TracChangeset
for help on using the changeset viewer.