Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mmu unify pr #1929

Closed
wants to merge 69 commits into from
Closed

Conversation

AngelaGonzalezMarino
Copy link
Contributor

New attempt of MMU unification

AngelaGonzalezMarino and others added 30 commits February 21, 2024 10:47
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
core/cva6_mmu/cva6_mmu.sv Outdated Show resolved Hide resolved
core/cva6_mmu/cva6_mmu.sv Outdated Show resolved Hide resolved
core/cva6_mmu/cva6_mmu.sv Outdated Show resolved Hide resolved
core/cva6_mmu/cva6_mmu.sv Outdated Show resolved Hide resolved
core/cva6_mmu/cva6_ptw.sv Outdated Show resolved Hide resolved
core/cva6_mmu/cva6_shared_tlb.sv Outdated Show resolved Hide resolved
core/cva6_mmu/cva6_shared_tlb.sv Outdated Show resolved Hide resolved
core/cva6_mmu/cva6_shared_tlb.sv Outdated Show resolved Hide resolved
Copy link
Contributor

✔️ successful run, report available here.

2 similar comments
Copy link
Contributor

✔️ successful run, report available here.

Copy link
Contributor

✔️ successful run, report available here.

@zarubaf
Copy link
Contributor

zarubaf commented Mar 19, 2024

I am getting an elaboration error with the wrapper:

fm_shell (setup)> set_top r:/wrapper_cva6_mmu_sv39
Setting top design to 'r:/WORK/wrapper_cva6_mmu_sv39'
Status:   Elaborating design wrapper_cva6_mmu_sv39   ...  
Status:   Elaborating design mmu  CVA6Cfg=9969'd0, icache_areq_t="struct(1:0:(fetch_valid:scalar(0:LOGIC))(fetch_paddr:vector(0:55:0:LOGIC))(fetch_exception:struct(1:0:(cause:vector(0:63:0:LOGIC))(tval:vector(0:63:0:LOGIC))(valid:scalar(0:LOGIC))$186$))$188$)", icache_arsp_t="struct(1:0:(fetch_req:scalar(0:LOGIC))(fetch_vaddr:vector(0:63:0:LOGIC))$191$)", icache_dreq_t="struct(1:0:(req:scalar(0:LOGIC))(kill_s1:scalar(0:LOGIC))(kill_s2:scalar(0:LOGIC))(spec:scalar(0:LOGIC))(vaddr:vector(0:63:0:LOGIC))$193$)", icache_drsp_t="struct(1:0:(ready:scalar(0:LOGIC))(valid:scalar(0:LOGIC))(data:vector(0:31:0:LOGIC))(user:vector(0:31:0:LOGIC))(vaddr:vector(0:63:0:LOGIC))(ex:struct(1:0:(cause:vector(0:63:0:LOGIC))(tval:vector(0:63:0:LOGIC))(valid:scalar(0:LOGIC))$186$))$195$)", dcache_req_i_t="struct(1:0:(address_index:vector(0:-1:0:LOGIC))(address_tag:vector(0:-1:0:LOGIC))(data_wdata:vector(0:63:0:LOGIC))(data_wuser:vector(0:-1:0:LOGIC))(data_req:scalar(0:LOGIC))(data_we:scalar(0:LOGIC))(data_be:vector(0:7:0:LOGIC))(data_size:vector(0:1:0:LOGIC))(data_id:vector(0:0:0:LOGIC))(kill_req:scalar(0:LOGIC))(tag_valid:scalar(0:LOGIC))$198$)", dcache_req_o_t="struct(1:0:(data_gnt:scalar(0:LOGIC))(data_rvalid:scalar(0:LOGIC))(data_rid:vector(0:0:0:LOGIC))(data_rdata:vector(0:63:0:LOGIC))(data_ruser:vector(0:-1:0:LOGIC))$200$)", exception_t="struct(1:0:(cause:vector(0:63:0:LOGIC))(tval:vector(0:63:0:LOGIC))(valid:scalar(0:LOGIC))$186$)", INSTR_TLB_ENTRIES=16, DATA_TLB_ENTRIES=16, ASID_WIDTH=16 ...  
Error: Illegal range select, selection range [63:-1] out of range [63:0]. (File: /home/zaruba/mmu-equiv/old/mmu.sv Line: 245)  (FMR_ELAB-251)
Warning: Cannot link cell '/WORK/wrapper_cva6_mmu_sv39/i_cva6_mmu' to its reference design 'mmu'. (FE-LINK-2)
Error: Unresolved references detected during link. (FM-234)
Error: Failed to set top design to 'r:/WORK/wrapper_cva6_mmu_sv39' (FM-156)

Screenshot 2024-03-19 at 13 44 01

Do you have the possibility to prepare something like the following structure and check whether the design elaborates with DC? Then I should be able to run it easily with formality.

Attached what I've tried so far:

mmu-equiv.zip

core/cva6_mmu/cva6_mmu.sv Outdated Show resolved Hide resolved
core/cva6_mmu/cva6_mmu.sv Outdated Show resolved Hide resolved
core/cva6_mmu/cva6_mmu.sv Outdated Show resolved Hide resolved
core/cva6_mmu/cva6_mmu.sv Outdated Show resolved Hide resolved
core/cva6_mmu/cva6_ptw.sv Outdated Show resolved Hide resolved
core/cva6_mmu/cva6_ptw.sv Outdated Show resolved Hide resolved
core/cva6_mmu/cva6_ptw.sv Outdated Show resolved Hide resolved
core/cva6_mmu/cva6_tlb.sv Outdated Show resolved Hide resolved
core/cva6_mmu/cva6_tlb.sv Outdated Show resolved Hide resolved
core/cva6_mmu/cva6_tlb.sv Outdated Show resolved Hide resolved
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Copy link
Contributor

✔️ successful run, report available here.

1 similar comment
Copy link
Contributor

✔️ successful run, report available here.

@AngelaGonzalezMarino
Copy link
Contributor Author

I am getting an elaboration error with the wrapper:

fm_shell (setup)> set_top r:/wrapper_cva6_mmu_sv39
Setting top design to 'r:/WORK/wrapper_cva6_mmu_sv39'
Status:   Elaborating design wrapper_cva6_mmu_sv39   ...  
Status:   Elaborating design mmu  CVA6Cfg=9969'd0, icache_areq_t="struct(1:0:(fetch_valid:scalar(0:LOGIC))(fetch_paddr:vector(0:55:0:LOGIC))(fetch_exception:struct(1:0:(cause:vector(0:63:0:LOGIC))(tval:vector(0:63:0:LOGIC))(valid:scalar(0:LOGIC))$186$))$188$)", icache_arsp_t="struct(1:0:(fetch_req:scalar(0:LOGIC))(fetch_vaddr:vector(0:63:0:LOGIC))$191$)", icache_dreq_t="struct(1:0:(req:scalar(0:LOGIC))(kill_s1:scalar(0:LOGIC))(kill_s2:scalar(0:LOGIC))(spec:scalar(0:LOGIC))(vaddr:vector(0:63:0:LOGIC))$193$)", icache_drsp_t="struct(1:0:(ready:scalar(0:LOGIC))(valid:scalar(0:LOGIC))(data:vector(0:31:0:LOGIC))(user:vector(0:31:0:LOGIC))(vaddr:vector(0:63:0:LOGIC))(ex:struct(1:0:(cause:vector(0:63:0:LOGIC))(tval:vector(0:63:0:LOGIC))(valid:scalar(0:LOGIC))$186$))$195$)", dcache_req_i_t="struct(1:0:(address_index:vector(0:-1:0:LOGIC))(address_tag:vector(0:-1:0:LOGIC))(data_wdata:vector(0:63:0:LOGIC))(data_wuser:vector(0:-1:0:LOGIC))(data_req:scalar(0:LOGIC))(data_we:scalar(0:LOGIC))(data_be:vector(0:7:0:LOGIC))(data_size:vector(0:1:0:LOGIC))(data_id:vector(0:0:0:LOGIC))(kill_req:scalar(0:LOGIC))(tag_valid:scalar(0:LOGIC))$198$)", dcache_req_o_t="struct(1:0:(data_gnt:scalar(0:LOGIC))(data_rvalid:scalar(0:LOGIC))(data_rid:vector(0:0:0:LOGIC))(data_rdata:vector(0:63:0:LOGIC))(data_ruser:vector(0:-1:0:LOGIC))$200$)", exception_t="struct(1:0:(cause:vector(0:63:0:LOGIC))(tval:vector(0:63:0:LOGIC))(valid:scalar(0:LOGIC))$186$)", INSTR_TLB_ENTRIES=16, DATA_TLB_ENTRIES=16, ASID_WIDTH=16 ...  
Error: Illegal range select, selection range [63:-1] out of range [63:0]. (File: /home/zaruba/mmu-equiv/old/mmu.sv Line: 245)  (FMR_ELAB-251)
Warning: Cannot link cell '/WORK/wrapper_cva6_mmu_sv39/i_cva6_mmu' to its reference design 'mmu'. (FE-LINK-2)
Error: Unresolved references detected during link. (FM-234)
Error: Failed to set top design to 'r:/WORK/wrapper_cva6_mmu_sv39' (FM-156)

Screenshot 2024-03-19 at 13 44 01

Do you have the possibility to prepare something like the following structure and check whether the design elaborates with DC? Then I should be able to run it easily with formality.

Attached what I've tried so far:

mmu-equiv.zip

@zarubaf Hi, I have been able to compile like this with Questa. Let me know if you can make it too
equiv.zip

core/cva6_mmu/cva6_mmu.sv Outdated Show resolved Hide resolved
core/cva6_mmu/cva6_ptw.sv Outdated Show resolved Hide resolved
core/cva6_mmu/cva6_ptw.sv Outdated Show resolved Hide resolved
core/cva6_mmu/cva6_ptw.sv Outdated Show resolved Hide resolved
core/cva6_mmu/cva6_ptw.sv Outdated Show resolved Hide resolved
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Copy link
Contributor

✔️ successful run, report available here.

1 similar comment
Copy link
Contributor

✔️ successful run, report available here.

@zarubaf
Copy link
Contributor

zarubaf commented Mar 20, 2024

Unfortunately, the two implementations are not equivalent:

fm_shell (setup)> match
Reference design is 'r:/WORK/wrapper_cva6_mmu_sv39'
Implementation design is 'i:/WORK/wrapper_cva6_mmu_unify_sv39'
Status:  Checking designs...
    Warning: 64 (158) undriven nets found in reference (implementation) design; see formality.log for list (FM-399)
Status:  Building verification models...
Status:  Matching...
.
    
*********************************** Matching Results ***********************************    
 1871 Compare points matched by name    
 66 Compare points matched by signature analysis    
 0 Compare points matched by topology    
 926 Matched primary inputs, black-box outputs    
 2193(2260) Unmatched reference(implementation) compare points    
 20(20) Unmatched reference(implementation) primary inputs, black-box outputs    
 561(516) Unmatched reference(implementation) unread points    
----------------------------------------------------------------------------------------    
Unmatched Objects                                                        REF        IMPL    
----------------------------------------------------------------------------------------    
 Cut-points (Cut)                                                         64           0    
 Input ports (Port)                                                       20          20    
 Registers                                                              2129        2260    
   DFF                                                                  2129        2229    
   Constrained 0X                                                          0          31    
****************************************************************************************

    Info:  Formality Guide Files (SVF) can improve matching performance and success by automating setup.
1
fm_shell (match)> 
fm_shell (match)> verify
Reference design is 'r:/WORK/wrapper_cva6_mmu_sv39'
Implementation design is 'i:/WORK/wrapper_cva6_mmu_unify_sv39'
    
*********************************** Matching Results ***********************************    
 1871 Compare points matched by name    
 66 Compare points matched by signature analysis    
 0 Compare points matched by topology    
 926 Matched primary inputs, black-box outputs    
 2193(2260) Unmatched reference(implementation) compare points    
 20(20) Unmatched reference(implementation) primary inputs, black-box outputs    
 561(516) Unmatched reference(implementation) unread points    
----------------------------------------------------------------------------------------    
Unmatched Objects                                                        REF        IMPL    
----------------------------------------------------------------------------------------    
 Cut-points (Cut)                                                         64           0    
 Input ports (Port)                                                       20          20    
 Registers                                                              2129        2260    
   DFF                                                                  2129        2229    
   Constrained 0X                                                          0          31    
****************************************************************************************

Status:  Verifying...
    Compare point dtlb_miss_o failed (is not equivalent)
    Compare point icache_areq_o\[fetch_exception]\[cause][0] failed (is not equivalent)
    Compare point icache_areq_o\[fetch_exception]\[cause][2] failed (is not equivalent)
    Compare point icache_areq_o\[fetch_exception]\[cause][3] failed (is not equivalent)
    Compare point icache_areq_o\[fetch_exception]\[tval][0] failed (is not equivalent)
    Compare point icache_areq_o\[fetch_exception]\[tval][10] failed (is not equivalent)
    Compare point icache_areq_o\[fetch_exception]\[tval][11] failed (is not equivalent)
    Compare point icache_areq_o\[fetch_exception]\[tval][12] failed (is not equivalent)
    Compare point icache_areq_o\[fetch_exception]\[tval][13] failed (is not equivalent)
    Compare point icache_areq_o\[fetch_exception]\[tval][14] failed (is not equivalent)
    Compare point icache_areq_o\[fetch_exception]\[tval][15] failed (is not equivalent)
    Compare point icache_areq_o\[fetch_exception]\[tval][16] failed (is not equivalent)
    Compare point icache_areq_o\[fetch_exception]\[tval][17] failed (is not equivalent)
    Compare point icache_areq_o\[fetch_exception]\[tval][18] failed (is not equivalent)
    Compare point icache_areq_o\[fetch_exception]\[tval][19] failed (is not equivalent)
    Compare point icache_areq_o\[fetch_exception]\[tval][1] failed (is not equivalent)
    Compare point icache_areq_o\[fetch_exception]\[tval][20] failed (is not equivalent)
    Compare point icache_areq_o\[fetch_exception]\[tval][21] failed (is not equivalent)
    Compare point icache_areq_o\[fetch_exception]\[tval][22] failed (is not equivalent)
    Compare point icache_areq_o\[fetch_exception]\[tval][23] failed (is not equivalent)
. 20F/0A/445P/1472U (24% Verification completed) 03/20/24 15:06 1626MB/ 137sec (36.0 hrs until timeout)

************ RTL Interpretation Summary ************
************ Implementation: i:/WORK/wrapper_cva6_mmu_unify_sv39
5 FMR_ELAB-147 messages produced    

Please refer to the Formality log file for more details,
or execute report_hdlin_mismatches.
****************************************************


********************************* Verification Results *********************************
Verification FAILED
   ATTENTION: RTL interpretation messages were produced during link
              of implementation design.
              Verification results may disagree with a logic simulator.
-----------------------------------------------------------------------
 Reference design: r:/WORK/wrapper_cva6_mmu_sv39
 Implementation design: i:/WORK/wrapper_cva6_mmu_unify_sv39
 445 Passing compare points
 20 Failing compare points (20 matched, 0 unmatched)
 0 Aborted compare points
 1472 Unverified compare points
----------------------------------------------------------------------------------------
Matched Compare Points     BBPin    Loop   BBNet     Cut    Port     DFF     LAT   TOTAL
----------------------------------------------------------------------------------------
Passing (equivalent)           0       0       0       0     196     249       0     445
Failing (not equivalent)       0       0       0       0      20       0       0      20
Unverified                     0       0       0       0     402    1070       0    1472
Not Compared
  Constant reg                                                        30       0      30
  Unread                       0       0       0       0       0      12    3072    3084
****************************************************************************************
Info:  Try the analyze_points command to see if Formality can determine potential
causes, or suggest next steps for a FAILED or INCONCLUSIVE verification.
See the man page for analyze_points usage and options.
Info:  Formality Guide Files (SVF) can improve verification success by automating setup.
0
fm_shell (verify)> analyze_points -all > analyze_points.rpt 

