Changeset 223 for trunk/modules/vci_mem_cache_v4/caba
- Timestamp:
- Mar 29, 2012, 6:43:02 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/vci_mem_cache_v4/caba/source/src/vci_mem_cache_v4.cpp
r222 r223 1733 1733 if( m_debug_write_fsm ) 1734 1734 { 1735 if( r_write_is_cnt.read() && r_write_count.read() ) 1736 { 1737 std::cout << " <MEMC.WRITE_DIR_READ> Read the cache to complete local buffer /" 1738 << " coherence broadcast required" << std::endl; 1739 } 1740 else 1741 { 1742 std::cout << " <MEMC.WRITE_DIR_READ> Read the cache to complete local buffer" 1743 << std::endl; 1744 } 1735 std::cout << " <MEMC.WRITE_DIR_READ> Read the cache to complete local buffer" << std::endl; 1745 1736 } 1746 1737 #endif … … 1800 1791 } 1801 1792 1802 if ( owner ) r_write_count = r_write_count.read() - 1;1793 if ( owner and not no_update ) r_write_count = r_write_count.read() - 1; 1803 1794 1804 1795 if ( no_update ) // Write transaction completed … … 1825 1816 std::cout << " <MEMC.WRITE_DIR_HIT> Coherence update required:" 1826 1817 << " is_cnt = " << r_write_is_cnt.read() 1827 << " count = " << std::dec << r_write_count.read() 1828 << std::endl; 1818 << " nb_copies = " << std::dec << r_write_count.read() << std::endl; 1819 if (owner) 1820 std::cout << " ... but the first copy is the writer" << std::endl; 1829 1821 } 1830 1822 } … … 1892 1884 break; 1893 1885 } 1894 ///////////////////// 1886 ///////////////////////// 1895 1887 case WRITE_UPT_HEAP_LOCK: // get access to heap 1896 1888 { … … 1909 1901 } 1910 1902 ////////////////// 1911 case WRITE_UPT_REQ: // prepare the request toINIT_CMD FSM1912 // and write the first srcidin the FIFO1903 case WRITE_UPT_REQ: // prepare the coherence ransaction for the INIT_CMD FSM 1904 // and write the first copy in the FIFO 1913 1905 // send the request if only one copy 1914 1906 { … … 1958 1950 r_write_to_dec = false; 1959 1951 } 1952 1953 #if DEBUG_MEMC_WRITE 1954 if( m_debug_write_fsm ) 1955 { 1956 std::cout << " <MEMC.WRITE_UPT_REQ> Post first request to INIT_CMD FSM" 1957 << " / srcid = " << r_write_copy.read() 1958 << " / inst = " << r_write_copy_inst.read() << std::endl; 1959 if ( r_write_count.read() == 1) 1960 std::cout << " ... and this is the last" << std::endl; 1961 } 1962 #endif 1960 1963 } 1961 1964 break; … … 1973 1976 HeapEntry entry = m_heap.read(r_write_ptr.read()); 1974 1977 1975 bool dec_upt_counter; // = r_write_to_dec.read();1978 bool dec_upt_counter; 1976 1979 1977 1980 if( (entry.owner.srcid != r_write_srcid.read()) or … … 1979 1982 (entry.owner.cache_id != r_write_pktid.read()) or 1980 1983 #endif 1981 entry.owner.inst) // put te next srcid in the fifo1984 entry.owner.inst) // put te next srcid in the fifo 1982 1985 { 1983 1986 dec_upt_counter = false; … … 1988 1991 write_to_init_cmd_fifo_cache_id = entry.owner.cache_id; 1989 1992 #endif 1993 1994 #if DEBUG_MEMC_WRITE 1995 if( m_debug_write_fsm ) 1996 { 1997 std::cout << " <MEMC.WRITE_UPT_NEXT> Post another request to INIT_CMD FSM" 1998 << " / heap_index = " << std::dec << r_write_ptr.read() 1999 << " / srcid = " << r_write_copy.read() 2000 << " / inst = " << r_write_copy_inst.read() << std::endl; 2001 if( entry.next == r_write_ptr.read() ) 2002 std::cout << " ... and this is the last" << std::endl; 2003 } 2004 #endif 1990 2005 } 1991 else // the UPT counter must be decremented2006 else // the UPT counter must be decremented 1992 2007 { 1993 2008 dec_upt_counter = true; 2009 2010 #if DEBUG_MEMC_WRITE 2011 if( m_debug_write_fsm ) 2012 { 2013 std::cout << " <MEMC.WRITE_UPT_NEXT> Skip one entry in heap matching the writer" 2014 << " / heap_index = " << std::dec << r_write_ptr.read() 2015 << " / srcid = " << r_write_copy.read() 2016 << " / inst = " << r_write_copy_inst.read() << std::endl; 2017 if( entry.next == r_write_ptr.read() ) 2018 std::cout << " ... and this is the last" << std::endl; 2019 } 2020 #endif 1994 2021 } 1995 2022 … … 2000 2027 { 2001 2028 std::cout << "VCI_MEM_CACHE ERROR " << name() << " WRITE_UPT_NEXT state" << std::endl 2002 << "The write_to_ cmd_write_fifo should not be full" << std::endl2029 << "The write_to_init_cmd_fifo should not be full" << std::endl 2003 2030 << "as the depth should be larger than the max number of copies" << std::endl; 2004 2031 exit(0); … … 3939 3966 } 3940 3967 ////////////////////// 3941 case SC_DIR_HIT_WRITE: // write data in the cache 3942 // and test if a coherence request is required 3943 { 3944 size_t way = r_sc_way.read(); 3945 size_t set = m_y[(vci_addr_t)(m_cmd_sc_addr_fifo.read())]; 3946 size_t word = m_x[(vci_addr_t)(m_cmd_sc_addr_fifo.read())]; 3947 3948 // cache update 3949 m_cache_data[way][set][word] = r_sc_wdata.read(); 3950 if(r_sc_cpt.read()==4) 3951 m_cache_data[way][set][word+1] = m_cmd_sc_wdata_fifo.read(); 3952 3953 // monitor 3954 if ( m_monitor_ok ) 3955 { 3956 vci_addr_t address = m_cmd_sc_addr_fifo.read(); 3957 char buf[80]; 3958 snprintf(buf, 80, "SC_DIR_HIT_WRITE srcid %d", m_cmd_sc_srcid_fifo.read()); 3959 check_monitor( buf, address, r_sc_wdata.read() ); 3960 if ( r_sc_cpt.read()==4 ) 3961 check_monitor( buf, address+4, m_cmd_sc_wdata_fifo.read() ); 3962 } 3963 3968 case SC_DIR_HIT_WRITE: // test if a CC transaction is required 3969 // write data in cache if no CC request 3970 { 3964 3971 // test coherence request 3965 3972 if(r_sc_count.read()) // replicated line … … 3981 3988 else // no copies 3982 3989 { 3990 size_t way = r_sc_way.read(); 3991 size_t set = m_y[(vci_addr_t)(m_cmd_sc_addr_fifo.read())]; 3992 size_t word = m_x[(vci_addr_t)(m_cmd_sc_addr_fifo.read())]; 3993 3994 // cache update 3995 m_cache_data[way][set][word] = r_sc_wdata.read(); 3996 if(r_sc_cpt.read()==4) 3997 m_cache_data[way][set][word+1] = m_cmd_sc_wdata_fifo.read(); 3998 3999 // monitor 4000 if ( m_monitor_ok ) 4001 { 4002 vci_addr_t address = m_cmd_sc_addr_fifo.read(); 4003 char buf[80]; 4004 snprintf(buf, 80, "SC_DIR_HIT_WRITE srcid %d", m_cmd_sc_srcid_fifo.read()); 4005 check_monitor( buf, address, r_sc_wdata.read() ); 4006 if ( r_sc_cpt.read()==4 ) 4007 check_monitor( buf, address+4, m_cmd_sc_wdata_fifo.read() ); 4008 } 3983 4009 r_sc_fsm = SC_RSP_SUCCESS; 3984 }3985 4010 3986 4011 #if DEBUG_MEMC_SC … … 3995 4020 } 3996 4021 #endif 4022 } 3997 4023 break; 3998 4024 } 3999 4025 ///////////////// 4000 case SC_UPT_LOCK: // register the transaction in UPT 4026 case SC_UPT_LOCK: // try to register the transaction in UPT 4027 // and write data in cache if successful registration 4028 // releases locks to retry later if UPT full 4001 4029 { 4002 4030 if ( r_alloc_upt_fsm.read() == ALLOC_UPT_SC ) … … 4021 4049 if (wok) // coherence transaction registered in UPT 4022 4050 { 4051 // cache update 4052 size_t way = r_sc_way.read(); 4053 size_t set = m_y[(vci_addr_t)(m_cmd_sc_addr_fifo.read())]; 4054 size_t word = m_x[(vci_addr_t)(m_cmd_sc_addr_fifo.read())]; 4055 4056 m_cache_data[way][set][word] = r_sc_wdata.read(); 4057 if(r_sc_cpt.read()==4) 4058 m_cache_data[way][set][word+1] = m_cmd_sc_wdata_fifo.read(); 4059 4060 // monitor 4061 if ( m_monitor_ok ) 4062 { 4063 vci_addr_t address = m_cmd_sc_addr_fifo.read(); 4064 char buf[80]; 4065 snprintf(buf, 80, "SC_DIR_HIT_WRITE srcid %d", m_cmd_sc_srcid_fifo.read()); 4066 check_monitor( buf, address, r_sc_wdata.read() ); 4067 if ( r_sc_cpt.read()==4 ) 4068 check_monitor( buf, address+4, m_cmd_sc_wdata_fifo.read() ); 4069 } 4070 4023 4071 r_sc_upt_index = index; 4024 4072 r_sc_fsm = SC_UPT_HEAP_LOCK; 4025 4073 } 4026 else // releases the locks protecting UPT and DIR if no entry4074 else // releases the locks protecting UPT and DIR UPT full 4027 4075 { 4028 4076 r_sc_fsm = SC_WAIT; … … 4213 4261 } 4214 4262 /////////////////// 4215 case SC_BC_UPT_LOCK: // Register a broadcast inval transaction in UPT 4263 case SC_BC_UPT_LOCK: // register a broadcast inval transaction in UPT 4264 // write data in cache in case of successful registration 4216 4265 { 4217 4266 if ( r_alloc_upt_fsm.read() == ALLOC_UPT_SC ) … … 4238 4287 if ( wok ) // UPT not full 4239 4288 { 4289 // cache update 4290 size_t way = r_sc_way.read(); 4291 size_t set = m_y[(vci_addr_t)(m_cmd_sc_addr_fifo.read())]; 4292 size_t word = m_x[(vci_addr_t)(m_cmd_sc_addr_fifo.read())]; 4293 4294 m_cache_data[way][set][word] = r_sc_wdata.read(); 4295 if(r_sc_cpt.read()==4) 4296 m_cache_data[way][set][word+1] = m_cmd_sc_wdata_fifo.read(); 4297 4298 // monitor 4299 if ( m_monitor_ok ) 4300 { 4301 vci_addr_t address = m_cmd_sc_addr_fifo.read(); 4302 char buf[80]; 4303 snprintf(buf, 80, "SC_DIR_HIT_WRITE srcid %d", m_cmd_sc_srcid_fifo.read()); 4304 check_monitor( buf, address, r_sc_wdata.read() ); 4305 if ( r_sc_cpt.read()==4 ) 4306 check_monitor( buf, address+4, m_cmd_sc_wdata_fifo.read() ); 4307 } 4240 4308 r_sc_upt_index = index; 4241 4309 r_sc_fsm = SC_BC_DIR_INVAL;
Note: See TracChangeset
for help on using the changeset viewer.