Changeset 495 for branches/RWT/modules
- Timestamp:
- Aug 22, 2013, 6:45:38 PM (11 years ago)
- Location:
- branches/RWT/modules
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/RWT/modules/vci_cc_vcache_wrapper/caba/source/include/vci_cc_vcache_wrapper.h
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
/trunk/modules/vci_cc_vcache_wrapper/caba/source/include/vci_cc_vcache_wrapper.h merged eligible /branches/v5/modules/vci_cc_vcache_wrapper/caba/source/include/vci_cc_vcache_wrapper.h 444-467
r477 r495 179 179 CC_RECEIVE_INS_UPDT_HEADER, 180 180 CC_RECEIVE_INS_UPDT_NLINE, 181 CC_RECEIVE_INS_UPDT_DATA,182 181 CC_RECEIVE_DATA_INVAL_HEADER, 183 182 CC_RECEIVE_DATA_INVAL_NLINE, 184 183 CC_RECEIVE_DATA_UPDT_HEADER, 185 184 CC_RECEIVE_DATA_UPDT_NLINE, 185 CC_RECEIVE_INS_UPDT_DATA, 186 186 CC_RECEIVE_DATA_UPDT_DATA, 187 187 }; … … 403 403 sc_signal<bool> r_icache_tlb_rsp_error; // tlb miss response error 404 404 405 // Filp-Flop in ICACHE FSM for saving the cleanup victim request 406 sc_signal<bool> r_icache_cleanup_victim_req; 407 sc_signal<paddr_t> r_icache_cleanup_victim_nline; 408 405 409 // communication between ICACHE FSM and CC_SEND FSM 406 410 sc_signal<bool> r_icache_cc_send_req; // ICACHE cc_send request … … 504 508 sc_signal<bool> r_dcache_xtn_req; // xtn request (caused by processor) 505 509 sc_signal<int> r_dcache_xtn_opcode; // xtn request type 510 511 // Filp-Flop in DCACHE FSM for saving the cleanup victim request 512 sc_signal<bool> r_dcache_cleanup_victim_req; 513 sc_signal<bool> r_dcache_cleanup_victim_line_ncc; 514 sc_signal<bool> r_dcache_cleanup_victim_updt_data; 515 sc_signal<paddr_t> r_dcache_cleanup_victim_nline; 506 516 507 517 // communication between DCACHE FSM and CC_SEND FSM -
Property
svn:mergeinfo
set to
(toggle deleted branches)
-
branches/RWT/modules/vci_cc_vcache_wrapper/caba/source/src/vci_cc_vcache_wrapper.cpp
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
/trunk/modules/vci_cc_vcache_wrapper/caba/source/src/vci_cc_vcache_wrapper.cpp merged eligible /branches/v5/modules/vci_cc_vcache_wrapper/caba/source/src/vci_cc_vcache_wrapper.cpp 444-467
r477 r495 354 354 r_dcache_xtn_req("r_dcache_xtn_req"), 355 355 r_dcache_xtn_opcode("r_dcache_xtn_opcode"), 356 356 357 r_dcache_cleanup_victim_req("r_dcache_cleanup_victim_req"), 358 r_dcache_cleanup_victim_nline("r_dcache_cleanup_victim_nline"), 359 357 360 r_dcache_cc_send_req("r_dcache_cc_send_req"), 358 361 r_dcache_cc_send_type("r_dcache_cc_send_type"), … … 374 377 r_vci_rsp_fifo_dcache("r_vci_rsp_fifo_dcache", 2), // 2 words depth 375 378 r_vci_rsp_fifo_rpktid("r_vci_rsp_fifo_rpktid", 2), // 2 words depth 376 r_cc_send_data_fifo("r_cc_send_data_fifo", 2),379 r_cc_send_data_fifo("r_cc_send_data_fifo", 16), 377 380 378 381 r_cc_send_fsm("r_cc_send_fsm"), … … 815 818 // No request from DCACHE FSM to CC_SEND FSM 816 819 r_dcache_cc_send_req = false; 817 818 820 r_dcache_clack_req = false; 819 821 … … 852 854 r_dcache_miss_data_cpt = 0; 853 855 r_dcache_miss_data_addr = 0; 856 857 r_dcache_cleanup_victim_req = false; 858 r_dcache_cleanup_victim_line_ncc = false; 859 r_dcache_cleanup_victim_updt_data = false; 854 860 855 861 // activity counters … … 1093 1099 1094 1100 // coherence interrupt 1095 if ( r_cc_receive_icache_req.read() )1101 if ( r_cc_receive_icache_req.read() and not r_icache_cc_send_req.read()) 1096 1102 { 1097 1103 r_icache_fsm = ICACHE_CC_CHECK; … … 1329 1335 1330 1336 // coherence interrupt 1331 if ( r_cc_receive_icache_req.read() )1337 if ( r_cc_receive_icache_req.read() and not r_icache_cc_send_req.read()) 1332 1338 { 1333 1339 r_icache_fsm = ICACHE_CC_CHECK; … … 1381 1387 1382 1388 // coherence request (from CC_RECEIVE FSM) 1383 if ( r_cc_receive_icache_req.read() )1389 if ( r_cc_receive_icache_req.read() and not r_icache_cc_send_req.read()) 1384 1390 { 1385 1391 r_icache_fsm = ICACHE_CC_CHECK; … … 1588 1594 1589 1595 // coherence interrupt 1590 if ( r_cc_receive_icache_req.read() )1596 if ( r_cc_receive_icache_req.read() and not r_icache_cc_send_req.read()) 1591 1597 { 1592 1598 r_icache_fsm = ICACHE_CC_CHECK; … … 1685 1691 1686 1692 // coherence interrupt 1687 if ( r_cc_receive_icache_req.read() )1693 if ( r_cc_receive_icache_req.read() and not r_icache_cc_send_req.read()) 1688 1694 { 1689 1695 r_icache_fsm = ICACHE_CC_CHECK; … … 1764 1770 1765 1771 // coherence interrupt 1766 if ( r_cc_receive_icache_req.read() )1772 if ( r_cc_receive_icache_req.read() and not r_icache_cc_send_req.read()) 1767 1773 { 1768 1774 r_icache_fsm = ICACHE_CC_CHECK; … … 1843 1849 1844 1850 // coherence interrupt 1845 if ( r_cc_receive_icache_req.read() )1851 if ( r_cc_receive_icache_req.read() and not r_icache_cc_send_req.read()) 1846 1852 { 1847 1853 r_icache_fsm = ICACHE_CC_CHECK; … … 1882 1888 paddr_t mask = ~((m_icache_words<<2)-1); 1883 1889 1890 // CLACK handler 1891 // We switch the directory slot to EMPTY state 1892 // and reset r_icache_miss_clack if the cleanup ack 1893 // is matching a pending miss. 1894 if ( r_icache_clack_req.read() ) 1895 { 1896 1897 if ( m_ireq.valid ) m_cost_ins_miss_frz++; 1898 1899 #ifdef INSTRUMENTATION 1900 m_cpt_icache_dir_write++; 1901 #endif 1902 r_icache.write_dir( 0, 1903 r_icache_clack_way.read(), 1904 r_icache_clack_set.read(), 1905 CACHE_SLOT_STATE_EMPTY); 1906 1907 if ( (r_icache_miss_set.read() == r_icache_clack_set.read()) and 1908 (r_icache_miss_way.read() == r_icache_clack_way.read()) ) 1909 { 1910 r_icache_miss_clack = false; 1911 } 1912 1913 r_icache_clack_req = false; 1914 1915 // return to cc_save state 1916 r_icache_fsm = r_icache_fsm_save.read(); 1917 1918 #if DEBUG_ICACHE 1919 if ( m_debug_activated ) 1920 { 1921 std::cout << " <PROC " << name() 1922 << " ICACHE_CC_CHECK> CC_TYPE_CLACK slot returns to empty state" 1923 << " set = " << r_icache_clack_set.read() 1924 << " / way = " << r_icache_clack_way.read() << std::endl; 1925 } 1926 #endif 1927 1928 break; 1929 } 1884 1930 1885 1931 // Match between MISS address and CC address … … 1921 1967 } 1922 1968 1923 // CLACK handler 1924 // We switch the directory slot to EMPTY state 1925 // and reset r_icache_miss_clack if the cleanup ack 1926 // is matching a pending miss. 1927 if ( r_icache_clack_req.read() ) 1928 { 1929 1930 if ( m_ireq.valid ) m_cost_ins_miss_frz++; 1931 1932 #ifdef INSTRUMENTATION 1933 m_cpt_icache_dir_write++; 1934 #endif 1935 r_icache.write_dir( 0, 1936 r_icache_clack_way.read(), 1937 r_icache_clack_set.read(), 1938 CACHE_SLOT_STATE_EMPTY); 1939 1940 if ( (r_icache_miss_set.read() == r_icache_clack_set.read()) and 1941 (r_icache_miss_way.read() == r_icache_clack_way.read()) ) 1942 { 1943 r_icache_miss_clack = false; 1944 } 1945 1946 r_icache_clack_req = false; 1947 1948 // return to cc_save state if no pending CC request 1949 if ( not r_cc_receive_icache_req.read() ) 1950 r_icache_fsm = r_icache_fsm_save.read(); 1951 1952 #if DEBUG_ICACHE 1953 if ( m_debug_activated ) 1954 { 1955 std::cout << " <PROC " << name() 1956 << " ICACHE_CC_CHECK> CC_TYPE_CLACK slot returns to empty state" 1957 << " set = " << r_icache_clack_set.read() 1958 << " / way = " << r_icache_clack_way.read() << std::endl; 1959 } 1960 #endif 1961 1962 break; 1963 } 1964 1965 // wait if pending request to CC_SEND. This way if there are pending 1966 // CLACK they can be treated in this state and then a deadlock 1967 // situation is avoided 1968 if ( r_icache_cc_send_req.read() ) break; 1969 assert ( not r_icache_cc_send_req.read() and "CC_SEND must be available in ICACHE_CC_CHECK"); 1969 1970 1970 1971 // CC request handler … … 2418 2419 } 2419 2420 // coherence request (from CC_RECEIVE FSM) 2420 else if ( r_cc_receive_dcache_req.read() )2421 else if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read()) 2421 2422 { 2422 2423 r_dcache_fsm = DCACHE_CC_CHECK; … … 3057 3058 3058 3059 // coherence request (from CC_RECEIVE FSM) 3059 if ( r_cc_receive_dcache_req.read() )3060 if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read()) 3060 3061 { 3061 3062 r_dcache_fsm = DCACHE_CC_CHECK; … … 3369 3370 3370 3371 // coherence request (from CC_RECEIVE FSM) 3371 if ( r_cc_receive_dcache_req.read() )3372 if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read()) 3372 3373 { 3373 3374 r_dcache_fsm = DCACHE_CC_CHECK; … … 3737 3738 3738 3739 // coherence request (from CC_RECEIVE FSM) 3739 if ( r_cc_receive_dcache_req.read() )3740 if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read()) 3740 3741 { 3741 3742 r_dcache_fsm = DCACHE_CC_CHECK; … … 3816 3817 3817 3818 // coherence request (from CC_RECEIVE FSM) 3818 if ( r_cc_receive_dcache_req.read() )3819 if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read()) 3819 3820 { 3820 3821 r_dcache_fsm = DCACHE_CC_CHECK; … … 3846 3847 3847 3848 // coherence request (from CC_RECEIVE FSM) 3848 if ( r_cc_receive_dcache_req.read() )3849 if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read()) 3849 3850 { 3850 3851 r_dcache_fsm = DCACHE_CC_CHECK; … … 3889 3890 3890 3891 // coherence request (from CC_RECEIVE FSM) 3891 if ( r_cc_receive_dcache_req.read() )3892 if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read()) 3892 3893 { 3893 3894 r_dcache_fsm = DCACHE_CC_CHECK; … … 3980 3981 size_t set; 3981 3982 size_t word; 3983 3982 3984 r_dcache.read_neutral(r_dcache_xtn_flush_addr_data.read(), 3983 3985 &rdata, … … 3999 4001 } 4000 4002 } 4003 // else if ( r_dcache_clack_req.read() ) 4004 // { 4005 // r_dcache_fsm = DCACHE_CC_CHECK; 4006 // r_dcache_fsm_cc_save = r_dcache_fsm.read(); 4007 // break; 4008 // } 4001 4009 break; 4002 4010 } … … 4311 4319 4312 4320 // coherence request (from CC_RECEIVE FSM) 4313 if ( r_cc_receive_dcache_req.read() )4321 if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read()) 4314 4322 { 4315 4323 r_dcache_fsm = DCACHE_CC_CHECK; … … 4318 4326 } 4319 4327 4320 if ( not r_dcache_cc_send_req.read() ) // blocked until previous cc_send request is sent4321 {4322 4328 bool found = false; 4323 4329 bool cleanup = false; … … 4326 4332 paddr_t victim = 0; 4327 4333 int state; 4334 bool s_cleanup_updt_data = false; 4335 bool s_cleanup_line_ncc = false; 4328 4336 4329 4337 #ifdef INSTRUMENTATION … … 4347 4355 r_dcache_miss_clack = true; 4348 4356 r_dcache_fsm = DCACHE_MISS_CLEAN; 4349 // request cleanup4350 r_dcache_cc_send_req = true;4351 r_dcache_cc_send_nline = victim;4352 r_dcache_cc_send_way = way;4353 r_dcache_cc_send_type = CC_TYPE_CLEANUP;4354 4357 if( (state == CACHE_SLOT_STATE_VALID_NCC) )//and (r_dcache_content_state[way*m_dcache_sets+set] == LINE_CACHE_DATA_DIRTY) ) 4355 4358 { 4356 4359 //MODIFIER POUR DIRTY BIT // 4357 r_dcache_cc_cleanup_line_ncc = true;4360 s_cleanup_line_ncc = true; 4358 4361 r_dcache_miss_data_addr = (victim*m_dcache_words)*4; 4359 4362 //if ((r_dcache_content_state[way*m_dcache_sets+set] != LINE_CACHE_DATA_NOT_DIRTY))//must send data 4360 4363 if (true)//must send data 4361 4364 { 4362 r_dcache_cc_cleanup_updt_data = true;4365 s_cleanup_updt_data = true; 4363 4366 for (size_t w = 0; w< m_dcache_words; w++) 4364 4367 { … … 4369 4372 else 4370 4373 { 4371 r_dcache_cc_cleanup_updt_data = false;4374 s_cleanup_updt_data = false; 4372 4375 } 4373 4376 … … 4378 4381 else 4379 4382 { 4380 r_dcache_cc_cleanup_line_ncc = false; 4381 r_dcache_cc_cleanup_updt_data = false; 4383 s_cleanup_line_ncc = false; 4384 s_cleanup_updt_data = false; 4385 } 4386 4387 if( not r_dcache_cc_send_req.read() ) 4388 { 4389 // request cleanup 4390 r_dcache_cc_send_req = true; 4391 r_dcache_cc_send_nline = victim; 4392 r_dcache_cc_send_way = way; 4393 r_dcache_cc_send_type = CC_TYPE_CLEANUP; 4394 r_dcache_cc_cleanup_updt_data = s_cleanup_updt_data; 4395 r_dcache_cc_cleanup_line_ncc = s_cleanup_line_ncc; 4396 } 4397 else 4398 { 4399 r_dcache_cleanup_victim_nline = victim; 4400 r_dcache_cleanup_victim_req = true; 4401 r_dcache_cleanup_victim_updt_data = s_cleanup_updt_data; 4402 r_dcache_cleanup_victim_line_ncc = s_cleanup_line_ncc; 4403 std::cout << " <PROC " << name() 4404 << "/ CYCLE = " 4405 << m_cpt_total_cycles 4406 << std :: endl; 4382 4407 } 4383 4408 } … … 4400 4425 #endif 4401 4426 } // end found 4402 }4403 4427 break; 4404 4428 } … … 4410 4434 size_t set; 4411 4435 size_t word; 4436 4437 if( r_dcache_cleanup_victim_req.read() and not r_dcache_cc_send_req.read() ) 4438 { 4439 r_dcache_cc_send_req = true; 4440 r_dcache_cc_send_type = CC_TYPE_CLEANUP; 4441 r_dcache_cc_send_nline = r_dcache_cleanup_victim_nline.read(); 4442 r_dcache_cleanup_victim_req = false; 4443 r_dcache_cc_cleanup_updt_data = r_dcache_cleanup_victim_updt_data.read(); 4444 r_dcache_cc_cleanup_line_ncc = r_dcache_cleanup_victim_line_ncc.read(); 4445 r_dcache_cc_send_way = r_dcache_miss_way; 4446 } 4412 4447 4413 4448 r_dcache.read_neutral(r_dcache_miss_data_addr, … … 4430 4465 } 4431 4466 } 4467 // else if ( r_dcache_clack_req.read() ) 4468 // { 4469 // r_dcache_fsm = DCACHE_CC_CHECK; 4470 // r_dcache_fsm_cc_save = r_dcache_fsm.read(); 4471 // break; 4472 // } 4473 4432 4474 break; 4433 4475 } … … 4495 4537 { 4496 4538 if ( m_dreq.valid) m_cost_data_miss_frz++; 4539 4540 if( r_dcache_cleanup_victim_req.read() and not r_dcache_cc_send_req.read() ) 4541 { 4542 r_dcache_cc_send_req = true; 4543 r_dcache_cc_send_type = CC_TYPE_CLEANUP; 4544 r_dcache_cc_send_nline = r_dcache_cleanup_victim_nline.read(); 4545 r_dcache_cleanup_victim_req = false; 4546 r_dcache_cc_cleanup_updt_data = r_dcache_cleanup_victim_updt_data.read(); 4547 r_dcache_cc_cleanup_line_ncc = r_dcache_cleanup_victim_line_ncc.read(); 4548 r_dcache_cc_send_way = r_dcache_miss_way; 4549 } 4550 4497 4551 // coherence clack request (from DSPIN CLACK) 4498 4552 if ( r_dcache_clack_req.read() ) … … 4504 4558 4505 4559 // coherence request (from CC_RECEIVE FSM) 4506 if ( r_cc_receive_dcache_req.read() )4560 if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read() and not r_dcache_cleanup_victim_req.read() ) 4507 4561 { 4508 4562 r_dcache_fsm = DCACHE_CC_CHECK; … … 4623 4677 if ( m_dreq.valid) m_cost_data_miss_frz++; 4624 4678 4679 if( r_dcache_cleanup_victim_req.read() and not r_dcache_cc_send_req.read() ) 4680 { 4681 r_dcache_cc_send_req = true; 4682 r_dcache_cc_send_type = CC_TYPE_CLEANUP; 4683 r_dcache_cc_send_nline = r_dcache_cleanup_victim_nline.read(); 4684 r_dcache_cleanup_victim_req = false; 4685 r_dcache_cc_cleanup_updt_data = r_dcache_cleanup_victim_updt_data.read(); 4686 r_dcache_cc_cleanup_line_ncc = r_dcache_cleanup_victim_line_ncc.read(); 4687 r_dcache_cc_send_way = r_dcache_miss_way; 4688 } 4689 4625 4690 // coherence clack request (from DSPIN CLACK) 4626 4691 if ( r_dcache_clack_req.read() ) … … 4632 4697 4633 4698 // coherence request (from CC_RECEIVE FSM) 4634 if ( r_cc_receive_dcache_req.read() )4699 if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read() and not r_dcache_cleanup_victim_req.read() ) 4635 4700 { 4636 4701 r_dcache_fsm = DCACHE_CC_CHECK; … … 4736 4801 4737 4802 // coherence request (from CC_RECEIVE FSM) 4738 if ( r_cc_receive_dcache_req.read() )4803 if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read()) 4739 4804 { 4740 4805 r_dcache_fsm = DCACHE_CC_CHECK; … … 4781 4846 4782 4847 // coherence request (from CC_RECEIVE FSM) 4783 if ( r_cc_receive_dcache_req.read() )4848 if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read()) 4784 4849 { 4785 4850 r_dcache_fsm = DCACHE_CC_CHECK; … … 4835 4900 4836 4901 // coherence request (from CC_RECEIVE FSM) 4837 if ( r_cc_receive_dcache_req.read() )4902 if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read()) 4838 4903 { 4839 4904 r_dcache_fsm = DCACHE_CC_CHECK; … … 4954 5019 4955 5020 // coherence request (from CC_RECEIVE FSM) 4956 if ( r_cc_receive_dcache_req.read() )5021 if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read()) 4957 5022 { 4958 5023 r_dcache_fsm = DCACHE_CC_CHECK; … … 5045 5110 } 5046 5111 #endif 5112 // CLACK handler 5113 // We switch the directory slot to EMPTY state and reset 5114 // r_dcache_miss_clack if the cleanup ack is matching a pending miss. 5115 if ( r_dcache_clack_req.read() ) 5116 { 5117 if ( m_dreq.valid ) m_cost_data_miss_frz++; 5118 5119 #ifdef INSTRUMENTATION 5120 m_cpt_dcache_dir_write++; 5121 #endif 5122 r_dcache.write_dir( 0, 5123 r_dcache_clack_way.read(), 5124 r_dcache_clack_set.read(), 5125 CACHE_SLOT_STATE_EMPTY); 5126 5127 if ( (r_dcache_miss_set.read() == r_dcache_clack_set.read()) and 5128 (r_dcache_miss_way.read() == r_dcache_clack_way.read()) ) 5129 { 5130 r_dcache_miss_clack = false; 5131 } 5132 5133 r_dcache_clack_req = false; 5134 5135 // return to cc_save state 5136 r_dcache_fsm = r_dcache_fsm_cc_save.read() ; 5137 5138 #if DEBUG_DCACHE 5139 if ( m_debug_activated ) 5140 { 5141 std::cout << " <PROC " << name() 5142 << " DCACHE_CC_CHECK> CC_TYPE_CLACK Switch slot to EMPTY state" 5143 << " set = " << r_dcache_clack_set.read() 5144 << " / way = " << r_dcache_clack_way.read() << std::endl; 5145 } 5146 #endif 5147 break; 5148 } 5047 5149 5048 5150 … … 5086 5188 } 5087 5189 5088 // CLACK handler 5089 // We switch the directory slot to EMPTY state and reset 5090 // r_dcache_miss_clack if the cleanup ack is matching a pending miss. 5091 if ( r_dcache_clack_req.read() ) 5092 { 5093 if ( m_dreq.valid ) m_cost_data_miss_frz++; 5094 5095 #ifdef INSTRUMENTATION 5096 m_cpt_dcache_dir_write++; 5097 #endif 5098 r_dcache.write_dir( 0, 5099 r_dcache_clack_way.read(), 5100 r_dcache_clack_set.read(), 5101 CACHE_SLOT_STATE_EMPTY); 5102 5103 if ( (r_dcache_miss_set.read() == r_dcache_clack_set.read()) and 5104 (r_dcache_miss_way.read() == r_dcache_clack_way.read()) ) 5105 { 5106 r_dcache_miss_clack = false; 5107 } 5108 5109 r_dcache_clack_req = false; 5110 5111 // return to cc_save state if no pending CC request 5112 if ( not r_cc_receive_dcache_req.read() ) 5113 { 5114 r_dcache_fsm = r_dcache_fsm_cc_save.read() ; 5115 } 5116 5117 #if DEBUG_DCACHE 5118 if ( m_debug_activated ) 5119 { 5120 std::cout << " <PROC " << name() 5121 << " DCACHE_CC_CHECK> CC_TYPE_CLACK Switch slot to EMPTY state" 5122 << " set = " << r_dcache_clack_set.read() 5123 << " / way = " << r_dcache_clack_way.read() << std::endl; 5124 } 5125 #endif 5126 break; 5127 } 5128 5129 // wait if pending request to CC_SEND. This way if there are pending 5130 // CLACK they can be treated in this state and then a deadlock 5131 // situation is avoided 5132 if ( r_dcache_cc_send_req.read() ) break; 5190 5191 assert ( not r_dcache_cc_send_req.read() and "CC_SEND must be available in DCACHE_CC_CHECK" ); 5133 5192 5134 5193 // CC request handler … … 5943 6002 if (p_vci.rspval.read()) 5944 6003 { 6004 /**/ 6005 if( p_vci.reop.read() ==0) 6006 { 6007 std::cout << "PROC " << m_srcid 6008 << "/ CYCLE " << m_cpt_total_cycles 6009 <<std::endl; 6010 } 5945 6011 assert( p_vci.reop.read() and 5946 6012 "a VCI response packet must contain one flit for a write transaction"); … … 6153 6219 // flip_flop to check that ? 6154 6220 if (not (r_cc_receive_icache_req.read()) and 6155 not (r_cc_receive_dcache_req.read()) and 6221 not (r_cc_receive_dcache_req.read()) and 6156 6222 (p_dspin_m2p.write.read())) 6157 6223 { … … 6193 6259 uint64_t receive_data = p_dspin_m2p.data.read(); 6194 6260 // for data INVAL, wait for dcache to take the request 6195 if (p_dspin_m2p.write.read() and not r_cc_receive_dcache_req.read()) 6261 if (p_dspin_m2p.write.read() and 6262 not r_cc_receive_dcache_req.read() ) 6196 6263 { 6197 6264 // request dcache to handle the INVAL … … 6211 6278 uint64_t receive_data = p_dspin_m2p.data.read(); 6212 6279 // for ins INVAL, wait for icache to take the request 6213 if (p_dspin_m2p.write.read() and not r_cc_receive_icache_req.read()) 6280 if (p_dspin_m2p.write.read() and 6281 not r_cc_receive_icache_req.read() ) 6214 6282 { 6215 6283 // request icache to handle the INVAL … … 6261 6329 // for data INVAL, wait for dcache to take the request and fifo to 6262 6330 // be empty 6263 if ( r_cc_receive_updt_fifo_be.empty() and 6331 if ( r_cc_receive_updt_fifo_be.empty() and 6264 6332 p_dspin_m2p.write.read() ) 6265 6333 { … … 6281 6349 // for ins INVAL, wait for icache to take the request and fifo to be 6282 6350 // empty 6283 if ( r_cc_receive_updt_fifo_be.empty() and 6351 if ( r_cc_receive_updt_fifo_be.empty() and 6284 6352 p_dspin_m2p.write.read() ) 6285 6353 { -
Property
svn:mergeinfo
set to
(toggle deleted branches)
-
branches/RWT/modules/vci_mem_cache/caba/source/include
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
/branches/ODCCP/modules/vci_mem_cache/caba/source/include merged eligible /branches/v5/modules/vci_mem_cache/caba/source/include 441-467
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
-
branches/RWT/modules/vci_mem_cache/caba/source/include/mem_cache_directory.h
r477 r495 6 6 #include <cassert> 7 7 #include "arithmetics.h" 8 9 // !!!10 // The L1_MULTI_CACHE mechanism does no longer work with the new pktid encoding11 // of TSAR. Turning the define below to a non null value will cause the memcache12 // to behave in an unpredicted way.13 // TODO Either remove the mechanism from the mem cache or update its behaviour.14 15 #define L1_MULTI_CACHE 016 8 17 9 //#define RANDOM_EVICTION … … 46 38 bool inst; // Is the owner an ICache ? 47 39 size_t srcid; // The SRCID of the owner 48 #if L1_MULTI_CACHE49 size_t cache_id; // In multi_cache configuration50 #endif51 40 52 41 //////////////////////// 53 42 // Constructors 54 43 //////////////////////// 55 Owner(bool i_inst 56 ,size_t i_srcid 57 #if L1_MULTI_CACHE 58 ,size_t i_cache_id 59 #endif 60 ){ 44 Owner(bool i_inst, 45 size_t i_srcid) 46 { 61 47 inst = i_inst; 62 48 srcid = i_srcid; 63 #if L1_MULTI_CACHE 64 cache_id= i_cache_id; 65 #endif 66 } 67 68 Owner(const Owner &a){ 49 } 50 51 Owner(const Owner &a) 52 { 69 53 inst = a.inst; 70 54 srcid = a.srcid; 71 #if L1_MULTI_CACHE 72 cache_id= a.cache_id; 73 #endif 74 } 75 76 Owner(){ 55 } 56 57 Owner() 58 { 77 59 inst = false; 78 60 srcid = 0; 79 #if L1_MULTI_CACHE80 cache_id= 0;81 #endif82 61 } 83 62 // end constructors … … 116 95 owner.inst = 0; 117 96 owner.srcid = 0; 118 #if L1_MULTI_CACHE119 owner.cache_id= 0;120 #endif121 97 ptr = 0; 122 98 } … … 177 153 << " ; Count = " << count 178 154 << " ; Owner = " << owner.srcid 179 #if L1_MULTI_CACHE180 << "." << owner.cache_id181 #endif182 155 << " " << owner.inst 183 156 << " ; Pointer = " << ptr << std::endl; … … 328 301 // - entry : the entry value 329 302 ///////////////////////////////////////////////////////////////////// 330 void write(const size_t &set, const size_t &way, const DirectoryEntry &entry) 303 void write( const size_t &set, 304 const size_t &way, 305 const DirectoryEntry &entry) 331 306 { 332 307 assert( (set<m_sets) … … 374 349 DirectoryEntry select(const size_t &set, size_t &way) 375 350 { 376 assert( (set < m_sets)351 assert( (set < m_sets) 377 352 && "Cache Directory : (select) The set index is invalid"); 378 353 379 for(size_t i=0; i<m_ways; i++){ 380 if(!m_dir_tab[set][i].valid){ 381 way=i; 382 return DirectoryEntry(m_dir_tab[set][way]); 354 // looking for an empty slot 355 for(size_t i=0; i<m_ways; i++) 356 { 357 if( not m_dir_tab[set][i].valid ) 358 { 359 way=i; 360 return DirectoryEntry(m_dir_tab[set][way]); 361 } 383 362 } 384 }385 363 386 364 #ifdef RANDOM_EVICTION 387 lfsr = (lfsr >> 1) ^ ((-(lfsr & 1)) & 0xd0000001);388 way = lfsr % m_ways;389 return DirectoryEntry(m_dir_tab[set][way]);365 lfsr = (lfsr >> 1) ^ ((-(lfsr & 1)) & 0xd0000001); 366 way = lfsr % m_ways; 367 return DirectoryEntry(m_dir_tab[set][way]); 390 368 #endif 391 369 392 for(size_t i=0; i<m_ways; i++){ 393 if(!(m_lru_tab[set][i].recent) && !(m_dir_tab[set][i].lock)){ 394 way=i; 395 return DirectoryEntry(m_dir_tab[set][way]); 370 // looking for a not locked and not recently used entry 371 for(size_t i=0; i<m_ways; i++) 372 { 373 if((not m_lru_tab[set][i].recent) && (not m_dir_tab[set][i].lock) ) 374 { 375 way=i; 376 return DirectoryEntry(m_dir_tab[set][way]); 377 } 396 378 } 397 } 398 for(size_t i=0; i<m_ways; i++){ 399 if( !(m_lru_tab[set][i].recent) && (m_dir_tab[set][i].lock)){ 400 way=i; 401 return DirectoryEntry(m_dir_tab[set][way]); 379 380 // looking for a locked not recently used entry 381 for(size_t i=0; i<m_ways; i++) 382 { 383 if( (not m_lru_tab[set][i].recent) && (m_dir_tab[set][i].lock)) 384 { 385 way=i; 386 return DirectoryEntry(m_dir_tab[set][way]); 387 } 402 388 } 403 } 404 for(size_t i=0; i<m_ways; i++){ 405 if( (m_lru_tab[set][i].recent) && !(m_dir_tab[set][i].lock)){ 406 way=i; 407 return DirectoryEntry(m_dir_tab[set][way]); 389 390 // looking for a recently used entry not locked 391 for(size_t i=0; i<m_ways; i++) 392 { 393 if( (m_lru_tab[set][i].recent) && (not m_dir_tab[set][i].lock)) 394 { 395 way=i; 396 return DirectoryEntry(m_dir_tab[set][way]); 397 } 408 398 } 409 } 410 way = 0; 411 return DirectoryEntry(m_dir_tab[set][0]); 399 400 // select way 0 (even if entry is locked and recently used) 401 way = 0; 402 return DirectoryEntry(m_dir_tab[set][0]); 412 403 } // end select() 413 404 … … 443 434 //////////////////////// 444 435 HeapEntry() 445 :owner(false,0 446 #if L1_MULTI_CACHE 447 ,0 448 #endif 449 ) 436 :owner(false,0) 450 437 { 451 438 next = 0; … … 455 442 // Constructor 456 443 //////////////////////// 457 HeapEntry(const HeapEntry &entry){ 444 HeapEntry(const HeapEntry &entry) 445 { 458 446 owner.inst = entry.owner.inst; 459 447 owner.srcid = entry.owner.srcid; 460 #if L1_MULTI_CACHE461 owner.cache_id = entry.owner.cache_id;462 #endif463 448 next = entry.next; 464 449 } // end constructor … … 467 452 // The copy() function copies an existing source entry to a target 468 453 ///////////////////////////////////////////////////////////////////// 469 void copy(const HeapEntry &entry){ 454 void copy(const HeapEntry &entry) 455 { 470 456 owner.inst = entry.owner.inst; 471 457 owner.srcid = entry.owner.srcid; 472 #if L1_MULTI_CACHE473 owner.cache_id = entry.owner.cache_id;474 #endif475 458 next = entry.next; 476 459 } // end copy() … … 483 466 << " -- owner.inst : " << std::dec << owner.inst << std::endl 484 467 << " -- owner.srcid : " << std::dec << owner.srcid << std::endl 485 #if L1_MULTI_CACHE486 << " -- owner.cache_id : " << std::dec << owner.cache_id << std::endl487 #endif488 468 << " -- next : " << std::dec << next << std::endl; 489 469 … … 646 626 // Cache Data 647 627 //////////////////////////////////////////////////////////////////////// 648 class CacheData { 628 class CacheData 629 { 649 630 private: 650 631 const uint32_t m_sets; … … 656 637 public: 657 638 639 /////////////////////////////////////////////////////// 658 640 CacheData(uint32_t ways, uint32_t sets, uint32_t words) 659 : m_sets(sets), m_ways(ways), m_words(words) {660 641 : m_sets(sets), m_ways(ways), m_words(words) 642 { 661 643 m_cache_data = new uint32_t ** [ways]; 662 for ( size_t i=0 ; i < ways ; i++ ) { 663 m_cache_data[i] = new uint32_t * [sets]; 644 for ( size_t i=0 ; i < ways ; i++ ) 645 { 646 m_cache_data[i] = new uint32_t * [sets]; 664 647 } 665 for ( size_t i=0; i<ways; i++ ) { 666 for ( size_t j=0; j<sets; j++ ) { 667 m_cache_data[i][j] = new uint32_t [words]; 668 } 648 for ( size_t i=0; i<ways; i++ ) 649 { 650 for ( size_t j=0; j<sets; j++ ) 651 { 652 m_cache_data[i][j] = new uint32_t [words]; 653 } 669 654 } 670 } 671 672 ~CacheData() { 673 for(size_t i=0; i<m_ways ; i++){ 674 for(size_t j=0; j<m_sets ; j++){ 655 } 656 //////////// 657 ~CacheData() 658 { 659 for(size_t i=0; i<m_ways ; i++) 660 { 661 for(size_t j=0; j<m_sets ; j++) 662 { 675 663 delete [] m_cache_data[i][j]; 676 664 } 677 665 } 678 for(size_t i=0; i<m_ways ; i++){ 666 for(size_t i=0; i<m_ways ; i++) 667 { 679 668 delete [] m_cache_data[i]; 680 669 } 681 670 delete [] m_cache_data; 682 671 } 683 684 uint32_t read ( 685 const uint32_t &way, 686 const uint32_t &set, 687 const uint32_t &word) const { 688 689 assert((set < m_sets ) && "Cache data error: Trying to read a wrong set" ); 690 assert((way < m_ways ) && "Cache data error: Trying to read a wrong way" ); 691 assert((word < m_words) && "Cache data error: Trying to read a wrong word"); 692 693 return m_cache_data[way][set][word]; 694 } 695 696 void read_line( 697 const uint32_t &way, 698 const uint32_t &set, 699 sc_core::sc_signal<uint32_t> * cache_line) 700 { 701 assert((set < m_sets ) && "Cache data error: Trying to read a wrong set" ); 702 assert((way < m_ways ) && "Cache data error: Trying to read a wrong way" ); 703 704 for (uint32_t word=0; word<m_words; word++) 705 cache_line[word].write(m_cache_data[way][set][word]); 706 } 707 708 void write ( 709 const uint32_t &way, 710 const uint32_t &set, 711 const uint32_t &word, 712 const uint32_t &data, 713 const uint32_t &be = 0xF) { 714 715 assert((set < m_sets ) && "Cache data error: Trying to write a wrong set" ); 716 assert((way < m_ways ) && "Cache data error: Trying to write a wrong way" ); 717 assert((word < m_words) && "Cache data error: Trying to write a wrong word"); 718 assert((be <= 0xF ) && "Cache data error: Trying to write a wrong word cell"); 719 720 if (be == 0x0) return; 721 722 if (be == 0xF) { 723 m_cache_data[way][set][word] = data; 724 return; 725 } 726 727 uint32_t mask = 0; 728 if (be & 0x1) mask = mask | 0x000000FF; 729 if (be & 0x2) mask = mask | 0x0000FF00; 730 if (be & 0x4) mask = mask | 0x00FF0000; 731 if (be & 0x8) mask = mask | 0xFF000000; 732 733 m_cache_data[way][set][word] = 734 (data & mask) | (m_cache_data[way][set][word] & ~mask); 672 ////////////////////////////////////////// 673 uint32_t read ( const uint32_t &way, 674 const uint32_t &set, 675 const uint32_t &word) const 676 { 677 assert((set < m_sets ) && "Cache data error: Trying to read a wrong set" ); 678 assert((way < m_ways ) && "Cache data error: Trying to read a wrong way" ); 679 assert((word < m_words) && "Cache data error: Trying to read a wrong word"); 680 681 return m_cache_data[way][set][word]; 682 } 683 ////////////////////////////////////////// 684 void read_line( const uint32_t &way, 685 const uint32_t &set, 686 sc_core::sc_signal<uint32_t> * cache_line) 687 { 688 assert((set < m_sets ) && "Cache data error: Trying to read a wrong set" ); 689 assert((way < m_ways ) && "Cache data error: Trying to read a wrong way" ); 690 691 for (uint32_t word=0; word<m_words; word++) 692 cache_line[word].write(m_cache_data[way][set][word]); 693 } 694 ///////////////////////////////////////// 695 void write ( const uint32_t &way, 696 const uint32_t &set, 697 const uint32_t &word, 698 const uint32_t &data, 699 const uint32_t &be = 0xF) 700 { 701 702 assert((set < m_sets ) && "Cache data error: Trying to write a wrong set" ); 703 assert((way < m_ways ) && "Cache data error: Trying to write a wrong way" ); 704 assert((word < m_words) && "Cache data error: Trying to write a wrong word"); 705 assert((be <= 0xF ) && "Cache data error: Trying to write a wrong be"); 706 707 if (be == 0x0) return; 708 709 if (be == 0xF) 710 { 711 m_cache_data[way][set][word] = data; 712 return; 713 } 714 715 uint32_t mask = 0; 716 if (be & 0x1) mask = mask | 0x000000FF; 717 if (be & 0x2) mask = mask | 0x0000FF00; 718 if (be & 0x4) mask = mask | 0x00FF0000; 719 if (be & 0x8) mask = mask | 0xFF000000; 720 721 m_cache_data[way][set][word] = 722 (data & mask) | (m_cache_data[way][set][word] & ~mask); 735 723 } 736 724 }; // end class CacheData -
branches/RWT/modules/vci_mem_cache/caba/source/include/update_tab.h
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
/trunk/modules/vci_mem_cache/caba/source/include/update_tab.h merged eligible /branches/v5/modules/vci_mem_cache/caba/source/include/update_tab.h 441-467
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
-
branches/RWT/modules/vci_mem_cache/caba/source/include/vci_mem_cache.h
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
/branches/ODCCP/modules/vci_mem_cache/caba/source/include/vci_mem_cache.h merged eligible /trunk/modules/vci_mem_cache/caba/source/include/vci_mem_cache.h merged eligible /branches/v5/modules/vci_mem_cache/caba/source/include/vci_mem_cache.h 441-467
r477 r495 25 25 * SOCLIB_LGPL_HEADER_END 26 26 * 27 * Maintainers: alain eric.guthmuller@polytechnique.edu 27 * Maintainers: alain.greiner@lip6.fr 28 * eric.guthmuller@polytechnique.edu 28 29 * cesar.fuguet-tortolero@lip6.fr 29 30 * alexandre.joannou@lip6.fr … … 154 155 MULTI_ACK_UPT_LOCK, 155 156 MULTI_ACK_UPT_CLEAR, 156 MULTI_ACK_WRITE_RSP, 157 MULTI_ACK_CONFIG_ACK 157 MULTI_ACK_WRITE_RSP 158 158 }; 159 159 … … 163 163 CONFIG_IDLE, 164 164 CONFIG_LOOP, 165 CONFIG_WAIT, 165 166 CONFIG_RSP, 166 167 CONFIG_DIR_REQ, 167 168 CONFIG_DIR_ACCESS, 168 CONFIG_ DIR_IVT_LOCK,169 CONFIG_IVT_LOCK, 169 170 CONFIG_BC_SEND, 170 CONFIG_BC_WAIT, 171 CONFIG_INV_SEND, 171 CONFIG_INVAL_SEND, 172 172 CONFIG_HEAP_REQ, 173 173 CONFIG_HEAP_SCAN, 174 174 CONFIG_HEAP_LAST, 175 CONFIG_INV_WAIT 175 CONFIG_TRT_LOCK, 176 CONFIG_TRT_SET, 177 CONFIG_PUT_REQ 176 178 }; 177 179 … … 204 206 WRITE_DIR_LOCK, 205 207 WRITE_IVT_LOCK_HIT_WB, 206 WRITE_DIR_READ,207 208 WRITE_DIR_HIT, 208 209 WRITE_UPT_LOCK, … … 217 218 WRITE_MISS_TRT_SET, 218 219 WRITE_MISS_XRAM_REQ, 220 WRITE_BC_DIR_READ, 219 221 WRITE_BC_TRT_LOCK, 220 222 WRITE_BC_IVT_LOCK, … … 243 245 XRAM_RSP_DIR_UPDT, 244 246 XRAM_RSP_DIR_RSP, 245 XRAM_RSP_I NVAL_LOCK,247 XRAM_RSP_IVT_LOCK, 246 248 XRAM_RSP_INVAL_WAIT, 247 249 XRAM_RSP_INVAL, … … 262 264 IXR_CMD_XRAM_IDLE, 263 265 IXR_CMD_CLEANUP_IDLE, 264 IXR_CMD_READ, 265 IXR_CMD_WRITE, 266 IXR_CMD_CAS, 267 IXR_CMD_XRAM, 268 IXR_CMD_CLEANUP_DATA 266 IXR_CMD_CONFIG_IDLE, 267 IXR_CMD_READ_TRT, 268 IXR_CMD_WRITE_TRT, 269 IXR_CMD_CAS_TRT, 270 IXR_CMD_XRAM_TRT, 271 IXR_CMD_CLEANUP_TRT, 272 IXR_CMD_CONFIG_TRT, 273 IXR_CMD_READ_SEND, 274 IXR_CMD_WRITE_SEND, 275 IXR_CMD_CAS_SEND, 276 IXR_CMD_XRAM_SEND, 277 IXR_CMD_CLEANUP_DATA_SEND, 278 IXR_CMD_CONFIG_SEND 269 279 }; 270 280 … … 318 328 CLEANUP_IXR_REQ, 319 329 CLEANUP_WAIT, 320 CLEANUP_CONFIG_ACK,321 330 CLEANUP_SEND_CLACK 322 331 }; … … 342 351 ALLOC_TRT_XRAM_RSP, 343 352 ALLOC_TRT_IXR_RSP, 344 ALLOC_TRT_CLEANUP 353 ALLOC_TRT_CLEANUP, 354 ALLOC_TRT_IXR_CMD, 355 ALLOC_TRT_CONFIG 345 356 }; 346 357 … … 404 415 }; 405 416 406 /* Configuration commands */ 407 enum cmd_config_type_e 408 { 409 CMD_CONFIG_INVAL = 0, 410 CMD_CONFIG_SYNC = 1 411 }; 412 413 // debug variables (for each FSM) 417 // debug variables 414 418 bool m_debug; 415 419 bool m_debug_previous_valid; 416 420 size_t m_debug_previous_count; 417 421 bool m_debug_previous_dirty; 418 sc_signal<data_t>* m_debug_previous_data; 419 sc_signal<data_t>* m_debug_data; 420 421 bool m_monitor_ok; 422 addr_t m_monitor_base; 423 addr_t m_monitor_length; 422 data_t * m_debug_previous_data; 423 data_t * m_debug_data; 424 424 425 425 // instrumentation counters … … 644 644 uint32_t m_broadcast_boundaries; 645 645 646 //////////////////////////////////////////////////647 // Registers controlled by the TGT_CMD fsm648 //////////////////////////////////////////////////649 650 sc_signal<int> r_tgt_cmd_fsm;651 652 646 // Fifo between TGT_CMD fsm and READ fsm 653 647 GenericFifo<addr_t> m_cmd_read_addr_fifo; … … 693 687 sc_signal<size_t> r_tgt_cmd_config_cmd; 694 688 689 ////////////////////////////////////////////////// 690 // Registers controlled by the TGT_CMD fsm 691 ////////////////////////////////////////////////// 692 693 sc_signal<int> r_tgt_cmd_fsm; 694 sc_signal<size_t> r_tgt_cmd_srcid; // srcid for response to config 695 sc_signal<size_t> r_tgt_cmd_trdid; // trdid for response to config 696 sc_signal<size_t> r_tgt_cmd_pktid; // pktid for response to config 697 695 698 /////////////////////////////////////////////////////// 696 699 // Registers controlled by the CONFIG fsm 697 700 /////////////////////////////////////////////////////// 698 701 699 sc_signal<int> r_config_fsm; // FSM state 700 sc_signal<bool> r_config_lock; // lock protecting exclusive access 701 sc_signal<int> r_config_cmd; // config request status 702 sc_signal<addr_t> r_config_address; // target buffer physical address 703 sc_signal<size_t> r_config_srcid; // config request srcid 704 sc_signal<size_t> r_config_trdid; // config request trdid 705 sc_signal<size_t> r_config_pktid; // config request pktid 706 sc_signal<size_t> r_config_nlines; // number of lines covering the buffer 707 sc_signal<size_t> r_config_dir_way; // DIR: selected way 708 sc_signal<size_t> r_config_dir_count; // DIR: number of copies 709 sc_signal<bool> r_config_dir_is_cnt; // DIR: counter mode (broadcast required) 710 sc_signal<size_t> r_config_dir_copy_srcid; // DIR: first copy SRCID 711 sc_signal<bool> r_config_dir_copy_inst; // DIR: first copy L1 type 712 sc_signal<size_t> r_config_dir_next_ptr; // DIR: index of next copy in HEAP 713 sc_signal<size_t> r_config_heap_next; // current pointer to scan HEAP 714 715 sc_signal<size_t> r_config_ivt_index; // IVT index 702 sc_signal<int> r_config_fsm; // FSM state 703 sc_signal<bool> r_config_lock; // lock protecting exclusive access 704 sc_signal<int> r_config_cmd; // config request type 705 sc_signal<addr_t> r_config_address; // target buffer physical address 706 sc_signal<size_t> r_config_srcid; // config request srcid 707 sc_signal<size_t> r_config_trdid; // config request trdid 708 sc_signal<size_t> r_config_pktid; // config request pktid 709 sc_signal<size_t> r_config_cmd_lines; // number of lines to be handled 710 sc_signal<size_t> r_config_rsp_lines; // number of lines not completed 711 sc_signal<size_t> r_config_dir_way; // DIR: selected way 712 sc_signal<bool> r_config_dir_lock; // DIR: locked entry 713 sc_signal<size_t> r_config_dir_count; // DIR: number of copies 714 sc_signal<bool> r_config_dir_is_cnt; // DIR: counter mode (broadcast) 715 sc_signal<size_t> r_config_dir_copy_srcid; // DIR: first copy SRCID 716 sc_signal<bool> r_config_dir_copy_inst; // DIR: first copy L1 type 717 sc_signal<size_t> r_config_dir_ptr; // DIR: index of next copy in HEAP 718 sc_signal<size_t> r_config_heap_next; // current pointer to scan HEAP 719 sc_signal<size_t> r_config_trt_index; // selected entry in TRT 720 sc_signal<size_t> r_config_ivt_index; // selected entry in IVT 721 722 // Buffer between CONFIG fsm and IXR_CMD fsm 723 sc_signal<bool> r_config_to_ixr_cmd_req; // valid request 724 sc_signal<size_t> r_config_to_ixr_cmd_index; // TRT index 725 716 726 717 727 // Buffer between CONFIG fsm and TGT_RSP fsm (send a done response to L1 cache) … … 730 740 GenericFifo<size_t> m_config_to_cc_send_srcid_fifo; // fifo for owners srcid 731 741 732 #if L1_MULTI_CACHE733 GenericFifo<size_t> m_config_to_cc_send_cache_id_fifo; // fifo for cache_id734 #endif735 736 742 /////////////////////////////////////////////////////// 737 743 // Registers controlled by the READ fsm 738 744 /////////////////////////////////////////////////////// 739 745 740 sc_signal<int> r_read_fsm; // FSM state 741 sc_signal<size_t> r_read_copy; // Srcid of the first copy 742 sc_signal<size_t> r_read_copy_cache; // Srcid of the first copy 743 sc_signal<bool> r_read_copy_inst; // Type of the first copy 744 sc_signal<tag_t> r_read_tag; // cache line tag (in directory) 745 sc_signal<bool> r_read_is_cnt; // is_cnt bit (in directory) 746 sc_signal<bool> r_read_lock; // lock bit (in directory) 747 sc_signal<bool> r_read_dirty; // dirty bit (in directory) 748 sc_signal<size_t> r_read_count; // number of copies 749 sc_signal<size_t> r_read_ptr; // pointer to the heap 750 sc_signal<data_t> * r_read_data; // data (one cache line) 751 sc_signal<size_t> r_read_way; // associative way (in cache) 752 sc_signal<size_t> r_read_trt_index; // Transaction Table index 753 sc_signal<size_t> r_read_next_ptr; // Next entry to point to 754 sc_signal<bool> r_read_last_free; // Last free entry 755 sc_signal<addr_t> r_read_ll_key; // LL key from the llsc_global_table 756 757 // Buffer between READ fsm and IXR_CMD fsm (ask a missing cache line to XRAM) 758 sc_signal<bool> r_read_to_ixr_cmd_req; // valid request 759 sc_signal<addr_t> r_read_to_ixr_cmd_nline; // cache line index 760 sc_signal<size_t> r_read_to_ixr_cmd_trdid; // index in Transaction Table 746 sc_signal<int> r_read_fsm; // FSM state 747 sc_signal<size_t> r_read_copy; // Srcid of the first copy 748 sc_signal<size_t> r_read_copy_cache; // Srcid of the first copy 749 sc_signal<bool> r_read_copy_inst; // Type of the first copy 750 sc_signal<tag_t> r_read_tag; // cache line tag (in directory) 751 sc_signal<bool> r_read_is_cnt; // is_cnt bit (in directory) 752 sc_signal<bool> r_read_lock; // lock bit (in directory) 753 sc_signal<bool> r_read_dirty; // dirty bit (in directory) 754 sc_signal<size_t> r_read_count; // number of copies 755 sc_signal<size_t> r_read_ptr; // pointer to the heap 756 sc_signal<data_t> * r_read_data; // data (one cache line) 757 sc_signal<size_t> r_read_way; // associative way (in cache) 758 sc_signal<size_t> r_read_trt_index; // Transaction Table index 759 sc_signal<size_t> r_read_next_ptr; // Next entry to point to 760 sc_signal<bool> r_read_last_free; // Last free entry 761 sc_signal<addr_t> r_read_ll_key; // LL key from llsc_global_table 762 763 // Buffer between READ fsm and IXR_CMD fsm 764 sc_signal<bool> r_read_to_ixr_cmd_req; // valid request 765 sc_signal<size_t> r_read_to_ixr_cmd_index; // TRT index 761 766 762 767 // Buffer between READ fsm and TGT_RSP fsm (send a hit read response to L1 cache) 763 sc_signal<bool> r_read_to_tgt_rsp_req; // valid request764 sc_signal<size_t> r_read_to_tgt_rsp_srcid; // Transaction srcid765 sc_signal<size_t> r_read_to_tgt_rsp_trdid; // Transaction trdid766 sc_signal<size_t> r_read_to_tgt_rsp_pktid; // Transaction pktid767 sc_signal<data_t> * r_read_to_tgt_rsp_data; // data (one cache line)768 sc_signal<size_t> r_read_to_tgt_rsp_word; // first word of the response769 sc_signal<size_t> r_read_to_tgt_rsp_length; // length of the response770 sc_signal<addr_t> r_read_to_tgt_rsp_ll_key; // LL key from thellsc_global_table768 sc_signal<bool> r_read_to_tgt_rsp_req; // valid request 769 sc_signal<size_t> r_read_to_tgt_rsp_srcid; // Transaction srcid 770 sc_signal<size_t> r_read_to_tgt_rsp_trdid; // Transaction trdid 771 sc_signal<size_t> r_read_to_tgt_rsp_pktid; // Transaction pktid 772 sc_signal<data_t> * r_read_to_tgt_rsp_data; // data (one cache line) 773 sc_signal<size_t> r_read_to_tgt_rsp_word; // first word of the response 774 sc_signal<size_t> r_read_to_tgt_rsp_length; // length of the response 775 sc_signal<addr_t> r_read_to_tgt_rsp_ll_key; // LL key from llsc_global_table 771 776 772 777 //RWT: Buffer between READ fsm and CC_SEND fsm (send inval) … … 795 800 /////////////////////////////////////////////////////////////// 796 801 797 sc_signal<int> r_write_fsm; // FSM state798 sc_signal<addr_t> r_write_address; // first word address799 sc_signal<size_t> r_write_word_index; // first word index in line800 sc_signal<size_t> r_write_word_count; // number of words in line801 sc_signal<size_t> r_write_srcid; // transaction srcid802 sc_signal<size_t> r_write_trdid; // transaction trdid803 sc_signal<size_t> r_write_pktid; // transaction pktid804 sc_signal<data_t> * r_write_data; // data (one cache line)805 sc_signal<be_t> * r_write_be; // one byte enable per word806 sc_signal<bool> r_write_byte; // (BE != 0X0) and (BE != 0xF)807 sc_signal<bool> r_write_is_cnt; // is_cnt bit (in directory)808 sc_signal<bool> r_write_lock; // lock bit (in directory)809 sc_signal<tag_t> r_write_tag; // cache line tag (in directory)810 sc_signal<size_t> r_write_copy; // first owner of the line811 sc_signal<size_t> r_write_copy_cache; // first owner of the line812 sc_signal<bool> r_write_copy_inst; // is this owner a ICache ?813 sc_signal<size_t> r_write_count; // number of copies814 sc_signal<size_t> r_write_ptr; // pointer to the heap815 sc_signal<size_t> r_write_next_ptr; // next pointer to the heap816 sc_signal<bool> r_write_to_dec; // need to decrement update counter817 sc_signal<size_t> r_write_way; // way of the line818 sc_signal<size_t> r_write_trt_index; // index in Transaction Table819 sc_signal<size_t> r_write_upt_index; // index in Update Table820 sc_signal<bool> r_write_sc_fail; // sc command failed821 sc_signal<bool> r_write_pending_sc; // sc command pending802 sc_signal<int> r_write_fsm; // FSM state 803 sc_signal<addr_t> r_write_address; // first word address 804 sc_signal<size_t> r_write_word_index; // first word index in line 805 sc_signal<size_t> r_write_word_count; // number of words in line 806 sc_signal<size_t> r_write_srcid; // transaction srcid 807 sc_signal<size_t> r_write_trdid; // transaction trdid 808 sc_signal<size_t> r_write_pktid; // transaction pktid 809 sc_signal<data_t> * r_write_data; // data (one cache line) 810 sc_signal<be_t> * r_write_be; // one byte enable per word 811 sc_signal<bool> r_write_byte; // (BE != 0X0) and (BE != 0xF) 812 sc_signal<bool> r_write_is_cnt; // is_cnt bit (in directory) 813 sc_signal<bool> r_write_lock; // lock bit (in directory) 814 sc_signal<tag_t> r_write_tag; // cache line tag (in directory) 815 sc_signal<size_t> r_write_copy; // first owner of the line 816 sc_signal<size_t> r_write_copy_cache; // first owner of the line 817 sc_signal<bool> r_write_copy_inst; // is this owner a ICache ? 818 sc_signal<size_t> r_write_count; // number of copies 819 sc_signal<size_t> r_write_ptr; // pointer to the heap 820 sc_signal<size_t> r_write_next_ptr; // next pointer to the heap 821 sc_signal<bool> r_write_to_dec; // need to decrement update counter 822 sc_signal<size_t> r_write_way; // way of the line 823 sc_signal<size_t> r_write_trt_index; // index in Transaction Table 824 sc_signal<size_t> r_write_upt_index; // index in Update Table 825 sc_signal<bool> r_write_sc_fail; // sc command failed 826 sc_signal<bool> r_write_pending_sc; // sc command pending 822 827 823 828 // Buffer between WRITE fsm and TGT_RSP fsm (acknowledge a write command from L1) … … 828 833 sc_signal<bool> r_write_to_tgt_rsp_sc_fail; // sc command failed 829 834 830 // Buffer between WRITE fsm and IXR_CMD fsm (ask a missing cache line to XRAM) 831 sc_signal<bool> r_write_to_ixr_cmd_req; // valid request 832 sc_signal<bool> r_write_to_ixr_cmd_write; // write request 833 sc_signal<addr_t> r_write_to_ixr_cmd_nline; // cache line index 834 sc_signal<data_t> * r_write_to_ixr_cmd_data; // cache line data 835 sc_signal<size_t> r_write_to_ixr_cmd_trdid; // index in Transaction Table 835 // Buffer between WRITE fsm and IXR_CMD fsm 836 sc_signal<bool> r_write_to_ixr_cmd_req; // valid request 837 sc_signal<bool> r_write_to_ixr_cmd_put; // request type (GET/PUT) 838 sc_signal<size_t> r_write_to_ixr_cmd_index; // TRT index 836 839 837 840 // Buffer between WRITE fsm and CC_SEND fsm (Update/Invalidate L1 caches) … … 847 850 GenericFifo<size_t> m_write_to_cc_send_srcid_fifo; // fifo for srcids 848 851 849 #if L1_MULTI_CACHE850 GenericFifo<size_t> m_write_to_cc_send_cache_id_fifo; // fifo for srcids851 #endif852 853 852 // Buffer between WRITE fsm and MULTI_ACK fsm (Decrement UPT entry) 854 853 sc_signal<bool> r_write_to_multi_ack_req; // valid request … … 878 877 sc_signal<addr_t> r_multi_ack_nline; // pending write nline 879 878 880 // signaling completion of multi-inval to CONFIG fsm881 sc_signal<bool> r_multi_ack_to_config_ack;882 883 879 // Buffer between MULTI_ACK fsm and TGT_RSP fsm (complete write/update transaction) 884 880 sc_signal<bool> r_multi_ack_to_tgt_rsp_req; // valid request … … 897 893 sc_signal<addr_t> r_cleanup_nline; // cache line index 898 894 899 #if L1_MULTI_CACHE900 sc_signal<size_t> r_cleanup_pktid; // transaction pktid901 #endif902 895 903 896 sc_signal<copy_t> r_cleanup_copy; // first copy … … 926 919 sc_signal<size_t> r_cleanup_index; // index of the INVAL line (in the UPT) 927 920 928 // signaling completion of broadcast-inval to CONFIG fsm929 sc_signal<bool> r_cleanup_to_config_ack;930 931 921 // Buffer between CLEANUP fsm and TGT_RSP fsm (acknowledge a write command from L1) 932 922 sc_signal<bool> r_cleanup_to_tgt_rsp_req; // valid request … … 950 940 /////////////////////////////////////////////////////// 951 941 952 sc_signal<int> r_cas_fsm; // FSM state953 sc_signal<data_t> r_cas_wdata; // write data word954 sc_signal<data_t> * r_cas_rdata; // read data word955 sc_signal<uint32_t> r_cas_lfsr; // lfsr for random introducing956 sc_signal<size_t> r_cas_cpt; // size of command957 sc_signal<copy_t> r_cas_copy; // Srcid of the first copy958 sc_signal<copy_t> r_cas_copy_cache; // Srcid of the first copy959 sc_signal<bool> r_cas_copy_inst; // Type of the first copy960 sc_signal<size_t> r_cas_count; // number of copies961 sc_signal<size_t> r_cas_ptr; // pointer to the heap962 sc_signal<size_t> r_cas_next_ptr; // next pointer to the heap963 sc_signal<bool> r_cas_is_cnt; // is_cnt bit (in directory)964 sc_signal<bool> r_cas_dirty; // dirty bit (in directory)965 sc_signal<size_t> r_cas_way; // way in directory966 sc_signal<size_t> r_cas_set; // set in directory967 sc_signal<data_t> r_cas_tag; // cache line tag (in directory)968 sc_signal<size_t> r_cas_trt_index; // Transaction Table index969 sc_signal<size_t> r_cas_upt_index; // Update Table index970 sc_signal<data_t> * r_cas_data; // cache line data942 sc_signal<int> r_cas_fsm; // FSM state 943 sc_signal<data_t> r_cas_wdata; // write data word 944 sc_signal<data_t> * r_cas_rdata; // read data word 945 sc_signal<uint32_t> r_cas_lfsr; // lfsr for random introducing 946 sc_signal<size_t> r_cas_cpt; // size of command 947 sc_signal<copy_t> r_cas_copy; // Srcid of the first copy 948 sc_signal<copy_t> r_cas_copy_cache; // Srcid of the first copy 949 sc_signal<bool> r_cas_copy_inst; // Type of the first copy 950 sc_signal<size_t> r_cas_count; // number of copies 951 sc_signal<size_t> r_cas_ptr; // pointer to the heap 952 sc_signal<size_t> r_cas_next_ptr; // next pointer to the heap 953 sc_signal<bool> r_cas_is_cnt; // is_cnt bit (in directory) 954 sc_signal<bool> r_cas_dirty; // dirty bit (in directory) 955 sc_signal<size_t> r_cas_way; // way in directory 956 sc_signal<size_t> r_cas_set; // set in directory 957 sc_signal<data_t> r_cas_tag; // cache line tag (in directory) 958 sc_signal<size_t> r_cas_trt_index; // Transaction Table index 959 sc_signal<size_t> r_cas_upt_index; // Update Table index 960 sc_signal<data_t> * r_cas_data; // cache line data 971 961 972 962 sc_signal<bool> r_cas_coherent; … … 974 964 // Buffer between CAS fsm and IXR_CMD fsm (XRAM write) 975 965 sc_signal<bool> r_cas_to_ixr_cmd_req; // valid request 976 sc_signal<addr_t> r_cas_to_ixr_cmd_nline; // cache line index 977 sc_signal<size_t> r_cas_to_ixr_cmd_trdid; // index in Transaction Table 978 sc_signal<bool> r_cas_to_ixr_cmd_write; // write request 979 sc_signal<data_t> * r_cas_to_ixr_cmd_data; // cache line data 980 966 sc_signal<bool> r_cas_to_ixr_cmd_put; // request type (GET/PUT) 967 sc_signal<size_t> r_cas_to_ixr_cmd_index; // TRT index 981 968 982 969 // Buffer between CAS fsm and TGT_RSP fsm … … 999 986 GenericFifo<size_t> m_cas_to_cc_send_srcid_fifo; // fifo for srcids 1000 987 1001 #if L1_MULTI_CACHE1002 GenericFifo<size_t> m_cas_to_cc_send_cache_id_fifo; // fifo for srcids1003 #endif1004 1005 988 //////////////////////////////////////////////////// 1006 989 // Registers controlled by the IXR_RSP fsm 1007 990 //////////////////////////////////////////////////// 1008 991 1009 sc_signal<int> r_ixr_rsp_fsm; // FSM state 1010 sc_signal<size_t> r_ixr_rsp_trt_index; // TRT entry index 1011 sc_signal<size_t> r_ixr_rsp_cpt; // word counter 992 sc_signal<int> r_ixr_rsp_fsm; // FSM state 993 sc_signal<size_t> r_ixr_rsp_trt_index; // TRT entry index 994 sc_signal<size_t> r_ixr_rsp_cpt; // word counter 995 996 // Buffer between IXR_RSP fsm and CONFIG fsm (response from the XRAM) 997 sc_signal<bool> r_ixr_rsp_to_config_ack; // one single bit 1012 998 1013 999 // Buffer between IXR_RSP fsm and XRAM_RSP fsm (response from the XRAM) 1014 sc_signal<bool> * r_ixr_rsp_to_xram_rsp_rok; // A xram response is ready1000 sc_signal<bool> * r_ixr_rsp_to_xram_rsp_rok; // one bit per TRT entry 1015 1001 1016 1002 //////////////////////////////////////////////////// … … 1055 1041 GenericFifo<size_t> m_xram_rsp_to_cc_send_srcid_fifo; // fifo for srcids 1056 1042 1057 #if L1_MULTI_CACHE 1058 GenericFifo<size_t> m_xram_rsp_to_cc_send_cache_id_fifo; // fifo for srcids 1059 #endif 1060 1061 // Buffer between XRAM_RSP fsm and IXR_CMD fsm (XRAM write) 1043 // Buffer between XRAM_RSP fsm and IXR_CMD fsm 1062 1044 sc_signal<bool> r_xram_rsp_to_ixr_cmd_req; // Valid request 1063 sc_signal<addr_t> r_xram_rsp_to_ixr_cmd_nline; // cache line index 1064 sc_signal<data_t> * r_xram_rsp_to_ixr_cmd_data; // cache line data 1065 sc_signal<size_t> r_xram_rsp_to_ixr_cmd_trdid; // index in transaction table 1045 sc_signal<size_t> r_xram_rsp_to_ixr_cmd_index; // TRT index 1066 1046 1067 1047 //RWT … … 1073 1053 1074 1054 sc_signal<int> r_ixr_cmd_fsm; 1075 sc_signal<size_t> r_ixr_cmd_cpt; 1055 sc_signal<size_t> r_ixr_cmd_word; // word index for a put 1056 sc_signal<size_t> r_ixr_cmd_trdid; // TRT index value 1057 sc_signal<addr_t> r_ixr_cmd_address; // address to XRAM 1058 sc_signal<data_t> * r_ixr_cmd_wdata; // cache line buffer 1059 sc_signal<bool> r_ixr_cmd_get; // transaction type (PUT/GET) 1076 1060 1077 1061 //////////////////////////////////////////////////// … … 1149 1133 sc_signal<data_t> *r_cleanup_to_ixr_cmd_data; 1150 1134 sc_signal<uint32_t> r_cleanup_to_ixr_cmd_srcid; 1151 sc_signal<uint32_t> r_cleanup_to_ixr_cmd_ trdid;1135 sc_signal<uint32_t> r_cleanup_to_ixr_cmd_index; 1152 1136 sc_signal<uint32_t> r_cleanup_to_ixr_cmd_pktid; 1153 1137 sc_signal<addr_t> r_cleanup_to_ixr_cmd_nline; -
Property
svn:mergeinfo
set to
(toggle deleted branches)
-
branches/RWT/modules/vci_mem_cache/caba/source/include/xram_transaction.h
r477 r495 34 34 bool rerror; // error returned by xram 35 35 data_t ll_key; // LL key returned by the llsc_global_table 36 bool config; // transaction required by CONFIG FSM 36 37 37 38 ///////////////////////////////////////////////////////////////////// … … 42 43 valid = false; 43 44 rerror = false; 45 config = false; 44 46 } 45 47 … … 80 82 rerror = source.rerror; 81 83 ll_key = source.ll_key; 84 config = source.config; 82 85 } 83 86 … … 87 90 void print() 88 91 { 92 std::cout << "------- TRT entry -------" << std::endl; 89 93 std::cout << "valid = " << valid << std::endl; 90 94 std::cout << "xram_read = " << xram_read << std::endl; … … 96 100 std::cout << "read_length = " << read_length << std::endl; 97 101 std::cout << "word_index = " << word_index << std::endl; 98 for(size_t i=0; i<wdata_be.size() ; i++){ 99 std::cout << "wdata_be [" << i <<"] = " << wdata_be[i] << std::endl; 100 } 101 for(size_t i=0; i<wdata.size() ; i++){ 102 std::cout << "wdata [" << i <<"] = " << wdata[i] << std::endl; 103 } 102 for(size_t i=0; i<wdata_be.size() ; i++) 103 { 104 std::cout << "wdata_be[" << std::dec << i << "] = " 105 << std::hex << wdata_be[i] << std::endl; 106 } 107 for(size_t i=0; i<wdata.size() ; i++) 108 { 109 std::cout << "wdata[" << std::dec << i << "] = " 110 << std::hex << wdata[i] << std::endl; 111 } 112 std::cout << "rerror = " << rerror << std::endl; 113 std::cout << "ll_key = " << ll_key << std::endl; 114 std::cout << "config = " << config << std::endl; 104 115 std::cout << std::endl; 105 std::cout << "rerror = " << rerror << std::endl;106 116 } 107 117 … … 114 124 wdata_be.clear(); 115 125 wdata.clear(); 116 valid=false; 117 rerror=false; 118 } 119 120 TransactionTabEntry(const TransactionTabEntry &source){ 126 valid = false; 127 rerror = false; 128 config = false; 129 } 130 131 TransactionTabEntry(const TransactionTabEntry &source) 132 { 121 133 valid = source.valid; 122 134 xram_read = source.xram_read; … … 132 144 rerror = source.rerror; 133 145 ll_key = source.ll_key; 146 config = source.config; 134 147 } 135 148 … … 197 210 delete [] tab; 198 211 } 199 200 212 ///////////////////////////////////////////////////////////////////// 201 213 // The size() function returns the size of the tab … … 205 217 return size_tab; 206 218 } 207 208 219 ///////////////////////////////////////////////////////////////////// 209 220 // The init() function initializes the transaction tab entries … … 211 222 void init() 212 223 { 213 for ( size_t i=0; i<size_tab; i++) { 224 for ( size_t i=0; i<size_tab; i++) 225 { 214 226 tab[i].init(); 215 227 } 216 228 } 217 218 229 ///////////////////////////////////////////////////////////////////// 219 230 // The print() function prints a transaction tab entry … … 223 234 void print(const size_t index) 224 235 { 225 assert( (index < size_tab) 226 && "Invalid Transaction Tab Entry"); 236 assert( (index < size_tab) and 237 "MEMC ERROR: The selected entry is out of range in TRT write_data_mask()"); 238 227 239 tab[index].print(); 228 240 return; 229 241 } 230 231 242 ///////////////////////////////////////////////////////////////////// 232 243 // The read() function returns a transaction tab entry. … … 236 247 TransactionTabEntry read(const size_t index) 237 248 { 238 assert( (index < size_tab) 239 && "Invalid Transaction Tab Entry"); 249 assert( (index < size_tab) and 250 "MEMC ERROR: Invalid Transaction Tab Entry"); 251 240 252 return tab[index]; 241 253 } 242 243 254 ///////////////////////////////////////////////////////////////////// 244 255 // The full() function returns the state of the transaction tab … … 249 260 bool full(size_t &index) 250 261 { 251 for(size_t i=0; i<size_tab; i++){ 252 if(!tab[i].valid){ 262 for(size_t i=0; i<size_tab; i++) 263 { 264 if(!tab[i].valid) 265 { 253 266 index=i; 254 267 return false; … … 257 270 return true; 258 271 } 259 260 272 ///////////////////////////////////////////////////////////////////// 261 273 // The hit_read() function checks if an XRAM read transaction exists … … 268 280 bool hit_read(const addr_t nline,size_t &index) 269 281 { 270 for(size_t i=0; i<size_tab; i++){ 271 if((tab[i].valid && (nline==tab[i].nline)) && (tab[i].xram_read)) { 282 for(size_t i=0; i<size_tab; i++) 283 { 284 if((tab[i].valid && (nline==tab[i].nline)) && (tab[i].xram_read)) 285 { 272 286 index=i; 273 287 return true; … … 276 290 return false; 277 291 } 278 279 292 /////////////////////////////////////////////////////////////////////// 280 293 // The hit_write() function looks if an XRAM write transaction exists … … 286 299 bool hit_write(const addr_t nline) 287 300 { 288 for(size_t i=0; i<size_tab; i++){ 289 if(tab[i].valid && (nline==tab[i].nline) && !(tab[i].xram_read)) { 301 for(size_t i=0; i<size_tab; i++) 302 { 303 if(tab[i].valid && (nline==tab[i].nline) && !(tab[i].xram_read)) 304 { 290 305 return true; 291 306 } … … 325 340 const std::vector<data_t> &data) 326 341 { 327 assert( (index < size_tab) 328 && "Invalid Transaction Tab Entry"); 329 assert(be.size()==tab[index].wdata_be.size() 330 && "Bad data mask in write_data_mask in TransactionTab"); 331 assert(data.size()==tab[index].wdata.size() 332 && "Bad data in write_data_mask in TransactionTab"); 333 334 for(size_t i=0; i<tab[index].wdata_be.size() ; i++) { 342 assert( (index < size_tab) and 343 "MEMC ERROR: The selected entry is out of range in TRT write_data_mask()"); 344 345 assert( (be.size()==tab[index].wdata_be.size()) and 346 "MEMC ERROR: Bad be size in TRT write_data_mask()"); 347 348 assert( (data.size()==tab[index].wdata.size()) and 349 "MEMC ERROR: Bad data size in TRT write_data_mask()"); 350 351 for(size_t i=0; i<tab[index].wdata_be.size() ; i++) 352 { 335 353 tab[index].wdata_be[i] = tab[index].wdata_be[i] | be[i]; 336 354 data_t mask = be_to_mask(be[i]); … … 338 356 } 339 357 } 340 341 358 ///////////////////////////////////////////////////////////////////// 342 359 // The set() function registers a transaction (read or write) … … 355 372 // - data_be : the mask of the data to write (in case of write) 356 373 // - ll_key : the ll key (if any) returned by the llsc_global_table 374 // - config : transaction required by config FSM 357 375 ///////////////////////////////////////////////////////////////////// 358 376 void set(const size_t index, … … 367 385 const std::vector<be_t> &data_be, 368 386 const std::vector<data_t> &data, 369 const data_t ll_key = 0) 370 { 371 assert( (index < size_tab) 372 && "The selected entry is out of range in set() Transaction Tab"); 373 assert(data_be.size()==tab[index].wdata_be.size() 374 && "Bad data_be argument in set() TransactionTab"); 375 assert(data.size()==tab[index].wdata.size() 376 && "Bad data argument in set() TransactionTab"); 387 const data_t ll_key = 0, 388 const bool config = false) 389 { 390 assert( (index < size_tab) and 391 "MEMC ERROR: The selected entry is out of range in TRT set()"); 392 393 assert( (data_be.size()==tab[index].wdata_be.size()) and 394 "MEMC ERROR: Bad data_be argument in TRT set()"); 395 396 assert( (data.size()==tab[index].wdata.size()) and 397 "MEMC ERROR: Bad data argument in TRT set()"); 377 398 378 399 tab[index].valid = true; … … 386 407 tab[index].word_index = word_index; 387 408 tab[index].ll_key = ll_key; 409 tab[index].config = config; 388 410 for(size_t i=0; i<tab[index].wdata.size(); i++) 389 411 { … … 398 420 // The BE field in TRT is taken into account. 399 421 // Arguments : 400 // - index : the index of the transaction in the transaction tab 401 // - word_index : the index of the data in the line 402 // - data : a 64 bits value 403 // - error : invalid data 422 // - index : index of the entry in TRT 423 // - word : index of the 32 bits word in the line 424 // - data : 64 bits value (first data right) 404 425 ///////////////////////////////////////////////////////////////////// 405 426 void write_rsp(const size_t index, 406 427 const size_t word, 407 const wide_data_t data, 408 const bool rerror) 428 const wide_data_t data) 409 429 { 410 430 data_t value; 411 431 data_t mask; 412 432 413 if ( index >= size_tab ) 414 { 415 std::cout << "VCI_MEM_CACHE ERRROR " << tab_name 416 << " TRT entry out of range in write_rsp()" << std::endl; 417 exit(0); 418 } 419 if ( word > tab[index].wdata_be.size() ) 420 { 421 std::cout << "VCI_MEM_CACHE ERRROR " << tab_name 422 << " Bad word_index in write_rsp() in TRT" << std::endl; 423 exit(0); 424 } 425 if ( not tab[index].valid ) 426 { 427 std::cout << "VCI_MEM_CACHE ERRROR " << tab_name 428 << " TRT Entry invalid in write_rsp()" << std::endl; 429 exit(0); 430 } 431 if ( not tab[index].xram_read ) 432 { 433 std::cout << "VCI_MEM_CACHE ERRROR " << tab_name 434 << " TRT entry is not an XRAM GET in write_rsp()" << std::endl; 435 exit(0); 436 } 433 assert( (index < size_tab) and 434 "MEMC ERROR: The selected entry is out of range in TRT write_rsp()"); 435 436 assert( (word < tab[index].wdata_be.size()) and 437 "MEMC ERROR: Bad word index in TRT write_rsp()"); 438 439 assert( (tab[index].valid) and 440 "MEMC ERROR: TRT entry not valid in TRT write_rsp()"); 441 442 assert( (tab[index].xram_read ) and 443 "MEMC ERROR: TRT entry is not a GET in TRT write_rsp()"); 437 444 438 445 // first 32 bits word … … 445 452 mask = be_to_mask(tab[index].wdata_be[word+1]); 446 453 tab[index].wdata[word+1] = (tab[index].wdata[word+1] & mask) | (value & ~mask); 447 448 // error update 449 tab[index].rerror |= rerror; 450 } 451 454 } 452 455 ///////////////////////////////////////////////////////////////////// 453 456 // The erase() function erases an entry in the transaction tab. … … 457 460 void erase(const size_t index) 458 461 { 459 assert( (index < size_tab) 460 && "The selected entry is out of range in erase() Transaction Tab"); 462 assert( (index < size_tab) and 463 "MEMC ERROR: The selected entry is out of range in TRT erase()"); 464 461 465 tab[index].valid = false; 462 466 tab[index].rerror = false; 467 } 468 ///////////////////////////////////////////////////////////////////// 469 // The is_config() function returns the config flag value. 470 // Arguments : 471 // - index : the index of the entry in the transaction tab 472 ///////////////////////////////////////////////////////////////////// 473 bool is_config(const size_t index) 474 { 475 assert( (index < size_tab) and 476 "MEMC ERROR: The selected entry is out of range in TRT is_config()"); 477 478 return tab[index].config; 463 479 } 464 480 }; // end class TransactionTab -
branches/RWT/modules/vci_mem_cache/caba/source/src/vci_mem_cache.cpp
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
/trunk/modules/vci_mem_cache/caba/source/src/vci_mem_cache.cpp merged eligible /branches/v5/modules/vci_mem_cache/caba/source/src/vci_mem_cache.cpp 441-467
r477 r495 45 45 #define DEBUG_MEMC_WRITE 1 // detailed trace of WRITE FSM 46 46 #define DEBUG_MEMC_CAS 1 // detailed trace of CAS FSM 47 #define DEBUG_MEMC_IXR_CMD 1 // detailed trace of IXR_ RSPFSM47 #define DEBUG_MEMC_IXR_CMD 1 // detailed trace of IXR_CMD FSM 48 48 #define DEBUG_MEMC_IXR_RSP 1 // detailed trace of IXR_RSP FSM 49 49 #define DEBUG_MEMC_XRAM_RSP 1 // detailed trace of XRAM_RSP FSM … … 129 129 "MULTI_ACK_UPT_CLEAR", 130 130 "MULTI_ACK_WRITE_RSP", 131 "MULTI_ACK_CONFIG_ACK"132 131 }; 133 132 const char *config_fsm_str[] = … … 135 134 "CONFIG_IDLE", 136 135 "CONFIG_LOOP", 136 "CONFIG_WAIT" 137 137 "CONFIG_RSP", 138 138 "CONFIG_DIR_REQ", 139 139 "CONFIG_DIR_ACCESS", 140 "CONFIG_ DIR_IVT_LOCK",140 "CONFIG_IVT_LOCK", 141 141 "CONFIG_BC_SEND", 142 "CONFIG_BC_WAIT", 143 "CONFIG_INV_SEND", 142 "CONFIG_INVAL_SEND" 144 143 "CONFIG_HEAP_REQ", 145 144 "CONFIG_HEAP_SCAN", 146 145 "CONFIG_HEAP_LAST", 147 "CONFIG_INV_WAIT" 146 "CONFIG_TRT_LOCK", 147 "CONFIG_TRT_SET", 148 "CONFIG_PUT_REQ" 148 149 }; 149 150 const char *read_fsm_str[] = … … 172 173 "WRITE_DIR_LOCK", 173 174 "WRITE_IVT_LOCK_HIT_WB", 174 "WRITE_DIR_READ",175 175 "WRITE_DIR_HIT", 176 176 "WRITE_UPT_LOCK", … … 185 185 "WRITE_MISS_TRT_SET", 186 186 "WRITE_MISS_XRAM_REQ", 187 "WRITE_BC_DIR_READ", 187 188 "WRITE_BC_TRT_LOCK", 188 189 "WRITE_BC_IVT_LOCK", … … 207 208 "XRAM_RSP_DIR_UPDT", 208 209 "XRAM_RSP_DIR_RSP", 209 "XRAM_RSP_I NVAL_LOCK",210 "XRAM_RSP_IVT_LOCK", 210 211 "XRAM_RSP_INVAL_WAIT", 211 212 "XRAM_RSP_INVAL", … … 224 225 "IXR_CMD_XRAM_IDLE", 225 226 "IXR_CMD_CLEANUP_IDLE", 226 "IXR_CMD_READ", 227 "IXR_CMD_WRITE", 228 "IXR_CMD_CAS", 229 "IXR_CMD_XRAM", 230 "IXR_CMD_CLEANUP_DATA" 227 "IXR_CMD_CONFIG_IDLE", 228 "IXR_CMD_READ_TRT", 229 "IXR_CMD_WRITE_TRT", 230 "IXR_CMD_CAS_TRT", 231 "IXR_CMD_XRAM_TRT", 232 "IXR_CMD_CLEANUP_TRT", 233 "IXR_CMD_CONFIG_TRT", 234 "IXR_CMD_READ_SEND", 235 "IXR_CMD_WRITE_SEND", 236 "IXR_CMD_CAS_SEND", 237 "IXR_CMD_XRAM_SEND", 238 "IXR_CMD_CLEANUP_DATA_SEND", 239 "IXR_CMD_CONFIG_SEND" 231 240 }; 232 241 const char *cas_fsm_str[] = … … 276 285 "CLEANUP_IXR_REQ", 277 286 "CLEANUP_WAIT", 278 "CLEANUP_CONFIG_ACK",279 287 "CLEANUP_SEND_CLACK" 280 288 }; … … 297 305 "ALLOC_TRT_IXR_RSP", 298 306 "ALLOC_TRT_CLEANUP" 307 "ALLOC_TRT_IXR_CMD", 308 "ALLOC_TRT_CONFIG" 299 309 }; 300 310 const char *alloc_upt_fsm_str[] = … … 357 367 : soclib::caba::BaseModule(name), 358 368 359 m_monitor_ok(false),360 369 p_clk( "p_clk" ), 361 370 p_resetn( "p_resetn" ), … … 437 446 m_write_to_cc_send_inst_fifo("m_write_to_cc_send_inst_fifo",8), 438 447 m_write_to_cc_send_srcid_fifo("m_write_to_cc_send_srcid_fifo",8), 439 #if L1_MULTI_CACHE440 m_write_to_cc_send_cache_id_fifo("m_write_to_cc_send_cache_id_fifo",8),441 #endif442 448 443 449 r_multi_ack_fsm("r_multi_ack_fsm"), … … 449 455 m_cas_to_cc_send_inst_fifo("m_cas_to_cc_send_inst_fifo",8), 450 456 m_cas_to_cc_send_srcid_fifo("m_cas_to_cc_send_srcid_fifo",8), 451 #if L1_MULTI_CACHE452 m_cas_to_cc_send_cache_id_fifo("m_cas_to_cc_send_cache_id_fifo",8),453 #endif454 457 455 458 r_ixr_rsp_fsm("r_ixr_rsp_fsm"), … … 458 461 m_xram_rsp_to_cc_send_inst_fifo("m_xram_rsp_to_cc_send_inst_fifo",8), 459 462 m_xram_rsp_to_cc_send_srcid_fifo("m_xram_rsp_to_cc_send_srcid_fifo",8), 460 #if L1_MULTI_CACHE461 m_xram_rsp_to_cc_send_cache_id_fifo("m_xram_rsp_to_cc_send_cache_id_fifo",8),462 #endif463 463 464 464 r_ixr_cmd_fsm("r_ixr_cmd_fsm"), … … 528 528 r_xram_rsp_victim_data = new sc_signal<data_t>[nwords]; 529 529 r_xram_rsp_to_tgt_rsp_data = new sc_signal<data_t>[nwords]; 530 r_xram_rsp_to_ixr_cmd_data = new sc_signal<data_t>[nwords];530 //r_xram_rsp_to_ixr_cmd_data = new sc_signal<data_t>[nwords]; 531 531 532 532 // Allocation for READ FSM … … 539 539 r_write_to_cc_send_data = new sc_signal<data_t>[nwords]; 540 540 r_write_to_cc_send_be = new sc_signal<be_t>[nwords]; 541 r_write_to_ixr_cmd_data = new sc_signal<data_t>[nwords];541 //r_write_to_ixr_cmd_data = new sc_signal<data_t>[nwords]; 542 542 543 543 // Allocation for CAS FSM 544 r_cas_to_ixr_cmd_data = new sc_signal<data_t>[nwords];544 //r_cas_to_ixr_cmd_data = new sc_signal<data_t>[nwords]; 545 545 r_cas_data = new sc_signal<data_t>[nwords]; 546 546 r_cas_rdata = new sc_signal<data_t>[2]; 547 548 // Allocation for IXR_CMD FSM 549 r_ixr_cmd_wdata = new sc_signal<data_t>[nwords]; 547 550 548 551 // Allocation for ODCCP … … 553 556 554 557 // Allocation for debug 555 m_debug_previous_data = new sc_signal<data_t>[nwords];556 m_debug_data = new sc_signal<data_t>[nwords];558 m_debug_previous_data = new data_t[nwords]; 559 m_debug_data = new data_t[nwords]; 557 560 558 561 SC_METHOD(transition); … … 564 567 sensitive << p_clk.neg(); 565 568 } // end constructor 566 567 ///////////////////////////////////////////////////////////////////////568 tmpl(void) ::start_monitor(addr_t addr, addr_t length)569 ///////////////////////////////////////////////////////////////////////570 {571 m_monitor_ok = true;572 m_monitor_base = addr;573 m_monitor_length = length;574 }575 576 ///////////////////////////////////////////////////////////////////////577 tmpl(void) ::stop_monitor()578 ///////////////////////////////////////////////////////////////////////579 {580 m_monitor_ok = false;581 }582 583 ////////////////////////////////////////////////584 tmpl(void) ::check_monitor( addr_t addr,585 data_t data,586 bool read )587 ////////////////////////////////////////////////588 {589 if((addr >= m_monitor_base) and590 (addr < m_monitor_base + m_monitor_length))591 {592 if ( read ) std::cout << " Monitor MEMC Read ";593 else std::cout << " Monitor MEMC Write";594 std::cout << " / Address = " << std::hex << addr595 << " / Data = " << data596 << " at cycle " << std::dec << m_cpt_cycles << std::endl;597 }598 }599 569 600 570 ///////////////////////////////////////////////////// … … 609 579 610 580 if ( entry.valid ) 611 { 612 m_cache_data.read_line( way, set, m_debug_data ); 613 614 for ( size_t i = 0 ; i<m_words ; i++ ) 615 { 616 if ( m_debug_previous_valid and 617 (m_debug_data[i].read() != m_debug_previous_data[i].read()) ) 618 data_change = true; 619 m_debug_previous_data[i] = m_debug_data[i].read(); 620 } 621 } 622 581 { 582 for ( size_t word = 0 ; word<m_words ; word++ ) 583 { 584 m_debug_data[word] = m_cache_data.read(way, set, word); 585 if ( m_debug_previous_valid and 586 (m_debug_data[word] != m_debug_previous_data[word]) ) 587 { 588 data_change = true; 589 } 590 } 591 } 592 593 // print values if any change 623 594 if ( (entry.valid != m_debug_previous_valid) or 624 595 (entry.valid and (entry.count != m_debug_previous_count)) or 625 596 (entry.valid and (entry.dirty != m_debug_previous_dirty)) or data_change ) 626 597 { 627 std::cout << "Monitor MEMC " << name() 628 << " at cycle " << std::dec << m_cpt_cycles 629 << " for address " << std::hex << addr 630 << " / HIT = " << std::dec << entry.valid 631 << " / WAY = " << way 632 << " / COUNT = " << entry.count 633 << " / DIRTY = " << entry.dirty 634 << " / DATA_CHANGE = " << entry.count 635 << std::endl; 598 std::cout << "Monitor MEMC " << name() 599 << " at cycle " << std::dec << m_cpt_cycles 600 << " for address " << std::hex << addr 601 << " / VAL = " << std::dec << entry.valid 602 << " / WAY = " << way 603 << " / COUNT = " << entry.count 604 << " / DIRTY = " << entry.dirty 605 << " / DATA_CHANGE = " << data_change 606 << std::endl; 607 std::cout << std::hex << " /0:" << m_debug_data[0] 608 << "/1:" << m_debug_data[1] 609 << "/2:" << m_debug_data[2] 610 << "/3:" << m_debug_data[3] 611 << "/4:" << m_debug_data[4] 612 << "/5:" << m_debug_data[5] 613 << "/6:" << m_debug_data[6] 614 << "/7:" << m_debug_data[7] 615 << "/8:" << m_debug_data[8] 616 << "/9:" << m_debug_data[9] 617 << "/A:" << m_debug_data[10] 618 << "/B:" << m_debug_data[11] 619 << "/C:" << m_debug_data[12] 620 << "/D:" << m_debug_data[13] 621 << "/E:" << m_debug_data[14] 622 << "/F:" << m_debug_data[15] 623 << std::endl; 636 624 } 637 625 m_debug_previous_count = entry.count; 638 626 m_debug_previous_valid = entry.valid; 639 627 m_debug_previous_dirty = entry.dirty; 628 for( size_t word=0 ; word<m_words ; word++ ) 629 m_debug_previous_data[word] = m_debug_data[word]; 640 630 } 641 631 … … 836 826 delete [] r_xram_rsp_victim_data; 837 827 delete [] r_xram_rsp_to_tgt_rsp_data; 838 delete [] r_xram_rsp_to_ixr_cmd_data;839 828 840 829 delete [] r_read_data; … … 919 908 m_config_to_cc_send_inst_fifo.init(); 920 909 m_config_to_cc_send_srcid_fifo.init(); 921 #if L1_MULTI_CACHE922 m_config_to_cc_send_cache_id_fifo.init();923 #endif924 910 925 911 r_tgt_cmd_to_tgt_rsp_req = false; … … 938 924 m_write_to_cc_send_inst_fifo.init(); 939 925 m_write_to_cc_send_srcid_fifo.init(); 940 #if L1_MULTI_CACHE941 m_write_to_cc_send_cache_id_fifo.init();942 #endif943 926 944 927 r_cleanup_to_tgt_rsp_req = false; … … 954 937 r_cas_lfsr = -1 ; 955 938 r_cas_to_ixr_cmd_req = false; 956 r_cas_to_cc_send_multi_req = false;957 r_cas_to_cc_send_brdcast_req = false;939 r_cas_to_cc_send_multi_req = false; 940 r_cas_to_cc_send_brdcast_req = false; 958 941 959 942 m_cas_to_cc_send_inst_fifo.init(); … … 969 952 970 953 r_xram_rsp_to_tgt_rsp_req = false; 971 r_xram_rsp_to_cc_send_multi_req = false;972 r_xram_rsp_to_cc_send_brdcast_req = false;954 r_xram_rsp_to_cc_send_multi_req = false; 955 r_xram_rsp_to_cc_send_brdcast_req = false; 973 956 r_xram_rsp_to_ixr_cmd_req = false; 974 957 r_xram_rsp_trt_index = 0; … … 976 959 m_xram_rsp_to_cc_send_inst_fifo.init(); 977 960 m_xram_rsp_to_cc_send_srcid_fifo.init(); 978 #if L1_MULTI_CACHE 979 m_xram_rsp_to_cc_send_cache_id_fifo.init(); 980 #endif 981 982 r_ixr_cmd_cpt = 0; 961 983 962 r_alloc_dir_reset_cpt = 0; 984 963 r_alloc_heap_reset_cpt = 0; … … 996 975 r_cleanup_to_ixr_cmd_req = false; 997 976 r_cleanup_to_ixr_cmd_srcid = 0; 998 r_cleanup_to_ixr_cmd_trdid = 0;999 977 r_cleanup_to_ixr_cmd_pktid = 0; 1000 978 r_cleanup_to_ixr_cmd_nline = 0; … … 1095 1073 size_t write_to_cc_send_fifo_srcid = 0; 1096 1074 1097 #if L1_MULTI_CACHE1098 size_t write_to_cc_send_fifo_cache_id = 0;1099 #endif1100 1101 1075 bool xram_rsp_to_cc_send_fifo_put = false; 1102 1076 bool xram_rsp_to_cc_send_fifo_get = false; … … 1104 1078 size_t xram_rsp_to_cc_send_fifo_srcid = 0; 1105 1079 1106 #if L1_MULTI_CACHE1107 size_t xram_rsp_to_cc_send_fifo_cache_id = 0;1108 #endif1109 1110 1080 bool config_to_cc_send_fifo_put = false; 1111 1081 bool config_to_cc_send_fifo_get = false; … … 1117 1087 bool cas_to_cc_send_fifo_inst = false; 1118 1088 size_t cas_to_cc_send_fifo_srcid = 0; 1119 1120 #if L1_MULTI_CACHE1121 size_t cas_to_cc_send_fifo_cache_id = 0;1122 #endif1123 1089 1124 1090 m_debug = (m_cpt_cycles > m_debug_start_cycle) and m_debug_ok; … … 1275 1241 case TGT_CMD_ERROR: // response error must be sent 1276 1242 1277 // wait if pending TGT_CMD request to TGT_RSP FSM1243 // wait if pending request 1278 1244 if(r_tgt_cmd_to_tgt_rsp_req.read()) break; 1279 1245 … … 1309 1275 size_t error; 1310 1276 uint32_t rdata = 0; // default value 1277 uint32_t wdata = p_vci_tgt.wdata.read(); 1311 1278 1312 1279 if ( (p_vci_tgt.cmd.read() == vci_param_int::CMD_READ) // get lock … … 1317 1284 error = 0; 1318 1285 r_config_lock = true; 1286 if ( rdata == 0 ) 1287 { 1288 r_tgt_cmd_srcid = p_vci_tgt.srcid.read(); 1289 r_tgt_cmd_trdid = p_vci_tgt.trdid.read(); 1290 r_tgt_cmd_pktid = p_vci_tgt.pktid.read(); 1291 } 1292 1319 1293 } 1320 1294 else if ( (p_vci_tgt.cmd.read() == vci_param_int::CMD_WRITE) // release lock 1321 and (cell == MEMC_LOCK) ) 1295 and (cell == MEMC_LOCK) 1296 and (p_vci_tgt.srcid.read() == r_tgt_cmd_srcid.read()) ) 1322 1297 { 1323 1298 need_rsp = true; … … 1326 1301 } 1327 1302 else if ( (p_vci_tgt.cmd.read() == vci_param_int::CMD_WRITE) // set addr_lo 1328 and (cell == MEMC_ADDR_LO) ) 1329 { 1303 and (cell == MEMC_ADDR_LO) 1304 and (p_vci_tgt.srcid.read() == r_tgt_cmd_srcid.read()) ) 1305 { 1306 assert( ((wdata % (m_words*vci_param_int::B)) == 0) and 1307 "VCI_MEM_CACHE CONFIG ERROR: The buffer must be aligned on a cache line"); 1308 1330 1309 need_rsp = true; 1331 1310 error = 0; … … 1334 1313 } 1335 1314 else if ( (p_vci_tgt.cmd.read() == vci_param_int::CMD_WRITE) // set addr_hi 1336 and (cell == MEMC_ADDR_HI) ) 1315 and (cell == MEMC_ADDR_HI) 1316 and (p_vci_tgt.srcid.read() == r_tgt_cmd_srcid.read()) ) 1337 1317 { 1338 1318 need_rsp = true; … … 1342 1322 } 1343 1323 else if ( (p_vci_tgt.cmd.read() == vci_param_int::CMD_WRITE) // set buf_lines 1344 and (cell == MEMC_BUF_LENGTH) ) 1324 and (cell == MEMC_BUF_LENGTH) 1325 and (p_vci_tgt.srcid.read() == r_tgt_cmd_srcid.read()) ) 1345 1326 { 1346 1327 need_rsp = true; 1347 1328 error = 0; 1348 1329 size_t lines = (size_t)(p_vci_tgt.wdata.read()/(m_words<<2)); 1349 if ( r_config_address.read()/(m_words*vci_param_int::B) ) lines++; 1350 r_config_nlines = lines; 1330 if ( r_config_address.read()%(m_words*4) ) lines++; 1331 r_config_cmd_lines = lines; 1332 r_config_rsp_lines = lines; 1351 1333 } 1352 1334 else if ( (p_vci_tgt.cmd.read() == vci_param_int::CMD_WRITE) // set cmd type 1353 and (cell == MEMC_CMD_TYPE) ) 1335 and (cell == MEMC_CMD_TYPE) 1336 and (p_vci_tgt.srcid.read() == r_tgt_cmd_srcid.read()) ) 1354 1337 { 1355 1338 need_rsp = false; … … 1386 1369 << " address = " << std::hex << p_vci_tgt.address.read() 1387 1370 << " / wdata = " << p_vci_tgt.wdata.read() 1371 << " / need_rsp = " << need_rsp 1388 1372 << " / error = " << error << std::endl; 1389 1373 #endif … … 1489 1473 // MULTI_ACK FSM 1490 1474 ///////////////////////////////////////////////////////////////////////// 1491 // This FSM controls the response to the multicast update or multicast 1492 // inval coherence requests sent by the memory cache to the L1 caches and 1493 // update the UPT. 1475 // This FSM controls the response to the multicast update requests sent 1476 // by the memory cache to the L1 caches and update the UPT. 1494 1477 // 1495 1478 // - The FSM decrements the proper entry in UPT, … … 1497 1480 // - If required, it sends a request to the TGT_RSP FSM to complete 1498 1481 // a pending write transaction. 1499 // - If required, it sends an acknowledge to the CONFIG FSM to signal1500 // completion of a line inval.1501 1482 // 1502 1483 // All those multi-ack packets are one flit packet. 1503 // The index in the UPT is defined in the UPDTID field.1484 // The index in the UPT is defined in the TRDID field. 1504 1485 //////////////////////////////////////////////////////////////////////// 1505 1486 … … 1618 1599 r_multi_ack_nline = m_upt.nline(r_multi_ack_upt_index.read()); 1619 1600 bool need_rsp = m_upt.need_rsp(r_multi_ack_upt_index.read()); 1620 bool need_ack = m_upt.need_ack(r_multi_ack_upt_index.read());1621 1601 1622 1602 // clear the UPT entry … … 1624 1604 1625 1605 if ( need_rsp ) r_multi_ack_fsm = MULTI_ACK_WRITE_RSP; 1626 else if ( need_ack ) r_multi_ack_fsm = MULTI_ACK_CONFIG_ACK;1627 1606 else r_multi_ack_fsm = MULTI_ACK_IDLE; 1628 1607 … … 1655 1634 break; 1656 1635 } 1657 //////////////////////////1658 case MULTI_ACK_CONFIG_ACK: // Signals multi-inval completion to CONFIG FSM1659 // Wait if pending request1660 {1661 if ( r_multi_ack_to_config_ack.read() ) break;1662 1663 r_multi_ack_to_config_ack = true;1664 r_multi_ack_fsm = MULTI_ACK_IDLE;1665 1666 #if DEBUG_MEMC_MULTI_ACK1667 if(m_debug)1668 std::cout << " <MEMC " << name() << " MULTI_ACK_CONFIG_ACK>"1669 << " Signals inval completion to CONFIG FSM" << std::endl;1670 #endif1671 break;1672 }1673 1636 } // end switch r_multi_ack_fsm 1674 1637 … … 1678 1641 // The CONFIG FSM handles the VCI configuration requests (INVAL & SYNC). 1679 1642 // The target buffer can have any size, and there is one single command for 1680 // all cache lines covered by the target buffer. 1681 // An INVAL or SYNC configuration request is defined by the followinf registers: 1682 // - bool r_config_cmd : INVAL / SYNC / NOP) 1643 // all cache lines covered by the target buffer. 1644 // 1645 // An INVAL or SYNC configuration operation is defined by the following registers: 1646 // - bool r_config_cmd : INVAL / SYNC / NOP 1647 1683 1648 // - uint64_t r_config_address : buffer base address 1684 // - uint32_t r_config_nlines : number of lines covering buffer 1649 // - uint32_t r_config_cmd_lines : number of lines to be handled 1650 // - uint32_t r_config_rsp_lines : number of lines not completed 1651 1685 1652 // 1686 1653 // For both INVAL and SYNC commands, the CONFIG FSM contains the loop handling 1687 // all cache lines covered by the target buffer.1688 1654 // 1655 // all cache lines covered by the buffer. The various lines of a given buffer 1656 // can be pipelined: the CONFIG FSM does not wait the response for line (n) to send 1657 // the command for line (n+1). It decrements the r_config_cmd_lines counter until 1658 // the last request has been registered in TRT (for a SYNC), or in IVT (for an INVAL). 1659 // 1689 1660 // - INVAL request: 1690 // For each line, it access to the DIR array.1661 // For each line, it access to the DIR. 1691 1662 // In case of miss, it does nothing, and a response is requested to TGT_RSP FSM. 1692 1663 // In case of hit, with no copies in L1 caches, the line is invalidated and 1693 1664 // a response is requested to TGT_RSP FSM. 1694 1665 // If there is copies, a multi-inval, or a broadcast-inval coherence transaction 1695 // is launched and registered in UPT. The multi-inval transaction is signaled1696 // by the r_multi_ack_to config_ack or r_cleanup_to_config_ack flip-flops.1697 // The config inval response is sent only when the last line has been invalidated.1698 1666 // 1667 // is launched and registered in UPT. The multi-inval transaction completion 1668 // is signaled by the CLEANUP FSM by decrementing the r_config_rsp_lines counter. 1669 // The CONFIG INVAL response is sent only when the last line has been invalidated. 1670 // TODO : The target buffer address must be aligned on a cache line boundary. 1671 // This constraint can be released, but it requires to make 2 PUT transactions 1672 // for the first and the last line... 1673 // 1699 1674 // - SYNC request: 1700 // 1701 // ... Not implemented yet ... 1675 // For each line, it access to the DIR. 1676 // In case of miss, it does nothing, and a response is requested to TGT_RSP FSM. 1677 // In case of hit, a PUT transaction is registered in TRT and a request is sent 1678 // to IXR_CMD FSM. The IXR_RSP FSM decrements the r_config_rsp_lines counter 1679 // when a PUT response is received. 1680 // The CONFIG SYNC response is sent only when the last PUT response is received. 1702 1681 // 1703 1682 // From the software point of view, a configuration request is a sequence 1704 // of 6 atomic accesses in an uncached segment: 1683 // of 6 atomic accesses in an uncached segment. A dedicated lock is used 1684 // to handle only one configuration command at a given time: 1705 1685 // - Read MEMC_LOCK : Get the lock 1706 1686 // - Write MEMC_ADDR_LO : Set the buffer address LSB … … 1724 1704 std::cout << " <MEMC " << name() << " CONFIG_IDLE> Config Request received" 1725 1705 << " address = " << std::hex << r_config_address.read() 1726 << " / nlines = " << std::dec << r_config_ nlines.read()1706 << " / nlines = " << std::dec << r_config_cmd_lines.read() 1727 1707 << " / type = " << r_config_cmd.read() << std::endl; 1728 1708 #endif … … 1731 1711 } 1732 1712 ///////////////// 1733 case CONFIG_LOOP: // test last line 1734 { 1735 if ( r_config_ nlines.read() == 0 )1713 case CONFIG_LOOP: // test last line to be handled 1714 { 1715 if ( r_config_cmd_lines.read() == 0 ) 1736 1716 { 1737 1717 r_config_cmd = MEMC_CMD_NOP; 1738 r_config_fsm = CONFIG_ RSP;1718 r_config_fsm = CONFIG_WAIT; 1739 1719 } 1740 1720 else … … 1747 1727 std::cout << " <MEMC " << name() << " CONFIG_LOOP>" 1748 1728 << " address = " << std::hex << r_config_address.read() 1749 << " / nlines = " << std::dec << r_config_ nlines.read()1729 << " / nlines = " << std::dec << r_config_cmd_lines.read() 1750 1730 << " / command = " << r_config_cmd.read() << std::endl; 1751 1731 #endif 1752 1732 break; 1753 1733 } 1734 ///////////////// 1735 case CONFIG_WAIT: // wait completion (last response) 1736 { 1737 if ( r_config_rsp_lines.read() == 0 ) // last response received 1738 { 1739 r_config_fsm = CONFIG_RSP; 1740 } 1741 1742 #if DEBUG_MEMC_CONFIG 1743 if(m_debug) 1744 std::cout << " <MEMC " << name() << " CONFIG_WAIT>" 1745 << " / lines to do = " << std::dec << r_config_rsp_lines.read() << std::endl; 1746 #endif 1747 break; 1748 } 1749 //////////////// 1750 case CONFIG_RSP: // request TGT_RSP FSM to return response 1751 { 1752 if ( not r_config_to_tgt_rsp_req.read() ) 1753 { 1754 r_config_to_tgt_rsp_srcid = r_config_srcid.read(); 1755 r_config_to_tgt_rsp_trdid = r_config_trdid.read(); 1756 r_config_to_tgt_rsp_pktid = r_config_pktid.read(); 1757 r_config_to_tgt_rsp_error = false; 1758 r_config_to_tgt_rsp_req = true; 1759 r_config_fsm = CONFIG_IDLE; 1760 1761 #if DEBUG_MEMC_CONFIG 1762 if(m_debug) 1763 std::cout << " <MEMC " << name() << " CONFIG_RSP> Request TGT_RSP FSM to return response:" 1764 << " error = " << r_config_to_tgt_rsp_error.read() 1765 << " / rsrcid = " << std::hex << r_config_srcid.read() 1766 << " / rtrdid = " << std::hex << r_config_trdid.read() 1767 << " / rpktid = " << std::hex << r_config_pktid.read() << std::endl; 1768 #endif 1769 } 1770 break; 1771 1772 } 1773 1754 1774 //////////////////// 1755 1775 case CONFIG_DIR_REQ: // Request directory lock … … 1770 1790 case CONFIG_DIR_ACCESS: // Access directory and decode config command 1771 1791 { 1792 assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_CONFIG) and 1793 "MEMC ERROR in CONFIG_DIR_ACCESS state: bad DIR allocation"); 1794 1772 1795 size_t way = 0; 1773 1796 DirectoryEntry entry = m_cache_directory.read(r_config_address.read(), way); … … 1781 1804 r_config_dir_is_cnt = entry.is_cnt; 1782 1805 r_config_dir_count = entry.count; 1783 r_config_dir_next_ptr = entry.ptr; 1784 1785 r_config_fsm = CONFIG_DIR_IVT_LOCK; 1806 r_config_dir_lock = entry.lock; 1807 r_config_dir_ptr = entry.ptr; 1808 1809 r_config_fsm = CONFIG_IVT_LOCK; 1786 1810 } 1787 1811 else if ( entry.valid and // hit & sync command … … 1789 1813 (r_config_cmd.read() == MEMC_CMD_SYNC) ) 1790 1814 { 1791 std::cout << "VCI_MEM_CACHE ERROR: " 1792 << "SYNC config request not implemented yet" << std::endl; 1793 exit(0); 1815 r_config_fsm = CONFIG_TRT_LOCK; 1794 1816 } 1795 1817 else // return to LOOP 1796 1818 { 1797 r_config_nlines = r_config_nlines.read() - 1; 1798 r_config_address = r_config_address.read() + (m_words<<2); 1799 r_config_fsm = CONFIG_LOOP; 1819 r_config_cmd_lines = r_config_cmd_lines.read() - 1; 1820 r_config_rsp_lines = r_config_rsp_lines.read() - 1; 1821 r_config_cmd_lines = r_config_cmd_lines.read() - 1; 1822 r_config_address = r_config_address.read() + (m_words<<2); 1823 r_config_fsm = CONFIG_LOOP; 1800 1824 } 1801 1825 … … 1811 1835 break; 1812 1836 } 1813 ///////////////////////// 1814 case CONFIG_DIR_IVT_LOCK: // enter this state in case of INVAL command 1815 // Try to get both DIR & IVT locks, and return 1816 // to LOOP state if IVT full. 1817 // Register inval in IVT, and invalidate the 1818 // directory if IVT not full. 1819 { 1837 ///////////////////// 1838 case CONFIG_TRT_LOCK: // enter this state in case of SYNC command 1839 // to a dirty cache line 1840 // keep DIR lock, and try to get TRT lock 1841 // return to LOOP state if TRT full 1842 // reset dirty bit in DIR and register a PUT 1843 // trabsaction in TRT if not full. 1844 { 1845 assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_CONFIG) and 1846 "MEMC ERROR in CONFIG_TRT_LOCK state: bad DIR allocation"); 1847 1848 if ( r_alloc_trt_fsm.read() == ALLOC_TRT_CONFIG ) 1849 { 1850 size_t index = 0; 1851 bool wok = not m_trt.full(index); 1852 1853 if ( not wok ) 1854 { 1855 r_config_fsm = CONFIG_LOOP; 1856 } 1857 else 1858 { 1859 size_t way = r_config_dir_way.read(); 1860 size_t set = m_y[r_config_address.read()]; 1861 1862 // reset dirty bit in DIR 1863 DirectoryEntry entry; 1864 entry.valid = true; 1865 entry.dirty = false; 1866 entry.tag = m_z[r_config_address.read()]; 1867 entry.is_cnt = r_config_dir_is_cnt.read(); 1868 entry.lock = r_config_dir_lock.read(); 1869 entry.ptr = r_config_dir_ptr.read(); 1870 entry.count = r_config_dir_count.read(); 1871 entry.owner.inst = r_config_dir_copy_inst.read(); 1872 entry.owner.srcid = r_config_dir_copy_srcid.read(); 1873 m_cache_directory.write( set, 1874 way, 1875 entry ); 1876 1877 r_config_trt_index = index; 1878 r_config_fsm = CONFIG_TRT_SET; 1879 } 1880 1881 #if DEBUG_MEMC_CONFIG 1882 if(m_debug) 1883 std::cout << " <MEMC " << name() << " CONFIG_TRT_LOCK> Access TRT: " 1884 << " wok = " << std::dec << wok 1885 << " index = " << index << std::endl; 1886 #endif 1887 } 1888 break; 1889 } 1890 //////////////////// 1891 case CONFIG_TRT_SET: // read data in cache 1892 // and post a PUT request in TRT 1893 { 1894 assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_CONFIG) and 1895 "MEMC ERROR in CONFIG_TRT_SET state: bad DIR allocation"); 1896 1897 assert( (r_alloc_trt_fsm.read() == ALLOC_TRT_CONFIG) and 1898 "MEMC ERROR in CONFIG_TRT_SET state: bad TRT allocation"); 1899 1900 // read data into cache 1901 size_t way = r_config_dir_way.read(); 1902 size_t set = m_y[r_config_address.read()]; 1903 1904 sc_signal<data_t> config_data[16]; 1905 m_cache_data.read_line( way, 1906 set, 1907 config_data ); 1908 1909 // post a PUT request in TRT 1910 std::vector<data_t> data_vector; 1911 data_vector.clear(); 1912 for(size_t i=0; i<m_words; i++) data_vector.push_back(config_data[i].read()); 1913 m_trt.set( r_config_trt_index.read(), 1914 false, // PUT 1915 m_nline[r_config_address.read()], // nline 1916 0, // srcid: unused 1917 0, // trdid: unused 1918 0, // pktid: unused 1919 false, // not proc_read 1920 0, // read_length: unused 1921 0, // word_index: unused 1922 std::vector<be_t>(m_words,0xF), 1923 data_vector); 1924 1925 #if DEBUG_MEMC_CONFIG 1926 if(m_debug) 1927 m_trt.print(0); 1928 std::cout << " <MEMC " << name() << " CONFIG_TRT_SET> PUT request in TRT:" 1929 << " address = " << std::hex << r_config_address.read() 1930 << " index = " << std::dec << r_config_trt_index.read() << std::endl; 1931 #endif 1932 break; 1933 } 1934 //////////////////// 1935 case CONFIG_PUT_REQ: // PUT request to IXR_CMD_FSM 1936 { 1937 if ( not r_config_to_ixr_cmd_req.read() ) 1938 { 1939 r_config_to_ixr_cmd_req = true; 1940 r_config_to_ixr_cmd_index = r_config_trt_index.read(); 1941 1942 // prepare next iteration 1943 r_config_cmd_lines = r_config_cmd_lines.read() - 1; 1944 r_config_address = r_config_address.read() + (m_words<<2); 1945 r_config_fsm = CONFIG_LOOP; 1946 1947 #if DEBUG_MEMC_CONFIG 1948 if(m_debug) 1949 std::cout << " <MEMC " << name() << " CONFIG_PUT_REQ> PUT request to IXR_CMD_FSM" 1950 << " / address = " << std::hex << r_config_address.read() << std::endl; 1951 #endif 1952 } 1953 break; 1954 } 1955 ///////////////////// 1956 case CONFIG_IVT_LOCK: // enter this state in case of INVAL command 1957 // Keep DIR lock and Try to get IVT lock. 1958 // Return to LOOP state if IVT full. 1959 // Register inval in IVT, and invalidate the 1960 // directory if IVT not full. 1961 { 1962 assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_CONFIG) and 1963 "MEMC ERROR in CONFIG_IVT_LOCK state: bad DIR allocation"); 1964 1820 1965 if ( r_alloc_ivt_fsm.read() == ALLOC_IVT_CONFIG ) 1821 1966 { … … 1826 1971 { 1827 1972 m_cache_directory.inval( way, set ); 1828 r_config_nlines = r_config_nlines.read() - 1; 1829 r_config_address = r_config_address.read() + (m_words<<2); 1830 r_config_fsm = CONFIG_LOOP; 1831 1832 #if DEBUG_MEMC_CONFIG 1833 if(m_debug) 1834 std::cout << " <MEMC " << name() << " CONFIG_DIR_IVT_LOCK>" 1973 r_config_cmd_lines = r_config_cmd_lines.read() - 1; 1974 r_config_rsp_lines = r_config_rsp_lines.read() - 1; 1975 r_config_address = r_config_address.read() + (m_words<<2); 1976 r_config_fsm = CONFIG_LOOP; 1977 1978 #if DEBUG_MEMC_CONFIG 1979 if(m_debug) 1980 std::cout << " <MEMC " << name() << " CONFIG_IVT_LOCK>" 1835 1981 << " No copies in L1 : inval DIR entry" << std::endl; 1836 1982 #endif … … 1863 2009 r_config_ivt_index = index; 1864 2010 if ( broadcast ) r_config_fsm = CONFIG_BC_SEND; 1865 else r_config_fsm = CONFIG_INV _SEND;2011 else r_config_fsm = CONFIG_INVAL_SEND; 1866 2012 1867 2013 #if DEBUG_MEMC_CONFIG 1868 2014 if(m_debug) 1869 std::cout << " <MEMC " << name() << " CONFIG_ DIR_IVT_LOCK>"2015 std::cout << " <MEMC " << name() << " CONFIG_IVT_LOCK>" 1870 2016 << " Inval DIR entry and register inval in IVT" 1871 2017 << " : index = " << std::dec << index … … 1879 2025 #if DEBUG_MEMC_CONFIG 1880 2026 if(m_debug) 1881 std::cout << " <MEMC " << name() << " CONFIG_ DIR_IVT_LOCK>"2027 std::cout << " <MEMC " << name() << " CONFIG_IVT_LOCK>" 1882 2028 << " IVT full : release DIR & IVT locks and retry" << std::endl; 1883 2029 #endif … … 1893 2039 not r_config_to_cc_send_brdcast_req.read() ) 1894 2040 { 2041 // post bc inval request 1895 2042 r_config_to_cc_send_multi_req = false; 1896 2043 r_config_to_cc_send_brdcast_req = true; 1897 2044 r_config_to_cc_send_trdid = r_config_ivt_index.read(); 1898 2045 r_config_to_cc_send_nline = m_nline[(addr_t)(r_config_address.read())]; 1899 r_cleanup_to_config_ack = false; 1900 r_config_fsm = CONFIG_BC_WAIT; 2046 2047 // prepare next iteration 2048 r_config_cmd_lines = r_config_cmd_lines.read() - 1; 2049 r_config_address = r_config_address.read() + (m_words<<2); 2050 r_config_fsm = CONFIG_LOOP; 1901 2051 1902 2052 #if DEBUG_MEMC_CONFIG … … 1909 2059 break; 1910 2060 } 1911 //////////////////// 1912 case CONFIG_BC_WAIT: // wait broadcast completion to return to LOOP 1913 { 1914 if ( r_cleanup_to_config_ack.read() ) 1915 { 1916 r_config_fsm = CONFIG_LOOP; 1917 r_config_nlines = r_config_nlines.read() - 1; 1918 r_config_address = r_config_address.read() + (m_words<<2); 1919 } 1920 1921 #if DEBUG_MEMC_CONFIG 1922 if(m_debug) 1923 std::cout << " <MEMC " << name() << " CONFIG_BC_WAIT> Waiting BC completion " 1924 << " done = " << r_cleanup_to_config_ack.read() 1925 << std::endl; 1926 #endif 1927 break; 1928 } 1929 ///////////////////// 1930 case CONFIG_INV_SEND: // Post a multi inval request to CC_SEND FSM 2061 /////////////////////// 2062 case CONFIG_INVAL_SEND: // Post a multi inval request to CC_SEND FSM 1931 2063 { 1932 2064 if( not r_config_to_cc_send_multi_req.read() and … … 1937 2069 r_config_to_cc_send_trdid = r_config_ivt_index.read(); 1938 2070 r_config_to_cc_send_nline = m_nline[(addr_t)(r_config_address.read())]; 1939 r_multi_ack_to_config_ack = false; 1940 2071 2072 // post data into FIFO 1941 2073 config_to_cc_send_fifo_srcid = r_config_dir_copy_srcid.read(); 1942 2074 config_to_cc_send_fifo_inst = r_config_dir_copy_inst.read(); 1943 2075 config_to_cc_send_fifo_put = true; 1944 2076 1945 if ( r_config_dir_count.read() == 1 ) r_config_fsm = CONFIG_INV_WAIT; 1946 else r_config_fsm = CONFIG_HEAP_REQ; 1947 2077 if ( r_config_dir_count.read() == 1 ) // one copy 2078 { 2079 // prepare next iteration 2080 r_config_cmd_lines = r_config_cmd_lines.read() - 1; 2081 r_config_address = r_config_address.read() + (m_words<<2); 2082 r_config_fsm = CONFIG_LOOP; 2083 } 2084 else // several copies 2085 { 2086 r_config_fsm = CONFIG_HEAP_REQ; 2087 } 2088 1948 2089 #if DEBUG_MEMC_CONFIG 1949 2090 if(m_debug) 1950 std::cout << " <MEMC " << name() << " CONFIG_INV _SEND>"2091 std::cout << " <MEMC " << name() << " CONFIG_INVAL_SEND>" 1951 2092 << " Post multi inval request to CC_SEND FSM" 1952 2093 << " / address = " << std::hex << r_config_address.read() … … 1963 2104 { 1964 2105 r_config_fsm = CONFIG_HEAP_SCAN; 1965 r_config_heap_next = r_config_dir_ next_ptr.read();2106 r_config_heap_next = r_config_dir_ptr.read(); 1966 2107 } 1967 2108 … … 2010 2151 if ( m_heap.is_full() ) 2011 2152 { 2012 last_entry.next = r_config_dir_ next_ptr.read();2153 last_entry.next = r_config_dir_ptr.read(); 2013 2154 m_heap.unset_full(); 2014 2155 } … … 2018 2159 } 2019 2160 2020 m_heap.write_free_ptr( r_config_dir_ next_ptr.read() );2161 m_heap.write_free_ptr( r_config_dir_ptr.read() ); 2021 2162 m_heap.write( r_config_heap_next.read(), last_entry ); 2022 r_config_fsm = CONFIG_INV_WAIT; 2163 2164 // prepare next iteration 2165 r_config_cmd_lines = r_config_cmd_lines.read() - 1; 2166 r_config_address = r_config_address.read() + (m_words<<2); 2167 r_config_fsm = CONFIG_LOOP; 2023 2168 2024 2169 #if DEBUG_MEMC_CONFIG … … 2028 2173 #endif 2029 2174 break; 2030 }2031 /////////////////////2032 case CONFIG_INV_WAIT: // wait inval completion to return to LOOP2033 {2034 if ( r_multi_ack_to_config_ack.read() )2035 {2036 r_config_fsm = CONFIG_LOOP;2037 r_config_nlines = r_config_nlines.read() - 1;2038 r_config_address = r_config_address.read() + (m_words<<2);2039 }2040 2041 #if DEBUG_MEMC_CONFIG2042 if(m_debug)2043 std::cout << " <MEMC " << name() << " CONFIG_INV_WAIT> Waiting inval completion "2044 << " done = " << r_multi_ack_to_config_ack.read()2045 << std::endl;2046 #endif2047 break;2048 }2049 2050 ////////////////2051 case CONFIG_RSP: // request TGT_RSP FSM to return response2052 {2053 if ( not r_config_to_tgt_rsp_req.read() )2054 {2055 r_config_to_tgt_rsp_srcid = r_config_srcid.read();2056 r_config_to_tgt_rsp_trdid = r_config_trdid.read();2057 r_config_to_tgt_rsp_pktid = r_config_pktid.read();2058 r_config_to_tgt_rsp_error = false;2059 r_config_to_tgt_rsp_req = true;2060 r_config_fsm = CONFIG_IDLE;2061 2062 #if DEBUG_MEMC_CONFIG2063 if(m_debug)2064 std::cout << " <MEMC " << name() << " CONFIG_RSP> Request TGT_RSP FSM to return response:"2065 << " error = " << r_config_to_tgt_rsp_error.read()2066 << " / rsrcid = " << std::hex << r_config_srcid.read() << std::endl;2067 #endif2068 }2069 break;2070 2071 2175 } 2072 2176 } // end switch r_config_fsm … … 2122 2226 case READ_DIR_REQ: // Get the lock to the directory 2123 2227 { 2124 if(r_alloc_dir_fsm.read() == ALLOC_DIR_READ)2125 {2126 r_read_fsm = READ_DIR_LOCK;2127 m_cpt_read_fsm_n_dir_lock++;2128 2228 if(r_alloc_dir_fsm.read() == ALLOC_DIR_READ) 2229 { 2230 r_read_fsm = READ_DIR_LOCK; 2231 m_cpt_read_fsm_n_dir_lock++; 2232 } 2129 2233 2130 2234 #if DEBUG_MEMC_READ … … 2141 2245 case READ_DIR_LOCK: // check directory for hit / miss 2142 2246 { 2143 if(r_alloc_dir_fsm.read() == ALLOC_DIR_READ) 2144 { 2247 assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_READ) and 2248 "MEMC ERROR in READ_DIR_LOCK state: Bad DIR allocation"); 2249 2145 2250 size_t way = 0; 2146 2251 DirectoryEntry entry = 2147 2252 m_cache_directory.read(m_cmd_read_addr_fifo.read(), way); 2148 2253 if(((m_cmd_read_pktid_fifo.read() & 0x7) == TYPE_LL) and not r_read_ll_done.read()) // access the global table ONLY when we have an LL cmd 2149 2254 { … … 2164 2269 r_read_copy = entry.owner.srcid; 2165 2270 2166 #if L1_MULTI_CACHE2167 r_read_copy_cache = entry.owner.cache_id;2168 #endif2169 2271 r_read_copy_inst = entry.owner.inst; 2170 2272 r_read_ptr = entry.ptr; // pointer to the heap … … 2216 2318 } 2217 2319 #endif 2218 }2219 else2220 {2221 std::cout << "VCI_MEM_CACHE ERROR " << name() << " READ_DIR_LOCK state"2222 << "Bad DIR allocation" << std::endl;2223 exit(0);2224 }2225 2320 break; 2226 2321 } … … 2318 2413 2319 2414 { 2320 if(r_alloc_dir_fsm.read() == ALLOC_DIR_READ)2321 {2415 assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_READ) and 2416 "MEMC ERROR in READ_DIR_HIT state: Bad DIR allocation"); 2322 2417 // check if this is an instruction read, this means pktid is either 2323 2418 // TYPE_READ_INS_UNC 0bX010 with TSAR encoding … … 2335 2430 2336 2431 m_cache_data.read_line(way, set, r_read_data); 2337 2338 if(m_monitor_ok) check_monitor( m_cmd_read_addr_fifo.read(), r_read_data[0], true);2339 2432 2340 2433 // update the cache directory … … 2353 2446 { 2354 2447 entry.owner.srcid = m_cmd_read_srcid_fifo.read(); 2355 #if L1_MULTI_CACHE2356 entry.owner.cache_id = m_cmd_read_pktid_fifo.read();2357 #endif2358 2448 entry.owner.inst = inst_read; 2359 2449 entry.count = r_read_count.read() + 1; … … 2362 2452 { 2363 2453 entry.owner.srcid = 0; 2364 #if L1_MULTI_CACHE2365 entry.owner.cache_id = 0;2366 #endif2367 2454 entry.owner.inst = false; 2368 2455 entry.count = r_read_count.read() + 1; … … 2372 2459 { 2373 2460 entry.owner.srcid = r_read_copy.read(); 2374 #if L1_MULTI_CACHE2375 entry.owner.cache_id = r_read_copy_cache.read();2376 #endif2377 2461 entry.owner.inst = r_read_copy_inst.read(); 2378 2462 entry.count = r_read_count.read(); … … 2394 2478 m_cache_directory.write(set, way, entry); 2395 2479 r_read_fsm = READ_RSP; 2396 } 2397 break; 2480 break; 2398 2481 } 2399 2482 /////////////////// … … 2436 2519 2437 2520 m_cache_data.read_line(way, set, r_read_data); 2438 2439 if(m_monitor_ok) check_monitor( m_cmd_read_addr_fifo.read(), r_read_data[0], true);2440 2521 2441 2522 // update the cache directory … … 2452 2533 { 2453 2534 entry.owner.srcid = r_read_copy.read(); 2454 #if L1_MULTI_CACHE2455 entry.owner.cache_id = r_read_copy_cache.read();2456 #endif2457 2535 entry.owner.inst = r_read_copy_inst.read(); 2458 2536 entry.ptr = m_heap.next_free_ptr(); // set pointer on the heap … … 2461 2539 { 2462 2540 entry.owner.srcid = 0; 2463 #if L1_MULTI_CACHE2464 entry.owner.cache_id = 0;2465 #endif2466 2541 entry.owner.inst = false; 2467 2542 entry.ptr = 0; … … 2529 2604 HeapEntry heap_entry; 2530 2605 heap_entry.owner.srcid = m_cmd_read_srcid_fifo.read(); 2531 #if L1_MULTI_CACHE2532 heap_entry.owner.cache_id = m_cmd_read_pktid_fifo.read();2533 #endif2534 2606 heap_entry.owner.inst = ((m_cmd_read_pktid_fifo.read() & 0x2) != 0); 2535 2607 … … 2595 2667 HeapEntry last_entry; 2596 2668 last_entry.owner.srcid = 0; 2597 #if L1_MULTI_CACHE2598 last_entry.owner.cache_id = 0;2599 #endif2600 2669 last_entry.owner.inst = false; 2601 2670 … … 2718 2787 #if DEBUG_MEMC_READ 2719 2788 if(m_debug) 2720 std::cout << " <MEMC " << name() << " READ_TRT_SET> Write in Transaction Table:" 2789 m_trt.print(0); 2790 std::cout << " <MEMC " << name() << " READ_TRT_SET> Set a GET in TGT:" 2721 2791 << " address = " << std::hex << m_cmd_read_addr_fifo.read() 2722 2792 << " / srcid = " << std::hex << m_cmd_read_srcid_fifo.read() << std::endl; … … 2734 2804 cmd_read_fifo_get = true; 2735 2805 r_read_to_ixr_cmd_req = true; 2736 r_read_to_ixr_cmd_nline = m_nline[(addr_t)(m_cmd_read_addr_fifo.read())];2737 r_read_to_ixr_cmd_ trdid= r_read_trt_index.read();2806 //r_read_to_ixr_cmd_nline = m_nline[(addr_t)(m_cmd_read_addr_fifo.read())]; 2807 r_read_to_ixr_cmd_index = r_read_trt_index.read(); 2738 2808 r_read_fsm = READ_IDLE; 2739 2809 … … 2762 2832 // If the data is cached by other processors, a coherence transaction must 2763 2833 // be launched (sc requests always require a coherence transaction): 2764 // It is a multicast update if the line is not in counter mode , andthe processor2834 // It is a multicast update if the line is not in counter mode: the processor 2765 2835 // takes the lock protecting the Update Table (UPT) to register this transaction. 2766 // It is a broadcast invalidate if the line is in counter mode.2767 2836 // If the UPT is full, it releases the lock(s) and retry. Then, it sends 2768 2837 // a multi-update request to all owners of the line (but the writer), … … 2770 2839 // does not respond to the writing processor, as this response will be sent by 2771 2840 // the MULTI_ACK FSM when all update responses have been received. 2841 // It is a broadcast invalidate if the line is in counter mode: The line 2842 // should be erased in memory cache, and written in XRAM with a PUT transaction, 2843 // after registration in TRT. 2772 2844 // 2773 2845 // - In case of MISS, the WRITE FSM takes the lock protecting the transaction 2774 2846 // table (TRT). If a read transaction to the XRAM for this line already exists, 2775 2847 // it writes in the TRT (write buffer). Otherwise, if a TRT entry is free, 2776 // the WRITE FSM register a new transaction in TRT, and sends a read linerequest2848 // the WRITE FSM register a new transaction in TRT, and sends a GET request 2777 2849 // to the XRAM. If the TRT is full, it releases the lock, and waits. 2778 2850 // Finally, the WRITE FSM returns an aknowledge response to the writing processor. … … 2849 2921 2850 2922 // check that the next word is in the same cache line 2851 if((m_nline[(addr_t)(r_write_address.read())] != 2852 m_nline[(addr_t)(m_cmd_write_addr_fifo.read())])) 2853 { 2854 std::cout << "VCI_MEM_CACHE ERROR " << name() << " WRITE_NEXT state" << std::endl 2855 << "all words in a write burst must be in same cache line" << std::endl; 2856 2857 exit(0); 2858 } 2923 assert( (m_nline[(addr_t)(r_write_address.read())] == 2924 m_nline[(addr_t)(m_cmd_write_addr_fifo.read())]) and 2925 "MEMC ERROR in WRITE_NEXT state: Illegal write burst"); 2859 2926 2860 2927 // consume a word in the FIFO & write it in the local buffer … … 2922 2989 // erase any possible new reservation when we release the lock on the 2923 2990 // directory 2924 m_llsc_table.sw( nline);2991 m_llsc_table.sw(m_nline[(addr_t)r_write_address.read()],r_write_word_index.read(),r_write_word_index.read()+r_write_word_count.read()); 2925 2992 2926 2993 //m_llsc_table.sw(r_write_address.read()); … … 2944 3011 case WRITE_DIR_LOCK: // access directory to check hit/miss 2945 3012 { 2946 if(r_alloc_dir_fsm.read() == ALLOC_DIR_WRITE)2947 {3013 assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_WRITE) and 3014 "MEMC ERROR in ALLOC_DIR_LOCK state: Bad DIR allocation"); 2948 3015 size_t way = 0; 2949 3016 DirectoryEntry entry(m_cache_directory.read(r_write_address.read(), way)); … … 2956 3023 r_write_tag = entry.tag; 2957 3024 r_write_copy = entry.owner.srcid; 2958 #if L1_MULTI_CACHE2959 r_write_copy_cache = entry.owner.cache_id;2960 #endif2961 3025 r_write_copy_inst = entry.owner.inst; 2962 3026 r_write_count = entry.count; … … 2970 3034 if(entry.is_cnt && entry.count) 2971 3035 { 2972 r_write_fsm = WRITE_ DIR_READ;3036 r_write_fsm = WRITE_BC_DIR_READ; 2973 3037 } 2974 3038 else … … 3012 3076 } 3013 3077 #endif 3014 }3015 else3016 {3017 std::cout << "VCI_MEM_CACHE ERROR " << name()3018 << " WRITE_DIR_LOCK state" << std::endl3019 << "bad DIR allocation" << std::endl;3020 3021 exit(0);3022 }3023 3078 break; 3024 3079 } … … 3076 3131 } 3077 3132 3078 3079 ////////////////////3080 case WRITE_DIR_READ: // read the cache and complete the buffer when be!=0xF3081 {3082 // update local buffer3083 size_t set = m_y[(addr_t)(r_write_address.read())];3084 size_t way = r_write_way.read();3085 for(size_t word=0 ; word<m_words ; word++)3086 {3087 data_t mask = 0;3088 if(r_write_be[word].read() & 0x1) mask = mask | 0x000000FF;3089 if(r_write_be[word].read() & 0x2) mask = mask | 0x0000FF00;3090 if(r_write_be[word].read() & 0x4) mask = mask | 0x00FF0000;3091 if(r_write_be[word].read() & 0x8) mask = mask | 0xFF000000;3092 3093 // complete only if mask is not null (for energy consumption)3094 r_write_data[word] = (r_write_data[word].read() & mask) |3095 (m_cache_data.read(way, set, word) & ~mask);3096 3097 } // end for3098 3099 // test if a coherence broadcast is required3100 r_write_fsm = WRITE_BC_TRT_LOCK;3101 3102 #if DEBUG_MEMC_WRITE3103 if(m_debug)3104 std::cout << " <MEMC " << name() << " WRITE_DIR_READ>"3105 << " Read the cache to complete local buffer" << std::endl;3106 #endif3107 break;3108 }3109 3110 3133 /////////////////// 3111 3134 case WRITE_DIR_HIT: 3112 3135 { 3136 assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_WRITE) and 3137 "MEMC ERROR in ALLOC_DIR_HIT state: Bad DIR allocation"); 3138 3113 3139 // update the cache directory 3114 3140 // update directory with Dirty bit … … 3121 3147 entry.lock = r_write_lock.read(); 3122 3148 entry.owner.srcid = r_write_copy.read(); 3123 #if L1_MULTI_CACHE3124 entry.owner.cache_id = r_write_copy_cache.read();3125 #endif3126 3149 entry.owner.inst = r_write_copy_inst.read(); 3127 3150 entry.count = r_write_count.read(); … … 3154 3177 m_cache_data.write(way, set, word, r_write_data[word].read(), r_write_be[word].read()); 3155 3178 3156 if(m_monitor_ok)3157 {3158 addr_t address = (r_write_address.read() & ~(addr_t) 0x3F) | word<<2;3159 check_monitor( address, r_write_data[word].read(), false);3160 }3161 3179 } 3162 3180 } … … 3242 3260 r_write_be[word].read()); 3243 3261 3244 if(m_monitor_ok)3245 {3246 addr_t address = (r_write_address.read() & ~(addr_t) 0x3F) | word<<2;3247 check_monitor( address, r_write_data[word].read(), false);3248 }3249 3262 } 3250 3263 } 3251 3264 3252 3265 #if DEBUG_MEMC_WRITE 3253 if(m_debug )3266 if(m_debug and wok) 3254 3267 { 3255 3268 if(wok) … … 3317 3330 for(size_t i=min ; i<max ; i++) r_write_to_cc_send_data[i] = r_write_data[i]; 3318 3331 3319 if((r_write_copy.read() != r_write_srcid.read()) or(r_write_pktid.read() == TYPE_SC) or 3320 #if L1_MULTI_CACHE 3321 (r_write_copy_cache.read() != r_write_pktid.read()) or 3322 #endif 3323 r_write_copy_inst.read()) 3332 if((r_write_copy.read() != r_write_srcid.read()) or(r_write_pktid.read() == TYPE_SC) or r_write_copy_inst.read()) 3324 3333 { 3325 3334 // put the first srcid in the fifo … … 3327 3336 write_to_cc_send_fifo_inst = r_write_copy_inst.read(); 3328 3337 write_to_cc_send_fifo_srcid = r_write_copy.read(); 3329 #if L1_MULTI_CACHE3330 write_to_cc_send_fifo_cache_id= r_write_copy_cache.read();3331 #endif3332 3338 if(r_write_count.read() == 1) 3333 3339 { … … 3380 3386 bool dec_upt_counter; 3381 3387 3382 if(((entry.owner.srcid != r_write_srcid.read()) or (r_write_pktid.read() == TYPE_SC)) or 3383 #if L1_MULTI_CACHE 3384 (entry.owner.cache_id != r_write_pktid.read()) or 3385 #endif 3386 entry.owner.inst) // put the next srcid in the fifo 3388 if(((entry.owner.srcid != r_write_srcid.read()) or (r_write_pktid.read() == TYPE_SC)) or entry.owner.inst) // put the next srcid in the fifo 3387 3389 { 3388 3390 dec_upt_counter = false; … … 3390 3392 write_to_cc_send_fifo_inst = entry.owner.inst; 3391 3393 write_to_cc_send_fifo_srcid = entry.owner.srcid; 3392 #if L1_MULTI_CACHE3393 write_to_cc_send_fifo_cache_id = entry.owner.cache_id;3394 #endif3395 3394 3396 3395 #if DEBUG_MEMC_WRITE … … 3573 3572 bool hit_read = m_trt.hit_read(m_nline[addr], hit_index); 3574 3573 bool hit_write = m_trt.hit_write(m_nline[addr]); 3575 bool wok = !m_trt.full(wok_index);3574 bool wok = not m_trt.full(wok_index); 3576 3575 //std::cout << "MEMCACHE : WRITE MISS at " << std::hex << (uint32_t)addr << std::dec << std::endl; 3577 3576 if(hit_read) // register the modified data in TRT … … 3641 3640 #if DEBUG_MEMC_WRITE 3642 3641 if(m_debug) 3642 m_trt.print(0); 3643 3643 std::cout << " <MEMC " << name() << " WRITE_MISS_TRT_SET> Set a new entry in TRT" << std::endl; 3644 3644 #endif … … 3662 3662 } 3663 3663 m_trt.write_data_mask(r_write_trt_index.read(), 3664 3665 3664 be_vector, 3665 data_vector); 3666 3666 r_write_fsm = WRITE_RSP; 3667 3667 … … 3677 3677 case WRITE_MISS_XRAM_REQ: // send a GET request to IXR_CMD FSM 3678 3678 { 3679 if( !r_write_to_ixr_cmd_req)3679 if(not r_write_to_ixr_cmd_req.read()) 3680 3680 { 3681 3681 r_write_to_ixr_cmd_req = true; 3682 r_write_to_ixr_cmd_write = false; 3683 r_write_to_ixr_cmd_nline = m_nline[(addr_t)(r_write_address.read())]; 3684 r_write_to_ixr_cmd_trdid = r_write_trt_index.read(); 3682 r_write_to_ixr_cmd_put = false; 3683 r_write_to_ixr_cmd_index = r_write_trt_index.read(); 3685 3684 r_write_fsm = WRITE_RSP; 3686 3685 … … 3694 3693 3695 3694 /////////////////////// 3696 case WRITE_BC_TRT_LOCK: // Check TRT not full 3697 { 3695 case WRITE_BC_DIR_READ: // enter this state if a broadcast-inval is required 3696 // the cache line must be erased in mem-cache, and written 3697 // into XRAM. we read the cache and complete the buffer 3698 { 3699 assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_WRITE) and 3700 "MEMC ERROR in WRITE_BC_DIR_READ state: Bad DIR allocation"); 3701 3702 // update local buffer 3703 size_t set = m_y[(addr_t)(r_write_address.read())]; 3704 size_t way = r_write_way.read(); 3705 for(size_t word=0 ; word<m_words ; word++) 3706 { 3707 data_t mask = 0; 3708 if(r_write_be[word].read() & 0x1) mask = mask | 0x000000FF; 3709 if(r_write_be[word].read() & 0x2) mask = mask | 0x0000FF00; 3710 if(r_write_be[word].read() & 0x4) mask = mask | 0x00FF0000; 3711 if(r_write_be[word].read() & 0x8) mask = mask | 0xFF000000; 3712 3713 // complete only if mask is not null (for energy consumption) 3714 r_write_data[word] = (r_write_data[word].read() & mask) | 3715 (m_cache_data.read(way, set, word) & ~mask); 3716 } // end for 3717 3718 r_write_fsm = WRITE_BC_TRT_LOCK; 3719 3720 #if DEBUG_MEMC_WRITE 3721 if(m_debug) 3722 std::cout << " <MEMC " << name() << " WRITE_BC_DIR_READ>" 3723 << " Read the cache to complete local buffer" << std::endl; 3724 #endif 3725 break; 3726 } 3727 3728 /////////////////////// 3729 case WRITE_BC_TRT_LOCK: // get TRT lock to check TRT not full 3730 { 3731 assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_WRITE) and 3732 "MEMC ERROR in WRITE_BC_TRT_LOCK state: Bad DIR allocation"); 3733 3698 3734 if(r_alloc_trt_fsm.read() == ALLOC_TRT_WRITE) 3699 3735 { 3700 3736 size_t wok_index = 0; 3701 bool wok = !m_trt.full(wok_index);3737 bool wok = not m_trt.full(wok_index); 3702 3738 if(wok) // set a new entry in TRT 3703 3739 { … … 3726 3762 case WRITE_BC_IVT_LOCK: // register BC transaction in IVT 3727 3763 { 3764 assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_WRITE) and 3765 "MEMC ERROR in WRITE_BC_IVT_LOCK state: Bad DIR allocation"); 3766 3767 assert( (r_alloc_trt_fsm.read() == ALLOC_TRT_WRITE) and 3768 "MEMC ERROR in WRITE_BC_IVT_LOCK state: Bad TRT allocation"); 3769 3728 3770 if(r_alloc_ivt_fsm.read() == ALLOC_IVT_WRITE) 3729 3771 { … … 3767 3809 case WRITE_BC_DIR_INVAL: 3768 3810 { 3769 // Register a put transaction to XRAM in TRT 3770 // and invalidate the line in directory 3771 if((r_alloc_trt_fsm.read() != ALLOC_TRT_WRITE) or 3772 (r_alloc_ivt_fsm.read() != ALLOC_IVT_WRITE) or 3773 (r_alloc_dir_fsm.read() != ALLOC_DIR_WRITE)) 3774 { 3775 std::cout << "VCI_MEM_CACHE ERROR " << name() << " WRITE_BC_DIR_INVAL state" << std::endl; 3776 std::cout << "bad TRT, DIR, or IVT allocation" << std::endl; 3777 exit(0); 3778 } 3779 3780 // register a write request to XRAM in TRT 3781 m_trt.set(r_write_trt_index.read(), 3782 false, // write request to XRAM 3783 m_nline[(addr_t)(r_write_address.read())], 3784 0, 3785 0, 3786 0, 3787 false, // not a processor read 3788 0, // not a single word 3789 0, // word index 3790 std::vector<be_t> (m_words,0), 3791 std::vector<data_t> (m_words,0)); 3811 assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_WRITE) and 3812 "MEMC ERROR in WRITE_BC_DIR_INVAL state: Bad DIR allocation"); 3813 3814 assert( (r_alloc_trt_fsm.read() == ALLOC_TRT_WRITE) and 3815 "MEMC ERROR in WRITE_BC_DIR_INVAL state: Bad TRT allocation"); 3816 3817 assert( (r_alloc_ivt_fsm.read() == ALLOC_IVT_WRITE) and 3818 "MEMC ERROR in WRITE_BC_DIR_INVAL state: Bad IVT allocation"); 3819 3820 // register PUT request in TRT 3821 std::vector<data_t> data_vector; 3822 data_vector.clear(); 3823 for(size_t i=0; i<m_words; i++) data_vector.push_back(r_write_data[i].read()); 3824 m_trt.set( r_write_trt_index.read(), 3825 false, // PUT request 3826 m_nline[(addr_t)(r_write_address.read())], 3827 0, // unused 3828 0, // unused 3829 0, // unused 3830 false, // not a processor read 3831 0, // unused 3832 0, // unused 3833 std::vector<be_t> (m_words,0), 3834 data_vector ); 3792 3835 3793 3836 // invalidate directory entry … … 3796 3839 entry.cache_coherent= false; 3797 3840 entry.dirty = false; 3798 entry.tag = 0;3841 entry.tag = 0; 3799 3842 entry.is_cnt = false; 3800 3843 entry.lock = false; 3801 3844 entry.owner.srcid = 0; 3802 #if L1_MULTI_CACHE3803 entry.owner.cache_id= 0;3804 #endif3805 3845 entry.owner.inst = false; 3806 3846 entry.ptr = 0; … … 3813 3853 #if DEBUG_MEMC_WRITE 3814 3854 if(m_debug) 3855 m_trt.print(0); 3815 3856 std::cout << " <MEMC " << name() << " WRITE_BC_DIR_INVAL> Invalidate the directory entry: @ = " 3816 3857 << r_write_address.read() << " / register the put transaction in TRT:" << std::endl; … … 3851 3892 case WRITE_BC_XRAM_REQ: // Post a put request to IXR_CMD FSM 3852 3893 { 3853 if( !r_write_to_ixr_cmd_req)3894 if( not r_write_to_ixr_cmd_req.read() ) 3854 3895 { 3855 3896 r_write_to_ixr_cmd_req = true; 3856 r_write_to_ixr_cmd_write = true; 3857 r_write_to_ixr_cmd_nline = m_nline[(addr_t)(r_write_address.read())]; 3858 r_write_to_ixr_cmd_trdid = r_write_trt_index.read(); 3859 3860 for(size_t i=0; i<m_words; i++) r_write_to_ixr_cmd_data[i] = r_write_data[i]; 3861 3897 r_write_to_ixr_cmd_put = true; 3898 r_write_to_ixr_cmd_index = r_write_trt_index.read(); 3862 3899 r_write_fsm = WRITE_IDLE; 3863 3900 … … 3876 3913 /////////////////////////////////////////////////////////////////////// 3877 3914 // The IXR_CMD fsm controls the command packets to the XRAM : 3878 // It handles requests from the READ, WRITE, CAS, XRAM_RSP FSMs3879 // with a round-robin priority.3915 // It handles requests from 5 FSMs with a round-robin priority: 3916 // READ > WRITE > CAS > XRAM_RSP > CONFIG 3880 3917 // 3881 // - It sends a single flit VCI read request to the XRAM in case of MISS 3882 // posted by the READ, WRITE or CAS FSMs : the TRDID field contains 3883 // the Transaction Tab index. 3884 // The VCI response is a multi-flit packet : the N cells contain 3885 // the N data words. 3918 // - It sends a single flit VCI read to the XRAM in case of 3919 // GET request posted by the READ, WRITE or CAS FSMs. 3920 // - It sends a multi-flit VCI write in case of PUT request posted by 3921 // the XRAM_RSP, WRITE, CAS, or CONFIG FSMs. 3886 3922 // 3887 // - It sends a multi-flit VCI write when the XRAM_RSP FSM, WRITE FSM 3888 // or CAS FSM request to save a dirty line to the XRAM. 3889 // The VCI response is a single flit packet. 3923 // For each client, there is three steps: 3924 // - IXR_CMD_*_IDLE : round-robin allocation to a client 3925 // - IXR_CMD_*_TRT : access to TRT for address and data 3926 // - IXR_CMD_*_SEND : send the PUT or GET VCI command 3927 // 3928 // The address and data to be written (for a PUT) are stored in TRT. 3929 // The trdid field contains always the TRT entry index. 3890 3930 //////////////////////////////////////////////////////////////////////// 3891 3931 … … 3894 3934 //////////////////////// 3895 3935 case IXR_CMD_READ_IDLE: 3896 if (r_write_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_WRITE; 3897 else if(r_cas_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_CAS; 3898 else if(r_xram_rsp_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_XRAM; 3899 else if(r_cleanup_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_CLEANUP_DATA; 3900 else if(r_read_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_READ; 3936 if (r_write_to_ixr_cmd_req.read()) r_ixr_cmd_fsm = IXR_CMD_WRITE_TRT; 3937 else if(r_cas_to_ixr_cmd_req.read()) r_ixr_cmd_fsm = IXR_CMD_CAS_TRT; 3938 else if(r_cleanup_to_ixr_cmd_req.read()) r_ixr_cmd_fsm = IXR_CMD_CLEANUP_TRT; 3939 else if(r_xram_rsp_to_ixr_cmd_req.read()) r_ixr_cmd_fsm = IXR_CMD_XRAM_TRT; 3940 else if(r_config_to_ixr_cmd_req.read()) r_ixr_cmd_fsm = IXR_CMD_CONFIG_TRT; 3941 else if(r_read_to_ixr_cmd_req.read()) r_ixr_cmd_fsm = IXR_CMD_READ_TRT; 3901 3942 break; 3902 3943 //////////////////////// 3903 3944 case IXR_CMD_WRITE_IDLE: 3904 if(r_cas_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_CAS; 3905 else if(r_xram_rsp_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_XRAM; 3906 else if(r_cleanup_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_CLEANUP_DATA; 3907 else if(r_read_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_READ; 3908 else if(r_write_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_WRITE; 3945 if (r_cas_to_ixr_cmd_req.read()) r_ixr_cmd_fsm = IXR_CMD_CAS_TRT; 3946 else if(r_cleanup_to_ixr_cmd_req.read()) r_ixr_cmd_fsm = IXR_CMD_CLEANUP_TRT; 3947 else if(r_xram_rsp_to_ixr_cmd_req.read()) r_ixr_cmd_fsm = IXR_CMD_XRAM_TRT; 3948 else if(r_config_to_ixr_cmd_req.read()) r_ixr_cmd_fsm = IXR_CMD_CONFIG_TRT; 3949 else if(r_read_to_ixr_cmd_req.read()) r_ixr_cmd_fsm = IXR_CMD_READ_TRT; 3950 else if(r_write_to_ixr_cmd_req.read()) r_ixr_cmd_fsm = IXR_CMD_WRITE_TRT; 3909 3951 break; 3910 3952 //////////////////////// 3911 3953 case IXR_CMD_CAS_IDLE: 3912 if(r_xram_rsp_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_XRAM; 3913 else if(r_cleanup_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_CLEANUP_DATA; 3914 else if(r_read_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_READ; 3915 else if(r_write_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_WRITE; 3916 else if(r_cas_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_CAS; 3954 if (r_cleanup_to_ixr_cmd_req.read()) r_ixr_cmd_fsm = IXR_CMD_CLEANUP_TRT; 3955 else if(r_xram_rsp_to_ixr_cmd_req.read()) r_ixr_cmd_fsm = IXR_CMD_XRAM_TRT; 3956 else if(r_config_to_ixr_cmd_req.read()) r_ixr_cmd_fsm = IXR_CMD_CONFIG_TRT; 3957 else if(r_read_to_ixr_cmd_req.read()) r_ixr_cmd_fsm = IXR_CMD_READ_TRT; 3958 else if(r_write_to_ixr_cmd_req.read()) r_ixr_cmd_fsm = IXR_CMD_WRITE_TRT; 3959 else if(r_cas_to_ixr_cmd_req.read()) r_ixr_cmd_fsm = IXR_CMD_CAS_TRT; 3917 3960 break; 3918 3961 //////////////////////// 3919 3962 case IXR_CMD_XRAM_IDLE: 3920 if(r_cleanup_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_CLEANUP_DATA; 3921 else if(r_read_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_READ; 3922 else if(r_write_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_WRITE; 3923 else if(r_cas_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_CAS; 3924 else if(r_xram_rsp_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_XRAM; 3963 if (r_config_to_ixr_cmd_req.read()) r_ixr_cmd_fsm = IXR_CMD_CONFIG_TRT; 3964 else if(r_read_to_ixr_cmd_req.read()) r_ixr_cmd_fsm = IXR_CMD_READ_TRT; 3965 else if(r_write_to_ixr_cmd_req.read()) r_ixr_cmd_fsm = IXR_CMD_WRITE_TRT; 3966 else if(r_cas_to_ixr_cmd_req.read()) r_ixr_cmd_fsm = IXR_CMD_CAS_TRT; 3967 else if(r_cleanup_to_ixr_cmd_req.read()) r_ixr_cmd_fsm = IXR_CMD_CLEANUP_TRT; 3968 else if(r_xram_rsp_to_ixr_cmd_req.read()) r_ixr_cmd_fsm = IXR_CMD_XRAM_TRT; 3925 3969 break; 3926 3970 //////////////////////// 3927 3971 case IXR_CMD_CLEANUP_IDLE: 3928 3972 /*ODCCP*///std::cout << "IXR_CMD_CLEANUP_IDLE" << std::endl; 3929 if(r_read_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_READ; 3930 else if(r_write_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_WRITE; 3931 else if(r_cas_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_CAS; 3932 else if(r_xram_rsp_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_XRAM; 3933 else if(r_cleanup_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_CLEANUP_DATA; 3973 if (r_read_to_ixr_cmd_req.read()) r_ixr_cmd_fsm = IXR_CMD_READ_TRT; 3974 else if(r_write_to_ixr_cmd_req.read()) r_ixr_cmd_fsm = IXR_CMD_WRITE_TRT; 3975 else if(r_cas_to_ixr_cmd_req.read()) r_ixr_cmd_fsm = IXR_CMD_CAS_TRT; 3976 else if(r_xram_rsp_to_ixr_cmd_req.read()) r_ixr_cmd_fsm = IXR_CMD_XRAM_TRT; 3977 else if(r_config_to_ixr_cmd_req.read()) r_ixr_cmd_fsm = IXR_CMD_CONFIG_TRT; 3978 else if(r_cleanup_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_CLEANUP_TRT; 3934 3979 break; 3935 ////////////////// // send a get from READ FSM 3936 case IXR_CMD_READ: 3937 { 3938 if(p_vci_ixr.cmdack) 3939 { 3940 r_ixr_cmd_fsm = IXR_CMD_READ_IDLE; 3941 r_read_to_ixr_cmd_req = false; 3980 ///////////////////////// 3981 case IXR_CMD_CONFIG_IDLE: 3982 { 3983 if (r_read_to_ixr_cmd_req.read()) r_ixr_cmd_fsm = IXR_CMD_READ_TRT; 3984 else if(r_write_to_ixr_cmd_req.read()) r_ixr_cmd_fsm = IXR_CMD_WRITE_TRT; 3985 else if(r_cas_to_ixr_cmd_req.read()) r_ixr_cmd_fsm = IXR_CMD_CAS_TRT; 3986 else if(r_cleanup_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_CLEANUP_TRT; 3987 else if(r_xram_rsp_to_ixr_cmd_req.read()) r_ixr_cmd_fsm = IXR_CMD_XRAM_TRT; 3988 else if(r_config_to_ixr_cmd_req.read()) r_ixr_cmd_fsm = IXR_CMD_CONFIG_TRT; 3989 break; 3990 } 3991 3992 ////////////////////// 3993 case IXR_CMD_READ_TRT: // access TRT for a GET 3994 { 3995 if ( r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_CMD ) 3996 { 3997 TransactionTabEntry entry = m_trt.read( r_read_to_ixr_cmd_index.read() ); 3998 r_ixr_cmd_address = entry.nline * (m_words<<2); 3999 r_ixr_cmd_trdid = r_read_to_ixr_cmd_index.read(); 4000 r_ixr_cmd_get = true; 4001 r_ixr_cmd_word = 0; 4002 r_ixr_cmd_fsm = IXR_CMD_READ_SEND; 4003 for( size_t i=0 ; i<m_words ; i++ ) r_ixr_cmd_wdata[i] = entry.wdata[i]; 3942 4004 3943 4005 #if DEBUG_MEMC_IXR_CMD 3944 4006 if(m_debug) 3945 std::cout << " <MEMC " << name() << " IXR_CMD_READ>" 3946 << " Send a get request to xram / address = " << std::hex 3947 << (addr_t)(r_read_to_ixr_cmd_nline.read()*m_words*4) << std::endl; 3948 #endif 3949 } 3950 break; 3951 } 3952 /////////////////// 3953 case IXR_CMD_WRITE: // send a put or get from WRITE FSM 3954 { 3955 if(p_vci_ixr.cmdack) 3956 { 3957 if(r_write_to_ixr_cmd_write.read()) // PUT 3958 { 3959 if(r_ixr_cmd_cpt.read() == (m_words - 2)) 3960 { 3961 r_ixr_cmd_cpt = 0; 3962 r_ixr_cmd_fsm = IXR_CMD_WRITE_IDLE; 3963 r_write_to_ixr_cmd_req = false; 3964 } 3965 else 3966 { 3967 r_ixr_cmd_cpt = r_ixr_cmd_cpt + 2; 3968 } 4007 std::cout << " <MEMC " << name() << " IXR_CMD_READ_TRT> TRT access" 4008 << " index = " << std::dec << r_read_to_ixr_cmd_index.read() 4009 << " / address = " << std::hex << (entry.nline*(m_words<<2)) << std::endl; 4010 #endif 4011 } 4012 break; 4013 } 4014 /////////////////////// 4015 case IXR_CMD_WRITE_TRT: // access TRT for a PUT or a GET 4016 { 4017 if ( r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_CMD ) 4018 { 4019 TransactionTabEntry entry = m_trt.read( r_write_to_ixr_cmd_index.read() ); 4020 r_ixr_cmd_address = entry.nline * (m_words<<2); 4021 r_ixr_cmd_trdid = r_write_to_ixr_cmd_index.read(); 4022 r_ixr_cmd_get = entry.xram_read; 4023 r_ixr_cmd_word = 0; 4024 r_ixr_cmd_fsm = IXR_CMD_WRITE_SEND; 4025 for( size_t i=0 ; i<m_words ; i++ ) r_ixr_cmd_wdata[i] = entry.wdata[i]; 3969 4026 3970 4027 #if DEBUG_MEMC_IXR_CMD 3971 4028 if(m_debug) 3972 std::cout << " <MEMC " << name() << " IXR_CMD_WRITE>" 3973 << " Send a put request to xram / address = " << std::hex 3974 << (addr_t)((r_write_to_ixr_cmd_nline.read() * m_words + 3975 r_ixr_cmd_cpt.read()) * 4 ) << std::endl; 3976 #endif 3977 } 3978 else // GET 3979 { 3980 r_ixr_cmd_fsm = IXR_CMD_WRITE_IDLE; 3981 r_write_to_ixr_cmd_req = false; 4029 std::cout << " <MEMC " << name() << " IXR_CMD_WRITE_TRT> TRT access" 4030 << " index = " << std::dec << r_write_to_ixr_cmd_index.read() 4031 << " / address = " << std::hex << (entry.nline*(m_words<<2)) << std::endl; 4032 #endif 4033 } 4034 break; 4035 } 4036 ///////////////////// 4037 case IXR_CMD_CAS_TRT: // access TRT for a PUT or a GET 4038 { 4039 if ( r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_CMD ) 4040 { 4041 TransactionTabEntry entry = m_trt.read( r_cas_to_ixr_cmd_index.read() ); 4042 r_ixr_cmd_address = entry.nline * (m_words<<2); 4043 r_ixr_cmd_trdid = r_cas_to_ixr_cmd_index.read(); 4044 r_ixr_cmd_get = entry.xram_read; 4045 r_ixr_cmd_word = 0; 4046 r_ixr_cmd_fsm = IXR_CMD_CAS_SEND; 4047 for( size_t i=0 ; i<m_words ; i++ ) r_ixr_cmd_wdata[i] = entry.wdata[i]; 3982 4048 3983 4049 #if DEBUG_MEMC_IXR_CMD 3984 4050 if(m_debug) 3985 std::cout << " <MEMC " << name() << " IXR_CMD_WRITE>" 3986 << " Send a get request to xram / address = " << std::hex 3987 << (addr_t)(r_write_to_ixr_cmd_nline.read()*m_words*4) << std::endl; 3988 #endif 3989 } 3990 } 3991 break; 3992 } 3993 ///////////////// 3994 case IXR_CMD_CAS: // send a put or get command from CAS FSM 3995 { 3996 if(p_vci_ixr.cmdack) 3997 { 3998 if(r_cas_to_ixr_cmd_write.read()) // PUT 3999 { 4000 if(r_ixr_cmd_cpt.read() == (m_words - 2)) 4001 { 4002 r_ixr_cmd_cpt = 0; 4003 r_ixr_cmd_fsm = IXR_CMD_CAS_IDLE; 4004 r_cas_to_ixr_cmd_req = false; 4005 } 4006 else 4007 { 4008 r_ixr_cmd_cpt = r_ixr_cmd_cpt + 2; 4009 } 4051 std::cout << " <MEMC " << name() << " IXR_CMD_CAS_TRT> TRT access" 4052 << " index = " << std::dec << r_cas_to_ixr_cmd_index.read() 4053 << " / address = " << std::hex << (entry.nline*(m_words<<2)) << std::endl; 4054 #endif 4055 } 4056 break; 4057 } 4058 ////////////////////// 4059 case IXR_CMD_XRAM_TRT: // access TRT for a PUT 4060 { 4061 if ( r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_CMD ) 4062 { 4063 TransactionTabEntry entry = m_trt.read( r_xram_rsp_to_ixr_cmd_index.read() ); 4064 r_ixr_cmd_address = entry.nline * (m_words<<2); 4065 r_ixr_cmd_trdid = r_xram_rsp_to_ixr_cmd_index.read(); 4066 r_ixr_cmd_get = false; 4067 r_ixr_cmd_word = 0; 4068 r_ixr_cmd_fsm = IXR_CMD_XRAM_SEND; 4069 for( size_t i=0 ; i<m_words ; i++ ) r_ixr_cmd_wdata[i] = entry.wdata[i]; 4010 4070 4011 4071 #if DEBUG_MEMC_IXR_CMD 4012 4072 if(m_debug) 4013 std::cout << " <MEMC " << name() << " IXR_CMD_CAS>" 4014 << " Send a put request to xram / address = " << std::hex 4015 << (addr_t)( (r_cas_to_ixr_cmd_nline.read() * m_words + 4016 r_ixr_cmd_cpt.read()) * 4 ) << std::endl; 4017 #endif 4018 } 4019 else // GET 4020 { 4021 r_ixr_cmd_fsm = IXR_CMD_CAS_IDLE; 4022 r_cas_to_ixr_cmd_req = false; 4073 std::cout << " <MEMC " << name() << " IXR_CMD_XRAM_TRT> TRT access" 4074 << " index = " << std::dec << r_xram_rsp_to_ixr_cmd_index.read() 4075 << " / address = " << std::hex << (entry.nline*(m_words<<2)) << std::endl; 4076 #endif 4077 } 4078 break; 4079 } 4080 ////////////////////// 4081 case IXR_CMD_CLEANUP_TRT: // access TRT for a PUT 4082 { 4083 if ( r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_CMD ) 4084 { 4085 4086 TransactionTabEntry entry = m_trt.read( r_cleanup_to_ixr_cmd_index.read() ); 4087 r_ixr_cmd_address = entry.nline * (m_words<<2); 4088 r_ixr_cmd_trdid = r_cleanup_to_ixr_cmd_index.read(); 4089 r_ixr_cmd_get = false; 4090 r_ixr_cmd_word = 0; 4091 r_ixr_cmd_fsm = IXR_CMD_CLEANUP_DATA_SEND; 4092 for( size_t i=0 ; i<m_words ; i++ ) r_ixr_cmd_wdata[i] = entry.wdata[i]; 4023 4093 4024 4094 #if DEBUG_MEMC_IXR_CMD 4025 4095 if(m_debug) 4026 std::cout << " <MEMC " << name() << " IXR_CMD_CAS>" 4027 << " Send a get request to xram / address = " << std::hex 4028 << (addr_t)(r_cas_to_ixr_cmd_nline.read()*m_words*4) << std::endl; 4029 #endif 4030 } 4031 } 4032 break; 4033 } 4034 ////////////////// 4035 case IXR_CMD_XRAM: // send a put from XRAM_RSP FSM 4036 { 4037 if(p_vci_ixr.cmdack) 4038 { 4039 if(r_ixr_cmd_cpt.read() == (m_words - 2)) 4040 { 4041 r_ixr_cmd_cpt = 0; 4042 r_ixr_cmd_fsm = IXR_CMD_XRAM_IDLE; 4043 r_xram_rsp_to_ixr_cmd_req = false; 4096 std::cout << " <MEMC " << name() << " IXR_CMD_CLEANUP_TRT> TRT access" 4097 << " index = " << std::dec << r_cleanup_to_ixr_cmd_index.read() 4098 << " / address = " << std::hex << (entry.nline*(m_words<<2)) << std::endl; 4099 #endif 4100 } 4101 break; 4102 } 4103 //////////////////////// 4104 case IXR_CMD_CONFIG_TRT: // access TRT for a PUT 4105 { 4106 if ( r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_CMD ) 4107 { 4108 TransactionTabEntry entry = m_trt.read( r_config_to_ixr_cmd_index.read() ); 4109 r_ixr_cmd_address = entry.nline * (m_words<<2); 4110 r_ixr_cmd_trdid = r_config_to_ixr_cmd_index.read(); 4111 r_ixr_cmd_get = false; 4112 r_ixr_cmd_word = 0; 4113 r_ixr_cmd_fsm = IXR_CMD_CONFIG_SEND; 4114 for( size_t i=0 ; i<m_words ; i++ ) r_ixr_cmd_wdata[i] = entry.wdata[i]; 4115 4116 #if DEBUG_MEMC_IXR_CMD 4117 if(m_debug) 4118 std::cout << " <MEMC " << name() << " IXR_CMD_CONFIG_TRT> TRT access" 4119 << " index = " << std::dec << r_config_to_ixr_cmd_index.read() 4120 << " / address = " << std::hex << (entry.nline*(m_words<<2)) << std::endl; 4121 #endif 4122 } 4123 break; 4124 } 4125 4126 /////////////////////// 4127 case IXR_CMD_READ_SEND: // send a get from READ FSM 4128 { 4129 if(p_vci_ixr.cmdack) 4130 { 4131 r_ixr_cmd_fsm = IXR_CMD_READ_IDLE; 4132 r_read_to_ixr_cmd_req = false; 4133 4134 #if DEBUG_MEMC_IXR_CMD 4135 if(m_debug) 4136 std::cout << " <MEMC " << name() << " IXR_CMD_READ_SEND> GET request:" << std::hex 4137 << " address = " << r_ixr_cmd_address.read() + (r_ixr_cmd_word.read()<<2) << std::endl; 4138 #endif 4139 } 4140 break; 4141 } 4142 //////////////////////// 4143 case IXR_CMD_WRITE_SEND: // send a put or get from WRITE FSM 4144 { 4145 if(p_vci_ixr.cmdack) 4146 { 4147 if(r_write_to_ixr_cmd_put.read()) // PUT 4148 { 4149 if(r_ixr_cmd_word.read() == (m_words - 2)) 4150 { 4151 r_ixr_cmd_fsm = IXR_CMD_WRITE_IDLE; 4152 r_write_to_ixr_cmd_req = false; 4153 } 4154 else 4155 { 4156 r_ixr_cmd_word = r_ixr_cmd_word.read() + 2; 4157 } 4158 4159 #if DEBUG_MEMC_IXR_CMD 4160 if(m_debug) 4161 std::cout << " <MEMC " << name() << " IXR_CMD_WRITE_SEND> PUT request:" << std::hex 4162 << " address = " << r_ixr_cmd_address.read() + (r_ixr_cmd_word.read()<<2) << std::endl; 4163 #endif 4164 } 4165 else // GET 4166 { 4167 r_ixr_cmd_fsm = IXR_CMD_WRITE_IDLE; 4168 r_write_to_ixr_cmd_req = false; 4169 4170 #if DEBUG_MEMC_IXR_CMD 4171 if(m_debug) 4172 std::cout << " <MEMC " << name() << " IXR_CMD_WRITE_SEND> GET request:" << std::hex 4173 << " address = " << r_ixr_cmd_address.read() + (r_ixr_cmd_word.read()<<2) << std::endl; 4174 #endif 4175 } 4176 } 4177 break; 4178 } 4179 ////////////////////// 4180 case IXR_CMD_CAS_SEND: // send a put or get command from CAS FSM 4181 { 4182 if(p_vci_ixr.cmdack) 4183 { 4184 if(r_cas_to_ixr_cmd_put.read()) // PUT 4185 { 4186 if(r_ixr_cmd_word.read() == (m_words - 2)) 4187 { 4188 r_ixr_cmd_fsm = IXR_CMD_CAS_IDLE; 4189 r_cas_to_ixr_cmd_req = false; 4190 } 4191 else 4192 { 4193 r_ixr_cmd_word = r_ixr_cmd_word.read() + 2; 4194 } 4195 4196 #if DEBUG_MEMC_IXR_CMD 4197 if(m_debug) 4198 std::cout << " <MEMC " << name() << " IXR_CMD_CAS_SEND> PUT request:" << std::hex 4199 << " address = " << r_ixr_cmd_address.read() + (r_ixr_cmd_word.read()<<2) << std::endl; 4200 #endif 4201 } 4202 else // GET 4203 { 4204 r_ixr_cmd_fsm = IXR_CMD_CAS_IDLE; 4205 r_cas_to_ixr_cmd_req = false; 4206 4207 #if DEBUG_MEMC_IXR_CMD 4208 if(m_debug) 4209 std::cout << " <MEMC " << name() << " IXR_CMD_CAS_SEND> GET request:" << std::hex 4210 << " address = " << r_ixr_cmd_address.read() + (r_ixr_cmd_word.read()<<2) << std::endl; 4211 #endif 4212 } 4213 } 4214 break; 4215 } 4216 /////////////////////// 4217 case IXR_CMD_XRAM_SEND: // send a put from XRAM_RSP FSM 4218 { 4219 if(p_vci_ixr.cmdack.read()) 4220 { 4221 if(r_ixr_cmd_word.read() == (m_words - 2)) 4222 { 4223 r_ixr_cmd_fsm = IXR_CMD_XRAM_IDLE; 4224 r_xram_rsp_to_ixr_cmd_req = false; 4225 } 4226 else 4227 { 4228 r_ixr_cmd_word = r_ixr_cmd_word.read() + 2; 4229 } 4230 #if DEBUG_MEMC_IXR_CMD 4231 if(m_debug) 4232 std::cout << " <MEMC " << name() << " IXR_CMD_XRAM_SEND> PUT request:" << std::hex 4233 << " address = " << r_ixr_cmd_address.read() + (r_ixr_cmd_word.read()<<2) << std::endl; 4234 #endif 4235 } 4236 break; 4237 } 4238 4239 //////////////////////// 4240 case IXR_CMD_CLEANUP_DATA_SEND: // send a put command to XRAM 4241 { 4242 if(p_vci_ixr.cmdack.read()) 4243 { 4244 /*ODCCP*/ //std::cout << "IXR_CMD_CLEANUP_DATA_SEND STATE at cycle : " << std::dec << m_cpt_cycles << std::endl; 4245 if(r_ixr_cmd_word.read() == (m_words - 2)) 4246 { 4247 /*ODCCP*/ //std::cout << "IXR_CMD_CLEANUP_DATA_SEND GO TO IXR_CMD_CLEANUP_IDLE" << std::endl; 4248 r_ixr_cmd_fsm = IXR_CMD_CLEANUP_IDLE; 4249 r_cleanup_to_ixr_cmd_req = false; 4250 //r_ixr_cmd_word = 0; 4251 //r_xram_rsp_to_ixr_cmd_inval_ncc_pending = false; 4044 4252 } 4045 4253 else 4046 4254 { 4047 r_ixr_cmd_cpt = r_ixr_cmd_cpt + 2; 4048 } 4049 4050 #if DEBUG_MEMC_IXR_CMD 4051 if(m_debug) 4052 std::cout << " <MEMC " << name() << " IXR_CMD_XRAM>" 4053 << " Send a put request to xram / address = " << std::hex 4054 << (addr_t)( (r_xram_rsp_to_ixr_cmd_nline.read() * m_words + 4055 r_ixr_cmd_cpt.read()) * 4 ) << std::endl; 4056 #endif 4057 } 4058 break; 4059 } 4060 4061 //////////////////////// 4062 case IXR_CMD_CLEANUP_DATA: // send a put command to XRAM 4063 /*ODCCP*///std::cout << "IXR_CMD_CLEANUP_DATA" << std::endl; 4064 if(p_vci_ixr.cmdack) 4065 { 4066 if(r_ixr_cmd_cpt.read() == (m_words - 2)) 4067 { 4068 r_ixr_cmd_cpt = 0; 4069 r_ixr_cmd_fsm = IXR_CMD_CLEANUP_IDLE; 4070 r_xram_rsp_to_ixr_cmd_inval_ncc_pending = false; 4071 r_cleanup_to_ixr_cmd_req = false; 4072 } 4073 else 4074 { 4075 r_ixr_cmd_cpt = r_ixr_cmd_cpt.read() + 2; 4255 r_ixr_cmd_word = r_ixr_cmd_word.read() + 2; 4076 4256 } 4077 4257 … … 4079 4259 if(m_debug) 4080 4260 { 4081 std::cout << " <MEMC " << name() << ".IXR_CMD_CLEANUP_DATA> Send a put request to xram" << std::endl; 4082 } 4083 #endif 4084 } 4085 break; 4086 4261 std::cout << " <MEMC " << name() << ".IXR_CMD_CLEANUP_DATA_SEND> Send a put request to xram" << std::endl; 4262 } 4263 #endif 4264 } 4265 break; 4266 } 4267 4268 ///////////////////////// 4269 case IXR_CMD_CONFIG_SEND: // send a put from CONFIG FSM 4270 { 4271 if(p_vci_ixr.cmdack.read()) 4272 { 4273 if(r_ixr_cmd_word.read() == (m_words - 2)) 4274 { 4275 r_ixr_cmd_fsm = IXR_CMD_CONFIG_IDLE; 4276 r_config_to_ixr_cmd_req = false; 4277 } 4278 else 4279 { 4280 r_ixr_cmd_word = r_ixr_cmd_word.read() + 2; 4281 } 4282 4283 #if DEBUG_MEMC_IXR_CMD 4284 if(m_debug) 4285 std::cout << " <MEMC " << name() << " IXR_CMD_CONFIG_SEND> PUT request:" << std::hex 4286 << " address = " << r_ixr_cmd_address.read() + (r_ixr_cmd_word.read()<<2) << std::endl; 4287 #endif 4288 } 4289 break; 4290 } 4087 4291 } // end switch r_ixr_cmd_fsm 4088 4292 … … 4091 4295 //////////////////////////////////////////////////////////////////////////// 4092 4296 // The IXR_RSP FSM receives the response packets from the XRAM, 4093 // for both put transaction, and gettransaction.4297 // for both PUT transaction, and GET transaction. 4094 4298 // 4095 // - A response to a putrequest is a single-cell VCI packet.4096 // The T ransaction Tabindex is contained in the RTRDID field.4299 // - A response to a PUT request is a single-cell VCI packet. 4300 // The TRT index is contained in the RTRDID field. 4097 4301 // The FSM takes the lock protecting the TRT, and the corresponding 4098 // entry is erased. 4302 // entry is erased. If an acknowledge was required (in case of software SYNC) 4303 // the r_config_rsp_lines counter is decremented. 4099 4304 // 4100 // - A response to a getrequest is a multi-cell VCI packet.4101 // The T ransaction Tabindex is contained in the RTRDID field.4305 // - A response to a GET request is a multi-cell VCI packet. 4306 // The TRT index is contained in the RTRDID field. 4102 4307 // The N cells contain the N words of the cache line in the RDATA field. 4103 4308 // The FSM takes the lock protecting the TRT to store the line in the TRT 4104 4309 // (taking into account the write requests already stored in the TRT). 4105 // When the line is completely written, the corresponding rok signal is set. 4310 // When the line is completely written, the r_ixr_rsp_to_xram_rsp_rok[index] 4311 // signal is set to inform the XRAM_RSP FSM. 4106 4312 /////////////////////////////////////////////////////////////////////////////// 4107 4313 … … 4111 4317 case IXR_RSP_IDLE: // test transaction type: PUT/GET 4112 4318 { 4113 if(p_vci_ixr.rspval.read()) 4114 { 4115 r_ixr_rsp_cpt = 0; 4116 r_ixr_rsp_trt_index = p_vci_ixr.rtrdid.read(); 4117 if(p_vci_ixr.reop.read() and !(p_vci_ixr.rerror.read() &0x1)) // PUT transaction 4118 { 4119 r_ixr_rsp_fsm = IXR_RSP_ACK; 4120 4121 #if DEBUG_MEMC_IXR_RSP 4122 if(m_debug) 4123 std::cout << " <MEMC " << name() 4124 << " IXR_RSP_IDLE> Response from XRAM to a put transaction" << std::endl; 4125 #endif 4126 } 4127 else // GET transaction 4128 { 4129 r_ixr_rsp_fsm = IXR_RSP_TRT_READ; 4319 if(p_vci_ixr.rspval.read()) 4320 { 4321 r_ixr_rsp_cpt = 0; 4322 r_ixr_rsp_trt_index = p_vci_ixr.rtrdid.read(); 4323 4324 assert( ((p_vci_ixr.rerror.read() & 0x1) == 0) and 4325 "MEMC ERROR in IXR_RSP state: XRAM response error !"); 4326 4327 if(p_vci_ixr.reop.read()) // PUT 4328 { 4329 r_ixr_rsp_fsm = IXR_RSP_TRT_ERASE; 4330 } 4331 4332 else // GET transaction 4333 { 4334 r_ixr_rsp_fsm = IXR_RSP_TRT_READ; 4130 4335 4131 4336 #if DEBUG_MEMC_IXR_RSP … … 4134 4339 << " IXR_RSP_IDLE> Response from XRAM to a get transaction" << std::endl; 4135 4340 #endif 4136 } 4137 } 4138 break; 4139 } 4140 ///////////////// 4141 case IXR_RSP_ACK: // Aknowledge the VCI response for a PUT 4142 { 4143 if(p_vci_ixr.rspval.read()) r_ixr_rsp_fsm = IXR_RSP_TRT_ERASE; 4144 4145 #if DEBUG_MEMC_IXR_RSP 4146 if(m_debug) 4147 std::cout << " <MEMC " << name() << " IXR_RSP_ACK>" << std::endl; 4148 #endif 4341 } 4342 } 4149 4343 break; 4150 4344 } 4151 4345 //////////////////////// 4346 case IXR_RSP_ACK: // Acknowledge PUT transaction 4347 { 4348 r_ixr_rsp_fsm = IXR_RSP_IDLE; 4349 break; 4350 } 4351 4352 //////////////////////// 4152 4353 case IXR_RSP_TRT_ERASE: // erase the entry in the TRT 4153 { 4154 if(r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_RSP) 4155 { 4156 m_trt.erase(r_ixr_rsp_trt_index.read()); 4157 r_ixr_rsp_fsm = IXR_RSP_IDLE; 4158 4354 // decrease the line counter if config request 4355 { 4356 if(r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_RSP) 4357 { 4358 size_t index = r_ixr_rsp_trt_index.read(); 4359 if (m_trt.is_config(index) ) r_config_rsp_lines = r_config_rsp_lines.read() - 1; 4360 m_trt.erase(index); 4361 r_ixr_rsp_fsm = IXR_RSP_IDLE; 4362 4363 // std::cout << "remove a valid slot in trt index = " << r_ixr_rsp_trt_index.read()<< std::endl; 4159 4364 #if DEBUG_MEMC_IXR_RSP 4160 4365 if(m_debug) … … 4162 4367 << r_ixr_rsp_trt_index.read() << std::endl; 4163 4368 #endif 4164 m_cpt_ixr_fsm_n_trt_lock++; 4165 } 4166 4167 m_cpt_ixr_fsm_trt_lock++; 4168 4169 break; 4369 } 4370 break; 4170 4371 } 4171 4372 ////////////////////// 4172 4373 case IXR_RSP_TRT_READ: // write a 64 bits data in the TRT 4173 4374 { 4174 if((r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_RSP) and p_vci_ixr.rspval)4175 {4176 size_t index = r_ixr_rsp_trt_index.read();4177 bool eop = p_vci_ixr.reop.read();4178 wide_data_t data = p_vci_ixr.rdata.read();4179 bool error = ((p_vci_ixr.rerror.read() & 0x1) == 1);4180 4181 assert(((eop == (r_ixr_rsp_cpt.read() == (m_words-2))) or p_vci_ixr.rerror.read()) 4182 and "Error in VCI_MEM_CACHE : invalid length for a response from XRAM");4183 4184 m_trt.write_rsp( index,4185 r_ixr_rsp_cpt.read(),4186 data,4187 error);4188 4189 r_ixr_rsp_cpt = r_ixr_rsp_cpt.read()+ 2;4190 4191 if(eop)4192 {4193 r_ixr_rsp_to_xram_rsp_rok[r_ixr_rsp_trt_index.read()]=true;4194 r_ixr_rsp_fsm = IXR_RSP_IDLE;4195 }4375 if((r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_RSP) and p_vci_ixr.rspval) 4376 { 4377 size_t index = r_ixr_rsp_trt_index.read(); 4378 size_t word = r_ixr_rsp_cpt.read(); 4379 bool eop = p_vci_ixr.reop.read(); 4380 wide_data_t data = p_vci_ixr.rdata.read(); 4381 bool error = ((p_vci_ixr.rerror.read() & 0x1) == 1); 4382 4383 assert(((eop == (word == (m_words-2))) or error) and 4384 "MEMC ERROR in IXR_RSP_TRT_READ state : invalid response from XRAM"); 4385 4386 m_trt.write_rsp( index, 4387 word, 4388 data ); 4389 4390 r_ixr_rsp_cpt = word + 2; 4391 4392 if(eop) 4393 { 4394 r_ixr_rsp_to_xram_rsp_rok[r_ixr_rsp_trt_index.read()]=true; 4395 r_ixr_rsp_fsm = IXR_RSP_IDLE; 4396 } 4196 4397 4197 4398 #if DEBUG_MEMC_IXR_RSP … … 4199 4400 std::cout << " <MEMC " << name() << " IXR_RSP_TRT_READ> Writing a word in TRT : " 4200 4401 << " index = " << std::dec << index 4201 << " / word = " << r_ixr_rsp_cpt.read()4402 << " / word = " << word 4202 4403 << " / data = " << std::hex << data << std::endl; 4203 4404 #endif … … 4212 4413 // XRAM_RSP FSM 4213 4414 //////////////////////////////////////////////////////////////////////////// 4214 // The XRAM_RSP FSM handles the incoming cache lines from the XRAM.4415 // The XRAM_RSP FSM handles the incoming cache lines after an XRAM GET. 4215 4416 // The cache line has been written in the TRT by the IXR_CMD_FSM. 4216 4417 // As the IXR_RSP FSM and the XRAM_RSP FSM are running in parallel, 4217 // there is as many flip-flops r_ixr_rsp_to_xram_rsp_rok[i] 4218 // as the number of entries in the TRT, that are handled with 4219 // a round-robin priority... 4418 // there is as many flip-flops r_ixr_rsp_to_xram_rsp_rok[i] as the number 4419 // of entries in the TRT, that are handled with a round-robin priority... 4220 4420 // 4221 // When a response is available, the corresponding TRT entry 4222 // is copied in a local buffer to be written in the cache. 4223 // The FSM takes the lock protecting the TRT, and the lock protecting the DIR. 4224 // It selects a cache slot and writes the line in the cache. 4421 // The FSM takes the lock protecting TRT, and the lock protecting DIR. 4422 // The selected TRT entry is copied in the local buffer r_xram_rsp_trt_buf. 4423 // It selects a cache slot and save the victim line in another local buffer 4424 // r_xram_rsp_victim_***. 4425 // It writes the line extracted from TRT in the cache. 4225 4426 // If it was a read MISS, the XRAM_RSP FSM send a request to the TGT_RSP 4226 4427 // FSM to return the cache line to the registered processor. … … 4237 4438 case XRAM_RSP_IDLE: // scan the XRAM responses / select a TRT index (round robin) 4238 4439 { 4239 size_t ptr= r_xram_rsp_trt_index.read();4240 size_t lines = m_trt_lines;4241 for(size_t i=0 ; i<lines ; i++)4242 {4243 size_t index = (i+ptr+1) %lines;4244 if(r_ixr_rsp_to_xram_rsp_rok[index])4245 {4246 r_xram_rsp_trt_index = index;4247 r_ixr_rsp_to_xram_rsp_rok[index] = false;4248 r_xram_rsp_fsm = XRAM_RSP_DIR_LOCK;4440 size_t old = r_xram_rsp_trt_index.read(); 4441 size_t lines = m_trt_lines; 4442 for(size_t i=0 ; i<lines ; i++) 4443 { 4444 size_t index = (i+old+1) %lines; 4445 if(r_ixr_rsp_to_xram_rsp_rok[index]) 4446 { 4447 r_xram_rsp_trt_index = index; 4448 r_ixr_rsp_to_xram_rsp_rok[index] = false; 4449 r_xram_rsp_fsm = XRAM_RSP_DIR_LOCK; 4249 4450 4250 4451 #if DEBUG_MEMC_XRAM_RSP … … 4254 4455 << " index = " << std::dec << index << std::endl; 4255 4456 #endif 4256 break;4257 }4258 }4457 break; 4458 } 4459 } 4259 4460 break; 4260 4461 } … … 4269 4470 size_t index = r_xram_rsp_trt_index.read(); 4270 4471 r_xram_rsp_trt_buf.copy( m_trt.read(index) ); 4271 4272 4472 r_xram_rsp_fsm = XRAM_RSP_TRT_COPY; 4273 4473 … … 4288 4488 // and copy it in a local buffer 4289 4489 { 4290 if ( (r_alloc_trt_fsm.read() == ALLOC_TRT_XRAM_RSP) and 4291 (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP) ) 4292 { 4490 assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP) and 4491 "MEMC ERROR in XRAM_RSP_TRT_COPY state: Bad DIR allocation"); 4492 4493 assert( (r_alloc_trt_fsm.read() == ALLOC_TRT_XRAM_RSP) and 4494 "MEMC ERROR in XRAM_RSP_TRT_COPY state: Bad TRT allocation"); 4495 4293 4496 // selects & extracts a victim line from cache 4294 4497 size_t way = 0; … … 4319 4522 r_xram_rsp_victim_dirty = victim.dirty or (!victim.cache_coherent && (victim.count == 1)); //a NCC line is by default considered as dirty in the L1: we must take a reservation on a TRT entry 4320 4523 4321 4322 if(!r_xram_rsp_trt_buf.rerror) 4323 { 4324 if (!victim.cache_coherent and r_xram_rsp_to_ixr_cmd_inval_ncc_pending.read()) //there can not be two L2 invalidation on NCC line at the same time 4325 { 4326 r_xram_rsp_fsm = XRAM_RSP_INVAL_WAIT; 4327 } 4328 else 4329 { 4330 r_xram_rsp_fsm = XRAM_RSP_INVAL_LOCK; 4331 } 4332 } 4333 else 4334 { 4335 r_xram_rsp_fsm = XRAM_RSP_ERROR_ERASE; 4336 } 4337 4338 #if DEBUG_MEMC_XRAM_RSP 4524 if( not r_xram_rsp_trt_buf.rerror ) r_xram_rsp_fsm = XRAM_RSP_IVT_LOCK; 4525 else r_xram_rsp_fsm = XRAM_RSP_ERROR_ERASE; 4526 4527 #if DEBUG_MEMC_XRAM_RSP 4339 4528 if(m_debug) 4340 4529 std::cout << " <MEMC " << name() << " XRAM_RSP_TRT_COPY>" 4341 << " Select a slot: "4530 << " Select a victim slot: " 4342 4531 << " way = " << std::dec << way 4343 4532 << " / set = " << set 4344 4533 << " / inval_required = " << inval << std::endl; 4345 4534 #endif 4346 } 4347 else 4348 { 4349 std::cout << "VCI_MEM_CACHE ERROR " << name() << " XRAM_RSP_TRT_COPY" 4350 << " bad TRT or DIR allocation" << std::endl; 4351 exit(0); 4352 } 4353 break; 4354 } 4355 ///////////////////////// 4356 case XRAM_RSP_INVAL_LOCK: // Take the IVT lock to check a possible pending inval 4357 { 4358 if(r_alloc_ivt_fsm == ALLOC_IVT_XRAM_RSP) 4359 { 4360 size_t index = 0; 4361 size_t index_victim = 0; 4362 if(m_ivt.search_inval(r_xram_rsp_trt_buf.nline, index) or 4363 m_ivt.search_inval(r_xram_rsp_victim_nline.read(), index_victim)) 4364 { 4365 r_xram_rsp_fsm = XRAM_RSP_INVAL_WAIT; 4535 break; 4536 } 4537 /////////////////////// 4538 case XRAM_RSP_IVT_LOCK: // Keep DIR and TRT locks and take the IVT lock 4539 // to check a possible pending inval 4540 { 4541 assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP) and 4542 "MEMC ERROR in XRAM_RSP_IVT_LOCK state: Bad DIR allocation"); 4543 4544 assert( (r_alloc_trt_fsm.read() == ALLOC_TRT_XRAM_RSP) and 4545 "MEMC ERROR in XRAM_RSP_IVT_LOCK state: Bad TRT allocation"); 4546 4547 if(r_alloc_ivt_fsm == ALLOC_IVT_XRAM_RSP) 4548 { 4549 size_t index = 0; 4550 if(m_ivt.search_inval(r_xram_rsp_trt_buf.nline, index)) // pending inval 4551 { 4552 r_xram_rsp_fsm = XRAM_RSP_INVAL_WAIT; 4366 4553 4367 4554 #if DEBUG_MEMC_XRAM_RSP 4368 4555 if(m_debug) 4369 std::cout << " <MEMC " << name() << " XRAM_RSP_I NVAL_LOCK>"4556 std::cout << " <MEMC " << name() << " XRAM_RSP_IVT_LOCK>" 4370 4557 << " Get acces to IVT, but line invalidation registered" 4371 << " / nline = " << std::hex << r_xram_rsp_trt_buf.nline4558 << " / address = " << std::hex << r_xram_rsp_trt_buf.nline*m_words*4 4372 4559 << " / index = " << std::dec << index << std::endl; 4373 4560 #endif 4374 4561 4375 } 4376 else if(m_ivt.is_full() and r_xram_rsp_victim_inval.read()) // IVT full 4377 { 4378 r_xram_rsp_fsm = XRAM_RSP_INVAL_WAIT; 4379 m_upt.print(); 4562 } 4563 else if(m_ivt.is_full() and r_xram_rsp_victim_inval.read()) // IVT full 4564 { 4565 r_xram_rsp_fsm = XRAM_RSP_INVAL_WAIT; 4380 4566 4381 4567 #if DEBUG_MEMC_XRAM_RSP 4382 4568 if(m_debug) 4383 std::cout << " <MEMC " << name() << " XRAM_RSP_I NVAL_LOCK>"4569 std::cout << " <MEMC " << name() << " XRAM_RSP_IVT_LOCK>" 4384 4570 << " Get acces to IVT, but inval required and IVT full" << std::endl; 4385 4571 #endif 4386 }4387 else4388 {4389 r_xram_rsp_fsm = XRAM_RSP_DIR_UPDT;4572 } 4573 else 4574 { 4575 r_xram_rsp_fsm = XRAM_RSP_DIR_UPDT; 4390 4576 4391 4577 #if DEBUG_MEMC_XRAM_RSP 4392 4578 if(m_debug) 4393 std::cout << " <MEMC " << name() << " XRAM_RSP_INVAL_LOCK>" 4394 << " Get acces to IVT" << std::endl; 4395 #endif 4396 } 4397 m_cpt_xram_rsp_fsm_n_upt_lock++; 4398 } 4399 4400 m_cpt_xram_rsp_fsm_upt_lock++; 4401 4402 break; 4579 std::cout << " <MEMC " << name() << " XRAM_RSP_IVT_LOCK>" 4580 << " Get acces to IVT / no pending inval request" << std::endl; 4581 #endif 4582 } 4583 } 4584 break; 4403 4585 } 4404 4586 ///////////////////////// … … 4415 4597 } 4416 4598 /////////////////////// 4417 case XRAM_RSP_DIR_UPDT: // updates the cache (both data & directory) 4418 // and possibly set an inval request in IVT 4419 { 4420 // check if this is an instruction read, this means pktid is either 4421 // TYPE_READ_INS_UNC 0bX010 with TSAR encoding 4422 // TYPE_READ_INS_MISS 0bX011 with TSAR encoding 4423 bool inst_read = (r_xram_rsp_trt_buf.pktid & 0x2) and r_xram_rsp_trt_buf.proc_read; 4424 4425 // check if this is a cached read, this means pktid is either 4426 // TYPE_READ_DATA_MISS 0bX001 with TSAR encoding 4427 // TYPE_READ_INS_MISS 0bX011 with TSAR encoding 4428 bool cached_read = (r_xram_rsp_trt_buf.pktid & 0x1) and r_xram_rsp_trt_buf.proc_read; 4429 4430 bool dirty = false; 4431 4432 // update cache data 4433 size_t set = r_xram_rsp_victim_set.read(); 4434 size_t way = r_xram_rsp_victim_way.read(); 4435 for(size_t word=0; word<m_words ; word++) 4436 { 4437 m_cache_data.write(way, set, word, r_xram_rsp_trt_buf.wdata[word]); 4438 4439 dirty = dirty or (r_xram_rsp_trt_buf.wdata_be[word] != 0); 4440 4441 if(m_monitor_ok) 4442 { 4443 addr_t address = r_xram_rsp_trt_buf.nline<<6 | word<<2; 4444 check_monitor( address, r_xram_rsp_trt_buf.wdata[word], false); 4445 } 4446 } 4599 case XRAM_RSP_DIR_UPDT: // updates the cache (both data & directory), 4600 // erases the TRT entry if victim not dirty, 4601 // and set inval request in IVT if required 4602 { 4603 assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP) and 4604 "MEMC ERROR in XRAM_RSP_DIR_UPDT state: Bad DIR allocation"); 4605 4606 assert( (r_alloc_trt_fsm.read() == ALLOC_TRT_XRAM_RSP) and 4607 "MEMC ERROR in XRAM_RSP_DIR_UPDT state: Bad TRT allocation"); 4608 4609 assert( (r_alloc_ivt_fsm.read() == ALLOC_IVT_XRAM_RSP) and 4610 "MEMC ERROR in XRAM_RSP_DIR_UPDT state: Bad IVT allocation"); 4611 4612 // check if this is an instruction read, this means pktid is either 4613 // TYPE_READ_INS_UNC 0bX010 with TSAR encoding 4614 // TYPE_READ_INS_MISS 0bX011 with TSAR encoding 4615 4616 // check if this is a cached read, this means pktid is either 4617 // TYPE_READ_DATA_MISS 0bX001 with TSAR encoding 4618 // TYPE_READ_INS_MISS 0bX011 with TSAR encoding 4619 bool cached_read = (r_xram_rsp_trt_buf.pktid & 0x1) and r_xram_rsp_trt_buf.proc_read; 4620 4621 bool inst_read = (r_xram_rsp_trt_buf.pktid & 0x2) and r_xram_rsp_trt_buf.proc_read; 4622 4623 bool dirty = false; 4624 4625 // update cache data 4626 size_t set = r_xram_rsp_victim_set.read(); 4627 size_t way = r_xram_rsp_victim_way.read(); 4628 for(size_t word=0; word<m_words ; word++) 4629 { 4630 m_cache_data.write(way, set, word, r_xram_rsp_trt_buf.wdata[word]); 4631 dirty = dirty or (r_xram_rsp_trt_buf.wdata_be[word] != 0); 4632 4633 } 4447 4634 4448 4635 // update cache directory … … 4458 4645 { 4459 4646 entry.owner.srcid = r_xram_rsp_trt_buf.srcid; 4460 #if L1_MULTI_CACHE4461 entry.owner.cache_id= r_xram_rsp_trt_buf.pktid;4462 #endif4463 4647 entry.owner.inst = inst_read; 4464 4648 entry.count = 1; … … 4466 4650 else 4467 4651 { 4468 entry.owner.srcid = r_xram_rsp_trt_buf.srcid; 4469 #if L1_MULTI_CACHE 4470 entry.owner.cache_id = 0; 4471 #endif 4652 entry.owner.srcid = 0; 4472 4653 entry.owner.inst = 0; 4473 4654 entry.count = 0; … … 4495 4676 4496 4677 r_xram_rsp_ivt_index = index; 4497 if(!wok) 4498 { 4499 std::cout << "VCI_MEM_CACHE ERROR " << name() << " XRAM_RSP_DIR_UPDT" 4500 << " invalidate_tab entry free but write unsuccessful" << std::endl; 4501 exit(0); 4502 } 4678 assert( wok and 4679 "MEMC ERROR in XRAM_RSP_DIR_UPDT state: IVT should not be full"); 4680 4503 4681 } 4504 4682 if (!r_xram_rsp_victim_coherent.read()) 4505 4683 { 4506 4684 //m_llsc_table.sw(r_xram_rsp_victim_nline.read()*m_words*4); 4507 m_llsc_table.sw(r_xram_rsp_victim_nline.read() );4685 m_llsc_table.sw(r_xram_rsp_victim_nline.read(), 0, m_words - 1); 4508 4686 } 4509 4687 #if DEBUG_MEMC_XRAM_RSP … … 4539 4717 case XRAM_RSP_TRT_DIRTY: // set the TRT entry (write to XRAM) if the victim is dirty or not coherent (RWT) 4540 4718 { 4541 if(r_alloc_trt_fsm.read() == ALLOC_TRT_XRAM_RSP) 4542 { 4543 4544 m_trt.set(r_xram_rsp_trt_index.read(), 4545 false, // write to XRAM 4546 r_xram_rsp_victim_nline.read(), // line index 4547 0, 4548 0, 4549 0, 4550 false, 4551 0, 4552 0, 4553 std::vector<be_t> (m_words,0), 4554 std::vector<data_t> (m_words,0)); 4555 4556 #if DEBUG_MEMC_XRAM_RSP 4557 if(m_debug) 4719 if(r_alloc_trt_fsm.read() == ALLOC_TRT_XRAM_RSP) 4720 { 4721 std::vector<data_t> data_vector; 4722 data_vector.clear(); 4723 for(size_t i=0; i<m_words; i++) 4724 { 4725 data_vector.push_back(r_xram_rsp_victim_data[i].read()); 4726 } 4727 m_trt.set( r_xram_rsp_trt_index.read(), 4728 false, // PUT 4729 r_xram_rsp_victim_nline.read(), // line index 4730 0, // unused 4731 0, // unused 4732 0, // unused 4733 false, // not proc_read 4734 0, // unused 4735 0, // unused 4736 std::vector<be_t>(m_words,0xF), 4737 data_vector); 4738 #if DEBUG_MEMC_XRAM_RSP 4739 if(m_debug) 4740 m_trt.print(0); 4558 4741 std::cout << " <MEMC " << name() << " XRAM_RSP_TRT_DIRTY>" 4559 4742 << " Set TRT entry for the put transaction" 4560 4743 << " / dirty victim line = " << r_xram_rsp_victim_nline.read() << std::endl; 4561 4744 #endif 4745 4746 if( not r_xram_rsp_victim_coherent ) 4747 std::cout << "a victim coherent not sent trt index =" << r_xram_rsp_trt_index.read() << std::endl; 4562 4748 if(r_xram_rsp_trt_buf.proc_read) r_xram_rsp_fsm = XRAM_RSP_DIR_RSP; 4563 4749 else if(r_xram_rsp_victim_inval.read()) r_xram_rsp_fsm = XRAM_RSP_INVAL; … … 4573 4759 case XRAM_RSP_DIR_RSP: // Request a response to TGT_RSP FSM 4574 4760 { 4575 if( !r_xram_rsp_to_tgt_rsp_req.read())4761 if( not r_xram_rsp_to_tgt_rsp_req.read()) 4576 4762 { 4577 4763 r_xram_rsp_to_tgt_rsp_srcid = r_xram_rsp_trt_buf.srcid; … … 4627 4813 xram_rsp_to_cc_send_fifo_srcid = r_xram_rsp_victim_copy.read(); 4628 4814 xram_rsp_to_cc_send_fifo_inst = r_xram_rsp_victim_copy_inst.read(); 4629 #if L1_MULTI_CACHE4630 xram_rsp_to_cc_send_fifo_cache_id = r_xram_rsp_victim_copy_cache.read();4631 #endif4632 4815 xram_rsp_to_cc_send_fifo_put = multi_req; 4633 r_xram_rsp_next_ptr 4634 4635 if(r_xram_rsp_victim_dirty ) r_xram_rsp_fsm = XRAM_RSP_WRITE_DIRTY;4816 r_xram_rsp_next_ptr = r_xram_rsp_victim_ptr.read(); 4817 4818 if(r_xram_rsp_victim_dirty and r_xram_rsp_victim_coherent) r_xram_rsp_fsm = XRAM_RSP_WRITE_DIRTY; 4636 4819 else if(not_last_multi_req) r_xram_rsp_fsm = XRAM_RSP_HEAP_REQ; 4637 4820 else r_xram_rsp_fsm = XRAM_RSP_IDLE; 4638 4821 4822 // std::cout << "cleanup sent for trt index =" << r_xram_rsp_trt_index.read() << std::endl; 4639 4823 #if DEBUG_MEMC_XRAM_RSP 4640 4824 if(m_debug) 4641 4825 std::cout << " <MEMC " << name() << " XRAM_RSP_INVAL>" 4642 4826 << " Send an inval request to CC_SEND FSM" 4643 << " / victim line = " << r_xram_rsp_victim_nline.read()<< std::endl;4827 << " / address = " << r_xram_rsp_victim_nline.read()*m_words*4 << std::endl; 4644 4828 #endif 4645 4829 } … … 4649 4833 case XRAM_RSP_WRITE_DIRTY: // send a write request to IXR_CMD FSM 4650 4834 { 4651 if(!r_xram_rsp_to_ixr_cmd_req.read() and !r_xram_rsp_to_ixr_cmd_inval_ncc_pending.read()) 4652 { 4653 r_xram_rsp_to_ixr_cmd_req = true; 4654 r_xram_rsp_to_ixr_cmd_nline = r_xram_rsp_victim_nline.read(); 4655 r_xram_rsp_to_ixr_cmd_trdid = r_xram_rsp_trt_index.read(); 4656 for(size_t i=0; i<m_words ; i++) 4657 { 4658 r_xram_rsp_to_ixr_cmd_data[i] = r_xram_rsp_victim_data[i]; 4659 std::cout << "data L2 = " << std::hex << r_xram_rsp_victim_data[i] << std::dec << std::endl; 4660 } 4661 m_cpt_write_dirty++; 4835 if ( not r_xram_rsp_to_ixr_cmd_req.read() ) 4836 { 4837 r_xram_rsp_to_ixr_cmd_req = true; 4838 r_xram_rsp_to_ixr_cmd_index = r_xram_rsp_trt_index.read(); 4839 4840 m_cpt_write_dirty++; 4662 4841 4663 if ((!r_xram_rsp_victim_coherent.read()) and (r_xram_rsp_victim_count.read() == 1)) //if NCC, we save the data in case of not dirty L1 4664 { 4665 r_xram_rsp_to_ixr_cmd_req = false; 4666 r_xram_rsp_to_ixr_cmd_inval_ncc_pending = true; 4667 r_xram_rsp_fsm = XRAM_RSP_IDLE; 4668 break; 4669 } 4670 4671 bool multi_req = !r_xram_rsp_victim_is_cnt.read() and r_xram_rsp_victim_inval.read(); 4672 bool not_last_multi_req = multi_req and (r_xram_rsp_victim_count.read() != 1); 4673 4674 if(not_last_multi_req) r_xram_rsp_fsm = XRAM_RSP_HEAP_REQ; 4675 else r_xram_rsp_fsm = XRAM_RSP_IDLE; 4842 bool multi_req = not r_xram_rsp_victim_is_cnt.read() and 4843 r_xram_rsp_victim_inval.read(); 4844 bool not_last_multi_req = multi_req and (r_xram_rsp_victim_count.read() != 1); 4845 4846 if(not_last_multi_req) r_xram_rsp_fsm = XRAM_RSP_HEAP_REQ; 4847 else r_xram_rsp_fsm = XRAM_RSP_IDLE; 4676 4848 4677 4849 #if DEBUG_MEMC_XRAM_RSP … … 4681 4853 << " / victim line = " << r_xram_rsp_victim_nline.read() << std::endl; 4682 4854 #endif 4683 }4684 break;4855 } 4856 break; 4685 4857 } 4686 4858 ///////////////////////// … … 4711 4883 4712 4884 xram_rsp_to_cc_send_fifo_srcid = entry.owner.srcid; 4713 #if L1_MULTI_CACHE4714 xram_rsp_to_cc_send_fifo_cache_id = entry.owner.cache_id;4715 #endif4716 4885 xram_rsp_to_cc_send_fifo_inst = entry.owner.inst; 4717 4886 xram_rsp_to_cc_send_fifo_put = true; … … 4757 4926 HeapEntry last_entry; 4758 4927 last_entry.owner.srcid = 0; 4759 #if L1_MULTI_CACHE4760 last_entry.owner.cache_id = 0;4761 #endif4762 4928 last_entry.owner.inst = false; 4763 4929 if(m_heap.is_full()) … … 4783 4949 break; 4784 4950 } 4785 // 4951 ///////////////////////// 4786 4952 case XRAM_RSP_ERROR_ERASE: // erase TRT entry in case of error 4787 4953 { … … 4873 5039 r_cleanup_contains_data = false; 4874 5040 4875 if(srcid >= m_initiators) 4876 { 4877 std::cout 4878 << "VCI_MEM_CACHE ERROR " << name() 4879 << " CLEANUP_IDLE state" << std::endl 4880 << "illegal srcid for cleanup request" << std::endl; 4881 4882 exit(0); 4883 } 5041 assert( (srcid < m_initiators) and 5042 "MEMC ERROR in CLEANUP_IDLE state : illegal SRCID value"); 4884 5043 4885 5044 m_cpt_cleanup++; … … 5026 5185 r_cleanup_copy = entry.owner.srcid; 5027 5186 r_cleanup_copy_inst = entry.owner.inst; 5028 #if L1_MULTI_CACHE5029 r_cleanup_copy_cache = entry.owner.cache_id;5030 #endif5031 5187 5032 5188 //RWT … … 5034 5190 m_cache_data.read_line(way, set, r_cleanup_old_data); 5035 5191 r_cleanup_coherent = entry.cache_coherent; 5036 5037 5038 5192 5039 5193 if(entry.valid) // hit : the copy must be cleared … … 5101 5255 bool match_srcid = (r_cleanup_copy.read() == r_cleanup_srcid.read()); 5102 5256 5103 #if L1_MULTI_CACHE5104 match_srcid &= (r_cleanup_copy_cache.read() == r_cleanup_pktid.read());5105 #endif5106 5107 5257 bool match_inst = (r_cleanup_copy_inst.read() == r_cleanup_inst.read()); 5108 5258 bool match = match_srcid and match_inst; … … 5149 5299 entry.owner.srcid = r_read_to_cleanup_srcid.read(); 5150 5300 entry.owner.inst = 0; 5151 #if L1_MULTI_CACHE5152 entry.owner.cache_id = r_cleanup_copy_cache.read();5153 #endif5154 5301 } 5155 5302 else … … 5158 5305 entry.owner.srcid = r_cleanup_copy.read(); 5159 5306 entry.owner.inst = r_cleanup_copy_inst.read(); 5160 #if L1_MULTI_CACHE5161 entry.owner.cache_id = r_cleanup_copy_cache.read();5162 #endif5163 5307 } 5164 5308 if (r_read_to_cleanup_is_ll.read()) … … 5172 5316 entry.owner.srcid = 0; 5173 5317 entry.owner.inst = 0; 5174 #if L1_MULTI_CACHE 5175 entry.owner.cache_id = 0; 5176 #endif 5177 } 5178 5318 } 5179 5319 5180 5320 if (r_cleanup_contains_data.read()) … … 5184 5324 m_cache_data.write(way, set, word, r_cleanup_data[word].read(), 0xF); 5185 5325 } 5186 m_llsc_table.sw(r_cleanup_nline.read() );5326 m_llsc_table.sw(r_cleanup_nline.read(), 0 , m_words - 1); 5187 5327 //m_llsc_table.sw(r_cleanup_nline.read()*m_words*4); 5188 5328 } 5189 5329 5190 5191 5330 m_cache_directory.write(set, way, entry); 5192 5193 5331 5194 5332 /*RWT*/ … … 5346 5484 // 1. the matching copy is directly in the directory 5347 5485 // 2. the matching copy is the first copy in the heap 5348 if(r_alloc_heap_fsm.read() != ALLOC_HEAP_CLEANUP) 5349 { 5350 std::cout 5351 << "VCI_MEM_CACHE ERROR " << name() 5352 << " CLEANUP_HEAP_LOCK state" 5353 << " bad HEAP allocation" << std::endl; 5354 5355 exit(0); 5356 } 5486 assert( (r_alloc_heap_fsm.read() == ALLOC_HEAP_CLEANUP) and 5487 "MEMC ERROR in CLEANUP_HEAP_LOCK state: bad HEAP allocation"); 5357 5488 5358 5489 size_t way = r_cleanup_way.read(); … … 5376 5507 r_cleanup_prev_inst = heap_entry.owner.inst; 5377 5508 5378 #if L1_MULTI_CACHE 5379 match_dir = match_dir and(r_cleanup_copy_cache.read() == r_cleanup_pktid.read()); 5380 match_heap = match_heap and(heap_entry.owner.cache_id == r_cleanup_pktid.read()); 5381 r_cleanup_prev_cache_id = heap_entry.owner.cache_id; 5382 #endif 5383 5384 if(not match_dir and not match_heap and last) 5385 { 5386 std::cout 5387 << "VCI_MEM_CACHE ERROR " << name() 5388 << " CLEANUP_HEAP_LOCK state" 5389 << " hit but copy not found" 5390 << std::endl; 5391 /**/ 5392 std::cout 5393 << "r_cleanup_srcid = " << r_cleanup_srcid.read() 5394 << " / r_cleanup_inst = " << r_cleanup_inst.read() << std::endl 5395 << "r_cleanup_copy = " << r_cleanup_copy.read() 5396 << " / r_cleanup_copy_inst = " << r_cleanup_copy_inst.read() << std::endl 5397 << "heap_entry.owner.srcid = " << heap_entry.owner.srcid 5398 << " / heap_entry.owner.inst = " << heap_entry.owner.inst << std::endl 5399 /**/ 5400 << "nline = " << r_cleanup_nline << std::endl; 5401 exit(0); 5402 } 5403 5404 if(match_dir and match_heap) 5405 { 5406 std::cout 5407 << "VCI_MEM_CACHE ERROR " << name() 5408 << " CLEANUP_HEAP_LOCK state" 5409 << " two copies matching the cleanup owner id" 5410 << std::endl; 5411 /**/ 5412 std::cout 5413 << "r_cleanup_srcid = " << r_cleanup_srcid.read() 5414 << " / r_cleanup_inst = " << r_cleanup_inst.read() << std::endl 5415 << "r_cleanup_copy = " << r_cleanup_copy.read() 5416 << " / r_cleanup_copy_inst = " << r_cleanup_copy_inst.read() << std::endl 5417 << "heap_entry.owner.srcid = " << heap_entry.owner.srcid 5418 << " / heap_entry.owner.inst = " << heap_entry.owner.inst << std::endl 5419 /**/ 5420 << "nline = " << r_cleanup_nline << std::endl; 5421 exit(0); 5422 } 5509 assert( (not last or match_dir or match_heap) and 5510 "MEMC ERROR in CLEANUP_HEAP_LOCK state: hit but no copy found"); 5511 5512 assert( (not match_dir or not match_heap) and 5513 "MEMC ERROR in CLEANUP_HEAP_LOCK state: two matching copies found"); 5423 5514 5424 5515 DirectoryEntry dir_entry; … … 5439 5530 dir_entry.owner.srcid = heap_entry.owner.srcid; 5440 5531 dir_entry.owner.inst = heap_entry.owner.inst; 5441 5442 #if L1_MULTI_CACHE5443 dir_entry.owner.cache_id = heap_entry.owner.cache_id;5444 #endif5445 5446 5532 r_cleanup_next_ptr = r_cleanup_ptr.read(); 5447 5533 r_cleanup_fsm = CLEANUP_HEAP_FREE; … … 5456 5542 dir_entry.owner.srcid = r_cleanup_copy.read(); 5457 5543 dir_entry.owner.inst = r_cleanup_copy_inst.read(); 5458 5459 #if L1_MULTI_CACHE5460 dir_entry.owner.cache_id = r_cleanup_copy_cache.read();5461 #endif5462 5463 5544 r_cleanup_next_ptr = r_cleanup_ptr.read(); 5464 5545 r_cleanup_fsm = CLEANUP_HEAP_FREE; … … 5472 5553 dir_entry.owner.srcid = r_cleanup_copy.read(); 5473 5554 dir_entry.owner.inst = r_cleanup_copy_inst.read(); 5474 5475 #if L1_MULTI_CACHE5476 dir_entry.owner.cache_id = r_cleanup_copy_cache.read();5477 #endif5478 5479 5555 r_cleanup_next_ptr = heap_entry.next; 5480 5556 r_cleanup_fsm = CLEANUP_HEAP_SEARCH; … … 5482 5558 5483 5559 m_cache_directory.write(set,way,dir_entry); 5484 5485 5560 5486 5561 #if DEBUG_MEMC_CLEANUP … … 5508 5583 // This state is handling the case where the copy 5509 5584 // is in the heap, but is not the first in the linked list 5510 if(r_alloc_heap_fsm.read() != ALLOC_HEAP_CLEANUP) 5511 { 5512 std::cout 5513 << "VCI_MEM_CACHE ERROR " << name() 5514 << " CLEANUP_HEAP_SEARCH state" 5515 << " bad HEAP allocation" << std::endl; 5516 5517 exit(0); 5518 } 5585 assert( (r_alloc_heap_fsm.read() == ALLOC_HEAP_CLEANUP) and 5586 "MEMC ERROR in CLEANUP_HEAP_LOCK state: bad HEAP allocation"); 5519 5587 5520 5588 HeapEntry heap_entry = m_heap.read(r_cleanup_next_ptr.read()); … … 5525 5593 bool match_heap = match_heap_srcid and match_heap_inst; 5526 5594 5527 #if L1_MULTI_CACHE 5528 match_heap = match_heap and(heap_entry.owner.cache_id == r_cleanup_pktid.read()); 5529 #endif 5530 5531 if(not match_heap and last) 5532 { 5533 std::cout 5534 << "VCI_MEM_CACHE_ERROR " << name() 5535 << " CLEANUP_HEAP_SEARCH state" 5536 << " cleanup on valid line but copy not found" 5537 << std::endl; 5538 5539 exit(0); 5540 } 5541 5542 // the matching copy must be removed 5595 assert( (not last or match_heap) and 5596 "MEMC ERROR in CLEANUP_HEAP_SEARCH state: no copy found"); 5597 5598 // the matching copy must be removed 5543 5599 if(match_heap) 5544 5600 { … … 5554 5610 r_cleanup_prev_inst = heap_entry.owner.inst; 5555 5611 r_cleanup_next_ptr = heap_entry.next; 5556 5557 5612 r_cleanup_fsm = CLEANUP_HEAP_SEARCH; 5558 5559 #if L1_MULTI_CACHE5560 r_cleanup_prev_cache_id = heap_entry.owner.cache_id;5561 #endif5562 5613 } 5563 5614 … … 5595 5646 case CLEANUP_HEAP_CLEAN: // remove a copy in the linked list 5596 5647 { 5597 if(r_alloc_heap_fsm.read() != ALLOC_HEAP_CLEANUP) 5598 { 5599 std::cout 5600 << "VCI_MEM_CACHE ERROR " << name() 5601 << " CLEANUP_HEAP_CLEAN state" 5602 << "Bad HEAP allocation" << std::endl; 5603 5604 exit(0); 5605 } 5648 assert( (r_alloc_heap_fsm.read() == ALLOC_HEAP_CLEANUP) and 5649 "MEMC ERROR in CLEANUP_HEAP_LOCK state: bad HEAP allocation"); 5606 5650 5607 5651 HeapEntry heap_entry; 5608 5652 heap_entry.owner.srcid = r_cleanup_prev_srcid.read(); 5609 5653 heap_entry.owner.inst = r_cleanup_prev_inst.read(); 5610 5611 #if L1_MULTI_CACHE5612 heap_entry.owner.cache_id = r_cleanup_prev_cache_id.read();5613 #endif5614 5615 5654 bool last = (r_cleanup_next_ptr.read() == r_cleanup_ptr.read()); 5616 5655 … … 5641 5680 // and becomes the head of the list of free entries 5642 5681 { 5643 if(r_alloc_heap_fsm.read() != ALLOC_HEAP_CLEANUP) 5644 { 5645 std::cout 5646 << "VCI_MEM_CACHE ERROR " << name() 5647 << " CLEANUP_HEAP_CLEAN state" << std::endl 5648 << "Bad HEAP allocation" << std::endl; 5649 5650 exit(0); 5651 } 5652 5682 assert( (r_alloc_heap_fsm.read() == ALLOC_HEAP_CLEANUP) and 5683 "MEMC ERROR in CLEANUP_HEAP_LOCK state: bad HEAP allocation"); 5653 5684 HeapEntry heap_entry; 5654 5685 heap_entry.owner.srcid = 0; 5655 5686 heap_entry.owner.inst = false; 5656 5657 #if L1_MULTI_CACHE5658 heap_entry.owner.cache_id = 0;5659 #endif5660 5687 5661 5688 if(m_heap.is_full()) … … 5706 5733 #endif 5707 5734 m_cpt_cleanup_fsm_n_upt_lock++; 5708 break; 5709 } 5710 5711 // pending inval 5712 r_cleanup_write_srcid = m_ivt.srcid(index); 5713 r_cleanup_write_trdid = m_ivt.trdid(index); 5714 r_cleanup_write_pktid = m_ivt.pktid(index); 5715 r_cleanup_need_rsp = m_ivt.need_rsp(index); 5716 r_cleanup_need_ack = m_ivt.need_ack(index); 5717 r_cleanup_index = index; 5718 5719 r_cleanup_fsm = CLEANUP_IVT_DECREMENT; 5720 5735 } 5736 else 5737 { 5738 // pending inval 5739 r_cleanup_write_srcid = m_ivt.srcid(index); 5740 r_cleanup_write_trdid = m_ivt.trdid(index); 5741 r_cleanup_write_pktid = m_ivt.pktid(index); 5742 r_cleanup_need_rsp = m_ivt.need_rsp(index); 5743 r_cleanup_need_ack = m_ivt.need_ack(index); 5744 r_cleanup_index = index; 5745 r_cleanup_fsm = CLEANUP_IVT_DECREMENT; 5721 5746 #if DEBUG_MEMC_CLEANUP 5722 5747 if(m_debug) … … 5727 5752 << " / ivt_entry = " << index << std::endl; 5728 5753 #endif 5754 } 5729 5755 break; 5730 5756 } … … 5732 5758 case CLEANUP_IVT_DECREMENT: // decrement response counter in IVT matching entry 5733 5759 { 5734 if(r_alloc_ivt_fsm.read() != ALLOC_IVT_CLEANUP) 5735 { 5736 std::cout 5737 << "VCI_MEM_CACHE ERROR " << name() 5738 << " CLEANUP_IVT_DECREMENT state" << std::endl 5739 << "Bad IVT allocation" 5740 << std::endl; 5741 5742 exit(0); 5743 } 5760 assert( (r_alloc_ivt_fsm.read() == ALLOC_IVT_CLEANUP) and 5761 "MEMC ERROR in CLEANUP_IVT_DECREMENT state: Bad IVT allocation"); 5744 5762 5745 5763 size_t count = 0; 5746 5764 m_ivt.decrement(r_cleanup_index.read(), count); 5747 5748 5765 5749 5766 if(count == 0) // multi inval transaction completed … … 5775 5792 case CLEANUP_IVT_CLEAR: // Clear IVT entry 5776 5793 { 5777 if(r_alloc_ivt_fsm.read() != ALLOC_IVT_CLEANUP) 5778 { 5779 std::cout 5780 << "VCI_MEM_CACHE ERROR " << name() 5781 << " CLEANUP_IVT_CLEAR state" << std::endl 5782 << "Bad IVT allocation" 5783 << std::endl; 5784 5785 exit(0); 5786 } 5794 assert( (r_alloc_ivt_fsm.read() == ALLOC_IVT_CLEANUP) and 5795 "MEMC ERROR in CLEANUP_IVT_CLEAR state : bad IVT allocation"); 5787 5796 5788 5797 m_ivt.clear(r_cleanup_index.read()); 5789 5798 5799 if ( r_cleanup_need_ack.read() ) 5800 { 5801 assert( (r_config_rsp_lines.read() > 0) and 5802 "MEMC ERROR in CLEANUP_IVT_CLEAR state"); 5803 5804 r_config_rsp_lines = r_config_rsp_lines.read() - 1; 5805 } 5806 5790 5807 if ( r_cleanup_need_rsp.read() ) r_cleanup_fsm = CLEANUP_WRITE_RSP; 5791 else if ( r_cleanup_need_ack.read() ) r_cleanup_fsm = CLEANUP_CONFIG_ACK;5792 5808 else if ( r_cleanup_ncc.read() ) r_cleanup_fsm = CLEANUP_IXR_REQ; 5793 5809 else r_cleanup_fsm = CLEANUP_SEND_CLACK; … … 5799 5815 << " IVT_index = " << r_cleanup_index.read() << std::endl; 5800 5816 #endif 5801 break;5802 }5817 break; 5818 } 5803 5819 /////////////////////// 5804 5820 case CLEANUP_WRITE_RSP: // response to a previous write on the direct network … … 5812 5828 r_cleanup_to_tgt_rsp_trdid = r_cleanup_write_trdid.read(); 5813 5829 r_cleanup_to_tgt_rsp_pktid = r_cleanup_write_pktid.read(); 5814 r_cleanup_to_tgt_rsp_type = true; 5830 r_cleanup_to_tgt_rsp_type = true; 5815 5831 5816 5832 if (r_cleanup_ncc.read()) … … 5833 5849 break; 5834 5850 } 5835 ////////////////////////5836 case CLEANUP_CONFIG_ACK: // signals inval completion to CONFIG FSM5837 // wait if pending request5838 {5839 if ( r_cleanup_to_config_ack.read() ) break;5840 5841 r_cleanup_to_config_ack = true;5842 r_cleanup_fsm = CLEANUP_SEND_CLACK;5843 5844 #if DEBUG_MEMC_CLEANUP5845 if(m_debug)5846 std::cout << " <MEMC " << name() << " CLEANUP_CONFIG_ACK>"5847 << " Acknowledge broacast inval completion" << std::endl;5848 #endif5849 break;5850 }5851 5852 5851 ///////////////////////// 5853 5852 case CLEANUP_IXR_REQ: 5854 5853 { 5855 5856 5854 //Send a request to the ixr to write the data in the XRAM using the prereserved TRT entry 5857 5855 if (r_alloc_trt_fsm.read() == ALLOC_TRT_CLEANUP) 5858 5856 { 5859 if( !r_cleanup_to_ixr_cmd_req.read())5857 if( not r_cleanup_to_ixr_cmd_req.read()) 5860 5858 { 5861 5859 size_t index = 0; … … 5864 5862 assert (hit and "CLEANUP_IXR_REQ found no matching entry in TRT"); 5865 5863 5866 r_cleanup_to_ixr_cmd_req = true; 5867 5868 for(size_t i = 0; i < m_words; i++){ 5869 r_cleanup_to_ixr_cmd_data[i] = r_cleanup_data[i]; 5864 r_cleanup_to_ixr_cmd_req = true; 5865 5866 if (r_cleanup_contains_data.read()) 5867 { 5868 std::vector<data_t> data_vector; 5869 data_vector.clear(); 5870 5871 for(size_t i=0; i<m_words; i++) 5872 { 5873 data_vector.push_back(r_cleanup_data[i]); 5870 5874 } 5871 5875 5872 r_cleanup_to_ixr_cmd_srcid = r_cleanup_srcid.read(); 5873 r_cleanup_to_ixr_cmd_trdid = index; 5874 r_cleanup_to_ixr_cmd_pktid = r_cleanup_pktid.read(); 5875 r_cleanup_to_ixr_cmd_nline = r_cleanup_nline.read(); 5876 r_cleanup_to_ixr_cmd_ncc_l1_dirty = r_cleanup_contains_data.read(); 5877 r_cleanup_fsm = CLEANUP_SEND_CLACK; 5876 m_trt.set(index, 5877 false, // write to XRAM 5878 r_cleanup_nline.read(), // line index 5879 0, 5880 0, 5881 0, 5882 false, 5883 0, 5884 0, 5885 std::vector<be_t> (m_words,0), 5886 data_vector); 5887 } 5888 //std::cout << "cleanup with a non coherent ligne in trt index = " << index << std::endl; 5889 r_cleanup_to_ixr_cmd_srcid = r_cleanup_srcid.read(); 5890 r_cleanup_to_ixr_cmd_index = index; 5891 r_cleanup_to_ixr_cmd_pktid = r_cleanup_pktid.read(); 5892 r_cleanup_to_ixr_cmd_nline = r_cleanup_nline.read(); 5893 //r_cleanup_to_ixr_cmd_l1_dirty_ncc = r_cleanup_contains_data.read(); 5894 r_cleanup_fsm = CLEANUP_SEND_CLACK; 5878 5895 #if DEBUG_MEMC_CLEANUP 5879 5896 if(m_debug) 5880 5897 { 5898 m_trt.print(0); 5881 5899 std::cout 5882 5900 << " <MEMC " << name() … … 5993 6011 r_cas_wdata = m_cmd_cas_wdata_fifo.read(); 5994 6012 5995 if(r_cas_cpt.read() >3) // more than 4 flits... 5996 { 5997 std::cout << "VCI_MEM_CACHE ERROR in CAS_IDLE state : illegal CAS command" 5998 << std::endl; 5999 exit(0); 6000 } 6001 6002 if(r_cas_cpt.read() ==2) 6013 assert( (r_cas_cpt.read() <= 3) and // no more than 4 flits... 6014 "MEMC ERROR in CAS_IDLE state: illegal CAS command"); 6015 6016 if(r_cas_cpt.read() ==2) 6003 6017 r_cas_wdata = m_cmd_cas_wdata_fifo.read(); 6004 6018 … … 6034 6048 case CAS_DIR_LOCK: // Read the directory 6035 6049 { 6036 if(r_alloc_dir_fsm.read() == ALLOC_DIR_CAS) 6037 { 6050 assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_CAS) and 6051 "MEMC ERROR in CAS_DIR_LOCK: Bad DIR allocation"); 6052 6038 6053 size_t way = 0; 6039 6054 DirectoryEntry entry(m_cache_directory.read(m_cmd_cas_addr_fifo.read(), way)); … … 6045 6060 r_cas_way = way; 6046 6061 r_cas_copy = entry.owner.srcid; 6047 #if L1_MULTI_CACHE6048 r_cas_copy_cache = entry.owner.cache_id;6049 #endif6050 6062 r_cas_copy_inst = entry.owner.inst; 6051 6063 r_cas_ptr = entry.ptr; … … 6065 6077 } 6066 6078 #endif 6067 } 6068 else 6069 { 6070 std::cout 6071 << "VCI_MEM_CACHE ERROR " << name() 6072 << " CAS_DIR_LOCK state" << std::endl 6073 << "Bad DIR allocation" << std::endl; 6074 6075 exit(0); 6076 } 6077 6078 break; 6079 break; 6079 6080 } 6080 6081 ///////////////////// … … 6094 6095 entry.tag = r_cas_tag.read(); 6095 6096 entry.owner.srcid = r_cas_copy.read(); 6096 #if L1_MULTI_CACHE6097 entry.owner.cache_id = r_cas_copy_cache.read();6098 #endif6099 6097 entry.owner.inst = r_cas_copy_inst.read(); 6100 6098 entry.count = r_cas_count.read(); … … 6156 6154 { 6157 6155 // The CAS is a success => sw access to the llsc_global_table 6158 // BUG LLSC6159 addr_t nline = m_nline[(addr_t)(m_cmd_cas_addr_fifo.read())];6160 m_llsc_table.sw(nline);6161 6156 //m_llsc_table.sw(m_cmd_cas_addr_fifo.read()); 6162 6157 /**//*std::cout << "MEMCACHE : from proc " << m_cmd_cas_srcid_fifo.read() 6163 6158 << " | @ " << std::hex << m_cmd_cas_addr_fifo.read() 6164 6159 << " | WRITE (cas triggered)" << std::endl;*/ 6160 m_llsc_table.sw(m_nline[(addr_t)m_cmd_cas_addr_fifo.read()],m_x[(addr_t)(m_cmd_cas_addr_fifo.read())],m_x[(addr_t)(m_cmd_cas_addr_fifo.read())]); 6165 6161 6166 6162 // test coherence request … … 6170 6166 { 6171 6167 r_cas_fsm = CAS_BC_TRT_LOCK; // broadcast invalidate required 6168 #if DEBUG_MEMC_CAS 6169 if(m_debug) 6170 std::cout << " <MEMC " << name() << " CAS_DIR_HIT_WRITE>" 6171 << " Broacast Inval required" 6172 << " / copies = " << r_cas_count.read() << std::endl; 6173 #endif 6174 6172 6175 } 6173 6176 else if(!r_cas_to_cc_send_multi_req.read() and … … 6175 6178 { 6176 6179 r_cas_fsm = CAS_UPT_LOCK; // multi update required 6180 #if DEBUG_MEMC_CAS 6181 if(m_debug) 6182 std::cout << " <MEMC " << name() << " CAS_DIR_HIT_WRITE>" 6183 << " Multi Inval required" 6184 << " / copies = " << r_cas_count.read() << std::endl; 6185 #endif 6177 6186 } 6178 6187 else 6179 6188 { 6180 6189 r_cas_fsm = CAS_WAIT; 6190 #if DEBUG_MEMC_CAS 6191 if(m_debug) 6192 std::cout << " <MEMC " << name() << " CAS_DIR_HIT_WRITE>" 6193 << " CC_SEND FSM busy: release all locks and retry" << std::endl; 6194 #endif 6181 6195 } 6182 6196 } … … 6193 6207 6194 6208 r_cas_fsm = CAS_RSP_SUCCESS; 6195 6196 // monitor6197 if(m_monitor_ok)6198 {6199 addr_t address = m_cmd_cas_addr_fifo.read();6200 check_monitor( address, r_cas_wdata.read(), false);6201 6202 if(r_cas_cpt.read() == 4)6203 check_monitor( address+4, m_cmd_cas_wdata_fifo.read(), false);6204 }6205 6209 6206 6210 #if DEBUG_MEMC_CAS … … 6256 6260 r_cas_fsm = CAS_UPT_HEAP_LOCK; 6257 6261 6258 // monitor6259 if(m_monitor_ok)6260 {6261 addr_t address = m_cmd_cas_addr_fifo.read();6262 check_monitor( address, r_cas_wdata.read(), false);6263 6264 if(r_cas_cpt.read() ==4)6265 check_monitor( address+4, m_cmd_cas_wdata_fifo.read(), false);6266 }6267 6262 } 6268 6263 else // releases the locks protecting UPT and DIR UPT full … … 6350 6345 cas_to_cc_send_fifo_inst = r_cas_copy_inst.read(); 6351 6346 cas_to_cc_send_fifo_srcid = r_cas_copy.read(); 6352 #if L1_MULTI_CACHE6353 cas_to_cc_send_fifo_cache_id= r_cas_copy_cache.read();6354 #endif6355 6347 if(r_cas_count.read() == 1) // one single copy 6356 6348 { … … 6387 6379 HeapEntry entry = m_heap.read(r_cas_ptr.read()); 6388 6380 cas_to_cc_send_fifo_srcid = entry.owner.srcid; 6389 #if L1_MULTI_CACHE6390 cas_to_cc_send_fifo_cache_id = entry.owner.cache_id;6391 #endif6392 6381 cas_to_cc_send_fifo_inst = entry.owner.inst; 6393 6382 cas_to_cc_send_fifo_put = true; … … 6421 6410 case CAS_BC_TRT_LOCK: // check the TRT to register a PUT transaction 6422 6411 { 6423 if(r_alloc_trt_fsm.read() == ALLOC_TRT_CAS) 6424 { 6425 if(!r_cas_to_ixr_cmd_req) // we can transfer the request to IXR_CMD FSM 6426 { 6427 // fill the data buffer 6428 size_t word = m_x[(addr_t)(m_cmd_cas_addr_fifo.read())]; 6429 for(size_t i = 0; i<m_words; i++) 6430 { 6431 if(i == word) 6412 assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_CAS) and 6413 "MEMC ERROR in CAS_BC_TRT_LOCK state: Bas DIR allocation"); 6414 6415 if(r_alloc_trt_fsm.read() == ALLOC_TRT_CAS) 6416 { 6417 size_t wok_index = 0; 6418 bool wok = !m_trt.full(wok_index); 6419 if( wok ) 6432 6420 { 6433 r_cas_to_ixr_cmd_data[i] = r_cas_wdata.read(); 6434 } 6435 else if((i == word+1) and (r_cas_cpt.read() == 4)) // 64 bit CAS 6436 { 6437 r_cas_to_ixr_cmd_data[i] = m_cmd_cas_wdata_fifo.read(); 6421 r_cas_trt_index = wok_index; 6422 r_cas_fsm = CAS_BC_IVT_LOCK; 6438 6423 } 6439 6424 else 6440 6425 { 6441 r_cas_to_ixr_cmd_data[i] = r_cas_data[i].read(); 6426 r_cas_fsm = CAS_WAIT; 6427 m_cpt_cas_fsm_n_trt_lock++; 6442 6428 } 6443 } 6444 size_t wok_index = 0; 6445 bool wok = !m_trt.full(wok_index); 6446 if(wok) 6447 { 6448 r_cas_trt_index = wok_index; 6449 r_cas_fsm = CAS_BC_IVT_LOCK; 6450 } 6451 else 6452 { 6453 r_cas_fsm = CAS_WAIT; 6454 } 6455 } 6456 else 6457 { 6458 r_cas_fsm = CAS_WAIT; 6459 } 6460 m_cpt_cas_fsm_n_trt_lock++; 6461 } 6462 6429 6430 #if DEBUG_MEMC_CAS 6431 if(m_debug) 6432 std::cout << " <MEMC " << name() << " CAS_BC_TRT_LOCK> Check TRT" 6433 << " : wok = " << wok << " / index = " << wok_index << std::endl; 6434 #endif 6435 } 6463 6436 m_cpt_cas_fsm_trt_lock++; 6464 6437 … … 6502 6475 m_cache_data.write(way, set, word+1, m_cmd_cas_wdata_fifo.read()); 6503 6476 6504 // monitor6505 if(m_monitor_ok)6506 {6507 addr_t address = m_cmd_cas_addr_fifo.read();6508 check_monitor( address, r_cas_wdata.read(), false);6509 6510 if(r_cas_cpt.read() ==4)6511 check_monitor( address+4, m_cmd_cas_wdata_fifo.read(), false);6512 }6513 6477 r_cas_upt_index = index; 6514 6478 r_cas_fsm = CAS_BC_DIR_INVAL; … … 6537 6501 case CAS_BC_DIR_INVAL: // Register the PUT transaction in TRT, and inval the DIR entry 6538 6502 { 6539 if((r_alloc_trt_fsm.read() == ALLOC_TRT_CAS) and 6540 (r_alloc_ivt_fsm.read() == ALLOC_IVT_CAS) and 6541 (r_alloc_dir_fsm.read() == ALLOC_DIR_CAS)) 6542 { 6543 // set TRT 6544 m_trt.set(r_cas_trt_index.read(), 6545 false, // PUT request to XRAM 6546 m_nline[(addr_t)(m_cmd_cas_addr_fifo.read())], 6547 0, 6548 0, 6549 0, 6550 false, // not a processor read 6551 0, 6552 0, 6553 std::vector<be_t> (m_words,0), 6554 std::vector<data_t> (m_words,0)); 6503 assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_CAS) and 6504 "MEMC ERROR in CAS_BC_DIR_INVAL state: Bad DIR allocation"); 6505 6506 assert( (r_alloc_trt_fsm.read() == ALLOC_TRT_CAS) and 6507 "MEMC ERROR in CAS_BC_DIR_INVAL state: Bad TRT allocation"); 6508 6509 assert( (r_alloc_ivt_fsm.read() == ALLOC_IVT_CAS) and 6510 "MEMC ERROR in CAS_BC_DIR_INVAL state: Bad IVT allocation"); 6511 6512 std::vector<data_t> data_vector; 6513 data_vector.clear(); 6514 size_t word = m_x[(addr_t)(m_cmd_cas_addr_fifo.read())]; 6515 for(size_t i=0; i<m_words; i++) 6516 { 6517 if(i == word) // first modified word 6518 data_vector.push_back( r_cas_wdata.read() ); 6519 else if((i == word+1) and (r_cas_cpt.read() == 4)) // second modified word 6520 data_vector.push_back( m_cmd_cas_wdata_fifo.read() ); 6521 else // unmodified words 6522 data_vector.push_back( r_cas_data[i].read() ); 6523 } 6524 m_trt.set( r_cas_trt_index.read(), 6525 false, // PUT request 6526 m_nline[(addr_t)(m_cmd_cas_addr_fifo.read())], 6527 0, 6528 0, 6529 0, 6530 false, // not a processor read 6531 0, 6532 0, 6533 std::vector<be_t> (m_words,0), 6534 data_vector ); 6555 6535 6556 6536 // invalidate directory entry … … 6558 6538 entry.valid = false; 6559 6539 entry.dirty = false; 6560 entry.tag = 0;6540 entry.tag = 0; 6561 6541 entry.is_cnt = false; 6562 6542 entry.lock = false; 6563 6543 entry.count = 0; 6564 6544 entry.owner.srcid = 0; 6565 #if L1_MULTI_CACHE6566 entry.owner.cache_id= 0;6567 #endif6568 6545 entry.owner.inst = false; 6569 6546 entry.ptr = 0; … … 6576 6553 #if DEBUG_MEMC_CAS 6577 6554 if(m_debug) 6578 std::cout << " <MEMC " << name() 6579 << " CAS_BC_DIR_INVAL> Register the PUT in TRT and invalidate DIR entry" 6580 << " / nline = " << std::hex << m_nline[(addr_t)(m_cmd_cas_addr_fifo.read())] 6581 << " / set = " << std::dec << set << " / way = " << way << std::endl; 6582 #endif 6583 } 6584 else 6585 { 6586 assert(false and "LOCK ERROR in CAS_FSM, STATE = CAS_BC_DIR_INVAL"); 6587 } 6555 m_trt.print(0); 6556 std::cout << " <MEMC " << name() << " CAS_BC_DIR_INVAL> Inval DIR & register in TRT:" 6557 << " address = " << m_cmd_cas_addr_fifo.read() << std::endl; 6558 #endif 6588 6559 break; 6589 6560 } … … 6591 6562 case CAS_BC_CC_SEND: // Request the broadcast inval to CC_SEND FSM 6592 6563 { 6593 if( !r_cas_to_cc_send_multi_req.read() and6594 !r_cas_to_cc_send_brdcast_req.read())6564 if( not r_cas_to_cc_send_multi_req.read() and 6565 not r_cas_to_cc_send_brdcast_req.read()) 6595 6566 { 6596 6567 r_cas_to_cc_send_multi_req = false; … … 6608 6579 case CAS_BC_XRAM_REQ: // request the IXR FSM to start a put transaction 6609 6580 { 6610 if( !r_cas_to_ixr_cmd_req)6581 if( not r_cas_to_ixr_cmd_req.read() ) 6611 6582 { 6612 6583 r_cas_to_ixr_cmd_req = true; 6613 r_cas_to_ixr_cmd_write = true; 6614 r_cas_to_ixr_cmd_nline = m_nline[(addr_t)(m_cmd_cas_addr_fifo.read())]; 6615 r_cas_to_ixr_cmd_trdid = r_cas_trt_index.read(); 6584 r_cas_to_ixr_cmd_put = true; 6585 r_cas_to_ixr_cmd_index = r_cas_trt_index.read(); 6616 6586 r_cas_fsm = CAS_IDLE; 6617 6587 cmd_cas_fifo_get = true; … … 6622 6592 std::cout << " <MEMC " << name() 6623 6593 << " CAS_BC_XRAM_REQ> Request a PUT transaction to IXR_CMD FSM" << std::hex 6624 << " / nline = " << m_nline[(addr_t) m_cmd_cas_addr_fifo.read()]6594 << " / address = " << (addr_t) m_cmd_cas_addr_fifo.read() 6625 6595 << " / trt_index = " << r_cas_trt_index.read() << std::endl; 6626 6596 #endif 6627 6597 } 6628 else 6629 { 6630 std::cout << "ERROR in MEM_CACHE / CAS_BC_XRAM_REQ state" 6631 << " : request should not have been previously set" << std::endl; 6632 } 6598 6633 6599 break; 6634 6600 } … … 6636 6602 case CAS_RSP_FAIL: // request TGT_RSP FSM to send a failure response 6637 6603 { 6638 if( !r_cas_to_tgt_rsp_req)6639 { 6640 cmd_cas_fifo_get = true;6604 if( not r_cas_to_tgt_rsp_req.read() ) 6605 { 6606 cmd_cas_fifo_get = true; 6641 6607 r_cas_cpt = 0; 6642 r_cas_to_tgt_rsp_req = true;6608 r_cas_to_tgt_rsp_req = true; 6643 6609 r_cas_to_tgt_rsp_data = 1; 6644 6610 r_cas_to_tgt_rsp_srcid = m_cmd_cas_srcid_fifo.read(); … … 6658 6624 case CAS_RSP_SUCCESS: // request TGT_RSP FSM to send a success response 6659 6625 { 6660 if( !r_cas_to_tgt_rsp_req)6626 if( not r_cas_to_tgt_rsp_req.read() ) 6661 6627 { 6662 6628 cmd_cas_fifo_get = true; … … 6687 6653 bool hit_write = m_trt.hit_write( 6688 6654 m_nline[(addr_t) m_cmd_cas_addr_fifo.read()]); 6689 bool wok = !m_trt.full(index);6655 bool wok = not m_trt.full(index); 6690 6656 6691 6657 #if DEBUG_MEMC_CAS … … 6719 6685 case CAS_MISS_TRT_SET: // register the GET transaction in TRT 6720 6686 { 6721 if(r_alloc_trt_fsm.read() == ALLOC_TRT_CAS) 6722 { 6687 assert( (r_alloc_trt_fsm.read() == ALLOC_TRT_CAS) and 6688 "MEMC ERROR in CAS_MISS_TRT_SET state: Bad TRT allocation"); 6689 6723 6690 std::vector<be_t> be_vector; 6724 6691 std::vector<data_t> data_vector; … … 6732 6699 6733 6700 m_trt.set(r_cas_trt_index.read(), 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6701 true, // read request 6702 m_nline[(addr_t) m_cmd_cas_addr_fifo.read()], 6703 m_cmd_cas_srcid_fifo.read(), 6704 m_cmd_cas_trdid_fifo.read(), 6705 m_cmd_cas_pktid_fifo.read(), 6706 false, // write request from processor 6707 0, 6708 0, 6709 be_vector, 6710 data_vector); 6744 6711 r_cas_fsm = CAS_MISS_XRAM_REQ; 6745 6712 … … 6747 6714 if(m_debug) 6748 6715 { 6716 m_trt.print(0); 6749 6717 std::cout << " <MEMC " << name() << " CAS_MISS_TRT_SET> Register a GET transaction in TRT" << std::hex 6750 6718 << " / nline = " << m_nline[(addr_t) m_cmd_cas_addr_fifo.read()] … … 6752 6720 } 6753 6721 #endif 6754 }6755 6722 break; 6756 6723 } … … 6758 6725 case CAS_MISS_XRAM_REQ: // request the IXR_CMD FSM to fetch the missing line 6759 6726 { 6760 if( !r_cas_to_ixr_cmd_req)6727 if( not r_cas_to_ixr_cmd_req.read() ) 6761 6728 { 6762 6729 r_cas_to_ixr_cmd_req = true; 6763 r_cas_to_ixr_cmd_write = false; 6764 r_cas_to_ixr_cmd_trdid = r_cas_trt_index.read(); 6765 r_cas_to_ixr_cmd_nline = m_nline[(addr_t) m_cmd_cas_addr_fifo.read()]; 6730 r_cas_to_ixr_cmd_put = false; 6731 r_cas_to_ixr_cmd_index = r_cas_trt_index.read(); 6766 6732 r_cas_fsm = CAS_WAIT; 6767 6733 6768 6734 #if DEBUG_MEMC_CAS 6769 if(m_debug) 6770 { 6771 std::cout << " <MEMC " << name() << " CAS_MISS_XRAM_REQ> Request a GET transaction to IXR_CMD FSM" << std::hex 6772 << " / nline = " << m_nline[(addr_t) m_cmd_cas_addr_fifo.read()] 6773 << " / trt_index = " << r_cas_trt_index.read() << std::endl; 6774 } 6735 if(m_debug) 6736 std::cout << " <MEMC " << name() << " CAS_MISS_XRAM_REQ> Request a GET transaction" 6737 << " / address = " << std::hex << (addr_t) m_cmd_cas_addr_fifo.read() 6738 << " / trt_index = " << std::dec << r_cas_trt_index.read() << std::endl; 6775 6739 #endif 6776 6740 } … … 7643 7607 r_tgt_rsp_cpt = r_cleanup_to_tgt_rsp_first_word.read(); 7644 7608 } 7645 7646 7609 else if(r_config_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_CONFIG; 7647 7610 else if(r_tgt_cmd_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_TGT_CMD; … … 7780 7743 } 7781 7744 ///////////////////// 7782 case TGT_RSP_TGT_CMD: // send the response for a segmentation violation7745 case TGT_RSP_TGT_CMD: // send the response for a configuration access 7783 7746 { 7784 7747 if ( p_vci_tgt.rspack ) … … 7792 7755 std::cout 7793 7756 << " <MEMC " << name() 7794 << " TGT_RSP_TGT_CMD> Se gmentation violation response"7757 << " TGT_RSP_TGT_CMD> Send response for a configuration access" 7795 7758 << " / rsrcid = " << std::hex << r_tgt_cmd_to_tgt_rsp_srcid.read() 7796 7759 << " / rtrdid = " << r_tgt_cmd_to_tgt_rsp_trdid.read() 7797 7760 << " / rpktid = " << r_tgt_cmd_to_tgt_rsp_pktid.read() 7761 << " / error = " << r_tgt_cmd_to_tgt_rsp_error.read() 7798 7762 << std::endl; 7799 7763 } … … 7916 7880 #endif 7917 7881 7918 7919 7882 uint32_t last_word_idx = r_cleanup_to_tgt_rsp_first_word.read() + r_cleanup_to_tgt_rsp_length.read() - 1; 7920 7883 bool is_ll = ((r_cleanup_to_tgt_rsp_pktid.read() & 0x7) == TYPE_LL); … … 7972 7935 } 7973 7936 } 7974 7975 7937 } 7976 7938 break; … … 8114 8076 else if (r_multi_ack_fsm.read() == MULTI_ACK_UPT_LOCK) 8115 8077 r_alloc_upt_fsm = ALLOC_UPT_MULTI_ACK; 8116 8117 8078 else 8118 8079 m_cpt_upt_unused++; … … 8145 8106 else if (r_cas_fsm.read() == CAS_UPT_LOCK) 8146 8107 r_alloc_upt_fsm = ALLOC_UPT_CAS; 8147 8148 8108 else 8149 8109 m_cpt_upt_unused++; … … 8178 8138 r_alloc_ivt_fsm = ALLOC_IVT_READ; 8179 8139 8180 else if (r_xram_rsp_fsm.read() == XRAM_RSP_I NVAL_LOCK)8140 else if (r_xram_rsp_fsm.read() == XRAM_RSP_IVT_LOCK) 8181 8141 r_alloc_ivt_fsm = ALLOC_IVT_XRAM_RSP; 8182 8142 … … 8188 8148 r_alloc_ivt_fsm = ALLOC_IVT_CAS; 8189 8149 8190 else if (r_config_fsm.read() == CONFIG_ DIR_IVT_LOCK)8150 else if (r_config_fsm.read() == CONFIG_IVT_LOCK) 8191 8151 r_alloc_ivt_fsm = ALLOC_IVT_CONFIG; 8192 8152 … … 8200 8160 if (r_read_fsm.read() != READ_IVT_LOCK) 8201 8161 { 8202 if (r_xram_rsp_fsm.read() == XRAM_RSP_I NVAL_LOCK)8162 if (r_xram_rsp_fsm.read() == XRAM_RSP_IVT_LOCK) 8203 8163 r_alloc_ivt_fsm = ALLOC_IVT_XRAM_RSP; 8204 8164 … … 8210 8170 r_alloc_ivt_fsm = ALLOC_IVT_CAS; 8211 8171 8212 else if (r_config_fsm.read() == CONFIG_ DIR_IVT_LOCK)8172 else if (r_config_fsm.read() == CONFIG_IVT_LOCK) 8213 8173 r_alloc_ivt_fsm = ALLOC_IVT_CONFIG; 8214 8174 … … 8217 8177 (r_write_fsm.read() == WRITE_MISS_IVT_LOCK)) 8218 8178 r_alloc_ivt_fsm = ALLOC_IVT_WRITE; 8219 8220 8179 else 8221 8180 m_cpt_ivt_unused++; … … 8225 8184 ////////////////////////// 8226 8185 case ALLOC_IVT_XRAM_RSP: // allocated to XRAM_RSP FSM 8227 if(r_xram_rsp_fsm.read() != XRAM_RSP_I NVAL_LOCK)8186 if(r_xram_rsp_fsm.read() != XRAM_RSP_IVT_LOCK) 8228 8187 { 8229 8188 if ((r_cleanup_fsm.read() == CLEANUP_IVT_LOCK) or … … 8234 8193 r_alloc_ivt_fsm = ALLOC_IVT_CAS; 8235 8194 8236 else if (r_config_fsm.read() == CONFIG_ DIR_IVT_LOCK)8195 else if (r_config_fsm.read() == CONFIG_IVT_LOCK) 8237 8196 r_alloc_ivt_fsm = ALLOC_IVT_CONFIG; 8238 8197 … … 8259 8218 r_alloc_ivt_fsm = ALLOC_IVT_CAS; 8260 8219 8261 else if (r_config_fsm.read() == CONFIG_ DIR_IVT_LOCK)8220 else if (r_config_fsm.read() == CONFIG_IVT_LOCK) 8262 8221 r_alloc_ivt_fsm = ALLOC_IVT_CONFIG; 8263 8222 … … 8270 8229 r_alloc_ivt_fsm = ALLOC_IVT_READ; 8271 8230 8272 else if (r_xram_rsp_fsm.read() == XRAM_RSP_I NVAL_LOCK)8231 else if (r_xram_rsp_fsm.read() == XRAM_RSP_IVT_LOCK) 8273 8232 r_alloc_ivt_fsm = ALLOC_IVT_XRAM_RSP; 8274 8233 … … 8282 8241 if (r_cas_fsm.read() != CAS_BC_IVT_LOCK) 8283 8242 { 8284 if (r_config_fsm.read() == CONFIG_ DIR_IVT_LOCK)8243 if (r_config_fsm.read() == CONFIG_IVT_LOCK) 8285 8244 r_alloc_ivt_fsm = ALLOC_IVT_CONFIG; 8286 8245 … … 8293 8252 r_alloc_ivt_fsm = ALLOC_IVT_READ; 8294 8253 8295 else if (r_xram_rsp_fsm.read() == XRAM_RSP_I NVAL_LOCK)8254 else if (r_xram_rsp_fsm.read() == XRAM_RSP_IVT_LOCK) 8296 8255 r_alloc_ivt_fsm = ALLOC_IVT_XRAM_RSP; 8297 8256 … … 8307 8266 ////////////////////////// 8308 8267 case ALLOC_IVT_CONFIG: // allocated to CONFIG FSM 8309 if (r_config_fsm.read() != CONFIG_ DIR_IVT_LOCK)8268 if (r_config_fsm.read() != CONFIG_IVT_LOCK) 8310 8269 { 8311 8270 if ((r_write_fsm.read() == WRITE_BC_IVT_LOCK) or … … 8317 8276 r_alloc_ivt_fsm = ALLOC_IVT_READ; 8318 8277 8319 else if (r_xram_rsp_fsm.read() == XRAM_RSP_I NVAL_LOCK)8278 else if (r_xram_rsp_fsm.read() == XRAM_RSP_IVT_LOCK) 8320 8279 r_alloc_ivt_fsm = ALLOC_IVT_XRAM_RSP; 8321 8280 … … 8326 8285 else if(r_cas_fsm.read() == CAS_BC_IVT_LOCK) 8327 8286 r_alloc_ivt_fsm = ALLOC_IVT_CAS; 8328 8329 8287 else 8330 8288 m_cpt_ivt_unused++; … … 8361 8319 if ( (r_config_fsm.read() != CONFIG_DIR_REQ) and 8362 8320 (r_config_fsm.read() != CONFIG_DIR_ACCESS) and 8363 (r_config_fsm.read() != CONFIG_DIR_IVT_LOCK) ) 8321 (r_config_fsm.read() != CONFIG_TRT_LOCK) and 8322 (r_config_fsm.read() != CONFIG_TRT_SET) and 8323 (r_config_fsm.read() != CONFIG_IVT_LOCK) ) 8364 8324 { 8365 8325 if(r_read_fsm.read() == READ_DIR_REQ) … … 8417 8377 if(((r_write_fsm.read() != WRITE_DIR_REQ) and 8418 8378 (r_write_fsm.read() != WRITE_DIR_LOCK) and 8419 (r_write_fsm.read() != WRITE_ DIR_READ) and8379 (r_write_fsm.read() != WRITE_BC_DIR_READ) and 8420 8380 (r_write_fsm.read() != WRITE_DIR_HIT) and 8421 8381 (r_write_fsm.read() != WRITE_BC_TRT_LOCK) and … … 8530 8490 if( (r_xram_rsp_fsm.read() != XRAM_RSP_DIR_LOCK) and 8531 8491 (r_xram_rsp_fsm.read() != XRAM_RSP_TRT_COPY) and 8532 (r_xram_rsp_fsm.read() != XRAM_RSP_I NVAL_LOCK))8492 (r_xram_rsp_fsm.read() != XRAM_RSP_IVT_LOCK)) 8533 8493 { 8534 8494 if(r_config_fsm.read() == CONFIG_DIR_REQ) … … 8579 8539 r_alloc_trt_fsm = ALLOC_TRT_CAS; 8580 8540 8541 else if((r_ixr_cmd_fsm.read() == IXR_CMD_READ_TRT) or 8542 (r_ixr_cmd_fsm.read() == IXR_CMD_WRITE_TRT) or 8543 (r_ixr_cmd_fsm.read() == IXR_CMD_CAS_TRT) or 8544 (r_ixr_cmd_fsm.read() == IXR_CMD_XRAM_TRT) or 8545 (r_ixr_cmd_fsm.read() == IXR_CMD_CLEANUP_TRT) or 8546 (r_ixr_cmd_fsm.read() == IXR_CMD_CONFIG_TRT) ) 8547 r_alloc_trt_fsm = ALLOC_TRT_IXR_CMD; 8548 8581 8549 else if((r_xram_rsp_fsm.read() == XRAM_RSP_DIR_LOCK) and 8582 8550 (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP)) … … 8587 8555 r_alloc_trt_fsm = ALLOC_TRT_IXR_RSP; 8588 8556 8557 else if( r_config_fsm.read() == CONFIG_TRT_LOCK ) 8558 r_alloc_trt_fsm = ALLOC_TRT_CONFIG; 8559 8589 8560 else if (r_cleanup_fsm.read() == CLEANUP_IXR_REQ) 8590 8561 r_alloc_trt_fsm = ALLOC_TRT_CLEANUP; … … 8607 8578 r_alloc_trt_fsm = ALLOC_TRT_CAS; 8608 8579 8580 else if((r_ixr_cmd_fsm.read() == IXR_CMD_READ_TRT) or 8581 (r_ixr_cmd_fsm.read() == IXR_CMD_WRITE_TRT) or 8582 (r_ixr_cmd_fsm.read() == IXR_CMD_CAS_TRT) or 8583 (r_ixr_cmd_fsm.read() == IXR_CMD_XRAM_TRT) or 8584 (r_ixr_cmd_fsm.read() == IXR_CMD_CLEANUP_TRT) or 8585 (r_ixr_cmd_fsm.read() == IXR_CMD_CONFIG_TRT) ) 8586 r_alloc_trt_fsm = ALLOC_TRT_IXR_CMD; 8587 8609 8588 else if((r_xram_rsp_fsm.read() == XRAM_RSP_DIR_LOCK) and 8610 8589 (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP)) … … 8618 8597 r_alloc_trt_fsm = ALLOC_TRT_CLEANUP; 8619 8598 8599 else if( r_config_fsm.read() == CONFIG_TRT_LOCK ) 8600 r_alloc_trt_fsm = ALLOC_TRT_CONFIG; 8601 8620 8602 else if(r_read_fsm.read() == READ_TRT_LOCK) 8621 8603 r_alloc_trt_fsm = ALLOC_TRT_READ; … … 8634 8616 (r_cas_fsm.read() != CAS_BC_IVT_LOCK)) 8635 8617 { 8636 if((r_xram_rsp_fsm.read() == XRAM_RSP_DIR_LOCK) and 8637 (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP)) 8618 if((r_ixr_cmd_fsm.read() == IXR_CMD_READ_TRT) or 8619 (r_ixr_cmd_fsm.read() == IXR_CMD_WRITE_TRT) or 8620 (r_ixr_cmd_fsm.read() == IXR_CMD_CAS_TRT) or 8621 (r_ixr_cmd_fsm.read() == IXR_CMD_XRAM_TRT) or 8622 (r_ixr_cmd_fsm.read() == IXR_CMD_CLEANUP_TRT) or 8623 (r_ixr_cmd_fsm.read() == IXR_CMD_CONFIG_TRT) ) 8624 r_alloc_trt_fsm = ALLOC_TRT_IXR_CMD; 8625 8626 else if((r_xram_rsp_fsm.read() == XRAM_RSP_DIR_LOCK) and 8627 (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP)) 8638 8628 r_alloc_trt_fsm = ALLOC_TRT_XRAM_RSP; 8639 8629 … … 8645 8635 r_alloc_trt_fsm = ALLOC_TRT_CLEANUP; 8646 8636 8637 else if( r_config_fsm.read() == CONFIG_TRT_LOCK ) 8638 r_alloc_trt_fsm = ALLOC_TRT_CONFIG; 8639 8647 8640 else if(r_read_fsm.read() == READ_TRT_LOCK) 8648 8641 r_alloc_trt_fsm = ALLOC_TRT_READ; … … 8658 8651 m_cpt_cas_fsm_trt_used++; 8659 8652 break; 8653 /////////////////////// 8654 case ALLOC_TRT_IXR_CMD: 8655 if((r_ixr_cmd_fsm.read() != IXR_CMD_READ_TRT) and 8656 (r_ixr_cmd_fsm.read() != IXR_CMD_WRITE_TRT) and 8657 (r_ixr_cmd_fsm.read() != IXR_CMD_CAS_TRT) and 8658 (r_ixr_cmd_fsm.read() != IXR_CMD_XRAM_TRT) and 8659 (r_ixr_cmd_fsm.read() != IXR_CMD_CLEANUP_TRT) and 8660 (r_ixr_cmd_fsm.read() != IXR_CMD_CONFIG_TRT)) 8661 { 8662 if((r_xram_rsp_fsm.read() == XRAM_RSP_DIR_LOCK) and 8663 (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP)) 8664 r_alloc_trt_fsm = ALLOC_TRT_XRAM_RSP; 8665 8666 else if((r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) or 8667 (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ)) 8668 r_alloc_trt_fsm = ALLOC_TRT_IXR_RSP; 8669 8670 else if (r_cleanup_fsm.read() == CLEANUP_IXR_REQ) 8671 r_alloc_trt_fsm = ALLOC_TRT_CLEANUP; 8672 8673 8674 else if( r_config_fsm.read() == CONFIG_TRT_LOCK ) 8675 r_alloc_trt_fsm = ALLOC_TRT_CONFIG; 8676 8677 else if(r_read_fsm.read() == READ_TRT_LOCK) 8678 r_alloc_trt_fsm = ALLOC_TRT_READ; 8679 8680 else if((r_write_fsm.read() == WRITE_MISS_TRT_LOCK) or 8681 (r_write_fsm.read() == WRITE_BC_TRT_LOCK)) 8682 r_alloc_trt_fsm = ALLOC_TRT_WRITE; 8683 8684 else if((r_cas_fsm.read() == CAS_MISS_TRT_LOCK) or 8685 (r_cas_fsm.read() == CAS_BC_TRT_LOCK)) 8686 r_alloc_trt_fsm = ALLOC_TRT_CAS; 8687 } 8688 break; 8660 8689 8661 8690 //////////////////////// … … 8665 8694 (r_xram_rsp_fsm.read() != XRAM_RSP_TRT_COPY) and 8666 8695 (r_xram_rsp_fsm.read() != XRAM_RSP_DIR_UPDT) and 8667 (r_xram_rsp_fsm.read() != XRAM_RSP_I NVAL_LOCK))8696 (r_xram_rsp_fsm.read() != XRAM_RSP_IVT_LOCK)) 8668 8697 { 8669 8698 if((r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) or … … 8685 8714 r_alloc_trt_fsm = ALLOC_TRT_CAS; 8686 8715 8716 else if( r_config_fsm.read() == CONFIG_TRT_LOCK ) 8717 r_alloc_trt_fsm = ALLOC_TRT_CONFIG; 8718 8719 else if((r_ixr_cmd_fsm.read() == IXR_CMD_READ_TRT) or 8720 (r_ixr_cmd_fsm.read() == IXR_CMD_WRITE_TRT) or 8721 (r_ixr_cmd_fsm.read() == IXR_CMD_CAS_TRT) or 8722 (r_ixr_cmd_fsm.read() == IXR_CMD_XRAM_TRT) or 8723 (r_ixr_cmd_fsm.read() == IXR_CMD_CLEANUP_TRT) or 8724 (r_ixr_cmd_fsm.read() == IXR_CMD_CONFIG_TRT) ) 8725 r_alloc_trt_fsm = ALLOC_TRT_IXR_CMD; 8726 8687 8727 else 8688 8728 m_cpt_trt_unused++; … … 8697 8737 (r_ixr_rsp_fsm.read() != IXR_RSP_TRT_READ)) 8698 8738 { 8739 if( r_config_fsm.read() == CONFIG_TRT_LOCK ) 8740 r_alloc_trt_fsm = ALLOC_TRT_CONFIG; 8699 8741 8700 if (r_cleanup_fsm.read() == CLEANUP_IXR_REQ)8742 else if (r_cleanup_fsm.read() == CLEANUP_IXR_REQ) 8701 8743 r_alloc_trt_fsm = ALLOC_TRT_CLEANUP; 8702 8744 … … 8711 8753 (r_cas_fsm.read() == CAS_BC_TRT_LOCK)) 8712 8754 r_alloc_trt_fsm = ALLOC_TRT_CAS; 8755 8756 else if((r_ixr_cmd_fsm.read() == IXR_CMD_READ_TRT) or 8757 (r_ixr_cmd_fsm.read() == IXR_CMD_WRITE_TRT) or 8758 (r_ixr_cmd_fsm.read() == IXR_CMD_CAS_TRT) or 8759 (r_ixr_cmd_fsm.read() == IXR_CMD_XRAM_TRT) or 8760 (r_ixr_cmd_fsm.read() == IXR_CMD_CLEANUP_TRT) or 8761 (r_ixr_cmd_fsm.read() == IXR_CMD_CONFIG_TRT) ) 8762 r_alloc_trt_fsm = ALLOC_TRT_IXR_CMD; 8713 8763 8714 8764 else if((r_xram_rsp_fsm.read() == XRAM_RSP_DIR_LOCK) && … … 8746 8796 (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ)) 8747 8797 r_alloc_trt_fsm = ALLOC_TRT_IXR_RSP; 8748 } 8749 break; 8798 8799 else if( r_config_fsm.read() == CONFIG_TRT_LOCK ) 8800 r_alloc_trt_fsm = ALLOC_TRT_CONFIG; 8801 8802 else if((r_ixr_cmd_fsm.read() == IXR_CMD_READ_TRT) or 8803 (r_ixr_cmd_fsm.read() == IXR_CMD_WRITE_TRT) or 8804 (r_ixr_cmd_fsm.read() == IXR_CMD_CAS_TRT) or 8805 (r_ixr_cmd_fsm.read() == IXR_CMD_XRAM_TRT) or 8806 (r_ixr_cmd_fsm.read() == IXR_CMD_CLEANUP_TRT) or 8807 (r_ixr_cmd_fsm.read() == IXR_CMD_CONFIG_TRT) ) 8808 r_alloc_trt_fsm = ALLOC_TRT_IXR_CMD; 8809 } 8810 break; 8811 ////////////////////// 8812 case ALLOC_TRT_CONFIG: 8813 if((r_config_fsm.read() != CONFIG_TRT_LOCK) and 8814 (r_config_fsm.read() != CONFIG_TRT_SET)) 8815 { 8816 if(r_read_fsm.read() == READ_TRT_LOCK) 8817 r_alloc_trt_fsm = ALLOC_TRT_READ; 8818 8819 else if((r_write_fsm.read() == WRITE_MISS_TRT_LOCK) or 8820 (r_write_fsm.read() == WRITE_BC_TRT_LOCK)) 8821 r_alloc_trt_fsm = ALLOC_TRT_WRITE; 8822 8823 else if((r_cas_fsm.read() == CAS_MISS_TRT_LOCK) or 8824 (r_cas_fsm.read() == CAS_BC_TRT_LOCK)) 8825 r_alloc_trt_fsm = ALLOC_TRT_CAS; 8826 8827 else if((r_ixr_cmd_fsm.read() == IXR_CMD_READ_TRT) or 8828 (r_ixr_cmd_fsm.read() == IXR_CMD_WRITE_TRT) or 8829 (r_ixr_cmd_fsm.read() == IXR_CMD_CAS_TRT) or 8830 (r_ixr_cmd_fsm.read() == IXR_CMD_XRAM_TRT) or 8831 (r_ixr_cmd_fsm.read() == IXR_CMD_CLEANUP_TRT) or 8832 (r_ixr_cmd_fsm.read() == IXR_CMD_CONFIG_TRT) ) 8833 r_alloc_trt_fsm = ALLOC_TRT_IXR_CMD; 8834 8835 else if((r_xram_rsp_fsm.read() == XRAM_RSP_DIR_LOCK) and 8836 (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP)) 8837 r_alloc_trt_fsm = ALLOC_TRT_XRAM_RSP; 8838 8839 else if (r_cleanup_fsm.read() == CLEANUP_IXR_REQ) 8840 r_alloc_trt_fsm = ALLOC_TRT_CLEANUP; 8841 8842 else if((r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) or 8843 (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ)) 8844 r_alloc_trt_fsm = ALLOC_TRT_IXR_RSP; 8845 } 8846 break; 8847 8750 8848 8751 8849 } // end switch alloc_trt_fsm … … 9034 9132 m_write_to_cc_send_srcid_fifo.update( write_to_cc_send_fifo_get, write_to_cc_send_fifo_put, 9035 9133 write_to_cc_send_fifo_srcid ); 9036 #if L1_MULTI_CACHE9037 m_write_to_cc_send_cache_id_fifo.update( write_to_cc_send_fifo_get, write_to_cc_send_fifo_put,9038 write_to_cc_send_fifo_cache_id );9039 #endif9040 9134 9041 9135 //////////////////////////////////////////////////////////////////////////////////// … … 9047 9141 m_config_to_cc_send_srcid_fifo.update( config_to_cc_send_fifo_get, config_to_cc_send_fifo_put, 9048 9142 config_to_cc_send_fifo_srcid ); 9049 #if L1_MULTI_CACHE9050 m_config_to_cc_send_cache_id_fifo.update( config_to_cc_send_fifo_get, config_to_cc_send_fifo_put,9051 config_to_cc_send_fifo_cache_id );9052 #endif9053 9143 9054 9144 //////////////////////////////////////////////////////////////////////////////////// … … 9060 9150 m_xram_rsp_to_cc_send_srcid_fifo.update( xram_rsp_to_cc_send_fifo_get, xram_rsp_to_cc_send_fifo_put, 9061 9151 xram_rsp_to_cc_send_fifo_srcid ); 9062 #if L1_MULTI_CACHE9063 m_xram_rsp_to_cc_send_cache_id_fifo.update( xram_rsp_to_cc_send_fifo_get, xram_rsp_to_cc_send_fifo_put,9064 xram_rsp_to_cc_send_fifo_cache_id );9065 #endif9066 9152 9067 9153 //////////////////////////////////////////////////////////////////////////////////// … … 9073 9159 m_cas_to_cc_send_srcid_fifo.update( cas_to_cc_send_fifo_get, cas_to_cc_send_fifo_put, 9074 9160 cas_to_cc_send_fifo_srcid ); 9075 #if L1_MULTI_CACHE9076 m_cas_to_cc_send_cache_id_fifo.update( cas_to_cc_send_fifo_get, cas_to_cc_send_fifo_put,9077 cas_to_cc_send_fifo_cache_id );9078 #endif9079 9080 9161 m_cpt_cycles++; 9081 9162 … … 9089 9170 // Command signals on the p_vci_ixr port 9090 9171 //////////////////////////////////////////////////////////// 9091 9092 p_vci_ixr.be = 0xFF; // nor transmited to external ram 9172 // DATA width is 8 bytes 9173 // The following values are not transmitted to XRAM 9174 // p_vci_ixr.be 9175 // p_vci_ixr.pktid 9176 // p_vci_ixr.cons 9177 // p_vci_ixr.wrap 9178 // p_vci_ixr.contig 9179 // p_vci_ixr.clen 9180 // p_vci_ixr.cfixed 9181 9182 p_vci_ixr.plen = 64; 9183 p_vci_ixr.srcid = m_srcid_x; 9184 p_vci_ixr.trdid = r_ixr_cmd_trdid.read(); 9185 p_vci_ixr.address = (addr_t)r_ixr_cmd_address.read() + (r_ixr_cmd_word.read()<<2); 9186 p_vci_ixr.be = 0xFF; 9093 9187 p_vci_ixr.pktid = 0; 9094 p_vci_ixr.srcid = m_srcid_x;9095 9188 p_vci_ixr.cons = false; 9096 9189 p_vci_ixr.wrap = false; … … 9098 9191 p_vci_ixr.clen = 0; 9099 9192 p_vci_ixr.cfixed = false; 9100 p_vci_ixr.plen = 64; 9101 9102 if(r_ixr_cmd_fsm.read() == IXR_CMD_READ) 9103 { 9104 p_vci_ixr.cmd = vci_param_ext::CMD_READ; 9105 p_vci_ixr.cmdval = true; 9106 p_vci_ixr.address = (addr_t)(r_read_to_ixr_cmd_nline.read() * m_words * 4); 9107 p_vci_ixr.wdata = 0; 9108 p_vci_ixr.trdid = r_read_to_ixr_cmd_trdid.read(); 9109 p_vci_ixr.eop = true; 9193 9194 if ( (r_ixr_cmd_fsm.read() == IXR_CMD_READ_SEND) or 9195 (r_ixr_cmd_fsm.read() == IXR_CMD_WRITE_SEND) or 9196 (r_ixr_cmd_fsm.read() == IXR_CMD_CAS_SEND) or 9197 (r_ixr_cmd_fsm.read() == IXR_CMD_XRAM_SEND) or 9198 (r_ixr_cmd_fsm.read() == IXR_CMD_CONFIG_SEND) ) 9199 { 9200 p_vci_ixr.cmdval = true; 9201 9202 if ( r_ixr_cmd_get.read() ) // GET 9203 { 9204 p_vci_ixr.cmd = vci_param_ext::CMD_READ; 9205 p_vci_ixr.wdata = 0; 9206 p_vci_ixr.eop = true; 9207 } 9208 else // PUT 9209 { 9210 size_t word = r_ixr_cmd_word.read(); 9211 p_vci_ixr.cmd = vci_param_ext::CMD_WRITE; 9212 p_vci_ixr.wdata = ((wide_data_t)(r_ixr_cmd_wdata[word].read())) | 9213 ((wide_data_t)(r_ixr_cmd_wdata[word+1].read()) << 32); 9214 p_vci_ixr.eop = (word == (m_words-2)); 9215 } 9110 9216 } 9111 else if(r_ixr_cmd_fsm.read() == IXR_CMD_CAS) 9112 { 9113 if(r_cas_to_ixr_cmd_write.read()) 9114 { 9115 size_t word = r_ixr_cmd_cpt.read(); 9116 p_vci_ixr.cmd = vci_param_ext::CMD_WRITE; 9117 p_vci_ixr.cmdval = true; 9118 p_vci_ixr.address = (addr_t)( (r_cas_to_ixr_cmd_nline.read() * m_words + word) * 4 ); 9119 p_vci_ixr.wdata = ((wide_data_t)(r_cas_to_ixr_cmd_data[word].read())) | 9120 ((wide_data_t)(r_cas_to_ixr_cmd_data[word+1].read()) << 32); 9121 p_vci_ixr.trdid = r_cas_to_ixr_cmd_trdid.read(); 9122 p_vci_ixr.eop = (r_ixr_cmd_cpt == (m_words-2)); 9123 } 9124 else 9125 { 9126 p_vci_ixr.cmd = vci_param_ext::CMD_READ; 9127 p_vci_ixr.cmdval = true; 9128 p_vci_ixr.address = (addr_t)(r_cas_to_ixr_cmd_nline.read() *m_words*4); 9129 p_vci_ixr.wdata = 0; 9130 p_vci_ixr.trdid = r_cas_to_ixr_cmd_trdid.read(); 9131 p_vci_ixr.eop = true; 9132 } 9133 } 9134 else if(r_ixr_cmd_fsm.read() == IXR_CMD_WRITE) 9135 { 9136 if(r_write_to_ixr_cmd_write.read()) 9137 { 9138 p_vci_ixr.cmd = vci_param_ext::CMD_WRITE; 9139 p_vci_ixr.cmdval = true; 9140 p_vci_ixr.address = (addr_t)( (r_write_to_ixr_cmd_nline.read() * m_words + 9141 r_ixr_cmd_cpt.read()) * 4 ); 9142 p_vci_ixr.wdata = ((wide_data_t)(r_write_to_ixr_cmd_data[r_ixr_cmd_cpt.read()].read()) | 9143 ((wide_data_t)(r_write_to_ixr_cmd_data[r_ixr_cmd_cpt.read()+1].read()) << 32)); 9144 p_vci_ixr.trdid = r_write_to_ixr_cmd_trdid.read(); 9145 p_vci_ixr.eop = (r_ixr_cmd_cpt == (m_words-2)); 9146 } 9147 else 9148 { 9149 p_vci_ixr.cmd = vci_param_ext::CMD_READ; 9150 p_vci_ixr.cmdval = true; 9151 p_vci_ixr.address = (addr_t)(r_write_to_ixr_cmd_nline.read() *m_words*4); 9152 p_vci_ixr.wdata = 0; 9153 p_vci_ixr.trdid = r_write_to_ixr_cmd_trdid.read(); 9154 p_vci_ixr.eop = true; 9155 } 9156 } 9157 else if(r_ixr_cmd_fsm.read() == IXR_CMD_XRAM) 9158 { 9159 p_vci_ixr.cmd = vci_param_ext::CMD_WRITE; 9160 p_vci_ixr.cmdval = true; 9161 p_vci_ixr.address = (addr_t)( (r_xram_rsp_to_ixr_cmd_nline.read() * m_words + 9162 r_ixr_cmd_cpt.read()) * 4 ); 9163 p_vci_ixr.wdata = ((wide_data_t)(r_xram_rsp_to_ixr_cmd_data[r_ixr_cmd_cpt.read()].read()) | 9164 ((wide_data_t)(r_xram_rsp_to_ixr_cmd_data[r_ixr_cmd_cpt.read()+1].read()) << 32)); 9165 p_vci_ixr.trdid = r_xram_rsp_to_ixr_cmd_trdid.read(); 9166 p_vci_ixr.eop = (r_ixr_cmd_cpt == (m_words-2)); 9167 } 9168 else if (r_ixr_cmd_fsm.read() == IXR_CMD_CLEANUP_DATA) 9217 else if (r_ixr_cmd_fsm.read() == IXR_CMD_CLEANUP_DATA_SEND) 9169 9218 { 9170 9219 p_vci_ixr.cmd = vci_param_ext::CMD_WRITE; 9171 9220 p_vci_ixr.cmdval = true; 9172 p_vci_ixr.address = (addr_t)((r_cleanup_to_ixr_cmd_nline.read() * m_words + r_ixr_cmd_cpt.read()) * 4); 9173 if (r_cleanup_to_ixr_cmd_ncc_l1_dirty.read()) //if L1 was dirty, the correct data is in the cleanup 9174 { 9175 p_vci_ixr.wdata = ((wide_data_t)(r_cleanup_to_ixr_cmd_data[r_ixr_cmd_cpt.read()].read()) | 9176 ((wide_data_t)(r_cleanup_to_ixr_cmd_data[r_ixr_cmd_cpt.read()+1].read()) << 32)); 9177 if(r_cleanup_to_ixr_cmd_nline.read() == 0x12bb) 9178 std::cout << "IXR data dirty = " << std::hex << p_vci_ixr.wdata << std::dec << std::endl; 9179 } 9180 else //if L1 was not dirty, the data is in the L2 9181 { 9182 p_vci_ixr.wdata = ((wide_data_t)(r_xram_rsp_to_ixr_cmd_data[r_ixr_cmd_cpt.read()].read()) | 9183 ((wide_data_t)(r_xram_rsp_to_ixr_cmd_data[r_ixr_cmd_cpt.read()+1].read()) << 32)); 9184 if(r_cleanup_to_ixr_cmd_nline.read() == 0x12bb) 9185 std::cout << "IXR data not dirty = " << std::hex << p_vci_ixr.wdata << std::dec << std::endl; 9186 } 9187 p_vci_ixr.trdid = r_cleanup_to_ixr_cmd_trdid.read(); 9188 p_vci_ixr.eop = (r_ixr_cmd_cpt == (m_words - 2)); 9221 /*p_vci_ixr.address = (addr_t)((r_cleanup_to_ixr_cmd_nline.read() * m_words + 9222 r_ixr_cmd_word.read()) * 4);*/ 9223 p_vci_ixr.address = (addr_t)r_ixr_cmd_address.read() + (r_ixr_cmd_word.read()<<2); 9224 p_vci_ixr.wdata = ((wide_data_t)(r_ixr_cmd_wdata[r_ixr_cmd_word.read()].read()) | 9225 ((wide_data_t)(r_ixr_cmd_wdata[r_ixr_cmd_word.read() + 1].read()) << 32)); 9226 p_vci_ixr.trdid = r_cleanup_to_ixr_cmd_index.read(); 9227 p_vci_ixr.eop = (r_ixr_cmd_word == (m_words - 2)); 9189 9228 } 9229 9190 9230 else 9191 9231 { 9192 p_vci_ixr.cmdval = false; 9193 p_vci_ixr.cmd = vci_param_ext::CMD_READ; 9194 p_vci_ixr.address = 0; 9195 p_vci_ixr.wdata = 0; 9196 p_vci_ixr.trdid = 0; 9197 p_vci_ixr.eop = false; 9232 p_vci_ixr.cmdval = false; 9198 9233 } 9199 9234 … … 9202 9237 //////////////////////////////////////////////////// 9203 9238 9204 if(((r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_RSP) and 9205 (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ)) or 9206 (r_ixr_rsp_fsm.read() == IXR_RSP_ACK)) 9207 9208 p_vci_ixr.rspack = true; 9209 9210 else 9211 p_vci_ixr.rspack = false; 9239 if( (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ) or 9240 (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) ) 9241 { 9242 p_vci_ixr.rspack = (r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_RSP); 9243 } 9244 else if (r_ixr_rsp_fsm.read() == IXR_RSP_ACK) 9245 { 9246 p_vci_ixr.rspack = true; 9247 } 9248 else // r_ixr_rsp_fsm == IXR_RSP_IDLE 9249 { 9250 p_vci_ixr.rspack = false; 9251 } 9212 9252 9213 9253 //////////////////////////////////////////////////// … … 9279 9319 { 9280 9320 p_vci_tgt.rspval = true; 9281 p_vci_tgt.rdata = 0;9321 p_vci_tgt.rdata = r_tgt_cmd_to_tgt_rsp_rdata.read(); 9282 9322 p_vci_tgt.rsrcid = r_tgt_cmd_to_tgt_rsp_srcid.read(); 9283 9323 p_vci_tgt.rtrdid = r_tgt_cmd_to_tgt_rsp_trdid.read(); … … 9904 9944 //////////////////////////////////////////////////////////////////// 9905 9945 9906 switch(r_cleanup_fsm.read())9946 if ( r_cleanup_fsm.read() == CLEANUP_SEND_CLACK ) 9907 9947 { 9908 case CLEANUP_IDLE: 9909 case CLEANUP_GET_NLINE: 9910 case CLEANUP_DIR_REQ: 9911 case CLEANUP_DIR_LOCK: 9912 case CLEANUP_DIR_WRITE: 9913 case CLEANUP_HEAP_REQ: 9914 case CLEANUP_HEAP_LOCK: 9915 case CLEANUP_HEAP_SEARCH: 9916 case CLEANUP_HEAP_CLEAN: 9917 case CLEANUP_HEAP_FREE: 9918 case CLEANUP_IVT_LOCK: 9919 case CLEANUP_IVT_DECREMENT: 9920 case CLEANUP_IVT_CLEAR: 9921 case CLEANUP_WRITE_RSP: 9922 case CLEANUP_CONFIG_ACK: 9923 p_dspin_clack.write = false; 9924 p_dspin_clack.eop = false; 9925 p_dspin_clack.data = 0; 9926 9927 break; 9928 9929 case CLEANUP_SEND_CLACK: 9930 { 9931 uint8_t cleanup_ack_type; 9932 if(r_cleanup_inst.read()) 9933 { 9948 uint8_t cleanup_ack_type; 9949 if(r_cleanup_inst.read()) 9950 { 9934 9951 cleanup_ack_type = DspinDhccpParam::TYPE_CLACK_INST; 9935 9936 9937 9952 } 9953 else 9954 { 9938 9955 cleanup_ack_type = DspinDhccpParam::TYPE_CLACK_DATA; 9939 } 9940 9941 uint64_t flit = 0; 9942 uint64_t dest = 9943 r_cleanup_srcid.read() << 9956 } 9957 9958 uint64_t flit = 0; 9959 uint64_t dest = r_cleanup_srcid.read() << 9944 9960 (DspinDhccpParam::SRCID_WIDTH - vci_param_int::S); 9945 9961 … … 9964 9980 DspinDhccpParam::CLACK_TYPE); 9965 9981 9966 p_dspin_clack.eop = true; 9967 p_dspin_clack.write = true; 9968 p_dspin_clack.data = flit; 9969 } 9970 break; 9982 p_dspin_clack.eop = true; 9983 p_dspin_clack.write = true; 9984 p_dspin_clack.data = flit; 9971 9985 } 9972 9986 else 9987 { 9988 p_dspin_clack.write = false; 9989 p_dspin_clack.eop = false; 9990 p_dspin_clack.data = 0; 9991 } 9973 9992 /////////////////////////////////////////////////////////////////// 9974 9993 // p_dspin_p2m port (CC_RECEIVE FSM) -
Property
svn:mergeinfo
set to
(toggle deleted branches)
Note: See TracChangeset
for help on using the changeset viewer.