analyze_points.log


Some other warnings before:

NAME
       FMR_ELAB-147  (warning)  Index may take values outside array bound, may
       cause simulation mismatch ..
5 FMR_ELAB-147 messages produced    
    File: /home/zaruba/mmu-equiv/unified/shared_tlb.sv, Line: 266
    File: /home/zaruba/mmu-equiv/unified/shared_tlb.sv, Line: 274
    File: /home/zaruba/mmu-equiv/unified/shared_tlb.sv, Line: 373
    File: /home/zaruba/mmu-equiv/unified/shared_tlb.sv, Line: 164
    File: /home/zaruba/mmu-equiv/unified/ptw.sv, Line: 520
Warning: Index may take values outside array bound, may cause simulation mismatch .. (Signal: v_st_enbl_i Block: /cva6_shared_tlb/tag_comparison File: /home/zaruba/mmu-equiv/unified/shared_tlb.sv Line: 266)  (FMR_ELAB-147)
Warning: Index may take values outside array bound, may cause simulation mismatch .. (Signal: v_st_enbl_i Block: /cva6_shared_tlb/tag_comparison File: /home/zaruba/mmu-equiv/unified/shared_tlb.sv Line: 274)  (FMR_ELAB-147)
Warning: Index may take values outside array bound, may cause simulation mismatch .. (Signal: v_st_enbl_i Block: /cva6_shared_tlb File: /home/zaruba/mmu-equiv/unified/shared_tlb.sv Line: 373)  (FMR_ELAB-147)
Warning: Index may take values outside array bound, may cause simulation mismatch .. (Signal: v_st_enbl_i Block: /cva6_shared_tlb File: /home/zaruba/mmu-equiv/unified/shared_tlb.sv Line: 164)  (FMR_ELAB-147)
Warning: Index may take values outside array bound, may cause simulation mismatch .. (Signal: vaddr_lvl Block: /cva6_ptw/ptw File: /home/zaruba/mmu-equiv/unified/ptw.sv Line: 520)  (FMR_ELAB-147)

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

verible-verilog-format

core/cva6_mmu/cva6_mmu.sv|719|
core/cva6_mmu/cva6_mmu.sv|730|
core/cva6_mmu/cva6_mmu.sv|732|
core/cva6_mmu/cva6_mmu.sv|735|
core/cva6_mmu/cva6_mmu.sv|741|
core/cva6_mmu/cva6_mmu.sv|745|
core/cva6_mmu/cva6_mmu.sv|754|
core/cva6_mmu/cva6_mmu.sv|759 col 1|
core/cva6_mmu/cva6_mmu.sv|760|
core/cva6_mmu/cva6_mmu.sv|763|
core/cva6_mmu/cva6_mmu.sv|769|
core/cva6_mmu/cva6_mmu.sv|773|
core/cva6_mmu/cva6_mmu.sv|782 col 1|
core/cva6_mmu/cva6_mmu.sv|783 col 1|
core/cva6_mmu/cva6_mmu.sv|785 col 1|
core/cva6_mmu/cva6_mmu.sv|788|
core/cva6_mmu/cva6_mmu.sv|790|
core/cva6_mmu/cva6_mmu.sv|806|
core/cva6_mmu/cva6_mmu.sv|812|
core/cva6_mmu/cva6_mmu.sv|849|
core/cva6_mmu/cva6_mmu.sv|868|
core/cva6_mmu/cva6_mmu.sv|881|
core/cva6_mmu/cva6_mmu.sv|894|
core/cva6_mmu/cva6_mmu.sv|899|
core/cva6_mmu/cva6_shared_tlb.sv|24|
core/cva6_mmu/cva6_shared_tlb.sv|35|
core/cva6_mmu/cva6_shared_tlb.sv|40|
core/cva6_mmu/cva6_shared_tlb.sv|43|
core/cva6_mmu/cva6_shared_tlb.sv|49|
core/cva6_mmu/cva6_shared_tlb.sv|53|
core/cva6_mmu/cva6_shared_tlb.sv|55|
core/cva6_mmu/cva6_shared_tlb.sv|59|
core/cva6_mmu/cva6_shared_tlb.sv|63|
core/cva6_mmu/cva6_shared_tlb.sv|67|
core/cva6_mmu/cva6_shared_tlb.sv|69|
core/cva6_mmu/cva6_shared_tlb.sv|74|
core/cva6_mmu/cva6_shared_tlb.sv|76|
core/cva6_mmu/cva6_shared_tlb.sv|82|
core/cva6_mmu/cva6_shared_tlb.sv|89|
core/cva6_mmu/cva6_shared_tlb.sv|92|
core/cva6_mmu/cva6_shared_tlb.sv|94|
core/cva6_mmu/cva6_shared_tlb.sv|96|
core/cva6_mmu/cva6_shared_tlb.sv|100|
core/cva6_mmu/cva6_shared_tlb.sv|104|
core/cva6_mmu/cva6_shared_tlb.sv|108|
core/cva6_mmu/cva6_shared_tlb.sv|112|
core/cva6_mmu/cva6_shared_tlb.sv|116|
core/cva6_mmu/cva6_shared_tlb.sv|120|
core/cva6_mmu/cva6_shared_tlb.sv|125|
core/cva6_mmu/cva6_shared_tlb.sv|128|
core/cva6_mmu/cva6_shared_tlb.sv|130|
core/cva6_mmu/cva6_shared_tlb.sv|133|
core/cva6_mmu/cva6_shared_tlb.sv|135|
core/cva6_mmu/cva6_shared_tlb.sv|139|
core/cva6_mmu/cva6_shared_tlb.sv|142|
core/cva6_mmu/cva6_shared_tlb.sv|144|
core/cva6_mmu/cva6_shared_tlb.sv|153|
core/cva6_mmu/cva6_shared_tlb.sv|157|
core/cva6_mmu/cva6_shared_tlb.sv|159|
core/cva6_mmu/cva6_shared_tlb.sv|164|
core/cva6_mmu/cva6_shared_tlb.sv|172|
core/cva6_mmu/cva6_shared_tlb.sv|177|
core/cva6_mmu/cva6_shared_tlb.sv|180 col 1|
core/cva6_mmu/cva6_shared_tlb.sv|181|
core/cva6_mmu/cva6_shared_tlb.sv|184|
core/cva6_mmu/cva6_shared_tlb.sv|190|
core/cva6_mmu/cva6_shared_tlb.sv|280|
core/cva6_mmu/cva6_shared_tlb.sv|282|
core/cva6_mmu/cva6_shared_tlb.sv|288|
core/cva6_mmu/cva6_shared_tlb.sv|292|
core/cva6_mmu/cva6_shared_tlb.sv|320|
core/cva6_mmu/cva6_shared_tlb.sv|371|
core/cva6_mmu/cva6_shared_tlb.sv|373|
core/cva6_mmu/cva6_shared_tlb.sv|388 col 1|
core/cva6_mmu/cva6_shared_tlb.sv|389|
core/cva6_mmu/cva6_shared_tlb.sv|392|
core/cva6_mmu/cva6_shared_tlb.sv|394|
core/cva6_mmu/cva6_shared_tlb.sv|414|
core/cva6_mmu/cva6_shared_tlb.sv|424|
core/cva6_mmu/cva6_shared_tlb.sv|460|
core/cva6_mmu/cva6_shared_tlb.sv|462|
core/cva6_mmu/cva6_shared_tlb.sv|465|
core/cva6_mmu/cva6_shared_tlb.sv|469|
core/cva6_mmu/cva6_shared_tlb.sv|472|
core/cva6_mmu/cva6_shared_tlb.sv|474|
core/cva6_mmu/cva6_shared_tlb.sv|477|



module cva6_mmu
import ariane_pkg::*;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[verible-verilog-format] reported by reviewdog 🐶

Suggested change
import ariane_pkg::*;
import ariane_pkg::*;

