From 8e826b212b4c6724a6395444a5c3952416f14ede Mon Sep 17 00:00:00 2001 From: AngelaGonzalezMarino Date: Fri, 15 Dec 2023 17:04:29 +0100 Subject: [PATCH] Revert "common tlb with hypervisor support" This reverts commit af0e57f3b05bd5e5ea8c54e532e030bbab9ee2ad. --- core/mmu_unify/cva6_tlb.sv | 122 ++++--------------------------------- 1 file changed, 13 insertions(+), 109 deletions(-) diff --git a/core/mmu_unify/cva6_tlb.sv b/core/mmu_unify/cva6_tlb.sv index 172dabc26a..e33d7c27ea 100644 --- a/core/mmu_unify/cva6_tlb.sv +++ b/core/mmu_unify/cva6_tlb.sv @@ -28,15 +28,13 @@ #( parameter type pte_cva6_t = logic, parameter type tlb_update_cva6_t = logic, - // parameter ariane_pkg::ariane_cfg_t CVA6Cfg = ariane_pkg::ArianeDefaultConfig, parameter config_pkg::cva6_cfg_t CVA6Cfg = config_pkg::cva6_cfg_empty, parameter logic HYP_EXT = 0, parameter int unsigned TLB_ENTRIES = 4, parameter int unsigned ASID_WIDTH [HYP_EXT:0] = {1}, //[vmid_width,asid_width] - parameter int unsigned ASID_LEN = 1, //[vmid_len,asid_len] + parameter int unsigned ASID_LEN[HYP_EXT:0] = 1, //[vmid_len,asid_len] parameter int unsigned VPN_LEN = 1, parameter int unsigned PT_LEVELS = 1 - ) ( input logic clk_i, // Clock input logic rst_ni, // Asynchronous reset active low @@ -47,9 +45,7 @@ // Lookup signals input logic lu_access_i, input logic [ASID_WIDTH[0]-1:0] lu_asid_i [HYP_EXT:0], //[lu_vmid,lu_asid] - input logic [riscv::VLEN-1:0] lu_vaddr_i , //[gp_addr,vaddr] - output logic [riscv::GPLEN-1:0] lu_gpaddr_o, - // output logic [riscv::GPLEN-1:0] lu_gpaddr_o, + input logic [riscv::VLEN-1:0] lu_vaddr_i [HYP_EXT:0], //[gp_addr,vaddr] output pte_cva6_t [HYP_EXT:0] lu_content_o , input logic [ASID_WIDTH[0]-1:0] asid_to_be_flushed_i [HYP_EXT:0], //[vmid,asid] input logic [riscv::VLEN-1:0] vaddr_to_be_flushed_i [HYP_EXT:0], // [gpaddr,vaddr] @@ -68,7 +64,6 @@ tags_q, tags_n; pte_cva6_t [TLB_ENTRIES-1:0][HYP_EXT:0] content_q , content_n; - pte_cva6_t g_content; logic [TLB_ENTRIES-1:0][PT_LEVELS-1:0] vpn_match; logic [TLB_ENTRIES-1:0][HYP_EXT:0] asid_match; logic [TLB_ENTRIES-1:0][PT_LEVELS-1:0] page_match; @@ -99,17 +94,12 @@ end for (x=0; x < PT_LEVELS; x++) begin - //identify page_match for all TLB Entries - assign page_match[i][x] = x==0 ? 1 :(HYP_EXT && x==(PT_LEVELS-1)? // - ((&v_st_enbl_i[HYP_EXT:0]) ? - ((tags_q[i].is_page[PT_LEVELS-x][0] && (tags_q[i].is_page[PT_LEVELS-1-x][1] || tags_q[i].is_page[PT_LEVELS-x][1])) // - || (tags_q[i].is_page[PT_LEVELS-x][1] && (tags_q[i].is_page[PT_LEVELS-1-x][0] || tags_q[i].is_page[PT_LEVELS-x][0]))): - tags_q[i].is_page[PT_LEVELS-x][0] && v_st_enbl_i[0] || tags_q[i].is_page[PT_LEVELS-1-x][1] && v_st_enbl_i[1]): - &(tags_q[i].is_page[PT_LEVELS-1-x] | !v_st_enbl_i[HYP_EXT:0])); + //identify page_match for all TLB Entries + assign page_match[i][x] = x==0 ? 1 : &(tags_q[i].is_page[PT_LEVELS-1-x] | !v_st_enbl_i[PT_LEVELS-1-x]); //identify if vpn matches at all PT levels for all TLB entries assign vpn_match[i][x] = (HYP_EXT && x==(PT_LEVELS-1) && !v_st_enbl_i[0]) ? // - lu_vaddr_i[12+((VPN_LEN/PT_LEVELS)*(x+1))-1:12+((VPN_LEN/PT_LEVELS)*x)] == tags_q[i].vpn[x] && lu_vaddr_i[VPN_LEN-1: VPN_LEN-VPN_LEN%PT_LEVELS] == tags_q[i].vpn[x+1][VPN_LEN%PT_LEVELS-1:0]: // - lu_vaddr_i[12+((VPN_LEN/PT_LEVELS)*(x+1))-1:12+((VPN_LEN/PT_LEVELS)*x)] == tags_q[i].vpn[x]; + lu_vaddr_i[0][12+((VPN_LEN/PT_LEVELS)*(x+1))-1:12+((VPN_LEN/PT_LEVELS)*x)] == tags_q[i].vpn[x] && lu_vaddr_i[0][VPN_LEN-1: VPN_LEN-VPN_LEN%PT_LEVELS] == tags_q[i].vpn[x+1][VPN_LEN%PT_LEVELS-1:0]: // + lu_vaddr_i[0][12+((VPN_LEN/PT_LEVELS)*(x+1))-1:12+((VPN_LEN/PT_LEVELS)*x)] == tags_q[i].vpn[x]; //identify if there is a hit at each PT level for all TLB entries assign level_match[i][x] = &vpn_match[i][PT_LEVELS-1:x] & page_match[i][x]; //identify if virtual address vpn matches at all PT levels for all TLB entries @@ -117,27 +107,12 @@ //identify if there is a hit at each PT level for all TLB entries assign vaddr_level_match[i][x]= &vaddr_vpn_match[i][PT_LEVELS-1:x] & page_match[i][x]; //update vpn field in tags_n for each TLB when the update is valid and the tag needs to be replaced - assign tags_n[i].vpn[x] = (!flush_i[0] && update_i.valid && replace_en[i]) ? update_i.vpn[(1+x)*(VPN_LEN/PT_LEVELS)-1:x*(VPN_LEN/PT_LEVELS)] : tags_q[i].vpn[x]; + assign tags_n[i].vpn[x] = (!flush_i && update_i.valid && replace_en[i]) ? update_i.vpn[(1+x)*(VPN_LEN/PT_LEVELS)-1:x*(VPN_LEN/PT_LEVELS)] : tags_q[i].vpn[x]; end if(HYP_EXT) begin assign tags_n[i].vpn[PT_LEVELS+HYP_EXT-1][VPN_LEN%PT_LEVELS-1:0] =(!flush_i && update_i.valid && replace_en[i]) ? update_i.vpn[VPN_LEN-1: VPN_LEN-VPN_LEN%PT_LEVELS] : tags_q[i].vpn[PT_LEVELS+HYP_EXT-1][VPN_LEN%PT_LEVELS-1:0]; - assign lu_gpaddr_o[29:12] = (tags_q[i].valid && (&asid_match[i] || (v_st_enbl_i[0] && content_q[i][0].g)) && match_stage[i]) ? - (v_st_enbl_i[0] ? - (page_match[i][1] ? (lu_vaddr_i[29:12]): - (page_match[i][2] ? {content_q[i][0].ppn[17:9],lu_vaddr_i[20:12]}: content_q[i][0].ppn[17:0] )) : - (lu_vaddr_i[29:12])) : - 0; - - - assign lu_gpaddr_o[(riscv::GPLEN-1):30] = (tags_q[i].valid && (&asid_match[i] || (v_st_enbl_i[0] && content_q[i][0].g)) && match_stage[i]) ? - (v_st_enbl_i[0] ? content_q[i][0].ppn[(riscv::GPPNW-1):18] : lu_vaddr_i[(riscv::GPLEN-1):30] ) : - 0; - assign lu_gpaddr_o[11:0] = (tags_q[i].valid && (&asid_match[i] || (v_st_enbl_i[0] && content_q[i][0].g)) && match_stage[i]) ? - lu_vaddr_i[11:0] : - 0; - - end + end end endgenerate @@ -149,7 +124,6 @@ lu_hit_o = 1'b0; lu_content_o = '{default: 0}; lu_is_page_o = 0; - g_content = '{default: 0}; for (int unsigned i = 0; i < TLB_ENTRIES; i++) begin // first level match, this may be a page, check the ASID flags as well @@ -161,33 +135,16 @@ lu_content_o = content_q[i]; lu_hit_o = 1'b1; lu_hit[i] = 1'b1; - // Compute G-Stage PPN based on the gpaddr - if(HYP_EXT) begin - g_content = content_q[i][1]; - if(tags_q[i].is_page[1][1]) - g_content.ppn[8:0] = lu_gpaddr_o[20:12]; - if(tags_q[i].is_page[0][1]) - g_content.ppn[17:0] = lu_gpaddr_o[29:12]; - end end end end end - logic [HYP_EXT:0] asid_to_be_flushed_is0; // indicates that the ASID provided by SFENCE.VMA (rs2)is 0, active high - logic [HYP_EXT:0] vaddr_to_be_flushed_is0; // indicates that the VADDR provided by SFENCE.VMA (rs1)is 0, active high - logic [TLB_ENTRIES-1:0] gpaddr_gppn0_match; - logic [TLB_ENTRIES-1:0] gpaddr_gppn1_match; - logic [TLB_ENTRIES-1:0] gpaddr_gppn2_match; - logic [TLB_ENTRIES-1:0] [(riscv::GPPNW-1):0] gppn; + logic asid_to_be_flushed_is0; // indicates that the ASID provided by SFENCE.VMA (rs2)is 0, active high + logic vaddr_to_be_flushed_is0; // indicates that the VADDR provided by SFENCE.VMA (rs1)is 0, active high - genvar a; - generate - for(a=0;a