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

soc: add OpenHW Group CVA6 SoC #77732

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

WorldofJARcraft
Copy link
Contributor

Adds support for the CVA6 family of RISC-V CPUs.
CVA6 is commonly found as a soft core CPU on FPGA designs. Different configurations and instruction set extensions can be configured, and different SoCs targeting various FPGA boards are available.
This commit adds support for the 64-bit configuration of CVA6, as well as two slightly different SoCs (the main difference being the Ethernet subsystem).
The configuration can also optionally target the hardware simulation environment (test harness) of the CVA6 project and can indicate test/failure to the environment.

@WorldofJARcraft
Copy link
Contributor Author

Full support for this SoC depends on drivers for the Ethernet subsystem: #73986, #73982, #73926

@@ -0,0 +1,5 @@
# Copyright 2024 CISPA Helmholtz Center for Information Security gGmbH
# SPDX-License-Identifier: Apache-2.0
config BOARD_CV32A6_ARTY_A7_100
Copy link
Collaborator

Choose a reason for hiding this comment

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

split this into commits, not going to review 77 files spanning multiple boards, multiple socs and even samples in a single commits

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have removed the boards and samples from this PR and created new PRs:

Copy link
Collaborator

Choose a reason for hiding this comment

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

Have this PR have a soc (in one commit), drivers (each in different commits) and one board (in another commit), then once that is merged you can add additional boards in a new PR each with their own commit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Ethernet subsystem is not specific to this hardware (e.g., it is also used on ARM boards), so I will leave it as separate PRs.
This PR now has one commit with the SoC and one with a board in 32 and 64 bit variants.

@kartben
Copy link
Collaborator

kartben commented Nov 6, 2024

@WorldofJARcraft please don't forget that new boards must come with associated documentation. See https://docs.zephyrproject.org/latest/hardware/porting/board_porting.html#contributing-your-board

@WorldofJARcraft
Copy link
Contributor Author

@WorldofJARcraft please don't forget that new boards must come with associated documentation. See https://docs.zephyrproject.org/latest/hardware/porting/board_porting.html#contributing-your-board

Thank you for the reminder, I will finalize my changes and add the documentation before un-drafting the PR.

@WorldofJARcraft WorldofJARcraft force-pushed the openhwgroup-cv64a6-soc branch 3 times, most recently from 125e01c to 5cd33ae Compare November 7, 2024 08:11
@DREXX-lab DREXX-lab mentioned this pull request Nov 7, 2024
Copy link
Collaborator

@nordicjm nordicjm left a comment

Choose a reason for hiding this comment

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

apply comments throughout, they have only been added to the first instance

@@ -0,0 +1,30 @@
// SPDX-License-Identifier: Apache-2.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