Comment on lines +28 to +44
parameter config_pkg::cva6_cfg_t CVA6Cfg = config_pkg::cva6_cfg_empty,
// parameter ariane_pkg::ariane_cfg_t ArianeCfg = ariane_pkg::ArianeDefaultConfig, //This is the required config param in the hypervisor version for now
parameter type exception_t = logic,
parameter type icache_areq_t = logic,
parameter type icache_arsp_t = logic,
parameter type icache_dreq_t = logic,
parameter type icache_drsp_t = logic,
parameter type dcache_req_i_t = logic,
parameter type dcache_req_o_t = logic,
parameter int unsigned INSTR_TLB_ENTRIES = 4,
parameter int unsigned DATA_TLB_ENTRIES = 4,
parameter int unsigned SHARED_TLB_DEPTH = 64,
parameter int unsigned USE_SHARED_TLB = 1,
parameter int unsigned HYP_EXT = 0,
parameter int ASID_WIDTH [HYP_EXT:0],
parameter int unsigned VPN_LEN = 1,
parameter int unsigned PT_LEVELS = 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[verible-verilog-format] reported by reviewdog 🐶

Suggested change
parameter config_pkg::cva6_cfg_t CVA6Cfg = config_pkg::cva6_cfg_empty,
// parameter ariane_pkg::ariane_cfg_t ArianeCfg = ariane_pkg::ArianeDefaultConfig, //This is the required config param in the hypervisor version for now
parameter type exception_t = logic,
parameter type icache_areq_t = logic,
parameter type icache_arsp_t = logic,
parameter type icache_dreq_t = logic,
parameter type icache_drsp_t = logic,
parameter type dcache_req_i_t = logic,
parameter type dcache_req_o_t = logic,
parameter int unsigned INSTR_TLB_ENTRIES = 4,
parameter int unsigned DATA_TLB_ENTRIES = 4,
parameter int unsigned SHARED_TLB_DEPTH = 64,
parameter int unsigned USE_SHARED_TLB = 1,
parameter int unsigned HYP_EXT = 0,
parameter int ASID_WIDTH [HYP_EXT:0],
parameter int unsigned VPN_LEN = 1,
parameter int unsigned PT_LEVELS = 1
parameter config_pkg::cva6_cfg_t CVA6Cfg = config_pkg::cva6_cfg_empty,
// parameter ariane_pkg::ariane_cfg_t ArianeCfg = ariane_pkg::ArianeDefaultConfig, //This is the required config param in the hypervisor version for now
parameter type exception_t = logic,
parameter type icache_areq_t = logic,
parameter type icache_arsp_t = logic,
parameter type icache_dreq_t = logic,
parameter type icache_drsp_t = logic,
parameter type dcache_req_i_t = logic,
parameter type dcache_req_o_t = logic,
parameter int unsigned INSTR_TLB_ENTRIES = 4,
parameter int unsigned DATA_TLB_ENTRIES = 4,
parameter int unsigned SHARED_TLB_DEPTH = 64,
parameter int unsigned USE_SHARED_TLB = 1,
parameter int unsigned HYP_EXT = 0,
parameter int ASID_WIDTH [HYP_EXT:0],
parameter int unsigned VPN_LEN = 1,
parameter int unsigned PT_LEVELS = 1

Comment on lines +47 to +258
pte_cva6_t [ HYP_EXT:0] dtlb_content;
logic [ PT_LEVELS-2:0] dtlb_is_page;
logic [ASID_WIDTH[0]-1:0] dtlb_lu_asid;
logic dtlb_lu_hit;
logic [ riscv::GPLEN-1:0] dtlb_gpaddr;

logic shared_tlb_access,shared_tlb_miss;
logic shared_tlb_hit, itlb_req;

// Assignments

assign itlb_lu_access = icache_areq_i.fetch_req;
assign dtlb_lu_access = lsu_req_i;


cva6_tlb #(
.CVA6Cfg (CVA6Cfg),
.pte_cva6_t (pte_cva6_t),
.tlb_update_cva6_t(tlb_update_cva6_t),
.TLB_ENTRIES (INSTR_TLB_ENTRIES),
.HYP_EXT (HYP_EXT),
.ASID_WIDTH (ASID_WIDTH),
.VPN_LEN (VPN_LEN),
.PT_LEVELS (PT_LEVELS)
) i_itlb (
.clk_i (clk_i),
.rst_ni (rst_ni),
.flush_i (flush_tlb_i),
.v_st_enbl_i (enable_translation_i),
.update_i (update_itlb),
.lu_access_i (itlb_lu_access),
.lu_asid_i (itlb_mmu_asid_i),
.asid_to_be_flushed_i (asid_to_be_flushed_i),
.vaddr_to_be_flushed_i(vaddr_to_be_flushed_i),
.lu_vaddr_i (icache_areq_i.fetch_vaddr),
.lu_content_o (itlb_content),
.lu_gpaddr_o (itlb_gpaddr),
.lu_is_page_o (itlb_is_page),
.lu_hit_o (itlb_lu_hit)
);

cva6_tlb #(
.CVA6Cfg (CVA6Cfg),
.pte_cva6_t (pte_cva6_t),
.tlb_update_cva6_t(tlb_update_cva6_t),
.TLB_ENTRIES (DATA_TLB_ENTRIES),
.HYP_EXT (HYP_EXT),
.ASID_WIDTH (ASID_WIDTH),
.VPN_LEN (VPN_LEN),
.PT_LEVELS (PT_LEVELS)
) i_dtlb (
.clk_i (clk_i),
.rst_ni (rst_ni),
.flush_i (flush_tlb_i),
.v_st_enbl_i (en_ld_st_translation_i),
.update_i (update_dtlb),
.lu_access_i (dtlb_lu_access),
.lu_asid_i (dtlb_mmu_asid_i),
.asid_to_be_flushed_i (asid_to_be_flushed_i),
.vaddr_to_be_flushed_i(vaddr_to_be_flushed_i),
.lu_vaddr_i (lsu_vaddr_i),
.lu_content_o (dtlb_content),
.lu_gpaddr_o (dtlb_gpaddr),
.lu_is_page_o (dtlb_is_page),
.lu_hit_o (dtlb_lu_hit)
);


