- Timestamp:
- Aug 16, 2012, 7:32:45 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/vci_cc_vcache_wrapper_v4/caba/source/src/vci_cc_vcache_wrapper_v4.cpp
r253 r254 43 43 "ICACHE_XTN_CACHE_FLUSH", 44 44 "ICACHE_XTN_TLB_INVAL", 45 45 "ICACHE_XTN_CACHE_INVAL_VA", 46 46 "ICACHE_XTN_CACHE_INVAL_PA", 47 47 "ICACHE_XTN_CACHE_INVAL_GO", … … 66 66 "DCACHE_TLB_MISS", 67 67 "DCACHE_TLB_PTE1_GET", 68 68 "DCACHE_TLB_PTE1_SELECT", 69 69 "DCACHE_TLB_PTE1_UPDT", 70 70 "DCACHE_TLB_PTE2_GET", 71 71 "DCACHE_TLB_PTE2_SELECT", 72 72 "DCACHE_TLB_PTE2_UPDT", 73 73 "DCACHE_TLB_LR_UPDT", … … 742 742 // Debug variables 743 743 m_debug_previous_hit = false; 744 m_idebug_previous_hit 745 m_debug_dcache_fsm = false;746 m_debug_icache_fsm = false;744 m_idebug_previous_hit = false; 745 m_debug_dcache_fsm = false; 746 m_debug_icache_fsm = false; 747 747 m_debug_cleanup_fsm = false; 748 748 … … 757 757 m_cpt_icache_dir_write = 0; 758 758 759 760 761 759 m_cpt_frz_cycles = 0; 760 m_cpt_total_cycles = 0; 761 m_cpt_stop_simulation = 0; 762 762 763 763 m_cpt_data_miss = 0; … … 782 782 m_cost_unc_transaction = 0; 783 783 m_cost_write_transaction = 0; 784 784 m_cost_icache_unc_transaction = 0; 785 785 m_length_write_transaction = 0; 786 786 … … 811 811 m_cost_data_tlb_inval_frz = 0; 812 812 813 814 815 m_cost_updt_data_frz = 0;816 m_cost_inval_ins_frz = 0;817 m_cost_inval_data_frz = 0;818 m_cost_broadcast_frz = 0;819 820 m_cpt_cc_cleanup_data = 0;821 m_cpt_cc_cleanup_ins = 0;813 m_cpt_cc_broadcast = 0; 814 815 m_cost_updt_data_frz = 0; 816 m_cost_inval_ins_frz = 0; 817 m_cost_inval_data_frz = 0; 818 m_cost_broadcast_frz = 0; 819 820 m_cpt_cc_cleanup_data = 0; 821 m_cpt_cc_cleanup_ins = 0; 822 822 823 823 m_cpt_itlbmiss_transaction = 0; … … 960 960 r_tgt_pktid = p_vci_tgt_c.pktid.read(); 961 961 962 if (sizeof(paddr_t) <= 32) { 963 assert(p_vci_tgt_c.be.read() == 0 && "byte enable should be 0 for 32bits paddr"); 964 r_tgt_paddr = 965 (paddr_t)p_vci_tgt_c.wdata.read() * m_dcache_words * 4; 966 } else { 967 r_tgt_paddr = (paddr_t)(p_vci_tgt_c.be.read() & 0x3) << 32 | 968 (paddr_t)p_vci_tgt_c.wdata.read() * m_dcache_words * 4; 962 if (sizeof(paddr_t) <= 32) 963 { 964 assert(p_vci_tgt_c.be.read() == 0 965 && "byte enable should be 0 for 32bits paddr"); 966 r_tgt_paddr = (paddr_t)p_vci_tgt_c.wdata.read() * m_dcache_words * 4; 967 } 968 else 969 { 970 r_tgt_paddr = (paddr_t)(p_vci_tgt_c.be.read() & 0x3) << 32 | 971 (paddr_t)p_vci_tgt_c.wdata.read() * m_dcache_words * 4; 969 972 } 970 973 … … 2027 2030 { 2028 2031 tlb_inval_required = true; 2029 r_dcache_tlb_inval_count = 0;2030 r_dcache_tlb_inval_line = r_dcache_p1_paddr.read()>>2032 r_dcache_tlb_inval_count = 0; 2033 r_dcache_tlb_inval_line = r_dcache_p1_paddr.read()>> 2031 2034 (uint32_log2(m_dcache_words<<2)); 2032 r_dcache_in_tlb[way*m_dcache_sets+set] = false;2035 r_dcache_in_tlb[way*m_dcache_sets+set] = false; 2033 2036 } 2034 2037 else if ( r_dcache_contains_ptd[way*m_dcache_sets+set] ) … … 2036 2039 r_itlb.reset(); 2037 2040 r_dtlb.reset(); 2038 r_dcache_contains_ptd[way*m_dcache_sets+set] = false;2041 r_dcache_contains_ptd[way*m_dcache_sets+set] = false; 2039 2042 } 2040 2043 … … 3295 3298 } 3296 3299 //////////////////////// 3297 case DCACHE_TLB_LR_WAIT: // Waiting aresponse to SC transaction.3298 3299 3300 3301 3302 3303 3300 case DCACHE_TLB_LR_WAIT: // Waiting the response to SC transaction. 3301 // We consume the response in rsp FIFO, 3302 // and exit the sub-fsm, but we don't 3303 // analyse the response, because we don't 3304 // care if the L/R bit update is not done. 3305 // We must take the coherence requests because 3306 // there is a risk of dead-lock 3304 3307 3305 3308 { … … 3544 3547 //////////////////////////// 3545 3548 case DCACHE_XTN_DC_INVAL_GO: // In this state, we invalidate the cache line 3546 // Blocked if previous cleanup not completed3549 // Blocked if previous cleanup not completed 3547 3550 // Test if itlb or dtlb inval is required 3548 3551 { 3549 3550 3552 if ( not r_dcache_cleanup_req.read() ) 3553 { 3551 3554 paddr_t nline; 3552 3555 size_t way = r_dcache_xtn_way.read(); 3553 3556 size_t set = r_dcache_xtn_set.read(); 3554 boolhit;3557 bool hit; 3555 3558 3556 3559 hit = r_dcache.inval( way, 3557 3560 set, 3558 3561 &nline ); 3559 3562 assert(hit && "XTN_DC_INVAL way/set should still be in cache"); 3560 3563 3561 3564 // request cleanup 3562 3563 3565 r_dcache_cleanup_req = true; 3566 r_dcache_cleanup_line = nline; 3564 3567 3565 3568 // possible itlb & dtlb invalidate 3566 3569 if ( r_dcache_in_tlb[way*m_dcache_sets+set] ) 3567 3570 { 3568 3569 3571 r_dcache_tlb_inval_line = nline; 3572 r_dcache_tlb_inval_count = 0; 3570 3573 r_dcache_fsm_scan_save = DCACHE_XTN_DC_INVAL_END; 3571 3574 r_dcache_fsm = DCACHE_INVAL_TLB_SCAN; 3572 3573 3575 r_dcache_in_tlb[way*m_dcache_sets+set] = false; 3576 } 3574 3577 else if ( r_dcache_contains_ptd[way*m_dcache_sets+set] ) 3575 3578 { 3576 3579 r_itlb.reset(); 3577 3580 r_dtlb.reset(); 3578 3581 r_dcache_contains_ptd[way*m_dcache_sets+set] = false; 3579 3582 r_dcache_fsm = DCACHE_IDLE; 3580 3583 m_drsp.valid = true; … … 3655 3658 size_t way = r_dcache_miss_way.read(); 3656 3659 size_t set = r_dcache_miss_set.read(); 3657 boolhit;3660 bool hit; 3658 3661 3659 3662 hit = r_dcache.inval( way, … … 3661 3664 &nline ); 3662 3665 3663 3666 assert(hit && "selected way/set line should be in dcache"); 3664 3667 3665 3668 #if DEBUG_DCACHE … … 3686 3689 r_itlb.reset(); 3687 3690 r_dtlb.reset(); 3688 3691 r_dcache_contains_ptd[way*m_dcache_sets+set] = false; 3689 3692 r_dcache_fsm = DCACHE_MISS_WAIT; 3690 3693 } … … 3937 3940 vci_rsp_fifo_dcache_get = true; 3938 3941 m_drsp.valid = true; 3939 3942 m_drsp.rdata = r_vci_rsp_fifo_dcache.read(); 3940 3943 r_dcache_fsm = DCACHE_IDLE; 3941 3944 } … … 3944 3947 ////////////////////////// 3945 3948 case DCACHE_DIRTY_GET_PTE: // This sub_fsm set the PTE Dirty bit in memory 3946 3947 3948 3949 3949 // before handling a processor WRITE or SC request 3950 // Input argument is r_dcache_dirty_paddr 3951 // In this first state, we get PTE value in dcache 3952 // and post a SC request to CMD FSM 3950 3953 { 3951 3954 // get PTE in dcache … … 4009 4012 { 4010 4013 vci_rsp_fifo_dcache_get = true; 4011 if ( r_vci_rsp_fifo_dcache.read() == 0 ) // exit if dirty bit update atomic 4012 { 4013 r_dcache_fsm = DCACHE_IDLE; 4014 r_dcache_fsm = DCACHE_IDLE; 4014 4015 4015 4016 #if DEBUG_DCACHE 4016 4017 if ( m_debug_dcache_fsm ) 4017 4018 { 4018 std::cout << " <PROC " << name() << ".DCACHE_DIRTY_SC_WAIT> Dirty bit successfully set" 4019 << std::endl; 4019 std::cout << " <PROC " << name() << ".DCACHE_DIRTY_SC_WAIT> SC completed" << std::endl; 4020 4020 } 4021 4021 #endif 4022 }4023 else // invalidate the cache line TLBs4024 {4025 4026 #if DEBUG_DCACHE4027 if ( m_debug_dcache_fsm )4028 {4029 std::cout << " <PROC " << name() << ".DCACHE_DIRTY_SC_WAIT> PTE modified : Inval cache line & TLBs"4030 << std::endl;4031 }4032 #endif4033 paddr_t nline;4034 size_t way = r_dcache_dirty_way.read();4035 size_t set = r_dcache_dirty_set.read();4036 bool hit;4037 4038 hit = r_dcache.inval( way,4039 set,4040 &nline );4041 4042 assert(hit && "PTE should still be in dcache");4043 4044 // request cleanup4045 r_dcache_cleanup_req = true;4046 r_dcache_cleanup_line = nline;4047 4048 if ( r_dcache_in_tlb[way*m_dcache_sets+set] ) // contains PTE4049 {4050 r_dcache_tlb_inval_line = nline;4051 r_dcache_tlb_inval_count = 0;4052 r_dcache_fsm_scan_save = DCACHE_IDLE;4053 r_dcache_fsm = DCACHE_INVAL_TLB_SCAN;4054 r_dcache_in_tlb[way*m_dcache_sets+set] = false;4055 }4056 else if ( r_dcache_contains_ptd[way*m_dcache_sets+set] ) // contains PTD4057 {4058 r_itlb.reset();4059 r_dtlb.reset();4060 r_dcache_contains_ptd[way*m_dcache_sets+set] = false;4061 r_dcache_fsm = DCACHE_IDLE;4062 }4063 else4064 {4065 r_dcache_fsm = DCACHE_IDLE;4066 }4067 }4068 4022 } 4069 4023 break; … … 4099 4053 4100 4054 } 4101 else // no match 4102 {4103 uint32_t 4104 size_t way;4105 size_t set;4106 size_t word;4107 4108 bool hit = r_dcache.read(paddr,4109 &rdata, 4055 else // no match for a pending miss 4056 { 4057 uint32_t rdata; 4058 size_t way; 4059 size_t set; 4060 size_t word; 4061 4062 bool hit = r_dcache.read( paddr, 4063 &rdata, // unused 4110 4064 &way, 4111 4065 &set, … … 4155 4109 } 4156 4110 ///////////////////// 4157 case DCACHE_CC_INVAL: // invalidate one cache line 4158 // and test possiblecopies in TLBs4159 { 4160 paddr_t nline;4161 size_t way= r_dcache_cc_way.read();4162 size_t set= r_dcache_cc_set.read();4163 boolhit;4111 case DCACHE_CC_INVAL: // invalidate one cache line after 4112 // invalidation of copies in TLBs 4113 { 4114 paddr_t nline; 4115 size_t way = r_dcache_cc_way.read(); 4116 size_t set = r_dcache_cc_set.read(); 4117 bool hit; 4164 4118 4165 4119 if ( r_dcache_in_tlb[way*m_dcache_sets+set] ) // selective TLB inval 4166 4120 { 4167 4121 r_dcache_in_tlb[way*m_dcache_sets+set] = false; 4168 r_dcache_tlb_inval_line = nline;4122 r_dcache_tlb_inval_line = r_tgt_paddr.read() >> (uint32_log2(m_dcache_words)+2); 4169 4123 r_dcache_tlb_inval_count = 0; 4170 4124 r_dcache_fsm_scan_save = r_dcache_fsm.read(); 4171 4125 r_dcache_fsm = DCACHE_INVAL_TLB_SCAN; 4172 4126 } 4173 else // actual cache line inval4127 else // actual cache line inval 4174 4128 { 4175 4129 if ( r_dcache_contains_ptd[way*m_dcache_sets+set] ) // TLB flush … … 4195 4149 #endif 4196 4150 4197 assert(hit && "CC_INVAL way/set should stillbe in dcache");4151 assert(hit && "CC_INVAL way/set should be in dcache"); 4198 4152 } 4199 4153 break;
Note: See TracChangeset
for help on using the changeset viewer.