Commit graph

54 commits

Author SHA1 Message Date
Côme
c784fd9047
WAW hazards elimination (#2881)
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 PR introduces a new RAW hazard detection mechanism to eliminate WAW hazards in CVA6 issue stage.

It first checks for hazards in all scoreboard entries in parallel.
Then it filters found hazards before vs after the current issue pointer.
It then finds the index of the last hazard before (resp. after) the issue pointer.
Finally, it gives precedence to a hazard before the issue pointer over the one after the issue pointer.

---------

Co-authored-by: Junheng Zheng <junheng.zheng@thalesgroup.com>
Co-authored-by: JeanRochCoulon <jean-roch.coulon@thalesgroup.com>
2025-04-23 22:26:50 +02:00
JeanRochCoulon
be5ac20e46
Fix RVFI rs1/rs2 len from VLEN to XLEN (#2749)
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
RVFI rs1 and rs2 operands were VLEN, it has been fixed to be XLEN.
2025-01-28 18:37:07 +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
4b9cbf9223
Various fixes for CVXIF following verification. (#2678)
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
* [CVXIF] Various fixes for bugs report with CVXIF's UVM agent

* Update options and simulators to support CVXIF's UVM agent

---------

Co-authored-by: ajalali <ayoub.jalali@external.thalesgroup.com>
Co-authored-by: André Sintzoff <61976467+ASintzoff@users.noreply.github.com>
2024-12-20 13:28:49 +01:00
AngelaGonzalezMarino
b718824e1e
Altera opt 3 (#2613)
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
The third optimization for Altera FPGA is to move the register file to LUTRAM. Same as before, the reason why the optimization previously done for Xilinx is not working, is that in that case asynchronous RAM primitives are used, and Altera does not support asynchronous RAM. Therefore, this optimization consists in using synchronous RAM for the register file.

The main changes to the existing code are:

Changes in ariane_regfile_fpga.sv file: The idea is the same as before, since synchronous RAM takes one clock cycle to read, we need to store the data when it is written, in case it is read right after. For this there is an auxiliary register that stores the last written data. On the read side, we need to identify if the data to be read is available in the RAM or if it is still in the auxiliary register (read after write). To compensate for the synchronous RAM delay the address is advanced one clock cycle. In this case there is a multiplexer in the output to select the block from where data is read, here we need to keep the read address for one clock cycle to select the right block when data is available.

Changes in issue_read_operands.sv file: adjust address to read from register file (when synchronous RAM is used reads take one cycle, so we advance the address). Since this address is an input, we need a new input port that brings the address in advance “issue_instr_i_prev”.

Changes in issue_stage.sv file: To connect the new input port that brings the address in advance “decoded_instr_i_prev”.

Changes in id_stage.sv file: To output the instruction to be issued before registering it (one clock cycle in advance). A new output port is needed for this “issue_entry_o_prev”

Changes in cva6.sv file: To connect the new output of the id_stage to the issue_stage to bring the address in advance to the register file (issue_entry_id_issue_prev)
2024-11-28 14:26:29 +01:00
Côme
7eb59c3e16
iro: remove an unreachable statement (#2588)
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
2024-11-12 20:32:40 +01:00
Côme
43edcd467e
document issue stage (#2598)
* Fill docs/design/design-manual/source/cva6_issue_stage.adoc
* Add variables to docs/design/design-manual/source/design.adoc
* Update port doc comments in core/issue_stage.sv, core/issue_read_operands.sv and core/scoreboard.sv
2024-11-12 20:28:25 +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
Guillaume Chauvon
fea98c65de
[HOTFIX] Fix Handling of CVXIF instruction being interrupted (#2537) 2024-10-09 16:34:45 +02:00
jzthales
6ccd8d8bfa
Refactor forwarding in issue_stage module (#2519) 2024-10-01 06:13:30 +02:00
JeanRochCoulon
8ef28596d5
Code clean-up of the number of register address bits (#2483) 2024-08-30 17:22:53 +02:00
André Sintzoff
af4e3744d4
spyglass: remove useless assignments (#2439) 2024-08-12 15:06:39 +02:00
Guillaume Chauvon
81671e39fa
Fixes and Update CVXIF non regression tests, regression and TB (#2424) 2024-08-01 16:06:24 +02:00
Guillaume Chauvon
211af02e5e
Separate RAW and WAW process to fix CVXIF with Superscalar (#2395) 2024-07-26 14:58:18 +02:00
Asmaa Kassimi
4c48a60804
increase condition coverage in lsu, issue and commit stages (#2391) 2024-07-25 07:37:21 +02:00
Guillaume Chauvon
8fa590b5c3
CVXIF 1.0.0 (#2340) 2024-07-12 10:53:18 +02:00
Côme
37d93a3758
superscalar: do not issue CSR with another instruction (#2329) 2024-07-05 23:49:44 +02:00
Côme
4df49a6b0f
superscalar: make SuperscalarEn a CVA6Cfg attribute (#2322) 2024-07-05 14:09:48 +02:00
Côme
636e6aff47
superscalar add second ALU (#2303) 2024-06-30 18:24:11 +02:00
Côme
96ae8ed223
superscalar: allow speculative instructions (#2278) 2024-06-20 15:55:56 +02:00
Côme
eac60af1a9
superscalar: add a second issue port (#2209) 2024-06-09 20:47:09 +02:00
JeanRochCoulon
4423feb06a
Rename ZiCondExtEn and FPGA_EN parameters (#1992) 2024-04-02 15:37:58 +02: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
32a3cd56ee
Parametrization step 2 (#1908) 2024-03-08 22:53:42 +01:00
JeanRochCoulon
f332688fc0
Complete Design Document (#1865) 2024-02-23 23:09:11 +01:00
Guillaume Chauvon
fa101fae7a
Parameterize TVAL to reduce size in embedded (#1784) 2024-01-25 15:47:06 +01:00
AEzzejjari
738d53af1c
Code coverage: condition RTL With parameters (#1703) 2023-12-13 07:52:47 +01:00
AEzzejjari
cbd3e9fe19
Modify coding style to improve CC (#1672) 2023-12-05 14:51:23 +01:00
André Sintzoff
c51819dcbd
verible-verilog-format: apply it on core directory (#1668)
using verible-v0.0-3430-g060bde0f/bin/verible-verilog-format
with default configuration

Signed-off-by: André Sintzoff <andre.sintzoff@thalesgroup.com>
2023-12-04 11:16:35 +00:00
AEzzejjari
2c4d8b3e11
Code coverage: Add SMODE parameter to the sfence_vma instruction (#1603) 2023-11-07 15:35:06 +01:00
Fatima Saleem
49a4b5b4ff
resolving lint warnings... (#1529) 2023-10-20 15:01:42 +02:00
André Sintzoff
7cd183b710
verible-verilog-format: apply it on core directory (#1540)
using verible-v0.0-3422-g520ca4b9/bin/verible-verilog-format
with default configuration

Note: two files are not correctly handled by verible
- core/include/std_cache_pkg.sv
- core/cache_subsystem/cva6_hpdcache_if_adapter.sv
2023-10-18 16:36:00 +02:00
Fatima Saleem
d3343f5210
resolving lint warnings (#1520) 2023-10-09 22:38:05 +02:00
AEzzejjari
b952b0d7c3
Code_coverage: Add conditions for the FPU (#1442) 2023-09-19 18:24:40 +02:00
Fatima Saleem
8355a70ade removed rename block 2023-09-07 20:02:48 +05:00
JeanRochCoulon
1db42ee8da
Add variant into CVA6 parameter (#1320)
* Variane as CVA6 parameter

Signed-off-by: Jean-Roch Coulon <jean-roch.coulon@thalesgroup.com>

* fix FPGA build

Signed-off-by: Jean-Roch Coulon <jean-roch.coulon@thalesgroup.com>

* Fix tipo in cva6.sv

* fix lint warnings

Signed-off-by: Jean-Roch Coulon <jean-roch.coulon@thalesgroup.com>

* Fix is_*_fpr functions

* remove blank lines

* set IsRVFI out of CVA6Cfg

* define config_pkg

* Fix ariane_pkg comments

* Fix Lint from André's feedbacks

* Fix parameter transmission

* Fix replace CVA6Cfg by CVA6ExtendCfg in cva6.sv

* fix add CVA6Cfg in instr_queue, instr_scan and pmp parameters

---------

Signed-off-by: Jean-Roch Coulon <jean-roch.coulon@thalesgroup.com>
Co-authored-by: ALLART Come <come.allart@thalesgroup.com>
2023-08-22 14:04:06 +02:00
JeanRochCoulon
279ce9fb9b
Define RVFI as cva6 parameter (#1293) 2023-07-19 08:21:39 +02:00
Fatima Saleem
4d2a9fe032
Resolved Lint WIDTHEXPAND warnings(1/2) (#1303) 2023-07-18 11:06:09 +02:00
Nils Wistoff
513bb91f82
Add Ara support (#1024)
Support Ara via a custom, parametrised accelerator interface.

    cv64a6_imafdcv_sv39_config_pkg.sv enables V extension
    Pre-processor constant ARIANE_ACCELERATOR_PORT enables the interface between CVA6 and Ara. 
    FPU is bumped to a SIMD-compatible version

Backwards compatibility should be preserved. Once this is merged, we will change the reference of Ara upstream CVA6.

-----

Signed-off-by: Nils Wistoff <nwistoff@iis.ee.ethz.ch>
Co-authored-by: Matheus Cavalcante <matheusd@iis.ee.ethz.ch>
Co-authored-by: Matteo Perotti <mperotti@iis.ee.ethz.ch>
Co-authored-by: JeanRochCoulon <jean-roch.coulon@thalesgroup.com>
2023-07-10 17:12:59 +02:00
JeanRochCoulon
5284f828e4
declare cva6_cfg_t to pass the configuration through the hierarchy (#1287)
Signed-off-by: Jean-Roch Coulon <jean-roch.coulon@thalesgroup.com>
2023-07-01 17:24:21 +02:00
cathales
3bab6ed815
perf: fix too strict restriction on FLU write-back (#1230) 2023-05-12 00:02:30 +02:00
Zbigniew Chamski
a0893bce2b
Enable assertions in Verilator after migrating to Verilator v5. (#1185) 2023-04-19 09:35:40 +02:00
TulikaSi
1a37f6cef1
64bit Performance counters (#1129) 2023-04-06 08:30:01 +02:00
JeanRochCoulon
640eb9dc67
Replace "operator" by "operation" to avoid C++ keyword names in the SV Code. (#1154) 2023-04-02 16:13:59 +02:00
sébastien jacq
1498700dd7
Optimize regfile implementation for fpga target (#1038) 2023-01-30 07:39:09 +01:00