cva6_shared_tlb #(
.CVA6Cfg (CVA6Cfg),
.SHARED_TLB_DEPTH (SHARED_TLB_DEPTH),
.USE_SHARED_TLB (USE_SHARED_TLB),
.SHARED_TLB_WAYS (2),
.HYP_EXT (HYP_EXT),
.ASID_WIDTH (ASID_WIDTH),
.VPN_LEN (VPN_LEN),
.PT_LEVELS (PT_LEVELS),
.pte_cva6_t (pte_cva6_t),
.tlb_update_cva6_t(tlb_update_cva6_t)
) i_shared_tlb (
.clk_i(clk_i),
.rst_ni(rst_ni),
.flush_i(flush_tlb_i),
.v_st_enbl_i({enable_translation_i, en_ld_st_translation_i}),

.dtlb_asid_i (dtlb_mmu_asid_i),
.itlb_asid_i (itlb_mmu_asid_i),
// from TLBs
// did we miss?
.itlb_access_i(itlb_lu_access),
.itlb_hit_i (itlb_lu_hit),
.itlb_vaddr_i (icache_areq_i.fetch_vaddr),

.dtlb_access_i(dtlb_lu_access),
.dtlb_hit_i (dtlb_lu_hit),
.dtlb_vaddr_i (lsu_vaddr_i),

// to TLBs, update logic
.itlb_update_o(update_itlb),
.dtlb_update_o(update_dtlb),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[verible-verilog-format] reported by reviewdog 🐶

Suggested change
input logic clk_i,
input logic rst_ni,
input logic flush_i,
input logic [HYP_EXT*2:0] enable_translation_i, //[v_i,enable_g_translation,enable_translation]
input logic [HYP_EXT*2:0] en_ld_st_translation_i, // enable virtual memory translation for ld/st
// IF interface
input icache_arsp_t icache_areq_i,
output icache_areq_t icache_areq_o,
// input icache_areq_o_t icache_areq_i, // this is the data type in the hypervisor version for now
// output icache_areq_i_t icache_areq_o,
// LSU interface
// this is a more minimalistic interface because the actual addressing logic is handled
// in the LSU as we distinguish load and stores, what we do here is simple address translation
input exception_t misaligned_ex_i,
input logic lsu_req_i, // request address translation
input logic [CVA6Cfg.VLEN-1:0] lsu_vaddr_i, // virtual address in
input logic [CVA6Cfg.XLEN-1:0] lsu_tinst_i, // transformed instruction in
input logic lsu_is_store_i, // the translation is requested by a store
output logic csr_hs_ld_st_inst_o, // hyp load store instruction
// if we need to walk the page table we can't grant in the same cycle
// Cycle 0
output logic lsu_dtlb_hit_o, // sent in same cycle as the request if translation hits in DTLB
output logic [CVA6Cfg.PPNW-1:0] lsu_dtlb_ppn_o, // ppn (send same cycle as hit)
// Cycle 1
output logic lsu_valid_o, // translation is valid
output logic [CVA6Cfg.PLEN-1:0] lsu_paddr_o, // translated address
output exception_t lsu_exception_o, // address translation threw an exception
// General control signals
input riscv::priv_lvl_t priv_lvl_i,
input riscv::priv_lvl_t ld_st_priv_lvl_i,
input logic [HYP_EXT:0] sum_i,
input logic [HYP_EXT:0] mxr_i,
input logic hlvx_inst_i,
input logic hs_ld_st_inst_i,
// input logic flag_mprv_i,
input logic [CVA6Cfg.PPNW-1:0] satp_ppn_i[HYP_EXT*2:0], //[hgatp,vsatp,satp]
input logic [ASID_WIDTH[0]-1:0] asid_i [HYP_EXT*2:0], //[vmid,vs_asid,asid]
input logic [ASID_WIDTH[0]-1:0] asid_to_be_flushed_i [ HYP_EXT:0],
input logic [ CVA6Cfg.VLEN-1:0] vaddr_to_be_flushed_i[ HYP_EXT:0],
input logic [HYP_EXT*2:0] flush_tlb_i,
// Performance counters
output logic itlb_miss_o,
output logic dtlb_miss_o,
// PTW memory interface
input dcache_req_o_t req_port_i,
output dcache_req_i_t req_port_o,
// PMP
input riscv::pmpcfg_t [15:0] pmpcfg_i,
input logic [15:0][CVA6Cfg.PLEN-3:0] pmpaddr_i
);
logic [ASID_WIDTH[0]-1:0] dtlb_mmu_asid_i[HYP_EXT:0];
logic [ASID_WIDTH[0]-1:0] itlb_mmu_asid_i[HYP_EXT:0];
genvar b;
generate
for (b = 0; b < HYP_EXT + 1; b++) begin : gen_tlbs_asid
assign dtlb_mmu_asid_i[b] = b==0 ?
((en_ld_st_translation_i[2*HYP_EXT] || flush_tlb_i[HYP_EXT]) ? asid_i[HYP_EXT] : asid_i[0]):
asid_i[HYP_EXT*2];
assign itlb_mmu_asid_i[b] = b==0 ?
(enable_translation_i[2*HYP_EXT] ? asid_i[HYP_EXT] : asid_i[0]):
asid_i[HYP_EXT*2];
end
endgenerate
// memory management, pte for cva6
localparam type pte_cva6_t = struct packed {
logic [CVA6Cfg.PPNW-1:0] ppn; // PPN length for
logic [1:0] rsw;
logic d;
logic a;
logic g;
logic u;
logic x;
logic w;
logic r;
logic v;
};
localparam type tlb_update_cva6_t = struct packed {
logic valid;
logic [PT_LEVELS-2:0][HYP_EXT:0] is_page;
logic [VPN_LEN-1:0] vpn;
logic [HYP_EXT:0][ASID_WIDTH[0]-1:0] asid;
logic [HYP_EXT*2:0] v_st_enbl; // v_i,g-stage enabled, s-stage enabled
pte_cva6_t [HYP_EXT:0] content;
};
logic [HYP_EXT:0] iaccess_err; // insufficient privilege to access this instruction page
logic [HYP_EXT:0] daccess_err; // insufficient privilege to access this data page
logic ptw_active; // PTW is currently walking a page table
logic walking_instr; // PTW is walking because of an ITLB miss
logic [HYP_EXT*2:0] ptw_error; // PTW threw an exception
logic ptw_access_exception; // PTW threw an access exception (PMPs)
logic [HYP_EXT:0][CVA6Cfg.PLEN-1:0] ptw_bad_paddr; // PTW guest page fault bad guest physical addr
logic [CVA6Cfg.VLEN-1:0] update_vaddr, shared_tlb_vaddr;
tlb_update_cva6_t update_itlb, update_dtlb, update_shared_tlb;
logic itlb_lu_access;
pte_cva6_t [ HYP_EXT:0] itlb_content;
logic [ PT_LEVELS-2:0] itlb_is_page;
logic itlb_lu_hit;
logic [ riscv::GPLEN-1:0] itlb_gpaddr;
logic [ASID_WIDTH[0]-1:0] itlb_lu_asid;
logic dtlb_lu_access;
pte_cva6_t [ HYP_EXT:0] dtlb_content;
logic [ PT_LEVELS-2:0] dtlb_is_page;
logic [ASID_WIDTH[0]-1:0] dtlb_lu_asid;
logic dtlb_lu_hit;
logic [ riscv::GPLEN-1:0] dtlb_gpaddr;
logic shared_tlb_access,shared_tlb_miss;
logic shared_tlb_hit, itlb_req;
// Assignments
assign itlb_lu_access = icache_areq_i.fetch_req;
assign dtlb_lu_access = lsu_req_i;
cva6_tlb #(
.CVA6Cfg (CVA6Cfg),
.pte_cva6_t (pte_cva6_t),
.tlb_update_cva6_t(tlb_update_cva6_t),
.TLB_ENTRIES (INSTR_TLB_ENTRIES),
.HYP_EXT (HYP_EXT),
.ASID_WIDTH (ASID_WIDTH),
.VPN_LEN (VPN_LEN),
.PT_LEVELS (PT_LEVELS)
) i_itlb (
.clk_i (clk_i),
.rst_ni (rst_ni),
.flush_i (flush_tlb_i),
.v_st_enbl_i (enable_translation_i),
.update_i (update_itlb),
.lu_access_i (itlb_lu_access),
.lu_asid_i (itlb_mmu_asid_i),
.asid_to_be_flushed_i (asid_to_be_flushed_i),
.vaddr_to_be_flushed_i(vaddr_to_be_flushed_i),
.lu_vaddr_i (icache_areq_i.fetch_vaddr),
.lu_content_o (itlb_content),
.lu_gpaddr_o (itlb_gpaddr),
.lu_is_page_o (itlb_is_page),
.lu_hit_o (itlb_lu_hit)
);
cva6_tlb #(
.CVA6Cfg (CVA6Cfg),
.pte_cva6_t (pte_cva6_t),
.tlb_update_cva6_t(tlb_update_cva6_t),
.TLB_ENTRIES (DATA_TLB_ENTRIES),
.HYP_EXT (HYP_EXT),
.ASID_WIDTH (ASID_WIDTH),
.VPN_LEN (VPN_LEN),
.PT_LEVELS (PT_LEVELS)
) i_dtlb (
.clk_i (clk_i),
.rst_ni (rst_ni),
.flush_i (flush_tlb_i),
.v_st_enbl_i (en_ld_st_translation_i),
.update_i (update_dtlb),
.lu_access_i (dtlb_lu_access),
.lu_asid_i (dtlb_mmu_asid_i),
.asid_to_be_flushed_i (asid_to_be_flushed_i),
.vaddr_to_be_flushed_i(vaddr_to_be_flushed_i),
.lu_vaddr_i (lsu_vaddr_i),
.lu_content_o (dtlb_content),
.lu_gpaddr_o (dtlb_gpaddr),
.lu_is_page_o (dtlb_is_page),
.lu_hit_o (dtlb_lu_hit)
);
cva6_shared_tlb #(
.CVA6Cfg (CVA6Cfg),
.SHARED_TLB_DEPTH (SHARED_TLB_DEPTH),
.USE_SHARED_TLB (USE_SHARED_TLB),
.SHARED_TLB_WAYS (2),
.HYP_EXT (HYP_EXT),
.ASID_WIDTH (ASID_WIDTH),
.VPN_LEN (VPN_LEN),
.PT_LEVELS (PT_LEVELS),
.pte_cva6_t (pte_cva6_t),
.tlb_update_cva6_t(tlb_update_cva6_t)
) i_shared_tlb (
.clk_i(clk_i),
.rst_ni(rst_ni),
.flush_i(flush_tlb_i),
.v_st_enbl_i({enable_translation_i, en_ld_st_translation_i}),
.dtlb_asid_i (dtlb_mmu_asid_i),
.itlb_asid_i (itlb_mmu_asid_i),
// from TLBs
// did we miss?
.itlb_access_i(itlb_lu_access),
.itlb_hit_i (itlb_lu_hit),
.itlb_vaddr_i (icache_areq_i.fetch_vaddr),
.dtlb_access_i(dtlb_lu_access),
.dtlb_hit_i (dtlb_lu_hit),
.dtlb_vaddr_i (lsu_vaddr_i),
// to TLBs, update logic
.itlb_update_o(update_itlb),
.dtlb_update_o(update_dtlb),
input logic clk_i,
input logic rst_ni,
input logic flush_i,
input logic [HYP_EXT*2:0] enable_translation_i, //[v_i,enable_g_translation,enable_translation]
input logic [HYP_EXT*2:0] en_ld_st_translation_i, // enable virtual memory translation for ld/st
// IF interface
input icache_arsp_t icache_areq_i,
output icache_areq_t icache_areq_o,
// input icache_areq_o_t icache_areq_i, // this is the data type in the hypervisor version for now
// output icache_areq_i_t icache_areq_o,
// LSU interface
// this is a more minimalistic interface because the actual addressing logic is handled
// in the LSU as we distinguish load and stores, what we do here is simple address translation
input exception_t misaligned_ex_i,
input logic lsu_req_i, // request address translation
input logic [CVA6Cfg.VLEN-1:0] lsu_vaddr_i, // virtual address in
input logic [CVA6Cfg.XLEN-1:0] lsu_tinst_i, // transformed instruction in
input logic lsu_is_store_i, // the translation is requested by a store
output logic csr_hs_ld_st_inst_o, // hyp load store instruction
// if we need to walk the page table we can't grant in the same cycle
// Cycle 0
output logic lsu_dtlb_hit_o, // sent in same cycle as the request if translation hits in DTLB
output logic [CVA6Cfg.PPNW-1:0] lsu_dtlb_ppn_o, // ppn (send same cycle as hit)
// Cycle 1
output logic lsu_valid_o, // translation is valid
output logic [CVA6Cfg.PLEN-1:0] lsu_paddr_o, // translated address
output exception_t lsu_exception_o, // address translation threw an exception
// General control signals
input riscv::priv_lvl_t priv_lvl_i,
input riscv::priv_lvl_t ld_st_priv_lvl_i,
input logic [HYP_EXT:0] sum_i,
input logic [HYP_EXT:0] mxr_i,
input logic hlvx_inst_i,
input logic hs_ld_st_inst_i,
// input logic flag_mprv_i,
input logic [CVA6Cfg.PPNW-1:0] satp_ppn_i[HYP_EXT*2:0], //[hgatp,vsatp,satp]
input logic [ASID_WIDTH[0]-1:0] asid_i [HYP_EXT*2:0], //[vmid,vs_asid,asid]
input logic [ASID_WIDTH[0]-1:0] asid_to_be_flushed_i [ HYP_EXT:0],
input logic [ CVA6Cfg.VLEN-1:0] vaddr_to_be_flushed_i[ HYP_EXT:0],
input logic [HYP_EXT*2:0] flush_tlb_i,

Comment on lines +261 to +298
.itlb_miss_o(itlb_miss_o),
.dtlb_miss_o(dtlb_miss_o),
.shared_tlb_miss_i(shared_tlb_miss),

.shared_tlb_access_o(shared_tlb_access),
.shared_tlb_hit_o (shared_tlb_hit),
.shared_tlb_vaddr_o (shared_tlb_vaddr),

.itlb_req_o (itlb_req),
// to update shared tlb
.shared_tlb_update_i(update_shared_tlb)
);

