Files
poky/meta/conf/machine/include/riscv/README
Mark Hatle 3c5c4cfa6b riscv tunes: ISA Implementation of RISC-V tune features
This implements the following base ISAs:

* rv32i, rv64i
* rv32e, rv64i

The following ABIs:
* ilp32, ilp32e, ilp32f, ilp32d
* lp64, lp64e, lp64f, lp64d

The following ISA extension are also implemented:
* M - Integer Multiplication and Division Extension
* A - Atomic Memory Extension
* F - Single-Precision Floating-Point Extension
* D - Double-Precision Floating-Point Extension
* C - Compressed Extension
* B - Bit Manipulation Extension (implies Zba, Zbb, Zbs)
* V - Vector Operations Extension
* Zicsr - Control and Status Register Access Extension
* Zifencei - Instruction-Fetch Fence Extension
* Zba - Address bit manipulation extension
* Zbb - Basic bit manipulation extension
* Zbc - Carry-less multiplication extension
* Zbs - Single-bit manipulation extension
* Zicbom - Cache-block management extension

The existing processors tunes are preserved:
* riscv64 (rv64gc)
* riscv32 (rv32gc)
* riscv64nf (rv64imac_zicsr_zifencei)
* riscv32nf (rv32imac_zicsr_zifencei)
* riscv64nc (rv64imafd_zicsr_zifencei)

Previously defined feature 'big-endian' has been removed as it was not used.

(From OE-Core rev: bcaf298a146dfd10e4c8f44223ea083bc4baf45c)

Signed-off-by: Mark Hatle <mark.hatle@amd.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2025-06-20 09:52:28 +01:00

123 lines
4.5 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

2025/06/08 - Mark Hatle <mark.hatle@amd.com>
- Initial Revision
The RISC-V ISA is broken into two parts, a base ISA and extensions. As
of the writing of this document these are documented at:
https://lf-riscv.atlassian.net/wiki/spaces/HOME/pages/16154769/RISC-V+Technical+Specifications
Specifically "The RISC-V Instruction Set Manual Volume I: Unprivileged ISA"
was used to create this implementation.
Requirements
------------
As RISC-V is a “variable” ISA (a base isa plus numerous extensions), a
mechanism is required to specify a series of ISA features that a user or
tune can use to specify a specific CPU instantiation.
Not all ratified or draft features should or can be implemented with the
available resources.
The implementation should work for Linux, baremetal (newlib), zephyr and
other operating systems. Supported extensions should be based on
real-world examples.
Linux
-----
Linux required base and support extensions should be available. Linux
requires:
* Base: rv32ima & rv64ima
* Optional FPU: fd
* Optional RISCV_ISA_C: c
* Optiona RISCV_ISA_V: v
* Required additional: _zicsr_zifencei
* Optional RISCV_ISA_ZBA: _zba
* Optional RISCV_ISA_ZBB: _zbb
* Optional RISCV_ISA_ZBC: _zbc (not supported by current QEMU design)
See: https://git.yoctoproject.org/linux-yocto/tree/arch/riscv/Makefile?h=v6.12/base
Baremetal
---------
AMD Microblaze-V FPGA support uses the following static configurations:
Base: rv32e, rv32i, rv64i
Extensions: m, a, f, d, c, b, zicsr, zifencei
Zephyr
------
AMD Microblaze-V development for Zephyr is the same as Baremetal, with a
few additional extensions: zbc, zicbom
ABI
---
The following ABIs are supported GNU tools and some combination of systems.
* ilp32 - Integer, long and pointer are 32-bit
* lp64 - Long and pointer are 64-bit (integer is 32-bit)
The ABI is dependent upon the core system implementation, as ilp32 can
only used on an rv32 system, while lp64 can only be used on an rv64
system.
There are additional variations of each ABI:
* e - used with the Reduced register extension
* f - used when single precision floating point (but not double precision) is
enabled
* d - used when both single and double precision floating point is enabled
Based on the above, the ABI should be automatically determined based on
the selected Base ISA and Extensions.
Implementation
--------------
To make it easier to generate the RISC-V canonical arch, ISA based -march,
and the ABI string, a few new variables are added for specific RISC-V items.
TUNE_RISCV_ARCH - This contains the canonical GNU style arch, generally this
will evaluate to "riscv32" or "riscv64".
TUNE_RISCV_MARCH - This will contain an ISA based -march string compatible
with gcc and similar toolchains. For example:
rv32imacfd_zicsr_zifencei
TUNE_RISCV_ABI - This is the generated ABI that corresponds to the ARCH and
MARCH/ISA values. For riscv32, the value will be ilp32
(int, long and pointer is 32-bit) with the ISA
variation. For riscv64, the value will be lp64 (long
and pointer are 64-bit bit, while int is 32-bit) with the
ISA variation. The ISA affects the ABI when the 'e', 'f'
and 'd' extension are used.
TUNE_RISCV_PKGARCH - This is the generated PKGARCH value.
The standard variables are defined as:
TUNE_CCARGS = "${@ '-march=${TUNE_RISCV_MARCH} -mabi=${TUNE_RISCV_ABI}' if not d.getVar('TUNE_CCARGS:tune-${DEFAULTTUNE}') else 'TUNE_CCARGS:tune-${DEFAULTTUNE}'}"
The above will allow the user to specify an implementation specific
TUNE_CCARGS for a given processor tune if the default implementtion is
not adequate for some reason. It is expected that most, if not all,
implementations will use the default behavior.
TUNE_ARCH = "${TUNE_RISCV_ARCH}"
TUNE_PKGARCH = "${TUNE_RISCV_PKGARCH}"
The above two will always base their setting off the standard TUNE_FEATURES.
Ratified and draft extensions should be implemented as TUNE_FEATURES in
the arch-riscv.inc file.
Vendor specific extensions and processor specific settings should go
into a 'tune-<vendor>.inc' file, with tune-riscv.inc being reserved for
general purpose tunes.
TUNE_FEATURE Helper
-------------------
A special helper function has been written that will convert RISC-V ISA
notation into TUNE_FEATURE notion, for example:
rv32g -> rv 32 i m a f d zicsr zifencei
The helper can be called using oe.tune.riscv_isa_to_tune("<ISA>") such as
oe.tune.riscv_isa_to_tune("rv64gc") which would return:
rv 64 i m a f d c zicsr zifencei