- Timestamp:
- Jul 19, 2013, 2:34:03 PM (11 years ago)
- Location:
- branches/ODCCP/modules/vci_cc_vcache_wrapper
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/ODCCP/modules/vci_cc_vcache_wrapper/caba/source/src/vci_cc_vcache_wrapper.cpp
r434 r460 32 32 #include "../include/vci_cc_vcache_wrapper.h" 33 33 34 #define DEBUG_DCACHE 1 35 #define DEBUG_ICACHE 1 36 #define DEBUG_CMD 0 34 #define DEBUG_DCACHE 1 35 #define DEBUG_ICACHE 1 36 #define DEBUG_CLEANUP 1 37 #define INSTRUMENTATION 1 38 #define FETCH_ON_WRITE_ENABLE 1 39 #define DEBUG_CMD 0 37 40 38 41 namespace soclib { … … 89 92 "DCACHE_XTN_IT_INVAL", 90 93 "DCACHE_XTN_DC_FLUSH", 94 "DCACHE_XTN_DC_FLUSH_DATA", 91 95 "DCACHE_XTN_DC_FLUSH_GO", 92 96 "DCACHE_XTN_DC_INVAL_VA", … … 94 98 "DCACHE_XTN_DC_INVAL_END", 95 99 "DCACHE_XTN_DC_INVAL_GO", 100 "DCACHE_XTN_DC_INVAL_DATA", 96 101 "DCACHE_XTN_DT_INVAL", 97 102 … … 101 106 "DCACHE_MISS_SELECT", 102 107 "DCACHE_MISS_CLEAN", 108 "DCACHE_MISS_DATA", 103 109 "DCACHE_MISS_WAIT", 104 110 "DCACHE_MISS_DATA_UPDT", … … 110 116 111 117 "DCACHE_CC_CHECK", 118 "DCACHE_CC_INVAL_DATA", 112 119 "DCACHE_CC_INVAL", 113 120 "DCACHE_CC_UPDT", … … 174 181 "CC_SEND_CLEANUP_1", 175 182 "CC_SEND_CLEANUP_2", 183 "CC_SEND_CLEANUP_DATA_UPDT", 176 184 "CC_SEND_MULTI_ACK", 177 185 }; … … 353 361 r_dcache_cc_send_way("r_dcache_cc_send_way"), 354 362 r_dcache_cc_send_updt_tab_idx("r_dcache_cc_send_updt_tab_idx"), 363 364 r_cc_send_data_fifo("r_cc_send_data_fifo", 2), // ODCCP 355 365 356 366 r_vci_cmd_fsm("r_vci_cmd_fsm"), … … 423 433 r_mmu_release = (uint32_t)(1 << 16) | 0x1; 424 434 425 r_dcache_in_tlb = new bool[dcache_ways*dcache_sets]; 426 r_dcache_contains_ptd = new bool[dcache_ways*dcache_sets]; 435 ////////////////////MODIFIED/////////////////////////////// 436 //r_dcache_in_tlb = new bool[dcache_ways*dcache_sets]; 437 //r_dcache_contains_ptd = new bool[dcache_ways*dcache_sets]; 438 dirty_stats = new bool [dcache_ways*dcache_sets*dcache_words]; 439 r_dcache_content_state = new int [dcache_ways*dcache_sets]; 440 /////////////////////////////////////////////////////////// 441 427 442 428 443 SC_METHOD(transition); … … 449 464 ///////////////////////////////////// 450 465 { 451 delete [] r_dcache_in_tlb; 452 delete [] r_dcache_contains_ptd; 466 ////////////MODIFIED///////////// 467 //delete [] r_dcache_in_tlb; 468 //delete [] r_dcache_contains_ptd; 469 delete [] dirty_stats; 470 delete [] r_dcache_content_state; 471 ///////////////////////////////// 453 472 } 454 473 … … 479 498 std::cout << " " << m_drsp << std::endl; 480 499 500 std::cout << r_iss << std::endl; 501 481 502 std::cout << " " << icache_fsm_state_str[r_icache_fsm.read()] 482 503 << " | " << dcache_fsm_state_str[r_dcache_fsm.read()] … … 561 582 } 562 583 563 /* 584 564 585 //////////////////////// 565 586 tmpl(void)::print_stats() … … 568 589 float run_cycles = (float)(m_cpt_total_cycles - m_cpt_frz_cycles); 569 590 std::cout << name() << std::endl 570 << "- CPI = " << (float)m_cpt_total_cycles/run_cycles << std::endl 571 << "- READ RATE = " << (float)m_cpt_read/run_cycles << std::endl 572 << "- WRITE RATE = " << (float)m_cpt_write/run_cycles << std::endl 573 << "- IMISS_RATE = " << (float)m_cpt_ins_miss/m_cpt_ins_read << std::endl 574 << "- DMISS RATE = " << (float)m_cpt_data_miss/(m_cpt_read-m_cpt_unc_read) << std::endl 575 << "- INS MISS COST = " << (float)m_cost_ins_miss_frz/m_cpt_ins_miss << std::endl 576 << "- DATA MISS COST = " << (float)m_cost_data_miss_frz/m_cpt_data_miss << std::endl 577 << "- WRITE COST = " << (float)m_cost_write_frz/m_cpt_write << std::endl 578 << "- UNC COST = " << (float)m_cost_unc_read_frz/m_cpt_unc_read << std::endl 579 << "- UNCACHED READ RATE = " << (float)m_cpt_unc_read/m_cpt_read << std::endl 580 << "- CACHED WRITE RATE = " << (float)m_cpt_write_cached/m_cpt_write << std::endl 581 << "- INS TLB MISS RATE = " << (float)m_cpt_ins_tlb_miss/m_cpt_ins_tlb_read << std::endl 582 << "- DATA TLB MISS RATE = " << (float)m_cpt_data_tlb_miss/m_cpt_data_tlb_read << std::endl 583 << "- ITLB MISS COST = " << (float)m_cost_ins_tlb_miss_frz/m_cpt_ins_tlb_miss << std::endl 584 << "- DTLB MISS COST = " << (float)m_cost_data_tlb_miss_frz/m_cpt_data_tlb_miss << std::endl 585 << "- ITLB UPDATE ACC COST = " << (float)m_cost_ins_tlb_update_acc_frz/m_cpt_ins_tlb_update_acc << std::endl 586 << "- DTLB UPDATE ACC COST = " << (float)m_cost_data_tlb_update_acc_frz/m_cpt_data_tlb_update_acc << std::endl 587 << "- DTLB UPDATE DIRTY COST = " << (float)m_cost_data_tlb_update_dirty_frz/m_cpt_data_tlb_update_dirty << std::endl 588 << "- ITLB HIT IN DCACHE RATE= " << (float)m_cpt_ins_tlb_hit_dcache/m_cpt_ins_tlb_miss << std::endl 589 << "- DTLB HIT IN DCACHE RATE= " << (float)m_cpt_data_tlb_hit_dcache/m_cpt_data_tlb_miss << std::endl 590 << "- DCACHE FROZEN BY ITLB = " << (float)m_cost_ins_tlb_occup_cache_frz/m_cpt_dcache_frz_cycles << std::endl 591 << "- DCACHE FOR TLB % = " << (float)m_cpt_tlb_occup_dcache/(m_dcache_ways*m_dcache_sets) << std::endl 592 << "- NB CC BROADCAST = " << m_cpt_cc_broadcast << std::endl 593 << "- NB CC UPDATE DATA = " << m_cpt_cc_update_data << std::endl 594 << "- NB CC INVAL DATA = " << m_cpt_cc_inval_data << std::endl 595 << "- NB CC INVAL INS = " << m_cpt_cc_inval_ins << std::endl 596 << "- CC BROADCAST COST = " << (float)m_cost_broadcast_frz/m_cpt_cc_broadcast << std::endl 597 << "- CC UPDATE DATA COST = " << (float)m_cost_updt_data_frz/m_cpt_cc_update_data << std::endl 598 << "- CC INVAL DATA COST = " << (float)m_cost_inval_data_frz/m_cpt_cc_inval_data << std::endl 599 << "- CC INVAL INS COST = " << (float)m_cost_inval_ins_frz/m_cpt_cc_inval_ins << std::endl 600 << "- NB CC CLEANUP DATA = " << m_cpt_cc_cleanup_data << std::endl 601 << "- NB CC CLEANUP INS = " << m_cpt_cc_cleanup_ins << std::endl 602 << "- IMISS TRANSACTION = " << (float)m_cost_imiss_transaction/m_cpt_imiss_transaction << std::endl 603 << "- DMISS TRANSACTION = " << (float)m_cost_dmiss_transaction/m_cpt_dmiss_transaction << std::endl 604 << "- UNC TRANSACTION = " << (float)m_cost_unc_transaction/m_cpt_unc_transaction << std::endl 605 << "- WRITE TRANSACTION = " << (float)m_cost_write_transaction/m_cpt_write_transaction << std::endl 606 << "- WRITE LENGTH = " << (float)m_length_write_transaction/m_cpt_write_transaction << std::endl 607 << "- ITLB MISS TRANSACTION = " << (float)m_cost_itlbmiss_transaction/m_cpt_itlbmiss_transaction << std::endl 608 << "- DTLB MISS TRANSACTION = " << (float)m_cost_dtlbmiss_transaction/m_cpt_dtlbmiss_transaction << std::endl; 591 << "- CPI = " << (float)m_cpt_total_cycles/run_cycles << std::endl 592 << "- READ RATE = " << (float)m_cpt_data_read/run_cycles << std::endl 593 << "- WRITE RATE = " << (float)m_cpt_data_write/run_cycles << std::endl 594 << "- IMISS_RATE = " << (float)m_cpt_ins_miss/m_cpt_ins_read << std::endl 595 << "- DMISS RATE = " << (float)m_cpt_data_miss/(m_cpt_data_read-m_cpt_unc_read) << std::endl 596 << "- INS MISS COST = " << (float)m_cost_ins_miss_frz/m_cpt_ins_miss << std::endl 597 << "- DATA MISS COST = " << (float)m_cost_data_miss_frz/m_cpt_data_miss << std::endl 598 << "- WRITE COST = " << (float)m_cost_write_frz/m_cpt_data_write << std::endl 599 << "- UNC COST = " << (float)m_cost_unc_read_frz/m_cpt_unc_read << std::endl 600 << "- UNCACHED READ RATE = " << (float)m_cpt_unc_read/m_cpt_data_read << std::endl 601 << "- CACHED WRITE RATE = " << (float)m_cpt_write_cached/m_cpt_data_write << std::endl 602 << "- INS TLB MISS RATE = " << (float)m_cpt_ins_tlb_miss/m_cpt_ins_tlb_read << std::endl 603 << "- DATA TLB MISS RATE = " << (float)m_cpt_data_tlb_miss/m_cpt_data_tlb_read << std::endl 604 << "- ITLB MISS COST = " << (float)m_cost_ins_tlb_miss_frz/m_cpt_ins_tlb_miss << std::endl 605 << "- DTLB MISS COST = " << (float)m_cost_data_tlb_miss_frz/m_cpt_data_tlb_miss << std::endl 606 << "- ITLB UPDATE ACC COST = " << (float)m_cost_ins_tlb_update_acc_frz/m_cpt_ins_tlb_update_acc << std::endl 607 << "- DTLB UPDATE ACC COST = " << (float)m_cost_data_tlb_update_acc_frz/m_cpt_data_tlb_update_acc << std::endl 608 << "- DTLB UPDATE DIRTY COST = " << (float)m_cost_data_tlb_update_dirty_frz/m_cpt_data_tlb_update_dirty << std::endl 609 << "- ITLB HIT IN DCACHE RATE = " << (float)m_cpt_ins_tlb_hit_dcache/m_cpt_ins_tlb_miss << std::endl 610 << "- DTLB HIT IN DCACHE RATE = " << (float)m_cpt_data_tlb_hit_dcache/m_cpt_data_tlb_miss << std::endl 611 //<< "- DCACHE FROZEN BY ITLB = " << (float)m_cost_ins_tlb_occup_cache_frz/m_cpt_dcache_frz_cycles << std::endl 612 << "- DCACHE FOR TLB % = " << (float)m_cpt_tlb_occup_dcache/(m_dcache_ways*m_dcache_sets) << std::endl 613 << "- NB CC BROADCAST = " << m_cpt_cc_broadcast << std::endl 614 << "- NB CC UPDATE DATA = " << m_cpt_cc_update_dcache << std::endl 615 << "- NB CC INVAL DATA = " << m_cpt_cc_inval_dcache << std::endl 616 << "- NB CC INVAL INS = " << m_cpt_cc_inval_icache << std::endl 617 << "- CC BROADCAST COST = " << (float)m_cost_broadcast_frz/m_cpt_cc_broadcast << std::endl 618 << "- CC UPDATE DATA COST = " << (float)m_cost_updt_data_frz/m_cpt_cc_update_dcache << std::endl 619 << "- CC INVAL DATA COST = " << (float)m_cost_inval_data_frz/m_cpt_cc_inval_dcache << std::endl 620 << "- CC INVAL INS COST = " << (float)m_cost_inval_ins_frz/m_cpt_cc_inval_icache << std::endl 621 << "- NB CC CLEANUP DATA = " << m_cpt_cc_cleanup_data << std::endl 622 << "- NB CC CLEANUP INS = " << m_cpt_cc_cleanup_ins << std::endl 623 << "- IMISS TRANSACTION = " << (float)m_cost_imiss_transaction/m_cpt_imiss_transaction << std::endl 624 << "- DMISS TRANSACTION = " << (float)m_cost_dmiss_transaction/m_cpt_dmiss_transaction << std::endl 625 << "- UNC TRANSACTION = " << (float)m_cost_unc_transaction/m_cpt_unc_transaction << std::endl 626 << "- WRITE TRANSACTION = " << (float)m_cost_write_transaction/m_cpt_write_transaction << std::endl 627 << "- NB WRITE TRANSACTION = " << m_cpt_write_transaction << std::endl 628 << "- NB WRITE WORDS VCI = " << m_length_write_transaction << std::endl 629 << "- NB WRITE PROC = " << m_cpt_data_write << std::endl 630 << "- NB WRITE NCC PROC = " << m_cpt_data_write_back << std::endl 631 << "- NB WRITE NCC COHERENCE = " << m_cpt_data_cleanup << std::endl 632 << "- NB CLEANUP DATA DIRTY = " << m_cpt_data_cleanup_dirty*16 << std::endl 633 << "- NB WORDS DIRTY = " << m_cpt_words_dirty << std::endl 634 << "- NB WRITE MISS NCC = " << m_cpt_data_write_miss_ncc << std::endl 635 << "- NB DATA SC = " << m_cpt_data_sc << std::endl 636 << "- WRITE LENGTH = " << (float)m_length_write_transaction/m_cpt_write_transaction << std::endl 637 << "- ITLB MISS TRANSACTION = " << (float)m_cost_itlbmiss_transaction/m_cpt_itlbmiss_transaction << std::endl 638 << "- DTLB MISS TRANSACTION = " << (float)m_cost_dtlbmiss_transaction/m_cpt_dtlbmiss_transaction << std::endl; 609 639 } 610 640 /* 611 641 //////////////////////// 612 642 tmpl(void)::clear_stats() … … 733 763 for (size_t i=0 ; i< m_dcache_ways*m_dcache_sets ; i++) 734 764 { 735 r_dcache_in_tlb[i] = false; 736 r_dcache_contains_ptd[i] = false; 765 // MODIFIED 766 //r_dcache_in_tlb[i] = false; 767 //r_dcache_contains_ptd[i] = false; 768 r_dcache_content_state[i] = LINE_CACHE_DATA_NOT_DIRTY; 769 } 770 for (size_t i=0; i<m_dcache_ways*m_dcache_sets*m_dcache_words; i++) 771 { 772 dirty_stats[i] = false; 737 773 } 738 774 … … 740 776 r_vci_rsp_fifo_icache.init(); 741 777 r_vci_rsp_fifo_dcache.init(); 778 r_cc_send_data_fifo.init(); 742 779 743 780 // ICACHE & DCACHE activated … … 799 836 m_debug_activated = false; 800 837 838 // SPECIAL REGISTERS ODCCP 839 r_dcache_cc_cleanup_updt_data = false; 840 r_dcache_miss_victim_no_coherence = false; 841 r_dcache_line_no_coherence = false; 842 r_dcache_miss_no_coherent = false; 843 r_vci_rsp_read_data_miss_no_coherent = false; 844 r_cc_send_cpt_word = 0; 845 r_dcache_miss_data_cpt = 0; 846 r_dcache_miss_data_addr = 0; 847 801 848 // activity counters 802 m_cpt_dcache_data_read = 0; 803 m_cpt_dcache_data_write = 0; 804 m_cpt_dcache_dir_read = 0; 805 m_cpt_dcache_dir_write = 0; 806 m_cpt_icache_data_read = 0; 807 m_cpt_icache_data_write = 0; 808 m_cpt_icache_dir_read = 0; 809 m_cpt_icache_dir_write = 0; 810 811 m_cpt_frz_cycles = 0; 812 m_cpt_total_cycles = 0; 813 m_cpt_stop_simulation = 0; 814 815 m_cpt_data_miss = 0; 816 m_cpt_ins_miss = 0; 817 m_cpt_unc_read = 0; 818 m_cpt_write_cached = 0; 819 m_cpt_ins_read = 0; 820 821 m_cost_write_frz = 0; 822 m_cost_data_miss_frz = 0; 823 m_cost_unc_read_frz = 0; 824 m_cost_ins_miss_frz = 0; 825 826 m_cpt_imiss_transaction = 0; 827 m_cpt_dmiss_transaction = 0; 828 m_cpt_unc_transaction = 0; 829 m_cpt_write_transaction = 0; 830 m_cpt_icache_unc_transaction = 0; 831 832 m_cost_imiss_transaction = 0; 833 m_cost_dmiss_transaction = 0; 834 m_cost_unc_transaction = 0; 835 m_cost_write_transaction = 0; 836 m_cost_icache_unc_transaction = 0; 837 m_length_write_transaction = 0; 838 839 m_cpt_ins_tlb_read = 0; 840 m_cpt_ins_tlb_miss = 0; 841 m_cpt_ins_tlb_update_acc = 0; 842 843 m_cpt_data_tlb_read = 0; 844 m_cpt_data_tlb_miss = 0; 845 m_cpt_data_tlb_update_acc = 0; 846 m_cpt_data_tlb_update_dirty = 0; 847 m_cpt_ins_tlb_hit_dcache = 0; 848 m_cpt_data_tlb_hit_dcache = 0; 849 m_cpt_ins_tlb_occup_cache = 0; 850 m_cpt_data_tlb_occup_cache = 0; 851 852 m_cost_ins_tlb_miss_frz = 0; 853 m_cost_data_tlb_miss_frz = 0; 854 m_cost_ins_tlb_update_acc_frz = 0; 855 m_cost_data_tlb_update_acc_frz = 0; 856 m_cost_data_tlb_update_dirty_frz = 0; 857 m_cost_ins_tlb_occup_cache_frz = 0; 858 m_cost_data_tlb_occup_cache_frz = 0; 859 860 m_cpt_ins_tlb_inval = 0; 861 m_cpt_data_tlb_inval = 0; 862 m_cost_ins_tlb_inval_frz = 0; 863 m_cost_data_tlb_inval_frz = 0; 864 865 m_cpt_cc_broadcast = 0; 866 867 m_cost_updt_data_frz = 0; 868 m_cost_inval_ins_frz = 0; 869 m_cost_inval_data_frz = 0; 870 m_cost_broadcast_frz = 0; 871 872 m_cpt_cc_cleanup_data = 0; 873 m_cpt_cc_cleanup_ins = 0; 874 875 m_cpt_itlbmiss_transaction = 0; 876 m_cpt_itlb_ll_transaction = 0; 877 m_cpt_itlb_sc_transaction = 0; 878 m_cpt_dtlbmiss_transaction = 0; 879 m_cpt_dtlb_ll_transaction = 0; 880 m_cpt_dtlb_sc_transaction = 0; 881 m_cpt_dtlb_ll_dirty_transaction = 0; 882 m_cpt_dtlb_sc_dirty_transaction = 0; 883 884 m_cost_itlbmiss_transaction = 0; 885 m_cost_itlb_ll_transaction = 0; 886 m_cost_itlb_sc_transaction = 0; 887 m_cost_dtlbmiss_transaction = 0; 888 m_cost_dtlb_ll_transaction = 0; 889 m_cost_dtlb_sc_transaction = 0; 890 m_cost_dtlb_ll_dirty_transaction = 0; 891 m_cost_dtlb_sc_dirty_transaction = 0; 849 m_cpt_dcache_data_read = 0; 850 m_cpt_dcache_data_write = 0; 851 m_cpt_dcache_dir_read = 0; 852 m_cpt_dcache_dir_write = 0; 853 m_cpt_icache_data_read = 0; 854 m_cpt_icache_data_write = 0; 855 m_cpt_icache_dir_read = 0; 856 m_cpt_icache_dir_write = 0; 857 858 m_cpt_frz_cycles = 0; 859 m_cpt_total_cycles = 0; 860 m_cpt_stop_simulation = 0; 861 862 m_cpt_data_miss = 0; 863 m_cpt_data_write = 0; 864 m_cpt_data_sc = 0; 865 m_cpt_data_write_back = 0; 866 m_cpt_data_write_miss_ncc = 0; 867 m_cpt_data_cleanup = 0; 868 m_cpt_data_cleanup_dirty = 0; 869 m_cpt_words_dirty = 0; 870 m_cpt_ins_miss = 0; 871 m_cpt_unc_read = 0; 872 m_cpt_write_cached = 0; 873 m_cpt_ins_read = 0; 874 875 m_cost_write_frz = 0; 876 m_cost_data_miss_frz = 0; 877 m_cost_unc_read_frz = 0; 878 m_cost_ins_miss_frz = 0; 879 880 m_cpt_imiss_transaction = 0; 881 m_cpt_dmiss_transaction = 0; 882 m_cpt_unc_transaction = 0; 883 m_cpt_write_transaction = 0; 884 m_cpt_icache_unc_transaction = 0; 885 886 m_cost_imiss_transaction = 0; 887 m_cost_dmiss_transaction = 0; 888 m_cost_unc_transaction = 0; 889 m_cost_write_transaction = 0; 890 m_cost_icache_unc_transaction = 0; 891 m_length_write_transaction = 0; 892 893 m_cpt_ins_tlb_read = 0; 894 m_cpt_ins_tlb_miss = 0; 895 m_cpt_ins_tlb_update_acc = 0; 896 897 m_cpt_data_tlb_read = 0; 898 m_cpt_data_tlb_miss = 0; 899 m_cpt_data_tlb_update_acc = 0; 900 m_cpt_data_tlb_update_dirty = 0; 901 m_cpt_ins_tlb_hit_dcache = 0; 902 m_cpt_data_tlb_hit_dcache = 0; 903 m_cpt_ins_tlb_occup_cache = 0; 904 m_cpt_data_tlb_occup_cache = 0; 905 906 m_cost_ins_tlb_miss_frz = 0; 907 m_cost_data_tlb_miss_frz = 0; 908 m_cost_ins_tlb_update_acc_frz = 0; 909 m_cost_data_tlb_update_acc_frz = 0; 910 m_cost_data_tlb_update_dirty_frz = 0; 911 m_cost_ins_tlb_occup_cache_frz = 0; 912 m_cost_data_tlb_occup_cache_frz = 0; 913 914 m_cpt_ins_tlb_inval = 0; 915 m_cpt_data_tlb_inval = 0; 916 m_cost_ins_tlb_inval_frz = 0; 917 m_cost_data_tlb_inval_frz = 0; 918 919 m_cpt_cc_broadcast = 0; 920 921 m_cost_updt_data_frz = 0; 922 m_cost_inval_ins_frz = 0; 923 m_cost_inval_data_frz = 0; 924 m_cost_broadcast_frz = 0; 925 926 m_cpt_cc_cleanup_data = 0; 927 m_cpt_cc_cleanup_ins = 0; 928 929 m_cpt_itlbmiss_transaction = 0; 930 m_cpt_itlb_ll_transaction = 0; 931 m_cpt_itlb_sc_transaction = 0; 932 m_cpt_dtlbmiss_transaction = 0; 933 m_cpt_dtlb_ll_transaction = 0; 934 m_cpt_dtlb_sc_transaction = 0; 935 m_cpt_dtlb_ll_dirty_transaction = 0; 936 m_cpt_dtlb_sc_dirty_transaction = 0; 937 938 m_cost_itlbmiss_transaction = 0; 939 m_cost_itlb_ll_transaction = 0; 940 m_cost_itlb_sc_transaction = 0; 941 m_cost_dtlbmiss_transaction = 0; 942 m_cost_dtlb_ll_transaction = 0; 943 m_cost_dtlb_sc_transaction = 0; 944 m_cost_dtlb_ll_dirty_transaction = 0; 945 m_cost_dtlb_sc_dirty_transaction = 0; 892 946 /* 893 947 m_cpt_dcache_frz_cycles = 0; … … 910 964 return; 911 965 } 966 /*ODDCP*/ 967 968 /*std::cout << "r_dcache_cc_send_req = " << r_dcache_cc_send_req.read() << std::endl; 969 std::cout << "r_icache_cc_send_req = " << r_icache_cc_send_req.read() << std::endl;*/ 912 970 913 971 // Response FIFOs default values … … 919 977 bool vci_rsp_fifo_dcache_put = false; 920 978 uint32_t vci_rsp_fifo_dcache_data = 0; 979 980 // FIFO for cleanup data updt 981 bool cleanup_data_updt_fifo_dcache_get = false; 982 bool cleanup_data_updt_fifo_dcache_put = false; 983 uint32_t cleanup_data_updt_fifo_dcache_data = 0; 921 984 922 985 // updt fifo … … 928 991 929 992 #ifdef INSTRUMENTATION 930 m_cpt_fsm_dcache [r_dcache_fsm.read()] ++;931 m_cpt_fsm_icache [r_icache_fsm.read()] ++;932 m_cpt_fsm_cmd [r_vci_cmd_fsm.read()] ++;933 m_cpt_fsm_rsp [r_vci_rsp_fsm.read()] ++;934 m_cpt_fsm_ tgt [r_tgt_fsm.read()] ++;935 m_cpt_fsm_c leanup [r_cleanup_cmd_fsm.read()] ++;993 m_cpt_fsm_dcache [r_dcache_fsm.read() ] ++; 994 m_cpt_fsm_icache [r_icache_fsm.read() ] ++; 995 m_cpt_fsm_cmd [r_vci_cmd_fsm.read() ] ++; 996 m_cpt_fsm_rsp [r_vci_rsp_fsm.read() ] ++; 997 m_cpt_fsm_cc_send [r_cc_send_fsm.read() ] ++; 998 m_cpt_fsm_cc_receive [r_cc_receive_fsm.read()] ++; 936 999 #endif 937 1000 … … 1015 1078 { 1016 1079 // coherence interrupt 1017 if ( r_cc_receive_icache_req.read() 1080 if ( r_cc_receive_icache_req.read()) 1018 1081 { 1019 1082 r_icache_fsm = ICACHE_CC_CHECK; … … 1084 1147 1085 1148 // We register processor request 1149 ///*ODCCP*/ std::cout << "DEBUG IREQ.ADDR = " << std::hex << m_ireq.addr << std::dec << " | on " << name() << std::endl; 1086 1150 r_icache_vaddr_save = m_ireq.addr; 1087 1151 … … 1091 1155 1092 1156 #ifdef INSTRUMENTATION 1093 m_cpt_i tlb_read++;1157 m_cpt_ins_tlb_read++; 1094 1158 #endif 1095 1159 tlb_hit = r_itlb.translate( m_ireq.addr, … … 1166 1230 1167 1231 #ifdef INSTRUMENTATION 1168 m_cpt_i tlb_miss++;1232 m_cpt_ins_tlb_miss++; 1169 1233 #endif 1170 1234 r_icache_fsm = ICACHE_TLB_WAIT; … … 1184 1248 1185 1249 #ifdef INSTRUMENTATION 1186 m_cpt_i cache_miss++;1250 m_cpt_ins_miss++; 1187 1251 #endif 1188 1252 // we request a VCI transaction … … 1309 1373 &state ); 1310 1374 1311 if ( state == CACHE_SLOT_STATE_VALID ) // inval required1375 if ( state == CACHE_SLOT_STATE_VALID_CC ) // inval required 1312 1376 { 1313 1377 // request cleanup … … 1390 1454 1391 1455 #ifdef INSTRUMENTATION 1392 m_cpt_i tlb_read++;1456 m_cpt_ins_tlb_read++; 1393 1457 #endif 1394 1458 hit = r_itlb.translate(r_dcache_save_wdata.read(), … … 1410 1474 1411 1475 #ifdef INSTRUMENTATION 1412 m_cpt_i tlb_miss++;1476 m_cpt_ins_tlb_miss++; 1413 1477 #endif 1414 1478 r_icache_tlb_miss_req = true; … … 1437 1501 &word); 1438 1502 1439 if ( state == CACHE_SLOT_STATE_VALID ) // inval to be done1503 if ( state == CACHE_SLOT_STATE_VALID_CC ) // inval to be done 1440 1504 { 1441 1505 r_icache_miss_way = way; … … 1696 1760 r_icache_miss_way.read(), 1697 1761 r_icache_miss_set.read(), 1698 CACHE_SLOT_STATE_VALID );1762 CACHE_SLOT_STATE_VALID_CC ); 1699 1763 #if DEBUG_ICACHE 1700 1764 if ( m_debug_activated ) … … 1840 1904 r_icache_cc_set = set; 1841 1905 1842 if ( state == CACHE_SLOT_STATE_VALID ) // hit1906 if ( state == CACHE_SLOT_STATE_VALID_CC) // hit 1843 1907 { 1844 1908 // need to update the cache state … … 1885 1949 { 1886 1950 std::cout << " <PROC " << name() 1887 << " ICACHE_ CC_INVAL> slot returns to empty state"1951 << " ICACHE_//CC_INVAL> slot returns to empty state" 1888 1952 << " set = " << r_icache_cc_set.read() 1889 1953 << " / way = " << r_icache_cc_way.read() << std::endl; … … 1894 1958 m_cpt_icache_dir_read++; 1895 1959 #endif 1896 if (r_icache_cc_need_write.read()) 1897 {1898 r_icache.write_dir( 0,1899 r_icache_cc_way.read(),1900 r_icache_cc_set.read(),1901 CACHE_SLOT_STATE_EMPTY );1902 // no need to write in the cache anymore1903 r_icache_cc_need_write = false;1904 }1905 1960 1961 if (r_icache_cc_need_write.read()) 1962 { 1963 r_icache.write_dir( 0, 1964 r_icache_cc_way.read(), 1965 r_icache_cc_set.read(), 1966 CACHE_SLOT_STATE_EMPTY ); 1967 // no need to write in the cache anymore 1968 r_icache_cc_need_write = false; 1969 } 1906 1970 // multicast acknowledgement 1907 1971 // send a request to cc_send_fsm … … 2001 2065 m_cpt_icache_dir_write++; 2002 2066 #endif 2003 2004 2067 if (r_icache_cc_need_write.read()) 2068 { 2005 2069 r_icache.write_dir( r_icache_cc_way.read(), 2006 2070 r_icache_cc_set.read(), 2007 2071 CACHE_SLOT_STATE_ZOMBI ); 2008 // no need to write in the cache anymore2072 // no need to write in the cache anymore 2009 2073 r_icache_cc_need_write = false; 2010 2074 } … … 2174 2238 &tlb_set ); 2175 2239 #ifdef INSTRUMENTATION 2176 m_cpt_d tlb_read++;2240 m_cpt_data_tlb_read++; 2177 2241 #endif 2178 2242 } … … 2239 2303 size_t way = r_dcache_save_cache_way.read(); 2240 2304 size_t set = r_dcache_save_cache_set.read(); 2241 2242 if ( r_dcache_in_tlb[way*m_dcache_sets+set] ) 2305 if ( r_dcache_content_state[way*m_dcache_sets+set] == LINE_CACHE_IN_TLB ) 2243 2306 { 2244 2307 tlb_inval_required = true; … … 2246 2309 r_dcache_tlb_inval_line = r_dcache_save_paddr.read()>> 2247 2310 (uint32_log2(m_dcache_words<<2)); 2248 r_dcache_in_tlb[way*m_dcache_sets+set] = false;2249 } 2250 else if ( r_dcache_cont ains_ptd[way*m_dcache_sets+set])2311 r_dcache_content_state[way*m_dcache_sets+set] = LINE_CACHE_DATA_NOT_DIRTY; 2312 } 2313 else if ( r_dcache_content_state[way*m_dcache_sets+set] == LINE_CACHE_CONTAINS_PTD ) 2251 2314 { 2252 2315 r_itlb.reset(); 2253 2316 r_dtlb.reset(); 2254 r_dcache_contains_ptd[way*m_dcache_sets+set] = false;2317 r_dcache_content_state[way*m_dcache_sets+set] = LINE_CACHE_DATA_NOT_DIRTY; 2255 2318 } 2256 2319 … … 2283 2346 r_dcache_save_wdata.read(), 2284 2347 r_dcache_save_cacheable.read() ); 2285 #ifdef INSTRUMENTATION2348 /*#ifdef INSTRUMENTATION 2286 2349 m_cpt_wbuf_write++; 2287 #endif 2350 #endif*/ 2288 2351 if ( not wok ) // miss if write buffer full 2289 2352 { … … 2588 2651 if ( not (r_mmu_mode.read() & DATA_CACHE_MASK) ) cacheable = false; 2589 2652 else cacheable = tlb_flags.c; 2590 2591 2653 // access rights checking 2592 2654 if ( not tlb_flags.u and (m_dreq.mode == iss_t::MODE_USER)) … … 2658 2720 { 2659 2721 #ifdef INSTRUMENTATION 2660 m_cpt_dcache_miss++; 2661 #endif 2662 // request a VCI DMISS transaction 2722 m_cpt_data_miss++; 2723 #endif 2663 2724 r_dcache_vci_paddr = paddr; 2664 2725 r_dcache_vci_miss_req = true; 2665 2726 r_dcache_miss_type = PROC_MISS; 2666 2727 r_dcache_fsm = DCACHE_MISS_SELECT; 2728 2729 /*ODCCP*/ // if tlb's flag cc egal 0 that means line is no coherent 2730 bool ncc = ((tlb_flags.cc == 0) and (r_mmu_mode.read() & DATA_TLB_MASK)); 2731 2732 if(ncc) 2733 { 2734 r_dcache_miss_no_coherent = true; 2667 2735 #if DEBUG_DCACHE 2668 2736 if ( m_debug_activated ) 2669 2737 std::cout << " <PROC " << name() << " DCACHE_IDLE>" 2670 << " READ MISS in dcache"2738 << " READ MISS NCC in dcache" 2671 2739 << " / PADDR = " << std::hex << paddr << std::endl; 2672 2740 #endif 2741 } 2742 else 2743 { 2744 r_dcache_miss_no_coherent = false; 2745 #if DEBUG_DCACHE 2746 if ( m_debug_activated ) 2747 std::cout << " <PROC " << name() << " DCACHE_IDLE>" 2748 << " READ MISS CC in dcache" 2749 << " / PADDR = " << std::hex << paddr << std::endl; 2750 #endif 2751 } 2673 2752 } 2674 2753 else if (cache_state == CACHE_SLOT_STATE_ZOMBI ) // pending cleanup … … 2765 2844 m_cpt_data_write++; 2766 2845 #endif 2846 // check if line is ncc or cc. 2847 bool ncc = ((tlb_flags.cc == 0) and (r_mmu_mode.read() & DATA_TLB_MASK)); 2848 2767 2849 // cleaning llsc buffer if address matching 2768 2850 if ( paddr == r_dcache_llsc_paddr.read() ) … … 2770 2852 2771 2853 // response to processor 2772 m_drsp.valid = true;2773 2774 2854 // activating P1 stage 2775 wbuf_request = true; 2776 updt_request = (cache_state == CACHE_SLOT_STATE_VALID); 2855 if( (cache_state != CACHE_SLOT_STATE_ZOMBI) && (cache_state != CACHE_SLOT_STATE_EMPTY) && (cacheable) ) 2856 { 2857 m_drsp.valid = true; 2858 2859 /*ODCCP*/ // if ncc we write locally the new data 2860 if (ncc) 2861 { 2862 #if DEBUG_DCACHE 2863 if ( m_debug_activated ) 2864 { 2865 std::cout << " <PROC " << name() 2866 << " DCACHE_IDLE> WRITE HIT NCC in dcache" 2867 << " : PADDR = " << std::hex << paddr << std::endl; 2868 } 2869 #endif 2870 m_cpt_data_write_back++; 2871 wbuf_request = false; 2872 r_dcache_content_state[cache_way*m_dcache_sets+cache_set] = LINE_CACHE_DATA_DIRTY; 2873 2874 /*STATS DIRTY*/ 2875 dirty_stats[(cache_way * m_dcache_sets + cache_set) * m_dcache_words + cache_word] = true; 2876 2877 updt_request = (cache_state == CACHE_SLOT_STATE_VALID_NCC) or (cache_state == CACHE_SLOT_STATE_VALID_CC); 2878 2879 } 2880 else 2881 { 2882 assert((cache_state != CACHE_SLOT_STATE_VALID_NCC) and "ODCCP/RWT : IMPOSSIBLE STATE NCC HERE !"); 2883 wbuf_request = true; 2884 updt_request = (cache_state == CACHE_SLOT_STATE_VALID_CC)or(cache_state == CACHE_SLOT_STATE_VALID_NCC); 2885 } 2886 } 2887 /*ODCCP We stall proc when Write NCC on line ZOMBI until line becomes not ZOMBI*/ 2888 else if( (cache_state == CACHE_SLOT_STATE_ZOMBI) && (ncc) && (cacheable) ) 2889 { 2890 #if DEBUG_DCACHE 2891 if ( m_debug_activated ) 2892 { 2893 std::cout << " <PROC " << name() 2894 << " DCACHE_IDLE> WRITE NCC on ZOMBI line in dcache" 2895 << " : PADDR = " << std::hex << paddr << std::endl; 2896 } 2897 #endif 2898 m_drsp.valid = false; 2899 r_dcache_fsm = DCACHE_IDLE; 2900 } 2901 #if FETCH_ON_WRITE_ENABLE 2902 /*ODCCP*/ // IF Fetch-on-Write is enabled, when a write NCC miss cache L1 fetch the missing line before writting it. 2903 else if( (cache_state == CACHE_SLOT_STATE_EMPTY) && (ncc) && (cacheable) ) 2904 { 2905 #if DEBUG_DCACHE 2906 if ( m_debug_activated ) 2907 { 2908 std::cout << " <PROC " << name() 2909 << " DCACHE_IDLE> WRITE MISS NCC in dcache" 2910 << " : PADDR = " << std::hex << paddr << std::endl; 2911 } 2912 #endif 2913 // request a VCI DMISS transaction 2914 r_dcache_vci_paddr = paddr; 2915 r_dcache_vci_miss_req = true; 2916 r_dcache_miss_type = PROC_MISS; 2917 r_dcache_fsm = DCACHE_MISS_SELECT; 2918 m_cpt_data_write_miss_ncc++; 2919 r_dcache_miss_no_coherent = true; 2920 } 2921 #endif 2922 else 2923 { 2924 m_drsp.valid = true; 2925 wbuf_request = true; 2926 updt_request = (cache_state == CACHE_SLOT_STATE_VALID_CC)or(cache_state == CACHE_SLOT_STATE_VALID_NCC); 2927 } 2777 2928 } 2778 2929 } // end WRITE … … 2867 3018 bool bypass; 2868 3019 paddr_t pte_paddr; 3020 3021 //r_dcache.printTrace(); 2869 3022 2870 3023 // evaluate bypass in order to skip first level page table access … … 2877 3030 bypass = r_dtlb.get_bypass(r_dcache_tlb_vaddr.read(), &ptba); 2878 3031 } 2879 3032 3033 2880 3034 if ( not bypass ) // Try to read PTE1/PTD1 in dcache 2881 3035 { 2882 3036 pte_paddr = (((paddr_t)r_mmu_ptpr.read()) << (INDEX1_NBITS+2)) | 2883 3037 ((((paddr_t)r_dcache_tlb_vaddr.read()) >> PAGE_M_NBITS) << 2); 2884 3038 r_dcache_tlb_paddr = pte_paddr; 2885 3039 r_dcache_fsm = DCACHE_TLB_PTE1_GET; … … 2888 3042 { 2889 3043 pte_paddr = (paddr_t)ptba << PAGE_K_NBITS | 2890 3044 (paddr_t)(r_dcache_tlb_vaddr.read()&PTD_ID2_MASK)>>(PAGE_K_NBITS-3); 2891 3045 r_dcache_tlb_paddr = pte_paddr; 2892 3046 r_dcache_fsm = DCACHE_TLB_PTE2_GET; … … 2903 3057 << " / ptpr = " << (((paddr_t)r_mmu_ptpr.read()) << (INDEX1_NBITS+2)) 2904 3058 << " / BYPASS = " << bypass 3059 << " / PTBA = " << ptba 2905 3060 << " / PTE_ADR = " << pte_paddr << std::endl; 2906 3061 } … … 2935 3090 m_cpt_dcache_dir_read++; 2936 3091 #endif 2937 if ( cache_state == CACHE_SLOT_STATE_VALID ) // hit in dcache 3092 /*ODCCP*/ 3093 assert((cache_state != CACHE_SLOT_STATE_VALID_NCC) and "DCACHE_TLB_PTE1_GET : IMPOSSIBLE NCC HERE"); 3094 if ( cache_state == CACHE_SLOT_STATE_VALID_CC ) // hit in dcache 2938 3095 { 2939 3096 if ( not (entry & PTE_V_MASK) ) // unmapped … … 2972 3129 { 2973 3130 // mark the cache line ac containing a PTD 2974 r_dcache_cont ains_ptd[m_dcache_sets*way+set] = true;3131 r_dcache_content_state[way*m_dcache_sets+set] = LINE_CACHE_CONTAINS_PTD; 2975 3132 2976 3133 // register bypass … … 3007 3164 else // PTE1 : we must update the TLB 3008 3165 { 3009 r_dcache_ in_tlb[m_icache_sets*way+set] = true;3166 r_dcache_content_state[m_icache_sets*way+set] = LINE_CACHE_IN_TLB; 3010 3167 r_dcache_tlb_pte_flags = entry; 3011 3168 r_dcache_tlb_cache_way = way; … … 3065 3222 &set ); 3066 3223 #ifdef INSTRUMENTATION 3067 m_cpt_i tlb_read++;3224 m_cpt_ins_tlb_read++; 3068 3225 #endif 3069 3226 } … … 3075 3232 &set ); 3076 3233 #ifdef INSTRUMENTATION 3077 m_cpt_d tlb_read++;3234 m_cpt_data_tlb_read++; 3078 3235 #endif 3079 3236 } … … 3151 3308 nline ); 3152 3309 #ifdef INSTRUMENTATION 3153 m_cpt_i tlb_write++;3310 m_cpt_ins_tlb_update_acc++; 3154 3311 #endif 3155 3312 … … 3175 3332 nline ); 3176 3333 #ifdef INSTRUMENTATION 3177 m_cpt_d tlb_write++;3334 m_cpt_data_tlb_update_acc++; 3178 3335 #endif 3179 3336 … … 3218 3375 3219 3376 uint32_t pte_flags; 3220 uint32_t pte_ppn ;3377 uint32_t pte_ppn=0; 3221 3378 size_t way; 3222 3379 size_t set; … … 3235 3392 m_cpt_dcache_dir_read++; 3236 3393 #endif 3237 if ( cache_state == CACHE_SLOT_STATE_VALID ) // hit in dcache 3394 /*ODCCP*/ 3395 assert((cache_state != CACHE_SLOT_STATE_VALID_NCC) and "DCACHE_TLB_PTE2_GET : IMPOSSIBLE NCC HERE"); 3396 if (cache_state == CACHE_SLOT_STATE_VALID_CC) // hit in dcache 3238 3397 { 3239 3398 if ( not (pte_flags & PTE_V_MASK) ) // unmapped … … 3267 3426 else // mapped : we must update the TLB 3268 3427 { 3269 r_dcache_ in_tlb[m_dcache_sets*way+set] = true;3428 r_dcache_content_state[m_dcache_sets*way+set] = LINE_CACHE_IN_TLB; 3270 3429 r_dcache_tlb_pte_flags = pte_flags; 3271 3430 r_dcache_tlb_pte_ppn = pte_ppn; … … 3332 3491 &set ); 3333 3492 #ifdef INSTRUMENTATION 3334 m_cpt_i tlb_read++;3493 m_cpt_ins_tlb_read++; 3335 3494 #endif 3336 3495 } … … 3342 3501 &set ); 3343 3502 #ifdef INSTRUMENTATION 3344 m_cpt_d tlb_read++;3503 m_cpt_data_tlb_read++; 3345 3504 #endif 3346 3505 } … … 3419 3578 nline ); 3420 3579 #ifdef INSTRUMENTATION 3421 m_cpt_i tlb_write++;3580 m_cpt_ins_tlb_update_acc++; 3422 3581 #endif 3423 3582 … … 3443 3602 nline ); 3444 3603 #ifdef INSTRUMENTATION 3445 m_cpt_d tlb_write++;3604 m_cpt_data_tlb_update_acc++; 3446 3605 #endif 3447 3606 … … 3656 3815 &state ); 3657 3816 3658 if ( state == CACHE_SLOT_STATE_VALID ) // inval required3817 if ( state == CACHE_SLOT_STATE_VALID_CC ) // inval required 3659 3818 { 3660 3819 // request cleanup … … 3667 3826 r_dcache_miss_way = way; 3668 3827 r_dcache_miss_set = set; 3828 r_dcache_cleanup_ncc = false; 3829 r_dcache_cc_cleanup_updt_data = false; 3669 3830 r_dcache_fsm = DCACHE_XTN_DC_FLUSH_GO; 3831 } 3832 else if ( state == CACHE_SLOT_STATE_VALID_NCC ) 3833 { 3834 // request cleanup 3835 r_dcache_cc_send_req = true; 3836 r_dcache_cc_send_nline = tag * m_dcache_sets + set; 3837 r_dcache_cc_send_way = way; 3838 r_dcache_cc_send_type = CC_TYPE_CLEANUP; 3839 3840 // goes to DCACHE_XTN_DC_FLUSH_GO to inval directory 3841 r_dcache_miss_way = way; 3842 r_dcache_miss_set = set; 3843 r_dcache_cleanup_ncc = true; 3844 3845 if (r_dcache_content_state[m_dcache_sets*way+set] == LINE_CACHE_DATA_NOT_DIRTY) 3846 { 3847 r_dcache_cc_cleanup_updt_data = false; 3848 r_dcache_fsm = DCACHE_XTN_DC_FLUSH_GO; 3849 } 3850 else // if line is dirty we save the data values for send into cleanup data 3851 { 3852 r_dcache_xtn_flush_addr_data = (tag * m_dcache_sets + set) * m_dcache_words * 4; 3853 r_dcache_xtn_flush_data_cpt = 0; 3854 r_dcache_cc_cleanup_updt_data = true; 3855 r_dcache_fsm = DCACHE_XTN_DC_FLUSH_DATA; 3856 3857 /*STATS DIRTY*/ 3858 for (size_t w = 0; w < m_dcache_words; w++) 3859 { 3860 if(dirty_stats[(way * m_dcache_sets + set) * m_dcache_words + w] == true) 3861 m_cpt_words_dirty++; 3862 } 3863 } 3670 3864 } 3671 3865 else if ( r_dcache_flush_count.read() == … … 3685 3879 } 3686 3880 //////////////////////////// 3881 case DCACHE_XTN_DC_FLUSH_DATA: /*ODCCP*/ // In this state we save data values into cc_send_data_fifo for 3882 // send cleanup with data 3883 { 3884 uint32_t rdata; 3885 size_t way; 3886 size_t set; 3887 size_t word; 3888 r_dcache.read_neutral(r_dcache_xtn_flush_addr_data.read(), 3889 &rdata, 3890 &way, 3891 &set, 3892 &word); 3893 if(r_cc_send_data_fifo.wok()) 3894 { 3895 r_dcache_xtn_flush_addr_data = r_dcache_xtn_flush_addr_data.read() + 4; 3896 3897 cleanup_data_updt_fifo_dcache_get = false; 3898 cleanup_data_updt_fifo_dcache_put = true; 3899 cleanup_data_updt_fifo_dcache_data = rdata; 3900 3901 r_dcache_xtn_flush_data_cpt = r_dcache_xtn_flush_data_cpt + 1; 3902 if(r_dcache_xtn_flush_data_cpt.read() == (m_dcache_words - 1)) 3903 { 3904 r_dcache_xtn_flush_data_cpt = 0; 3905 r_dcache_fsm = DCACHE_XTN_DC_FLUSH_GO; 3906 } 3907 } 3908 break; 3909 3910 } 3911 //////////////////////////// 3687 3912 case DCACHE_XTN_DC_FLUSH_GO: // Switch the cache slot to ZOMBI state 3688 3913 // and reset directory extension. … … 3692 3917 size_t set = r_dcache_miss_set.read(); 3693 3918 3694 r_dcache_in_tlb[m_dcache_sets*way+set] = false; 3695 r_dcache_contains_ptd[m_dcache_sets*way+set] = false; 3919 r_dcache_content_state[m_dcache_sets*way+set] = LINE_CACHE_DATA_NOT_DIRTY; 3696 3920 3697 3921 #ifdef INSTRUMENTATION … … 3736 3960 3737 3961 #ifdef INSTRUMENTATION 3738 m_cpt_d tlb_read++;3962 m_cpt_data_tlb_read++; 3739 3963 #endif 3740 3964 hit = r_dtlb.translate( r_dcache_save_wdata.read(), … … 3756 3980 3757 3981 #ifdef INSTRUMENTATION 3758 m_cpt_d tlb_miss++;3982 m_cpt_data_tlb_miss++; 3759 3983 #endif 3760 3984 r_dcache_tlb_ins = false; // dtlb … … 3793 4017 &set, 3794 4018 &word ); 3795 3796 if ( state == CACHE_SLOT_STATE_VALID ) // inval to be done 3797 { 3798 r_dcache_xtn_way = way; 3799 r_dcache_xtn_set = set; 3800 r_dcache_fsm = DCACHE_XTN_DC_INVAL_GO; 4019 /*ODCCP*/ 4020 if ((state == CACHE_SLOT_STATE_VALID_CC) or (state == CACHE_SLOT_STATE_VALID_NCC)) // inval to be done 4021 { 4022 r_dcache_xtn_way = way; 4023 r_dcache_xtn_set = set; 4024 r_dcache_xtn_state = state; 4025 r_dcache_xtn_data_addr = r_dcache_save_paddr.read()&~0x3F; 4026 r_dcache_fsm = DCACHE_XTN_DC_INVAL_GO; 4027 3801 4028 } 3802 4029 else // miss : nothing to do … … 3812 4039 << " DCACHE_XTN_DC_INVAL_PA> Test hit in dcache" << std::hex 3813 4040 << " / PADDR = " << r_dcache_save_paddr.read() << std::dec 3814 << " / HIT = " << ( state == CACHE_SLOT_STATE_VALID)4041 << " / HIT = " << ((state == CACHE_SLOT_STATE_VALID_CC) or (state == CACHE_SLOT_STATE_VALID_NCC)) 3815 4042 << " / SET = " << set 3816 4043 << " / WAY = " << way << std::endl; 4044 //r_dcache.printTrace(); 3817 4045 } 3818 4046 #endif … … 3826 4054 if ( not r_dcache_cc_send_req.read() ) // blocked until previous cc_send request is sent 3827 4055 { 4056 int state = r_dcache_xtn_state.read(); 3828 4057 size_t way = r_dcache_xtn_way.read(); 3829 4058 size_t set = r_dcache_xtn_set.read(); … … 3833 4062 m_cpt_dcache_dir_write++; 3834 4063 #endif 3835 r_dcache.write_dir( way, 3836 set, 3837 CACHE_SLOT_STATE_ZOMBI ); 4064 if(state == CACHE_SLOT_STATE_VALID_CC) 4065 { 4066 r_dcache.write_dir( way, 4067 set, 4068 CACHE_SLOT_STATE_ZOMBI ); 4069 } 3838 4070 3839 4071 // request cleanup … … 3842 4074 r_dcache_cc_send_way = way; 3843 4075 r_dcache_cc_send_type = CC_TYPE_CLEANUP; 4076 r_dcache_cleanup_ncc = false; 4077 4078 /*ODCCP*/ 4079 if( (state == CACHE_SLOT_STATE_VALID_NCC) /*and (r_dcache_content_state[way*m_dcache_sets+set] == LINE_CACHE_DATA_DIRTY)*/ ) 4080 { 4081 r_dcache_cleanup_ncc = true; 4082 /*ODCCP*/ // If line is dirty we read data values for send cleanup with data 4083 if (r_dcache_content_state[way*m_dcache_sets+set] == LINE_CACHE_DATA_DIRTY) 4084 { 4085 r_dcache_cc_cleanup_updt_data = true; 4086 r_dcache_fsm = DCACHE_XTN_DC_INVAL_DATA; 4087 m_cpt_data_cleanup_dirty ++; 4088 4089 /*STATS DIRTY*/ 4090 for (size_t w = 0; w < m_dcache_words; w++) 4091 { 4092 if(dirty_stats[(way * m_dcache_sets + set) * m_dcache_words + w] == true) 4093 m_cpt_words_dirty++; 4094 } 4095 } 4096 else 4097 { 4098 r_dcache.write_dir( way, 4099 set, 4100 CACHE_SLOT_STATE_ZOMBI ); 4101 r_dcache_cc_cleanup_updt_data = false; 4102 r_dcache_fsm = DCACHE_IDLE; 4103 m_drsp.valid = true; 4104 } 4105 } 3844 4106 3845 4107 // possible itlb & dtlb invalidate 3846 if ( r_dcache_in_tlb[way*m_dcache_sets+set])4108 else if ( r_dcache_content_state[way*m_dcache_sets+set] == LINE_CACHE_IN_TLB ) 3847 4109 { 3848 4110 r_dcache_tlb_inval_line = nline; … … 3850 4112 r_dcache_fsm_scan_save = DCACHE_XTN_DC_INVAL_END; 3851 4113 r_dcache_fsm = DCACHE_INVAL_TLB_SCAN; 3852 r_dcache_ in_tlb[way*m_dcache_sets+set] = false;3853 } 3854 else if ( r_dcache_cont ains_ptd[way*m_dcache_sets+set])4114 r_dcache_content_state[way*m_dcache_sets+set] = LINE_CACHE_DATA_NOT_DIRTY; 4115 } 4116 else if ( r_dcache_content_state[way*m_dcache_sets+set] == LINE_CACHE_CONTAINS_PTD) 3855 4117 { 3856 4118 r_itlb.reset(); 3857 4119 r_dtlb.reset(); 3858 r_dcache_cont ains_ptd[way*m_dcache_sets+set] = false;4120 r_dcache_content_state[way*m_dcache_sets+set] = LINE_CACHE_DATA_NOT_DIRTY; 3859 4121 r_dcache_fsm = DCACHE_IDLE; 3860 4122 m_drsp.valid = true; … … 3877 4139 break; 3878 4140 } 4141 4142 /*ODCCP*/ 4143 ////////////////////////////// 4144 case DCACHE_XTN_DC_INVAL_DATA: 4145 { 4146 4147 uint32_t rdata; 4148 size_t way; 4149 size_t set; 4150 size_t word; 4151 r_dcache.read_neutral(r_dcache_xtn_data_addr.read(), 4152 &rdata, 4153 &way, 4154 &set, 4155 &word); 4156 if(r_cc_send_data_fifo.wok()) 4157 { 4158 r_dcache_xtn_data_addr = r_dcache_xtn_data_addr.read() + 4; 4159 4160 cleanup_data_updt_fifo_dcache_get = false; 4161 cleanup_data_updt_fifo_dcache_put = true; 4162 cleanup_data_updt_fifo_dcache_data = rdata; 4163 4164 r_dcache_xtn_data_cpt = r_dcache_xtn_data_cpt.read() + 1; 4165 /*ODCCP*/ // after read the last word we set the line as ZOMBI 4166 if(r_dcache_xtn_data_cpt.read() == (m_dcache_words - 1)) 4167 { 4168 r_dcache_xtn_data_cpt = 0; 4169 r_dcache_fsm = DCACHE_IDLE; 4170 r_dcache.write_dir( way, 4171 set, 4172 CACHE_SLOT_STATE_ZOMBI ); 4173 m_drsp.valid = true; 4174 } 4175 } 4176 break; 4177 } 4178 3879 4179 ////////////////////////////// 3880 4180 case DCACHE_XTN_DC_INVAL_END: // send response to processor XTN request … … 3909 4209 size_t set = 0; 3910 4210 paddr_t victim = 0; 4211 int state; 3911 4212 3912 4213 #ifdef INSTRUMENTATION … … 3919 4220 &found, 3920 4221 &cleanup ); 3921 4222 state = r_dcache.get_cache_state(way,set); 3922 4223 if ( found ) 3923 4224 { … … 3934 4235 r_dcache_cc_send_way = way; 3935 4236 r_dcache_cc_send_type = CC_TYPE_CLEANUP; 4237 4238 if( (state == CACHE_SLOT_STATE_VALID_NCC) ) 4239 { 4240 r_dcache_cleanup_ncc = true; 4241 4242 /*ODCCP*/ // if line is dirty we must save the data values 4243 if (r_dcache_content_state[way*m_dcache_sets+set] == LINE_CACHE_DATA_DIRTY) 4244 { 4245 r_dcache_cc_cleanup_updt_data = true; 4246 r_dcache_miss_data_addr = (victim*m_dcache_words)*4; 4247 r_dcache_fsm = DCACHE_MISS_DATA; 4248 m_cpt_data_cleanup_dirty ++; 4249 4250 /*STATS DIRTY*/ 4251 for (size_t w = 0; w < m_dcache_words; w++) 4252 { 4253 if(dirty_stats[(way * m_dcache_sets + set) * m_dcache_words + w] == true) 4254 m_cpt_words_dirty++; 4255 } 4256 } 4257 else 4258 { 4259 r_dcache_cc_cleanup_updt_data = false; 4260 } 4261 } 4262 else 4263 { 4264 r_dcache_cc_cleanup_updt_data = false; 4265 r_dcache_cleanup_ncc = false; 4266 } 3936 4267 } 3937 4268 else … … 3957 4288 } 3958 4289 /////////////////////// 4290 case DCACHE_MISS_DATA: 4291 { 4292 uint32_t rdata; 4293 size_t way; 4294 size_t set; 4295 size_t word; 4296 4297 r_dcache.read_neutral(r_dcache_miss_data_addr, 4298 &rdata, 4299 &way, 4300 &set, 4301 &word); 4302 if(r_cc_send_data_fifo.wok()) 4303 { 4304 r_dcache_miss_data_addr = r_dcache_miss_data_addr.read() + 4; 4305 4306 cleanup_data_updt_fifo_dcache_get = false; 4307 cleanup_data_updt_fifo_dcache_put = true; 4308 cleanup_data_updt_fifo_dcache_data = rdata; 4309 4310 r_dcache_miss_data_cpt = r_dcache_miss_data_cpt.read() + 1; 4311 if (r_dcache_miss_data_cpt.read() == m_dcache_words-1 ) 4312 { 4313 r_dcache_miss_data_cpt = 0; 4314 r_dcache_fsm = DCACHE_MISS_CLEAN; 4315 } 4316 } 4317 break; 4318 } 4319 /////////////////////// 3959 4320 case DCACHE_MISS_CLEAN: // switch the slot to ZOMBI state 3960 4321 // and possibly request itlb or dtlb invalidate … … 3982 4343 // if selective itlb & dtlb invalidate are required 3983 4344 // the miss response is not handled before invalidate completed 3984 if ( r_dcache_ in_tlb[way*m_dcache_sets+set])3985 { 3986 r_dcache_ in_tlb[way*m_dcache_sets+set] = false;4345 if ( r_dcache_content_state[way*m_dcache_sets+set] == LINE_CACHE_IN_TLB ) 4346 { 4347 r_dcache_content_state[way*m_dcache_sets+set] = LINE_CACHE_DATA_NOT_DIRTY; 3987 4348 r_dcache_tlb_inval_line = r_dcache_cc_send_nline; 3988 4349 r_dcache_tlb_inval_set = 0; … … 3990 4351 r_dcache_fsm = DCACHE_INVAL_TLB_SCAN; 3991 4352 } 3992 else if ( r_dcache_cont ains_ptd[way*m_dcache_sets+set])4353 else if ( r_dcache_content_state[way*m_dcache_sets+set] == LINE_CACHE_CONTAINS_PTD ) 3993 4354 { 3994 4355 r_itlb.reset(); 3995 4356 r_dtlb.reset(); 3996 r_dcache_cont ains_ptd[way*m_dcache_sets+set] = false;4357 r_dcache_content_state[way*m_dcache_sets+set] = LINE_CACHE_DATA_NOT_DIRTY; 3997 4358 r_dcache_fsm = DCACHE_MISS_WAIT; 3998 4359 } … … 4145 4506 r_dcache_cc_send_way = r_dcache_miss_way.read(); 4146 4507 r_dcache_cc_send_type = CC_TYPE_CLEANUP; 4508 4509 if (r_vci_rsp_read_data_miss_no_coherent.read() == true) 4510 { 4511 r_dcache_cleanup_ncc = true; 4512 r_dcache_cc_cleanup_updt_data = false; 4513 } 4514 else 4515 { 4516 r_dcache_cleanup_ncc = false; 4517 r_dcache_cc_cleanup_updt_data = false; 4518 } 4147 4519 4148 4520 #ifdef INSTRUMENTATION … … 4171 4543 m_cpt_dcache_dir_write++; 4172 4544 #endif 4173 r_dcache.write_dir( r_dcache_save_paddr.read(), 4174 r_dcache_miss_way.read(), 4175 r_dcache_miss_set.read(), 4176 CACHE_SLOT_STATE_VALID ); 4177 4545 size_t way = r_dcache_miss_way.read(); 4546 size_t set = r_dcache_miss_set.read(); 4547 4548 /*ODCCP*/ // if the read miss is on line NCC we set the state's line as VALID_NCC 4549 if (r_vci_rsp_read_data_miss_no_coherent.read() == true) 4550 { 4551 r_dcache.write_dir( r_dcache_save_paddr.read(), 4552 r_dcache_miss_way.read(), 4553 r_dcache_miss_set.read(), 4554 CACHE_SLOT_STATE_VALID_NCC ); 4555 r_vci_rsp_read_data_miss_no_coherent = false; 4178 4556 #if DEBUG_DCACHE 4179 4557 if ( m_debug_activated ) 4180 4558 std::cout << " <PROC " << name() 4181 << " DCACHE_MISS_DIR_UPDT> Switch slot to VALID state"4559 << " DCACHE_MISS_DIR_UPDT> Switch slot to VALID_NCC state" 4182 4560 << " PADDR = " << std::hex << r_dcache_save_paddr.read() 4183 4561 << " / WAY = " << std::dec << r_dcache_miss_way.read() 4184 4562 << " / SET = " << r_dcache_miss_set.read() << std::endl; 4185 4563 #endif 4564 } 4565 else 4566 { 4567 r_dcache.write_dir( r_dcache_save_paddr.read(), 4568 r_dcache_miss_way.read(), 4569 r_dcache_miss_set.read(), 4570 CACHE_SLOT_STATE_VALID_CC ); 4571 #if DEBUG_DCACHE 4572 if ( m_debug_activated ) 4573 std::cout << " <PROC " << name() 4574 << " DCACHE_MISS_DIR_UPDT> Switch slot to VALID_CC state" 4575 << " PADDR = " << std::hex << r_dcache_save_paddr.read() 4576 << " / WAY = " << std::dec << r_dcache_miss_way.read() 4577 << " / SET = " << r_dcache_miss_set.read() << std::endl; 4578 #endif 4579 } 4186 4580 // reset directory extension 4187 size_t way = r_dcache_miss_way.read(); 4188 size_t set = r_dcache_miss_set.read(); 4189 r_dcache_in_tlb[way*m_dcache_sets+set] = false; 4190 r_dcache_contains_ptd[way*m_dcache_sets+set] = false; 4581 /*ODCCP*/ // We set the new line as not dirty 4582 r_dcache_content_state[way*m_dcache_sets+set] = LINE_CACHE_DATA_NOT_DIRTY; 4583 4191 4584 } 4192 4585 if (r_dcache_miss_type.read()==PTE1_MISS) r_dcache_fsm = DCACHE_TLB_PTE1_GET; … … 4335 4728 &state ); 4336 4729 4337 assert( (state == CACHE_SLOT_STATE_VALID ) and4730 assert( (state == CACHE_SLOT_STATE_VALID_CC) and 4338 4731 "error in DCACHE_DIRTY_TLB_SET: the PTE should be in dcache" ); 4339 4732 … … 4447 4840 r_cc_receive_dcache_set.read(), 4448 4841 CACHE_SLOT_STATE_EMPTY); 4449 4842 4843 /*STATS DIRTY*/ 4844 for (size_t word = 0; word < m_dcache_words; word++) 4845 { 4846 dirty_stats[(r_cc_receive_dcache_way * m_dcache_sets + r_cc_receive_dcache_set) * m_dcache_words + word] = false; 4847 } 4848 4849 4450 4850 if ( (r_dcache_miss_set.read() == r_cc_receive_dcache_set.read()) and 4451 4851 (r_dcache_miss_way.read() == r_cc_receive_dcache_way.read()) ) … … 4516 4916 r_dcache_cc_way = way; 4517 4917 r_dcache_cc_set = set; 4518 4519 if ( state == CACHE_SLOT_STATE_VALID)// hit4918 /*ODCCP*/ 4919 if ((state == CACHE_SLOT_STATE_VALID_CC) or (state == CACHE_SLOT_STATE_VALID_NCC)) // hit 4520 4920 { 4521 4921 // need to update the cache state 4922 r_dcache_cleanup_ncc = false; 4522 4923 r_dcache_cc_need_write = true; 4523 4924 if (r_cc_receive_dcache_type.read() == CC_TYPE_UPDT) // hit update 4524 4925 { 4926 /*ODCCP*/ // we can't receive a CC_UPDT on a NCC line 4927 if (state == CACHE_SLOT_STATE_VALID_NCC) 4928 std::cout << "DCACHE_CC_CHECK : IMPOSSIBLE NCC STATE FOR CC_UPDT at cycle " << m_cpt_total_cycles << std::endl; 4929 assert((state != CACHE_SLOT_STATE_VALID_NCC) and "DCACHE_CC_CHECK : IMPOSSIBLE NCC STATE FOR CC_UPDT"); 4930 4525 4931 r_dcache_fsm = DCACHE_CC_UPDT; 4526 4932 r_dcache_cc_word = r_cc_receive_word_idx.read(); … … 4528 4934 else if (r_cc_receive_dcache_type.read() == CC_TYPE_INVAL) // hit inval 4529 4935 { 4530 r_dcache_fsm = DCACHE_CC_INVAL; 4936 if ( (state == CACHE_SLOT_STATE_VALID_NCC) ) 4937 { 4938 if (r_dcache_content_state[way*m_dcache_sets+set] == LINE_CACHE_DATA_DIRTY) 4939 m_cpt_data_cleanup_dirty ++; 4940 r_dcache_cc_state = state; 4941 r_dcache_cc_inval_addr = (paddr &~0x3F); 4942 r_dcache_cc_inval_data_cpt = 0; 4943 } 4944 else 4945 { 4946 r_dcache_cc_state = state; 4947 r_dcache_cc_inval_addr = (paddr &~0x3F); 4948 } 4949 r_dcache_fsm = DCACHE_CC_INVAL; 4531 4950 } 4532 4951 else if ( r_cc_receive_dcache_type.read() == CC_TYPE_BRDCAST) // hit broadcast 4533 4952 { 4953 assert((state != CACHE_SLOT_STATE_VALID_NCC) and "DCACHE_CC_CHECK : IMPOSSIBLE NCC STATE FOR CC_BROADCAST"); 4534 4954 r_dcache_fsm = DCACHE_CC_BROADCAST; 4535 4955 } … … 4559 4979 << " PADDR = " << std::hex << paddr 4560 4980 << " / TYPE = " << std::dec << r_cc_receive_dcache_type.read() 4561 << " / HIT = " << ( state == CACHE_SLOT_STATE_VALID) << std::endl;4981 << " / HIT = " << ((state == CACHE_SLOT_STATE_VALID_CC) or (state == CACHE_SLOT_STATE_VALID_NCC)) << std::endl; 4562 4982 } 4563 4983 #endif 4984 } 4985 break; 4986 } 4987 ///////////////////// 4988 case DCACHE_CC_INVAL_DATA: 4989 { 4990 uint32_t rdata; 4991 size_t way; 4992 size_t set; 4993 size_t word; 4994 r_dcache.read_neutral(r_dcache_cc_inval_addr.read(), 4995 &rdata, 4996 &way, 4997 &set, 4998 &word); 4999 if(r_cc_send_data_fifo.wok()) 5000 { 5001 r_dcache_cc_inval_addr = r_dcache_cc_inval_addr.read() + 4; 5002 5003 cleanup_data_updt_fifo_dcache_get = false; 5004 cleanup_data_updt_fifo_dcache_put = true; 5005 cleanup_data_updt_fifo_dcache_data = rdata; 5006 5007 r_dcache_cc_inval_data_cpt = r_dcache_cc_inval_data_cpt.read() + 1; 5008 /*ODCCP*/ // After reading the last word we switch slot to ZOMBI state 5009 if(r_dcache_cc_inval_data_cpt.read() == (m_dcache_words - 1)) 5010 { 5011 r_dcache_fsm = r_dcache_fsm_cc_save.read(); 5012 r_dcache.write_dir( way, 5013 set, 5014 CACHE_SLOT_STATE_ZOMBI ); 5015 #if DEBUG_DCACHE 5016 if ( m_debug_activated ) 5017 { 5018 std::cout << " <PROC " << name() 5019 << " DCACHE_CC_INVAL_DATA> Switch slot to ZOMBI state:" << std::dec 5020 << " / WAY = " << way 5021 << " / SET = " << set << std::endl; 5022 } 5023 #endif 5024 } 4564 5025 } 4565 5026 break; … … 4571 5032 size_t way = r_dcache_cc_way.read(); 4572 5033 size_t set = r_dcache_cc_set.read(); 4573 5034 int state = r_dcache_cc_state.read(); 4574 5035 if (r_dcache_cc_need_write.read()) 4575 5036 { 4576 if ( r_dcache_ in_tlb[way*m_dcache_sets+set] ) // selective TLB inval4577 { 4578 r_dcache_ in_tlb[way*m_dcache_sets+set] = false;5037 if ( r_dcache_content_state[way*m_dcache_sets+set] == LINE_CACHE_IN_TLB ) 5038 { 5039 r_dcache_content_state[way*m_dcache_sets+set] = LINE_CACHE_DATA_NOT_DIRTY; 4579 5040 r_dcache_tlb_inval_line = r_cc_receive_dcache_nline.read(); 4580 5041 r_dcache_tlb_inval_set = 0; … … 4585 5046 else 4586 5047 { 4587 if ( r_dcache_cont ains_ptd[way*m_dcache_sets+set] ) // TLB flush5048 if ( r_dcache_content_state[way*m_dcache_sets+set] == LINE_CACHE_CONTAINS_PTD ) 4588 5049 { 4589 5050 r_itlb.reset(); 4590 5051 r_dtlb.reset(); 4591 r_dcache_cont ains_ptd[way*m_dcache_sets+set] = false;5052 r_dcache_content_state[way*m_dcache_sets+set] = LINE_CACHE_DATA_NOT_DIRTY; 4592 5053 4593 5054 #if DEBUG_DCACHE 4594 if ( m_debug_activated ) 4595 { 4596 std::cout << " <PROC " << name() 4597 << " DCACHE_CC_INVAL> Flush DTLB & ITLB" << std::endl; 4598 } 4599 #endif 4600 } 4601 4602 r_dcache.write_dir( 0, 4603 way, 4604 set, 4605 CACHE_SLOT_STATE_EMPTY ); 4606 5055 if ( m_debug_activated ) 5056 { 5057 std::cout << " <PROC " << name() 5058 << " DCACHE_CC_INVAL> Flush DTLB & ITLB" << std::endl; 5059 } 5060 #endif 5061 } 5062 5063 if ( state == CACHE_SLOT_STATE_VALID_CC ) 5064 { 5065 r_dcache.write_dir( 0, 5066 way, 5067 set, 5068 CACHE_SLOT_STATE_EMPTY ); 5069 #if DEBUG_DCACHE 5070 if ( m_debug_activated ) 5071 { 5072 std::cout << " <PROC " << name() 5073 5074 << " DCACHE_CC_INVAL> Switch slot to EMPTY state:" << std::dec 5075 << " / WAY = " << way 5076 << " / SET = " << set << std::endl; 5077 } 5078 #endif 5079 } 4607 5080 r_dcache_cc_need_write = false; 4608 5081 4609 #if DEBUG_DCACHE 4610 if ( m_debug_activated ) 4611 { 4612 std::cout << " <PROC " << name() 4613 << " DCACHE_CC_INVAL> Switch slot to EMPTY state:" << std::dec 4614 << " / WAY = " << way 4615 << " / SET = " << set << std::endl; 4616 } 4617 #endif 4618 } 4619 } 5082 } 5083 } 5084 4620 5085 // multicast acknowledgement 4621 5086 // send a request to cc_send_fsm 4622 5087 if(not r_dcache_cc_send_req.read()) // cc_send is available 4623 5088 { 5089 4624 5090 // coherence request completed 4625 5091 r_cc_receive_dcache_req = false; 4626 // request multicast acknowledgement4627 5092 r_dcache_cc_send_req = true; 4628 5093 r_dcache_cc_send_nline = r_cc_receive_dcache_nline.read(); 4629 r_dcache_cc_send_updt_tab_idx = r_cc_receive_dcache_updt_tab_idx.read(); 4630 r_dcache_cc_send_type = CC_TYPE_MULTI_ACK; 4631 4632 r_dcache_fsm = r_dcache_fsm_cc_save.read(); 5094 5095 5096 if ( (state == CACHE_SLOT_STATE_VALID_NCC) ) 5097 { 5098 r_dcache_cleanup_ncc = true; 5099 r_dcache_cc_send_type = CC_TYPE_CLEANUP; 5100 r_dcache_cc_send_way = way; 5101 5102 if (r_dcache_content_state[way*m_dcache_sets+set] == LINE_CACHE_DATA_DIRTY) 5103 { 5104 r_dcache_cc_cleanup_updt_data = true; 5105 r_dcache_fsm = DCACHE_CC_INVAL_DATA; 5106 5107 /*STATS DIRTY*/ 5108 for (size_t w = 0; w < m_dcache_words; w++) 5109 { 5110 if(dirty_stats[(way * m_dcache_sets + set) * m_dcache_words + w] == true) 5111 m_cpt_words_dirty++; 5112 } 5113 } 5114 else 5115 { 5116 r_dcache_cc_cleanup_updt_data = false; 5117 r_dcache.write_dir( way, 5118 set, 5119 CACHE_SLOT_STATE_ZOMBI ); 5120 r_dcache_fsm = r_dcache_fsm_cc_save.read(); 5121 } 5122 } 5123 else 5124 { 5125 // request multicast acknowledgement 5126 r_dcache_cc_send_updt_tab_idx = r_cc_receive_dcache_updt_tab_idx.read(); 5127 r_dcache_cc_send_type = CC_TYPE_MULTI_ACK; 5128 r_dcache_fsm = r_dcache_fsm_cc_save.read(); 5129 } 4633 5130 } 4634 5131 //else wait for previous cc_send request to be sent … … 4647 5144 if (r_dcache_cc_need_write.read()) 4648 5145 { 4649 if ( r_dcache_in_tlb[way*m_dcache_sets+set] ) // selective TLB inval 4650 { 4651 r_dcache_in_tlb[way*m_dcache_sets+set] = false; 5146 // selective TLB inval 5147 if ( r_dcache_content_state[way*m_dcache_sets+set] == LINE_CACHE_IN_TLB ) 5148 { 5149 r_dcache_content_state[way*m_dcache_sets+set] = LINE_CACHE_DATA_NOT_DIRTY; 4652 5150 r_dcache_tlb_inval_line = r_cc_receive_dcache_nline.read(); 4653 5151 r_dcache_tlb_inval_set = 0; … … 4656 5154 break; 4657 5155 } 4658 4659 if ( r_dcache_cont ains_ptd[way*m_dcache_sets+set] ) // TLB flush5156 // TLB flush 5157 if ( r_dcache_content_state[way*m_dcache_sets+set] == LINE_CACHE_CONTAINS_PTD ) 4660 5158 { 4661 5159 r_itlb.reset(); 4662 5160 r_dtlb.reset(); 4663 r_dcache_cont ains_ptd[way*m_dcache_sets+set] = false;5161 r_dcache_content_state[way*m_dcache_sets+set] = LINE_CACHE_DATA_NOT_DIRTY; 4664 5162 4665 5163 #if DEBUG_DCACHE … … 4739 5237 if (r_dcache_cc_need_write.read()) 4740 5238 { 4741 if ( r_dcache_in_tlb[way*m_dcache_sets+set] ) // selective TLB inval 4742 { 4743 r_dcache_in_tlb[way*m_dcache_sets+set] = false; 5239 // selective TLB inval 5240 if ( r_dcache_content_state[way*m_dcache_sets+set] == LINE_CACHE_IN_TLB ) 5241 { 5242 r_dcache_content_state[way*m_dcache_sets+set] = LINE_CACHE_DATA_NOT_DIRTY; 4744 5243 r_dcache_tlb_inval_line = nline; 4745 5244 r_dcache_tlb_inval_set = 0; … … 4750 5249 else 4751 5250 { 4752 if ( r_dcache_contains_ptd[way*m_dcache_sets+set] ) // TLB flush 5251 // TLB flush 5252 if ( r_dcache_content_state[way*m_dcache_sets+set] == LINE_CACHE_CONTAINS_PTD ) 4753 5253 { 4754 5254 r_itlb.reset(); 4755 5255 r_dtlb.reset(); 4756 r_dcache_cont ains_ptd[way*m_dcache_sets+set] = false;5256 r_dcache_content_state[way*m_dcache_sets+set] = LINE_CACHE_DATA_NOT_DIRTY; 4757 5257 4758 5258 #if DEBUG_DCACHE 4759 if ( m_debug_activated )4760 {4761 std::cout << " <PROC " << name()4762 << " DCACHE_CC_BROADCAST> Flush DTLB & ITLB" << std::endl;4763 }5259 if ( m_debug_activated ) 5260 { 5261 std::cout << " <PROC " << name() 5262 << " DCACHE_CC_BROADCAST> Flush DTLB & ITLB" << std::endl; 5263 } 4764 5264 #endif 4765 5265 } 4766 5266 4767 5267 #ifdef INSTRUMENTATION 4768 m_cpt_dcache_dir_write++;5268 m_cpt_dcache_dir_write++; 4769 5269 #endif 4770 5270 r_dcache.write_dir( way, 4771 4772 5271 set, 5272 CACHE_SLOT_STATE_ZOMBI ); 4773 5273 4774 5274 r_dcache_cc_need_write = false; 4775 5275 #if DEBUG_DCACHE 4776 if ( m_debug_activated )4777 {4778 std::cout << " <PROC " << name()4779 << " DCACHE_CC_BROADCAST > Slot goes to ZOMBI state "4780 << " SET = " << set4781 << " / WAY = " << way << std::endl;4782 }5276 if ( m_debug_activated ) 5277 { 5278 std::cout << " <PROC " << name() 5279 << " DCACHE_CC_BROADCAST > Slot goes to ZOMBI state " 5280 << " SET = " << set 5281 << " / WAY = " << way << std::endl; 5282 } 4783 5283 #endif 4784 5284 } … … 4969 5469 r_dcache_vci_unc_req.read()) 4970 5470 or r_vci_cmd_imiss_prio.read() ); 4971 4972 5471 // 1 - Data Read Miss 4973 5472 if ( dcache_miss_req and r_wbuf.miss(r_dcache_vci_paddr.read()) ) … … 4976 5475 r_dcache_vci_miss_req = false; 4977 5476 r_vci_cmd_imiss_prio = true; 4978 //m_cpt_dmiss_transaction++;5477 m_cpt_dmiss_transaction++; 4979 5478 } 4980 5479 // 2 - Data Read Uncachable … … 4983 5482 r_vci_cmd_fsm = CMD_DATA_UNC; 4984 5483 r_dcache_vci_unc_req = false; 4985 //m_cpt_dunc_transaction++;5484 //m_cpt_dunc_transaction++; 4986 5485 } 4987 5486 // 3 - Data Linked Load … … 4990 5489 r_dcache_vci_ll_req = false; 4991 5490 r_vci_cmd_fsm = CMD_DATA_LL; 4992 //m_cpt_ll_transaction++;5491 //m_cpt_ll_transaction++; 4993 5492 } 4994 5493 // 4 - Instruction Miss … … 4998 5497 r_icache_miss_req = false; 4999 5498 r_vci_cmd_imiss_prio = false; 5000 //m_cpt_imiss_transaction++;5499 m_cpt_imiss_transaction++; 5001 5500 } 5002 5501 // 5 - Instruction Uncachable … … 5005 5504 r_vci_cmd_fsm = CMD_INS_UNC; 5006 5505 r_icache_unc_req = false; 5007 //m_cpt_iunc_transaction++;5506 //m_cpt_iunc_transaction++; 5008 5507 } 5009 5508 // 6 - Data Write … … 5014 5513 r_vci_cmd_min = wbuf_min; 5015 5514 r_vci_cmd_max = wbuf_max; 5016 //m_cpt_write_transaction++;5017 //m_length_write_transaction += (wbuf_max-wbuf_min+1);5515 m_cpt_write_transaction++; 5516 m_length_write_transaction += (wbuf_max-wbuf_min+1); 5018 5517 } 5019 5518 // 7 - Data Store Conditionnal … … 5023 5522 r_vci_cmd_cpt = 0; 5024 5523 r_vci_cmd_fsm = CMD_DATA_SC; 5025 //m_cpt_sc_transaction++;5524 //m_cpt_sc_transaction++; 5026 5525 } 5027 5526 // 8 - Compare And Swap … … 5031 5530 r_dcache_vci_cas_req = false; 5032 5531 r_vci_cmd_cpt = 0; 5033 //m_cpt_cas_transaction++;5532 //m_cpt_cas_transaction++; 5034 5533 } 5035 5534 … … 5074 5573 case CMD_INS_MISS: 5075 5574 case CMD_INS_UNC: 5076 case CMD_DATA_MISS:5077 5575 case CMD_DATA_UNC: 5078 5576 case CMD_DATA_LL: … … 5080 5578 // all read VCI commands contain one single flit 5081 5579 if ( p_vci.cmdack.read() ) { 5580 r_vci_cmd_fsm = CMD_IDLE; 5581 } 5582 break; 5583 } 5584 5585 case CMD_DATA_MISS: 5586 { 5587 // all read VCI commands contain one single flit 5588 if ( p_vci.cmdack.read() ) { 5589 r_dcache_miss_no_coherent = false; 5082 5590 r_vci_cmd_fsm = CMD_IDLE; 5083 5591 } … … 5123 5631 r_vci_rsp_cpt = 0; 5124 5632 5125 if ( (p_vci.rpktid.read() & 0x 7) == TYPE_READ_DATA_UNC )5633 if ( (p_vci.rpktid.read() & 0xF) == TYPE_READ_DATA_UNC ) 5126 5634 { 5127 5635 r_vci_rsp_fsm = RSP_DATA_UNC; 5128 5636 } 5129 else if ( (p_vci.rpktid.read() & 0x 7) == TYPE_READ_DATA_MISS )5637 else if ( (p_vci.rpktid.read() & 0xF) == TYPE_READ_DATA_MISS ) 5130 5638 { 5131 5639 r_vci_rsp_fsm = RSP_DATA_MISS; 5132 5640 } 5133 else if ( (p_vci.rpktid.read() & 0x7) == TYPE_READ_INS_UNC ) 5641 else if ( (p_vci.rpktid.read() & 0xF) == TYPE_READ_DATA_MISS_NO_COHERENT ) 5642 { 5643 r_vci_rsp_read_data_miss_no_coherent = true; 5644 r_vci_rsp_fsm = RSP_DATA_MISS; 5645 } 5646 else if ( (p_vci.rpktid.read() & 0xF) == TYPE_READ_INS_UNC ) 5134 5647 { 5135 5648 r_vci_rsp_fsm = RSP_INS_UNC; 5136 5649 } 5137 else if ( (p_vci.rpktid.read() & 0x 7) == TYPE_READ_INS_MISS )5650 else if ( (p_vci.rpktid.read() & 0xF) == TYPE_READ_INS_MISS ) 5138 5651 { 5139 5652 r_vci_rsp_fsm = RSP_INS_MISS; 5140 5653 } 5141 else if ( (p_vci.rpktid.read() & 0x 7) == TYPE_WRITE )5654 else if ( (p_vci.rpktid.read() & 0xF) == TYPE_WRITE ) 5142 5655 { 5143 5656 r_vci_rsp_fsm = RSP_DATA_WRITE; 5144 5657 } 5145 else if ( (p_vci.rpktid.read() & 0x 7) == TYPE_CAS )5658 else if ( (p_vci.rpktid.read() & 0xF) == TYPE_CAS ) 5146 5659 { 5147 5660 r_vci_rsp_fsm = RSP_DATA_UNC; 5148 5661 } 5149 else if ( (p_vci.rpktid.read() & 0x 7) == TYPE_LL )5662 else if ( (p_vci.rpktid.read() & 0xF) == TYPE_LL ) 5150 5663 { 5151 5664 r_vci_rsp_fsm = RSP_DATA_LL; 5152 5665 } 5153 else if ( (p_vci.rpktid.read() & 0x 7) == TYPE_SC )5666 else if ( (p_vci.rpktid.read() & 0xF) == TYPE_SC ) 5154 5667 { 5155 5668 r_vci_rsp_fsm = RSP_DATA_UNC; … … 5400 5913 if (p_dspin_out.read.read()) 5401 5914 { 5402 if (r_cc_send_last_client.read() == 0) // dcache active request 5403 r_dcache_cc_send_req = false; // reset dcache request 5404 else // icache active request 5405 r_icache_cc_send_req = false; // reset icache request 5406 5407 // go back to idle state 5408 r_cc_send_fsm = CC_SEND_IDLE; 5915 /*ODCCP*/ // If there is a cleanup with data and dcache active request we send other flits contained data 5916 if(r_dcache_cc_cleanup_updt_data.read() and (r_cc_send_last_client.read() == 0) ) 5917 { 5918 r_cc_send_fsm = CC_SEND_CLEANUP_DATA_UPDT; 5919 } 5920 else 5921 { 5922 if (r_cc_send_last_client.read() == 0) // dcache active request 5923 r_dcache_cc_send_req = false; // reset dcache request 5924 else // icache active request 5925 r_icache_cc_send_req = false; // reset icache request 5926 // go back to idle state 5927 r_cc_send_fsm = CC_SEND_IDLE; 5928 } 5929 } 5930 break; 5931 } 5932 /////////////////////////// 5933 case CC_SEND_CLEANUP_DATA_UPDT: /*ODCCP*/ // we send the data values of line cache into [m_dcache_words] flits 5934 { 5935 if (p_dspin_out.read.read()) 5936 { 5937 if(r_cc_send_data_fifo.rok()) 5938 { 5939 m_cpt_data_cleanup++; 5940 cleanup_data_updt_fifo_dcache_get = true; 5941 r_cc_send_cpt_word = r_cc_send_cpt_word.read() + 1; 5942 if (r_cc_send_cpt_word.read() == m_dcache_words-1) 5943 { 5944 /*ODCCP*/ 5945 r_dcache_cc_send_req = false; 5946 r_dcache_cc_cleanup_updt_data = false; 5947 r_cc_send_cpt_word = 0; 5948 r_cc_send_fsm = CC_SEND_IDLE; 5949 } 5950 } 5409 5951 } 5410 5952 break; … … 5487 6029 // for data CLACK, wait for dcache to take the request 5488 6030 if ((r_cc_receive_data_ins.read() == 0) and 5489 not (r_cc_receive_dcache_req.read()))6031 not r_cc_receive_dcache_req.read()) 5490 6032 { 5491 6033 // request dcache to handle the CLACK 5492 6034 r_cc_receive_dcache_req = true; 5493 r_cc_receive_dcache_set = DspinDhccpParam::dspin_get(receive_data, 6035 r_cc_receive_dcache_set = DspinDhccpParam::dspin_get(receive_data, 5494 6036 DspinDhccpParam::CLEANUP_ACK_SET) & 5495 6037 ((1ULL<<(uint32_log2(m_dcache_sets)))-1); 5496 r_cc_receive_dcache_way = DspinDhccpParam::dspin_get(receive_data, 6038 r_cc_receive_dcache_way = DspinDhccpParam::dspin_get(receive_data, 5497 6039 DspinDhccpParam::CLEANUP_ACK_WAY) & 5498 6040 ((1ULL<<(uint32_log2(m_dcache_ways)))-1); … … 5710 6252 vci_rsp_fifo_dcache_data); 5711 6253 6254 r_cc_send_data_fifo.update(cleanup_data_updt_fifo_dcache_get, 6255 cleanup_data_updt_fifo_dcache_put, 6256 cleanup_data_updt_fifo_dcache_data); 6257 5712 6258 ///////////////// updt FIFO update ////////////////////// 5713 6259 //TODO check this … … 5804 6350 p_vci.be = 0xF; 5805 6351 p_vci.trdid = 0; 5806 p_vci.pktid = TYPE_READ_DATA_MISS; 6352 /*ODCCP*/ // If miss on no coherent line pktid = TYPE_READ_DATA_MISS_NO_COHERENT 6353 if(r_dcache_miss_no_coherent.read() == true) 6354 p_vci.pktid = TYPE_READ_DATA_MISS_NO_COHERENT; 6355 else 6356 p_vci.pktid = TYPE_READ_DATA_MISS; 5807 6357 p_vci.plen = m_dcache_words << 2; 5808 6358 p_vci.cmd = vci_param::CMD_READ; … … 5904 6454 { 5905 6455 // initialize dspin send data 5906 // DspinDhccpParam::dspin_set(dspin_send_data,5907 // 0,5908 // DspinDhccpParam::FROM_L1_EOP);5909 6456 DspinDhccpParam::dspin_set(dspin_send_data, 5910 6457 m_cc_global_id, … … 5919 6466 >> (m_nline_width - m_x_width - m_y_width) 5920 6467 << (DspinDhccpParam::GLOBALID_WIDTH - m_x_width - m_y_width); 5921 5922 6468 DspinDhccpParam::dspin_set(dspin_send_data, 5923 6469 dest, … … 5935 6481 DspinDhccpParam::TYPE_CLEANUP_DATA, 5936 6482 DspinDhccpParam::FROM_L1_TYPE); 6483 /*ODCCP*/ // If cleanup on NCC line we set the CLEANUP_NCC bit in cleanup flit 6484 if (r_dcache_cleanup_ncc.read()) 6485 { 6486 DspinDhccpParam::dspin_set(dspin_send_data, 6487 1, 6488 DspinDhccpParam::CLEANUP_NCC); 6489 } 6490 else 6491 { 6492 DspinDhccpParam::dspin_set(dspin_send_data, 6493 0, 6494 DspinDhccpParam::CLEANUP_NCC); 6495 } 6496 5937 6497 } 5938 6498 else // icache active request … … 5957 6517 DspinDhccpParam::TYPE_CLEANUP_INST, 5958 6518 DspinDhccpParam::FROM_L1_TYPE); 6519 6520 DspinDhccpParam::dspin_set(dspin_send_data, 6521 0, 6522 DspinDhccpParam::CLEANUP_NCC); 5959 6523 } 5960 6524 // send flit … … 5968 6532 { 5969 6533 // initialize dspin send data 5970 // DspinDhccpParam::dspin_set(dspin_send_data, 5971 // 1, 5972 // DspinDhccpParam::FROM_L1_EOP); 6534 /*ODCCP*/ // if cleanup contains data and dcache active request, there is other flits to send 6535 if (r_dcache_cc_cleanup_updt_data.read() and not r_cc_send_last_client.read()) 6536 { 6537 p_dspin_out.eop = false; 6538 } 6539 else 6540 { 6541 p_dspin_out.eop = true; 6542 } 5973 6543 5974 6544 if(r_cc_send_last_client.read() == 0) // dcache active request … … 5987 6557 p_dspin_out.data = dspin_send_data; 5988 6558 p_dspin_out.write = true; 5989 p_dspin_out.eop = true; 6559 break; 6560 } 6561 /////////////////////// 6562 case CC_SEND_CLEANUP_DATA_UPDT: 6563 { 6564 if (r_cc_send_cpt_word.read() == m_dcache_words-1) /*ODCCP*/ // Last flit sent 6565 { 6566 p_dspin_out.eop = true; 6567 } 6568 else 6569 { 6570 p_dspin_out.eop = false; 6571 } 6572 6573 DspinDhccpParam::dspin_set(dspin_send_data, 6574 r_cc_send_data_fifo.read(), 6575 DspinDhccpParam::CLEANUP_DATA_UPDT); 6576 6577 p_dspin_out.data = dspin_send_data; 6578 p_dspin_out.write = true; 5990 6579 break; 5991 6580 }
Note: See TracChangeset
for help on using the changeset viewer.