cva6_ptw #(
.CVA6Cfg (CVA6Cfg),
// .ArianeCfg ( ArianeCfg ), // this is the configuration needed in the hypervisor extension for now
.pte_cva6_t (pte_cva6_t),
.tlb_update_cva6_t(tlb_update_cva6_t),
.dcache_req_i_t (dcache_req_i_t),
.dcache_req_o_t (dcache_req_o_t),
.HYP_EXT (HYP_EXT),
.ASID_WIDTH (ASID_WIDTH),
.VPN_LEN (VPN_LEN),
.PT_LEVELS (PT_LEVELS)
) i_ptw (
.clk_i (clk_i),
.rst_ni (rst_ni),
.flush_i(flush_i),

.ptw_active_o (ptw_active),
.walking_instr_o (walking_instr),
.ptw_error_o (ptw_error),
.ptw_access_exception_o(ptw_access_exception),

.enable_translation_i (enable_translation_i),
.en_ld_st_translation_i(en_ld_st_translation_i),

.lsu_is_store_i(lsu_is_store_i),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[verible-verilog-format] reported by reviewdog 🐶

Suggested change
.itlb_miss_o(itlb_miss_o),
.dtlb_miss_o(dtlb_miss_o),
.shared_tlb_miss_i(shared_tlb_miss),
.shared_tlb_access_o(shared_tlb_access),
.shared_tlb_hit_o (shared_tlb_hit),
.shared_tlb_vaddr_o (shared_tlb_vaddr),
.itlb_req_o (itlb_req),
// to update shared tlb
.shared_tlb_update_i(update_shared_tlb)
);
cva6_ptw #(
.CVA6Cfg (CVA6Cfg),
// .ArianeCfg ( ArianeCfg ), // this is the configuration needed in the hypervisor extension for now
.pte_cva6_t (pte_cva6_t),
.tlb_update_cva6_t(tlb_update_cva6_t),
.dcache_req_i_t (dcache_req_i_t),
.dcache_req_o_t (dcache_req_o_t),
.HYP_EXT (HYP_EXT),
.ASID_WIDTH (ASID_WIDTH),
.VPN_LEN (VPN_LEN),
.PT_LEVELS (PT_LEVELS)
) i_ptw (
.clk_i (clk_i),
.rst_ni (rst_ni),
.flush_i(flush_i),
.ptw_active_o (ptw_active),
.walking_instr_o (walking_instr),
.ptw_error_o (ptw_error),
.ptw_access_exception_o(ptw_access_exception),
.enable_translation_i (enable_translation_i),
.en_ld_st_translation_i(en_ld_st_translation_i),
.lsu_is_store_i(lsu_is_store_i),
output logic itlb_miss_o,
output logic dtlb_miss_o,

Comment on lines +300 to +326
.req_port_i (req_port_i),
.req_port_o (req_port_o),

.asid_i(asid_i),

.update_vaddr_o(update_vaddr),

// to Shared TLB, update logic
.shared_tlb_update_o(update_shared_tlb),


// from shared TLB
// did we miss?
.shared_tlb_access_i(shared_tlb_access),
.shared_tlb_hit_i (shared_tlb_hit),
.shared_tlb_vaddr_i (shared_tlb_vaddr),

.itlb_req_i(itlb_req),

.hlvx_inst_i(hlvx_inst_i),
// from CSR file
.satp_ppn_i (satp_ppn_i),
.mxr_i (mxr_i),

// Performance counters
.shared_tlb_miss_o(shared_tlb_miss), //open for now

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[verible-verilog-format] reported by reviewdog 🐶

Suggested change
.req_port_i (req_port_i),
.req_port_o (req_port_o),
.asid_i(asid_i),
.update_vaddr_o(update_vaddr),
// to Shared TLB, update logic
.shared_tlb_update_o(update_shared_tlb),
// from shared TLB
// did we miss?
.shared_tlb_access_i(shared_tlb_access),
.shared_tlb_hit_i (shared_tlb_hit),
.shared_tlb_vaddr_i (shared_tlb_vaddr),
.itlb_req_i(itlb_req),
.hlvx_inst_i(hlvx_inst_i),
// from CSR file
.satp_ppn_i (satp_ppn_i),
.mxr_i (mxr_i),
// Performance counters
.shared_tlb_miss_o(shared_tlb_miss), //open for now
input dcache_req_o_t req_port_i,
output dcache_req_i_t req_port_o,

Comment on lines +600 to +601
lsu_dtlb_ppn_o[PPNWMin:12] = lsu_vaddr_n[0][PPNWMin:12];
lsu_paddr_o[PPNWMin:12] = lsu_vaddr_q[0][PPNWMin:12];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[verible-verilog-format] reported by reviewdog 🐶

Suggested change
lsu_dtlb_ppn_o[PPNWMin:12] = lsu_vaddr_n[0][PPNWMin:12];
lsu_paddr_o[PPNWMin:12] = lsu_vaddr_q[0][PPNWMin:12];
lsu_dtlb_ppn_o = (en_ld_st_translation_i[HYP_EXT] && HYP_EXT == 1)? dtlb_content[HYP_EXT].ppn :dtlb_content[0].ppn;
lsu_paddr_o = {
(en_ld_st_translation_i[HYP_EXT] && HYP_EXT == 1)? dtlb_pte_q[HYP_EXT].ppn : dtlb_pte_q[0].ppn,
lsu_vaddr_q[0][11:0]
};
// Mega page
if (dtlb_is_page_q[0]) begin

lsu_dtlb_ppn_o[PPNWMin:12] = lsu_vaddr_n[0][PPNWMin:12];
lsu_paddr_o[PPNWMin:12] = lsu_vaddr_q[0][PPNWMin:12];

end else if (PT_LEVELS == 3 && dtlb_is_page_q[PT_LEVELS-2]) begin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[verible-verilog-format] reported by reviewdog 🐶

Suggested change
end else if (PT_LEVELS == 3 && dtlb_is_page_q[PT_LEVELS-2]) begin
lsu_dtlb_ppn_o[PPNWMin:12] = lsu_vaddr_n[0][PPNWMin:12];
lsu_paddr_o[PPNWMin:12] = lsu_vaddr_q[0][PPNWMin:12];

Comment on lines +605 to +606
lsu_paddr_o[PPNWMin-(VPN_LEN/PT_LEVELS):9+PT_LEVELS] = lsu_vaddr_q[0][PPNWMin-(VPN_LEN/PT_LEVELS):9+PT_LEVELS];
lsu_dtlb_ppn_o[PPNWMin-(VPN_LEN/PT_LEVELS):9+PT_LEVELS] = lsu_vaddr_n[0][PPNWMin-(VPN_LEN/PT_LEVELS):9+PT_LEVELS];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[verible-verilog-format] reported by reviewdog 🐶

Suggested change
lsu_paddr_o[PPNWMin-(VPN_LEN/PT_LEVELS):9+PT_LEVELS] = lsu_vaddr_q[0][PPNWMin-(VPN_LEN/PT_LEVELS):9+PT_LEVELS];
lsu_dtlb_ppn_o[PPNWMin-(VPN_LEN/PT_LEVELS):9+PT_LEVELS] = lsu_vaddr_n[0][PPNWMin-(VPN_LEN/PT_LEVELS):9+PT_LEVELS];
end else if (PT_LEVELS == 3 && dtlb_is_page_q[PT_LEVELS-2]) begin

lsu_paddr_o[PPNWMin-(VPN_LEN/PT_LEVELS):9+PT_LEVELS] = lsu_vaddr_q[0][PPNWMin-(VPN_LEN/PT_LEVELS):9+PT_LEVELS];
lsu_dtlb_ppn_o[PPNWMin-(VPN_LEN/PT_LEVELS):9+PT_LEVELS] = lsu_vaddr_n[0][PPNWMin-(VPN_LEN/PT_LEVELS):9+PT_LEVELS];

end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[verible-verilog-format] reported by reviewdog 🐶

Suggested change
end
lsu_paddr_o[PPNWMin-(VPN_LEN/PT_LEVELS):9+PT_LEVELS] = lsu_vaddr_q[0][PPNWMin-(VPN_LEN/PT_LEVELS):9+PT_LEVELS];
lsu_dtlb_ppn_o[PPNWMin-(VPN_LEN/PT_LEVELS):9+PT_LEVELS] = lsu_vaddr_n[0][PPNWMin-(VPN_LEN/PT_LEVELS):9+PT_LEVELS];

Comment on lines +610 to +717
// physical memory based exceptions are ACCESS_FAULTS (PMA/PMP)

// this is a store
if (lsu_is_store_q) begin
// check if the page is write-able and we are not violating privileges
// also check if the dirty flag is set
if(HYP_EXT==1 && en_ld_st_translation_i[HYP_EXT] && (!dtlb_pte_q[HYP_EXT].w || daccess_err[HYP_EXT] || !dtlb_pte_q[HYP_EXT].d)) begin
lsu_exception_o = exception_t'({
riscv::STORE_GUEST_PAGE_FAULT,
{{CVA6Cfg.XLEN - CVA6Cfg.VLEN{lsu_vaddr_q[0][CVA6Cfg.VLEN-1]}}, lsu_vaddr_q[0]},
lsu_vaddr_q[HYP_EXT][(CVA6Cfg.XLEN==32?CVA6Cfg.VLEN : riscv::GPLEN)-1:0],
{CVA6Cfg.XLEN{1'b0}},
en_ld_st_translation_i[HYP_EXT*2],
1'b1
});
end else if ((en_ld_st_translation_i[0] || HYP_EXT==0) && (!dtlb_pte_q[0].w || daccess_err[0] || !dtlb_pte_q[0].d)) begin
if (HYP_EXT == 1) begin
lsu_exception_o = exception_t'({
riscv::STORE_PAGE_FAULT,
{{CVA6Cfg.XLEN - CVA6Cfg.VLEN{lsu_vaddr_q[0][CVA6Cfg.VLEN-1]}}, lsu_vaddr_q[0]},
{riscv::GPLEN{1'b0}},
lsu_tinst_q,
en_ld_st_translation_i[HYP_EXT*2],
1'b1
});
end else begin
lsu_exception_o = exception_t'({
riscv::STORE_PAGE_FAULT,
{{CVA6Cfg.XLEN - CVA6Cfg.VLEN{lsu_vaddr_q[0][CVA6Cfg.VLEN-1]}}, lsu_vaddr_q[0]},
1'b1
});
end
// Check if any PMPs are violated
end else if (!pmp_data_allow) begin
if (HYP_EXT == 1) begin
lsu_exception_o =exception_t'({
riscv::ST_ACCESS_FAULT,
{CVA6Cfg.XLEN'(lsu_paddr_o)},
{riscv::GPLEN{1'b0}},
lsu_tinst_q,
en_ld_st_translation_i[HYP_EXT*2],
1'b1
});
end else begin
lsu_exception_o = exception_t'({
riscv::ST_ACCESS_FAULT,
CVA6Cfg.XLEN'(lsu_paddr_o[CVA6Cfg.PLEN-1:(CVA6Cfg.PLEN > CVA6Cfg.VLEN) ? (CVA6Cfg.PLEN - CVA6Cfg.VLEN) : 0]),
1'b1
});
end
end