/* comment style

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

status = "okay";
compatible = "riscv";
riscv,isa = "rv32ima";

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

};
};
};

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

dts/riscv/openhwgroup/cva6.dtsi Show resolved Hide resolved
ranges;

memory0:memory@80000000 {
device_type = "memory";
Copy link
Collaborator

Choose a reason for hiding this comment

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

tab indents

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines +18 to +22
default "cv32a6" if SOC_SERIES_CV32A6

config SOC
default "cv32a6" if SOC_CV32A6
Copy link
Collaborator

Choose a reason for hiding this comment

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

do you really need a soc series and a soc if they are the same value? If not, remove the soc series from Kconfig and soc.yml and just have the soc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are several slightly different versions of the CVA6 32-bit SOC: with and without MMU, with and without FPU, and a RV32E version is currently being developed. I have added the least common denominator here, future PRs can add the other variants as soon as they are finalized.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All of the RV32I SoCs work with the config I provided, but the RV32E really needs to be separate (it has fewer registers).

# SPDX-License-Identifier: Apache-2.0
# RISCV64 OpenHW Group cva6 configuration options

config SOC_CV64A6_IMAFDC
Copy link
Collaborator

Choose a reason for hiding this comment

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

have a config SOC_CV64A6 symbol which selects common this, then you can select the unique ones in the separate Kconfigs. And select the common Kconfig from Kconfig.soc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

default "cv64a6" if SOC_CV64A6_IMAFDC
default "cv64a6" if SOC_CV64A6_IMAC
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
default "cv64a6" if SOC_CV64A6_IMAFDC
default "cv64a6" if SOC_CV64A6_IMAC
default "cv64a6" if SOC_CV64A6

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


#include <stdint.h>

void z_cva6_finish_test(const int32_t status);
Copy link
Collaborator

Choose a reason for hiding this comment

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

what is this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One of the "board" configurations from the other PRs describes a verification harness in which the CVA6 CPU is run in verilator (a HDL simulator). This is used to run test programs in the simulator and check whether the CPU behaves as expected. To this end, the simulator provides an interface that allows completing the test case successfully or with an error code. This is exposed via this SoC-specific function.
The samples I added in #81017 show how this can be used in software.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added a comment that explains what the function does.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I remove this functionality from this PR and re-introduce it with the board that actually uses this?


#include "cva6.dtsi"

// minimal configuration of CVA6 32-bit CPUs: no instruction set extensions,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Capitalise first letter of comments i.e. English

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@WorldofJARcraft
Copy link
Contributor Author

I have incorporated the requested changes and re-written the commits.

@WorldofJARcraft WorldofJARcraft force-pushed the openhwgroup-cv64a6-soc branch 2 times, most recently from 36c400e to bfe15c0 Compare November 8, 2024 11:37
@WorldofJARcraft
Copy link
Contributor Author

Documentation for the new boards in this PR has been added.

@WorldofJARcraft WorldofJARcraft force-pushed the openhwgroup-cv64a6-soc branch 5 times, most recently from 7f1aaf4 to 8abbff3 Compare November 8, 2024 13:47
@WorldofJARcraft WorldofJARcraft marked this pull request as ready for review November 8, 2024 13:59
@zephyrbot zephyrbot added area: RISCV RISCV Architecture (32-bit & 64-bit) area: Devicetree labels Nov 8, 2024
@WorldofJARcraft
Copy link
Contributor Author

The support/ariane.cfg file (openocd configuration) is shared between the 32- and the 64-bit version of the board I am adding. Is there a good place to move it, such that there is only one copy?

@WorldofJARcraft WorldofJARcraft force-pushed the openhwgroup-cv64a6-soc branch 2 times, most recently from 2fd47f0 to 59944bd Compare November 8, 2024 14:34
@decsny decsny removed their request for review November 8, 2024 15:20
boards/openhwgroup/cv32a6_genesysII/cv32a6_genesysII.dts Outdated Show resolved Hide resolved
dts/riscv/openhwgroup/cv32a6.dtsi Outdated Show resolved Hide resolved
dts/riscv/openhwgroup/cv64a6.dtsi Outdated Show resolved Hide resolved
soc/openhwgroup/cva6/cv64a6/Kconfig Outdated Show resolved Hide resolved
/*
*
* Copyright(c) 2024, CISPA Helmholtz Center for Information Security
* SPDX - License - Identifier : Apache-2.0
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* SPDX - License - Identifier : Apache-2.0
* SPDX-License-Identifier: Apache-2.0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

soc/openhwgroup/cva6/soc.yml Show resolved Hide resolved
Comment on lines 11 to 22
void arch_dcache_enable(void)
{
__asm__ volatile("csrwi 0x7C1, 0x01");
}

void arch_dcache_disable(void)
{
__asm__ volatile("csrwi 0x7C1, 0x00");
}
Copy link
Member

Choose a reason for hiding this comment

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

A comment or two would be nice to explain what we're doing here, i.e. what is the 0x7c1 CSR, what are those bits that we're writing/clearing and so on.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a comment

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the comment. Let's use here the csr_write() macro from include/zephyr/arch/riscv/csr.h

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. I have also created defines for the CSR numbers and enable/disable values and moved them to the cva6.h header.

Comment on lines 31 to 32
for (;;) {
}
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't seem to look like a poweroff, could be misleading for the user.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will remove this file from the PR.
I have only added it such that my samples for the testbench board compile on the other CVA6 boards as well. I think a better solution is to simply depend on the "proper" power off at configuration time for the samples.

@WorldofJARcraft WorldofJARcraft force-pushed the openhwgroup-cv64a6-soc branch 3 times, most recently from 3396eba to a2674db Compare November 15, 2024 14:51
Adds support for the CVA6 family of RISC-V CPUs.
CVA6 is commonly found as a soft core CPU on FPGA designs.
Different configurations and instruction set extensions can be
configured, and different SoCs targeting various FPGA boards are
available.
This commit adds support for the 32-bit and 64-bit configurations
of CVA6, as well as three slightly different SoCs (a minimal 32-bit
configuration, a 64-bit configuration without FPU, a 64-bit
configuration with FPU).

Signed-off-by: Eric Ackermann <eric.ackermann@cispa.de>
Adds support for the CVA6 CPU on a GenesysII FPGA board
(https://github.com/openhwgroup/cva6).
The SoC currently contains the CVA6 CPU  with the SV39 MMU, interrupt
controllers (CLINT and PLIC), UART, a SPI for booting from SD, a boot
ROM, and I2C controller for on-board audio, a GPIO and the lowRISC
ethernet subsystem.
Two slightly different versions of the board are added, with a 64-bit
and a 64-bit configuration of CVA6, respectively.

Signed-off-by: Eric Ackermann <eric.ackermann@cispa.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Devicetree area: RISCV RISCV Architecture (32-bit & 64-bit)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants