Commit graph

105 commits

Author SHA1 Message Date
Matteo Perotti
1bc415391a
[RVV] CVA6 re-parametrization and MMU interface (#2652)
Follow-up to the discussion on extending Linux support to the Ara vector processor.

* Main changes:
Add:
Add external MMU interface to share the MMU with the external accelerator.
Add avoid_neg() function used to clip negative numbers to zero. Useful for parametric array sizes and vector multipliers.

Modifications:
2 commit ports by default in cv64a6_imafdcv_config_pkg.
Change exception_t from localparam to param in cva6.sv.
Add parameters accelerator_req_t, accelerator_resp_t, acc_mmu_req_t, and acc_mmu_resp_t to cva6.sv.
Replace the fall-through register with a spill register in acc_dispatcher to decouple timing with the accelerator.
Decrease cache sizes in cv64a6_imafdcv_sv39_config_pkg.
Modify Bender.yml package name from ariane to cva6.
Add harmless code to prevent synthesizer tool from crashing when compiling csr_regfile.

* Collateral changes:
Fixes:
Guard some X-IF code lines with correct parameter in cva6.sv.
Parametrize the tracer interface with NrCommitPorts.
Add missing local dependencies to Bender.yml.

---------

Co-authored-by: JeanRochCoulon <jean-roch.coulon@thalesgroup.com>
2025-02-11 07:22:31 +01:00
André Sintzoff
10fced1c99
csr_regfile.sv: move CVA6Cfg.DebugEn to improve code coverage (#2753)
Some checks are pending
bender-up-to-date / bender-up-to-date (push) Waiting to run
ci / build-riscv-tests (push) Waiting to run
ci / execute-riscv64-tests (push) Blocked by required conditions
ci / execute-riscv32-tests (push) Blocked by required conditions
Use CVA6Cfg.DebugEn in an outer test instead of in inner tests
Signed-off-by: André Sintzoff <andre.sintzoff@thalesgroup.com>
Co-authored-by: JeanRochCoulon <jean-roch.coulon@thalesgroup.com>
2025-01-31 05:46:24 +01:00
Farhan Ali Shah
542fe39adc
Adding support for ZCMT Extension for Code-Size Reduction in CVA6 (#2659)
Some checks are pending
bender-up-to-date / bender-up-to-date (push) Waiting to run
ci / build-riscv-tests (push) Waiting to run
ci / execute-riscv64-tests (push) Blocked by required conditions
ci / execute-riscv32-tests (push) Blocked by required conditions
## Introduction
This PR implements the ZCMT extension in the CVA6 core, targeting the 32-bit embedded-class platforms. ZCMT is a code-size reduction feature that utilizes compressed table jump instructions (cm.jt and cm.jalt) to reduce code size for embedded systems
**Note:** Due to implementation complexity, ZCMT extension is primarily targeted at embedded class CPUs. Additionally, it is not compatible with architecture class profiles.(Ref. [Unprivilege spec 27.20](https://drive.google.com/file/d/1uviu1nH-tScFfgrovvFCrj7Omv8tFtkp/view))

## Key additions

- Added zcmt_decoder module for compressed table jump instructions: cm.jt (jump table) and cm.jalt (jump-and-link table)

- Implemented the Jump Vector Table (JVT) CSR to store the base address of the jump table in csr_reg module

- Implemented a return address stack, enabling cm.jalt to behave equivalently to jal ra (jump-and-link with return address), by pushing the return address onto the stack in zcmt_decoder module

## Implementation in CVA6
The implementation of the ZCMT extension involves the following major modifications:

### compressed decoder 
The compressed decoder scans and identifies the cm.jt and cm.jalt instructions, and generates signals indicating that the instruction is both compressed and a ZCMT instruction.

### zcmt_decoder
A new zcmt_decoder module was introduced to decode the cm.jt and cm.jalt instructions, fetch the base address of the JVT table from JVT CSR, extract the index and construct jump instructions to ensure efficient integration of the ZCMT extension in embedded platforms. Table.1 shows the IO port connection of zcmt_decoder module. High-level block diagram of zcmt implementation in CVA6 is shown in Figure 1.

_Table. 1 IO port connection with zcmt_decoder module_
Signals | IO | Description | Connection | Type
-- | -- | -- | -- | --
clk_i | in | Subsystem Clock | SUBSYSTEM | logic
rst_ni | in | Asynchronous reset active low | SUBSYSTEM | logic
instr_i | in | Instruction in | compressed_decoder | logic [31:0]
pc_i | in | Current PC | PC from FRONTEND | logic [CVA6Cfg.VLEN-1:0]
is_zcmt_instr_i | in | Is instruction a zcmt instruction | compressed_decoder | logic
illegal_instr_i | in | Is instruction a illegal instruction | compressed_decoder | logic
is_compressed_i | in | Is instruction a compressed instruction | compressed_decoder | logic
jvt_i | in | JVT struct from CSR | CSR | jvt_t
req_port_i | in | Handshake between CACHE and FRONTEND (fetch) | Cache | dcache_req_o_t
instr_o | out | Instruction out | cvxif_compressed_if_driver | logic [31:0]
illegal_instr_o | out | Is the instruction is illegal | cvxif_compressed_if_driver | logic
is_compressed_o | out | Is the instruction is compressed | cvxif_compressed_if_driver | logic
fetch_stall_o | out | Stall siganl | cvxif_compressed_if_driver | logic
req_port_o | out | Handshake between CACHE and FRONTEND (fetch) | Cache | dcache_req_i_t

### branch unit condition
A condition is implemented in the branch unit to ensure that ZCMT instructions always cause a misprediction, forcing the program to jump to the calculated address of the newly constructed jump instruction.

### JVT CSR
A new JVT csr is implemented in csr_reg which holds the base address of the JVT table. The base address is fetched from the JVT CSR, and combined with the index value to calculate the effective address.

### No MMU
Embedded platform does not utilize the MMU, so zcmt_decoder is connected with cache through port 0 of the Dcache module for implicit read access from the memory.

![zcmt_block drawio](https://github.com/user-attachments/assets/ac7bba75-4f56-42f4-9f5e-0c18f00d4dae)
_Figure. 1 High level block diagram of ZCMT extension implementation_

## Known Limitations
The implementation targets 32-bit instructions for embedded-class platforms without an MMU. Since the core does not utilize an MMU, it is leveraged to connect the zcmt_decoder to the cache via port 0.

## Testing and Verification

- Developed directed test cases to validate cm.jt and cm.jalt instruction functionality
- Verified correct initialization and updates of JVT CSR

### Test Plan 
A test plan is developed to test the functionality of ZCMT extension along with JVT CSR. Directed Assembly test executed to check the functionality. 

_Table. 2 Test plan_
S.no | Features | Description | Pass/Fail Criteria | Test Type | Test status
-- | -- | -- | -- | ---- | --
1 | cm.jt | Simple assembly test to validate the working of cm.jt instruction in  CV32A60x. | Check against Spike's ref. model | Directed | Pass
2 | cm.jalt | Simple assembly test to validate the working of cm.jalt instruction in both CV32A60x. | Check against Spike's ref. model | Directed | Pass
3 | cm.jalt with return address stack | Simple assembly test to validate the working of cm.jalt instruction with return address stack in both CV32A60x. It works as jump and link ( j ra, imm) | Check against Spike's ref. model | Directed | Pass
4 | JVT CSR | Read and write base address of Jump table to JVT CSR | Check against Spike's ref. model | Directed | Pass


**Note**: Please find the test under CVA6_REPO_DIR/verif/tests/custom/zcmt"
2025-01-27 13:23:26 +01:00
Guillaume Chauvon
3ce44b1b4e
Spyglass clean up: multiple change to remove Spyglass warnings (#2727)
Some checks are pending
bender-up-to-date / bender-up-to-date (push) Waiting to run
ci / build-riscv-tests (push) Waiting to run
ci / execute-riscv64-tests (push) Blocked by required conditions
ci / execute-riscv32-tests (push) Blocked by required conditions
Multiple changes to clean up code and remove Spyglass warnings.

Co-authored-by: JeanRochCoulon <jean-roch.coulon@thalesgroup.com>
2025-01-23 08:32:31 +01:00
Guillaume Chauvon
98604b5920
csr_regfile: SEIP is read only 0 (fix #2056) (#2716)
Fix #2056

---------

Co-authored-by: JeanRochCoulon <jean-roch.coulon@thalesgroup.com>
2025-01-21 14:53:37 +01:00
Guillaume Chauvon
41c22069a0
Add parameter to disable software interrupt. Fix issue #2500 (#2711)
Fix issue #2500
Add parameter to disable software interrupt.
MIP.MSIP and MIE.MSIE are now read only when this parameter is disabled.
2025-01-16 23:09:57 +01:00
Nils Wistoff
e55f25d23c
csr_regfile: Fix irq/ex delegation in RVH (#2689)
In RVH, interrupts are currently delegated if hxdeleg is set but mxdeleg
is not, violating the spec ("A trap/irq *that has been delegated to
HS-mode (using mxdeleg)* is further delegated to VS-mode if the
corresponding hxdeleg bit is set"). Fix and simplify the corresponding logic.
2025-01-08 13:40:30 +01:00
JeanRochCoulon
2155d0e9c4
Fix #2665 #2400 #2657 (#2685)
Some checks are pending
bender-up-to-date / bender-up-to-date (push) Waiting to run
ci / build-riscv-tests (push) Waiting to run
ci / execute-riscv64-tests (push) Blocked by required conditions
ci / execute-riscv32-tests (push) Blocked by required conditions
* Fix #2400: define new PmpNapotEn parameter to disable NAPOT

* Fix #2665 by removing NA4 related RTL lines

* Fix Spyglass

* Fix gate count
2025-01-07 08:45:28 +01:00
Côme
a4cec295a8
csr only uses one commit port (#2671)
Some checks are pending
bender-up-to-date / bender-up-to-date (push) Waiting to run
ci / build-riscv-tests (push) Waiting to run
ci / execute-riscv64-tests (push) Blocked by required conditions
ci / execute-riscv32-tests (push) Blocked by required conditions
Only the first commit port is used by CSR.
2024-12-17 23:37:02 +01:00
Nils Wistoff
f54b9d4152
csr_regfile: Fix S-mode traps when H extension is enabled (#2599)
Some checks failed
bender-up-to-date / bender-up-to-date (push) Has been cancelled
ci / build-riscv-tests (push) Has been cancelled
ci / execute-riscv64-tests (push) Has been cancelled
ci / execute-riscv32-tests (push) Has been cancelled
If Hypervisor extension is enabled, the logic required to properly trap
to S mode is currently excluded. Fix this by adjusting the if block.
2024-11-14 12:35:40 +01:00
AngelaGonzalezMarino
16f37b95e6
Fix issue when NrPMPEntries=0 (#2589)
Additional fix to #2392
2024-11-12 15:32:08 +01:00
JeanRochCoulon
5bc34d73a9
Revert "csr_regfile: Fix S-mode traps when H extension is enabled (#2587)" (#2594)
Some checks are pending
bender-up-to-date / bender-up-to-date (push) Waiting to run
ci / build-riscv-tests (push) Waiting to run
ci / execute-riscv64-tests (push) Blocked by required conditions
ci / execute-riscv32-tests (push) Blocked by required conditions
This reverts commit 485c382b23.
2024-11-12 10:41:03 +01:00
Nils Wistoff
485c382b23
csr_regfile: Fix S-mode traps when H extension is enabled (#2587)
If Hypervisor extension is enabled, the logic required to properly trap to S mode is currently excluded. Fix this by adjusting the if block.
2024-11-12 08:33:13 +01:00
Côme
4619a67fc6
expand glob port maps (#2585)
Some checks failed
bender-up-to-date / bender-up-to-date (push) Has been cancelled
ci / build-riscv-tests (push) Has been cancelled
ci / execute-riscv64-tests (push) Has been cancelled
ci / execute-riscv32-tests (push) Has been cancelled
Expands all glob port maps in the core/ directory of this repository except the core/cache_subsystem/ directory, despite the glob port maps in core/cache_subsystem/miss_handler.sv and core/cache_subsystem/std_nbdcache.sv.

Also reorders port maps to keep the same order as port declarations.
2024-11-07 16:51:46 +01:00
Moritz Schneider
21dc824040
Fix pmpaddr read logic considering G=2 (#2469)
Some checks are pending
bender-up-to-date / bender-up-to-date (push) Waiting to run
ci / build-riscv-tests (push) Waiting to run
ci / execute-riscv64-tests (push) Blocked by required conditions
ci / execute-riscv32-tests (push) Blocked by required conditions
fixes #2465
2024-10-23 08:54:25 +02:00
JeanRochCoulon
faf4536b37
fix #2464: exception is not generated when INHIBIT CSR is accessed (#2468) 2024-08-27 10:38:48 +02:00
Côme
76e5b40961
fix single-step which was x in cv32a65x config and fix mcycle for double commit (#2369) 2024-08-22 12:03:20 +02:00
Moritz Schneider
fd489a16fb
Fix off by one error in PMP length (#2394) 2024-07-25 12:08:53 +02:00
Asmaa Kassimi
631513eda8
Add RVU condition to increase coverage (#2396) 2024-07-25 12:03:38 +02:00
Somya Dashora
1e48237a7a
Update csr_regfile.sv to fix #2373 (#2374) 2024-07-25 09:54:13 +02:00
Asmaa Kassimi
14be0af7f0
solve simple lint errors (#2388) 2024-07-24 12:09:25 +02:00
Asmaa Kassimi
214444cc93
csr_regfile lint error fix (#2346) 2024-07-10 13:13:26 +02:00
Moritz Schneider
6044454a07
Fix index calculation for PMPCFG CSR write logic (#2330) 2024-07-05 22:56:27 +02:00
Asmaa Kassimi
67dba2cad3
condition csr_regfile.sv (#2310) 2024-07-05 14:14:01 +02:00
Moritz Schneider
246961b3c3
Increase max num PMPs to 64 (#2279) 2024-07-04 14:09:37 +02:00
Asmaa Kassimi
3874c41320
fix lint errors in csr_regfile.sv (#2306) 2024-07-02 15:36:04 +02:00
Guillaume Chauvon
ced13a56b1
Fix typo on Bitmanip comment (#2300) 2024-06-28 15:01:50 +02:00
JeanRochCoulon
21383ce16d
Fix mstatus.mpp in relation to the possible legal values (#2285) 2024-06-21 17:27:48 +02:00
Moritz Schneider
fe1a19fca7
Fix WARL behavior of MPP (#2283)
Related to #2274
2024-06-21 14:38:57 +02:00
André Sintzoff
546a8c26da
csr_regfile.sv: if no U-mode, mstatus.tw is read-only 0 (fix #2228) (#2233) 2024-06-11 15:08:28 +02:00
JeanRochCoulon
2266f75f2d
MTVAL is read-only zero when TvalEn = 0 (#2231) 2024-06-11 11:22:41 +02:00
André Sintzoff
afb3265296
csr_regfile.sv: if no U-mode, mcounteren does not exist (fix #2221) (#2227) 2024-06-10 21:42:00 +02:00
JeanRochCoulon
7ccf82ce76
Add param to enable/disable Zihpm and Zicntr extensions for 65x (#2208) 2024-06-10 15:14:03 +02:00
JeanRochCoulon
dc000d6c37
Define a new param to constraint mtvec to be in direct mode only (#2226) 2024-06-10 11:59:54 +00:00
MarioOpenHWGroup
b48a2bb63d
[CSR] Fix bits when RVS and RVU not available (#2074) 2024-05-22 15:54:51 +02:00
Moritz Schneider
0a160c9294
Fix reserved value in MPP (#2035) 2024-04-12 11:13:17 +02:00
JeanRochCoulon
5df5a5c247
Define InstrTlbEntries, DataTlbEntries, cfg.NrLoadPipeRegs, NrStorePipeRegs, DcacheIdWidth as CVA6 parameters (#2034) 2024-04-12 09:06:35 +02:00
Moritz Schneider
fa2cea2d65
Fix PMPCFG WARL behavior (#2019) 2024-04-09 16:40:00 +02:00
JeanRochCoulon
f4ec364bf4
Fix MIE CSR described in #2004 and #2008 Github issue (#2017) 2024-04-08 19:54:55 +02:00
Moritz Schneider
90d780eb14
Fix PMP CSR locked behavior (#2015) 2024-04-08 14:01:14 +02:00
Yannick Casamatta
5bc063131a
csr_regfile.sv: use CVA6Cfg.ASID_WIDTH instead of AsidWidth (fix cv64a6) (#1951) 2024-03-25 11:51:12 +01:00
Bruno Sá
86e1408666
Hypervisor extension (#1938)
Support 64bit H extension
2024-03-21 10:28:01 +01:00
Côme
bd4b57cc64
Parametrization step 3 part 3 (last) (#1940) 2024-03-18 16:19:52 +01:00
Côme
4817575de9
Parametrization step 3 part 2 (#1939) 2024-03-18 12:06:55 +01:00
Côme
987c645bb7
Parametrization step 3 (#1935)
This is the third step for #1451. Many values are moved but not all values are moved yet

* move NR_SB_ENTRIES & TRANS_ID_BITS
* remove default rvfi_instr_t from spike.sv
* fifo_v3: ariane_pkg::FPGA_EN becomes a param
* move FPGA_EN
* inline wt_cache_pkg::L15_SET_ASSOC
* move wt_cache_pkg::L15_WAY_WIDTH
* inline wt_cache_pkg::L1I_SET_ASSOC
* inline wt_cache_pkg::L1D_SET_ASSOC
* move wt_cache_pkg::DCACHE_CL_IDX_WIDTH
* move ICACHE_TAG_WIDTH
* move DCACHE_TAG_WIDTH
* move ICACHE_INDEX_WIDTH
* move ICACHE_SET_ASSOC
* use ICACHE_SET_ASSOC_WIDTH instead of $clog2(ICACHE_SET_ASSOC)
* move DCACHE_NUM_WORDS
* move DCACHE_INDEX_WIDTH
* move DCACHE_OFFSET_WIDTH
* move DCACHE_BYTE_OFFSET
* move DCACHE_DIRTY_WIDTH
* move DCACHE_SET_ASSOC_WIDTH
* move DCACHE_SET_ASSOC
* move CONFIG_L1I_SIZE
* move CONFIG_L1D_SIZE
* move DCACHE_LINE_WIDTH
* move ICACHE_LINE_WIDTH
* move ICACHE_USER_LINE_WIDTH
* move DCACHE_USER_LINE_WIDTH
* DATA_USER_WIDTH = DCACHE_USER_WIDTH
* move DCACHE_USER_WIDTH
* move FETCH_USER_WIDTH
* move FETCH_USER_EN
* move LOG2_INSTR_PER_FETCH
* move INSTR_PER_FETCH
* move FETCH_WIDTH
* transform SSTATUS_SD and SMODE_STATUS_READ_MASK into functions
* move [SM]_{SW,TIMER,EXT}_INTERRUPT into a structure
* move SV
* move vm_mode_t to config_pkg
* move MODE_SV
* move VPN2
* move PPNW
* move ASIDW
* move ModeW
* move XLEN_ALIGN_BYTES
* move DATA_USER_EN
* format: apply verible
2024-03-15 17:21:34 +00:00
Côme
aed4ed7c23
move functions into modules (#1926) 2024-03-13 17:46:33 +01:00
Côme
83d94bbb69
transform rvfi types into macros (#1921) 2024-03-12 17:34:27 +01:00
Côme
32a3cd56ee
Parametrization step 2 (#1908) 2024-03-08 22:53:42 +01:00
Yannick Casamatta
1dec79464e
add csr in rvfi (#1833) 2024-02-24 00:10:23 +01:00
JeanRochCoulon
f332688fc0
Complete Design Document (#1865) 2024-02-23 23:09:11 +01:00