// this is a load
end else begin
if (HYP_EXT == 1 && daccess_err[HYP_EXT]) begin
lsu_exception_o = exception_t'({
riscv::LOAD_GUEST_PAGE_FAULT,
{{CVA6Cfg.XLEN - CVA6Cfg.VLEN{lsu_vaddr_q[0][CVA6Cfg.VLEN-1]}}, lsu_vaddr_q[0]},
lsu_vaddr_q[HYP_EXT][(CVA6Cfg.XLEN==32?CVA6Cfg.VLEN : riscv::GPLEN)-1:0],
{CVA6Cfg.XLEN{1'b0}},
en_ld_st_translation_i[HYP_EXT*2],
1'b1
});
// check for sufficient access privileges - throw a page fault if necessary
end else if (daccess_err[0]) begin
if (HYP_EXT == 1) begin
lsu_exception_o = exception_t'({
riscv::LOAD_PAGE_FAULT,
{{CVA6Cfg.XLEN - CVA6Cfg.VLEN{lsu_vaddr_q[0][CVA6Cfg.VLEN-1]}}, lsu_vaddr_q[0]},
{riscv::GPLEN{1'b0}},
lsu_tinst_q,
en_ld_st_translation_i[HYP_EXT*2],
1'b1
});
end else begin
lsu_exception_o = exception_t'({
riscv::LOAD_PAGE_FAULT,
{{CVA6Cfg.XLEN - CVA6Cfg.VLEN{lsu_vaddr_q[0][CVA6Cfg.VLEN-1]}}, lsu_vaddr_q[0]},
1'b1
});
end
// Check if any PMPs are violated
end else if (!pmp_data_allow) begin
if (HYP_EXT == 1) begin
lsu_exception_o = exception_t'({
riscv::LD_ACCESS_FAULT,
{{CVA6Cfg.XLEN - CVA6Cfg.VLEN{lsu_vaddr_q[0][CVA6Cfg.VLEN-1]}}, lsu_vaddr_q[0]},
{riscv::GPLEN{1'b0}},
lsu_tinst_q,
en_ld_st_translation_i[HYP_EXT*2],
1'b1
});
end else begin
lsu_exception_o = exception_t'({
riscv::LD_ACCESS_FAULT,
lsu_paddr_o[CVA6Cfg.PLEN-1:(CVA6Cfg.PLEN>CVA6Cfg.VLEN)?(CVA6Cfg.PLEN-CVA6Cfg.VLEN) : 0],
1'b1
});
end
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[verible-verilog-format] reported by reviewdog 🐶

Suggested change
// ---------
// DTLB Hit
// --------
if (dtlb_hit_q && lsu_req_q) begin
lsu_valid_o = 1'b1;
// exception priority:
// PAGE_FAULTS have higher priority than ACCESS_FAULTS
// virtual memory based exceptions are PAGE_FAULTS
// physical memory based exceptions are ACCESS_FAULTS (PMA/PMP)
// this is a store
if (lsu_is_store_q) begin
// check if the page is write-able and we are not violating privileges
// also check if the dirty flag is set
if(HYP_EXT==1 && en_ld_st_translation_i[HYP_EXT] && (!dtlb_pte_q[HYP_EXT].w || daccess_err[HYP_EXT] || !dtlb_pte_q[HYP_EXT].d)) begin
lsu_exception_o = exception_t'({
riscv::STORE_GUEST_PAGE_FAULT,
{{CVA6Cfg.XLEN - CVA6Cfg.VLEN{lsu_vaddr_q[0][CVA6Cfg.VLEN-1]}}, lsu_vaddr_q[0]},
lsu_vaddr_q[HYP_EXT][(CVA6Cfg.XLEN==32?CVA6Cfg.VLEN : riscv::GPLEN)-1:0],
{CVA6Cfg.XLEN{1'b0}},
en_ld_st_translation_i[HYP_EXT*2],
1'b1
});
end else if ((en_ld_st_translation_i[0] || HYP_EXT==0) && (!dtlb_pte_q[0].w || daccess_err[0] || !dtlb_pte_q[0].d)) begin
if (HYP_EXT == 1) begin
lsu_exception_o = exception_t'({
riscv::STORE_PAGE_FAULT,
{{CVA6Cfg.XLEN - CVA6Cfg.VLEN{lsu_vaddr_q[0][CVA6Cfg.VLEN-1]}}, lsu_vaddr_q[0]},
{riscv::GPLEN{1'b0}},
lsu_tinst_q,
en_ld_st_translation_i[HYP_EXT*2],
1'b1
});
end else begin
lsu_exception_o = exception_t'({
riscv::STORE_PAGE_FAULT,
{{CVA6Cfg.XLEN - CVA6Cfg.VLEN{lsu_vaddr_q[0][CVA6Cfg.VLEN-1]}}, lsu_vaddr_q[0]},
1'b1
});
end
// Check if any PMPs are violated
end else if (!pmp_data_allow) begin
if (HYP_EXT == 1) begin
lsu_exception_o =exception_t'({
riscv::ST_ACCESS_FAULT,
{CVA6Cfg.XLEN'(lsu_paddr_o)},
{riscv::GPLEN{1'b0}},
lsu_tinst_q,
en_ld_st_translation_i[HYP_EXT*2],
1'b1
});
end else begin
lsu_exception_o = exception_t'({
riscv::ST_ACCESS_FAULT,
CVA6Cfg.XLEN'(lsu_paddr_o[CVA6Cfg.PLEN-1:(CVA6Cfg.PLEN > CVA6Cfg.VLEN) ? (CVA6Cfg.PLEN - CVA6Cfg.VLEN) : 0]),
1'b1
});
end
end
// this is a load
end else begin
if (HYP_EXT == 1 && daccess_err[HYP_EXT]) begin
lsu_exception_o = exception_t'({
riscv::LOAD_GUEST_PAGE_FAULT,
{{CVA6Cfg.XLEN - CVA6Cfg.VLEN{lsu_vaddr_q[0][CVA6Cfg.VLEN-1]}}, lsu_vaddr_q[0]},
lsu_vaddr_q[HYP_EXT][(CVA6Cfg.XLEN==32?CVA6Cfg.VLEN : riscv::GPLEN)-1:0],
{CVA6Cfg.XLEN{1'b0}},
en_ld_st_translation_i[HYP_EXT*2],
1'b1
});
// check for sufficient access privileges - throw a page fault if necessary
end else if (daccess_err[0]) begin
if (HYP_EXT == 1) begin
lsu_exception_o = exception_t'({
riscv::LOAD_PAGE_FAULT,
{{CVA6Cfg.XLEN - CVA6Cfg.VLEN{lsu_vaddr_q[0][CVA6Cfg.VLEN-1]}}, lsu_vaddr_q[0]},
{riscv::GPLEN{1'b0}},
lsu_tinst_q,
en_ld_st_translation_i[HYP_EXT*2],
1'b1
});
end else begin
lsu_exception_o = exception_t'({
riscv::LOAD_PAGE_FAULT,
{{CVA6Cfg.XLEN - CVA6Cfg.VLEN{lsu_vaddr_q[0][CVA6Cfg.VLEN-1]}}, lsu_vaddr_q[0]},
1'b1
});
end
// Check if any PMPs are violated
end else if (!pmp_data_allow) begin
if (HYP_EXT == 1) begin
lsu_exception_o = exception_t'({
riscv::LD_ACCESS_FAULT,
{{CVA6Cfg.XLEN - CVA6Cfg.VLEN{lsu_vaddr_q[0][CVA6Cfg.VLEN-1]}}, lsu_vaddr_q[0]},
{riscv::GPLEN{1'b0}},
lsu_tinst_q,
en_ld_st_translation_i[HYP_EXT*2],
1'b1
});
end else begin
lsu_exception_o = exception_t'({
riscv::LD_ACCESS_FAULT,
lsu_paddr_o[CVA6Cfg.PLEN-1:(CVA6Cfg.PLEN>CVA6Cfg.VLEN)?(CVA6Cfg.PLEN-CVA6Cfg.VLEN) : 0],
1'b1
});
end
end

Copy link
Contributor

✔️ successful run, report available here.

@JeanRochCoulon
Copy link
Contributor

Superseeded bby #1958

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants