Line 11... |
Line 11... |
** `C` - 16-bit compressed instructions
|
** `C` - 16-bit compressed instructions
|
** `I` - integer base ISA (always enabled)
|
** `I` - integer base ISA (always enabled)
|
** `E` - embedded CPU version (reduced register file size)
|
** `E` - embedded CPU version (reduced register file size)
|
** `M` - integer multiplication and division hardware
|
** `M` - integer multiplication and division hardware
|
** `U` - less-privileged _user_ mode
|
** `U` - less-privileged _user_ mode
|
|
** `Zbb` - basic bit-manipulation operations
|
** `Zfinx` - single-precision floating-point unit
|
** `Zfinx` - single-precision floating-point unit
|
** `Zicsr` - control and status register access (privileged architecture)
|
** `Zicsr` - control and status register access (privileged architecture)
|
** `Zifencei` - instruction stream synchronization
|
** `Zifencei` - instruction stream synchronization
|
** `Zmmul` - integer multiplication hardware
|
** `Zmmul` - integer multiplication hardware
|
** `PMP` - physical memory protection
|
** `PMP` - physical memory protection
|
Line 340... |
Line 341... |
(instruction set architecture) extensions. For more information regarding the RISC-V ISA extensions please
|
(instruction set architecture) extensions. For more information regarding the RISC-V ISA extensions please
|
see the The _RISC-V Instruction Set Manual – Volume I: Unprivileged ISA_ and _The RISC-V Instruction Set Manual
|
see the The _RISC-V Instruction Set Manual – Volume I: Unprivileged ISA_ and _The RISC-V Instruction Set Manual
|
Volume II: Privileged Architecture_, which are available in the projects `docs/references` folder.
|
Volume II: Privileged Architecture_, which are available in the projects `docs/references` folder.
|
|
|
[TIP]
|
[TIP]
|
The CPU can discover available ISA extensions via the <<_misa>> and <<_mzext>> CSRs or by executing an instruction
|
The CPU can discover available ISA extensions via the <<_misa>> CSR and the
|
and checking for an _illegal instruction exception_.
|
_SYSINFO_CPU_ <<_system_configuration_information_memory_sysinfo, SYSINFO>> register
|
|
or by executing an instruction and checking for an _illegal instruction exception_.
|
|
|
|
[NOTE]
|
|
Executing an instruction from an extension that is not implemented or not enabled (for example via the according
|
|
top entity generic) will raise an _illegal instruction_ exception.
|
|
|
|
|
==== **`A`** - Atomic Memory Access
|
==== **`A`** - Atomic Memory Access
|
|
|
Atomic memory access instructions (for implementing semaphores and mutexes) are available when the
|
Atomic memory access instructions (for implementing semaphores and mutexes) are available when the
|
Line 385... |
Line 391... |
|
|
The embedded CPU extensions reduces the size of the general purpose register file from 32 entries to 16 entries to reduce hardware
|
The embedded CPU extensions reduces the size of the general purpose register file from 32 entries to 16 entries to reduce hardware
|
requirements. This extensions is enabled when the `CPU_EXTENSION_RISCV_E` configuration generic is _true_. Accesses to registers beyond
|
requirements. This extensions is enabled when the `CPU_EXTENSION_RISCV_E` configuration generic is _true_. Accesses to registers beyond
|
`x15` will raise and _illegal instruction exception_.
|
`x15` will raise and _illegal instruction exception_.
|
|
|
Due to the reduced register file an alternate ABI (**`ilp32e`**) is required for the toolchain.
|
[IMPORTANT]
|
|
Due to the reduced register file size an alternate toolchain ABI (**`ilp32e`**) is required.
|
|
|
|
|
==== **`I`** - Base Integer ISA
|
==== **`I`** - Base Integer ISA
|
The CPU always supports the complete `rv32i` base integer instruction set. This base set is always enabled
|
The CPU always supports the complete `rv32i` base integer instruction set. This base set is always enabled
|
regardless of the setting of the remaining exceptions. The base instruction set includes the following
|
regardless of the setting of the remaining exceptions. The base instruction set includes the following
|
Line 437... |
Line 444... |
integer multiplications but not hardware-based divisions, which will be computed entirely in software.
|
integer multiplications but not hardware-based divisions, which will be computed entirely in software.
|
This extension requires only ~50% of the hardware utilization of the `M` extension.
|
This extension requires only ~50% of the hardware utilization of the `M` extension.
|
|
|
* multiplication: `mul`, `mulh`, `mulhsu`, `mulhu`
|
* multiplication: `mul`, `mulh`, `mulhsu`, `mulhu`
|
|
|
If `Zmmul` is enabled, executing any division instruction from the `M` ISA (`div`, `divu`, `rem`, `remu`)
|
If `Zmmul` is enabled, executing any division instruction from the `M` ISA extension (`div`, `divu`, `rem`, `remu`)
|
will raise an illegal instruction exception.
|
will raise an _illegal instruction exception_.
|
|
|
Note that `M` and `Zmmul` extensions _cannot_ be enabled in parallel.
|
Note that `M` and `Zmmul` extensions _cannot_ be enabled at the same time.
|
|
|
[TIP]
|
[TIP]
|
If your RISC-V GCC toolchain does not (yet) support the `_Zmmul` ISA extensions, it can be "emulated"
|
If your RISC-V GCC toolchain does not (yet) support the `_Zmmul` ISA extensions, it can be "emulated"
|
using a `rv32im` machine architecture and setting the `-mno-div` compiler flag
|
using a `rv32im` machine architecture and setting the `-mno-div` compiler flag
|
(example `$ make MARCH=-march=rv32im USER_FLAGS+=-mno-div clean_all exe`).
|
(example `$ make MARCH=-march=rv32im USER_FLAGS+=-mno-div clean_all exe`).
|
|
|
|
|
==== **`U`** - Less-Privileged User Mode
|
==== **`U`** - Less-Privileged User Mode
|
|
|
Adds the less-privileged _user mode_ when the `CPU_EXTENSION_RISCV_U` configuration generic is _true_. For
|
Adds the less-privileged _user mode_ if the `CPU_EXTENSION_RISCV_U` configuration generic is _true_. For
|
instance, use-level code cannot access machine-mode CSRs. Furthermore, access to the address space (like
|
instance, use-level code cannot access machine-mode CSRs. Furthermore, access to the address space (like
|
peripheral/IO devices) can be limited via the physical memory protection (_PMP_) unit for code running in user mode.
|
peripheral/IO devices) can be limited via the physical memory protection (_PMP_) unit for code running in user mode.
|
|
|
|
|
==== **`X`** - NEORV32-Specific (Custom) Extensions
|
==== **`X`** - NEORV32-Specific (Custom) Extensions
|
|
|
The NEORV32-specific extensions are always enabled and are indicated by the set `X` bit in the `misa` CSR.
|
The NEORV32-specific extensions are always enabled and are indicated by the set `X` bit in the `misa` CSR.
|
|
|
[NOTE]
|
The most important points of the NEORV32-specific extensions are:
|
The CPU provides 16 _fast interrupt_ interrupts (`FIRQ)`, which are controlled via custom bits in the `mie`
|
* The CPU provides 16 _fast interrupt_ interrupts (`FIRQ)`, which are controlled via custom bits in the `mie`
|
and `mip` CSR. This extension is mapped to bits, that are available for custom use (according to the
|
and `mip` CSR. This extension is mapped to bits, that are available for custom use (according to the
|
RISC-V specs). Also, custom trap codes for `mcause` are implemented.
|
RISC-V specs). Also, custom trap codes for `mcause` are implemented.
|
|
* The CPU provides a single _non-maskable_ interrupt (`NMI)` that also provides a custom trap code for `mcause`.
|
[NOTE]
|
* All undefined/unimplemented/malformed/illegal instructions do raise an illegal instruction exception (see <<_full_virtualization>>).
|
The CPU provides a single _non-maskable_ interrupt (`NMI)` that also provides a custom trap code for `mcause`.
|
|
|
|
[NOTE]
|
|
A custom CSR `mzext` is available that can be used to check for implemented `Z*` CPU extensions
|
|
(for example `Zifencei`). This CSR is mapped to the official "custom CSR address region".
|
|
|
|
[NOTE]
|
|
All undefined/unimplemented/malformed/illegal instructions do raise an illegal instruction exception
|
|
(see <<_full_virtualization>>).
|
|
|
|
|
|
==== **`Zfinx`** Single-Precision Floating-Point Operations
|
==== **`Zfinx`** Single-Precision Floating-Point Operations
|
|
|
|
[WARNING]
|
|
The NEORV32 `Zfinx` extension is specification-compliant and operational but still _experimental_.
|
|
|
The `Zfinx` floating-point extension is an alternative of the `F` floating-point instruction that also uses the
|
The `Zfinx` floating-point extension is an alternative of the `F` floating-point instruction that also uses the
|
integer register file `x` to store and operate on floating-point data (hence, `F-in-x`). Since not dedicated floating-point `f`
|
integer register file `x` to store and operate on floating-point data (hence, `F-in-x`). Since not dedicated floating-point `f`
|
register file exists, the `Zfinx` extension requires less hardware resources and features faster context changes.
|
register file exists, the `Zfinx` extension requires less hardware resources and features faster context changes.
|
This also implies that there are NO dedicated `f` register file related load/store or move instructions. The
|
This also implies that there are NO dedicated `f` register file related load/store or move instructions. The
|
official RISC-V specifications can be found here: https://github.com/riscv/riscv-zfinx
|
official RISC-V specifications can be found here: https://github.com/riscv/riscv-zfinx
|
Line 514... |
Line 515... |
The `Zfinx` extension is not yet officially ratified, but is expected to stay unchanged. There is no
|
The `Zfinx` extension is not yet officially ratified, but is expected to stay unchanged. There is no
|
software support for the `Zfinx` extension in the upstream GCC RISC-V port yet. However, an
|
software support for the `Zfinx` extension in the upstream GCC RISC-V port yet. However, an
|
intrinsic library is provided to utilize the provided `Zfinx` floating-point extension from C-language
|
intrinsic library is provided to utilize the provided `Zfinx` floating-point extension from C-language
|
code (see `sw/example/floating_point_test`).
|
code (see `sw/example/floating_point_test`).
|
|
|
|
|
|
==== **`Zbb`** Basic Bit-Manipulation Operations
|
|
|
|
[WARNING]
|
|
The NEORV32 `Zbb` extension is specification-compliant and operational but still _experimental_.
|
|
|
|
The `Zbb` extension implements the _basic_ sub-set of the RISC-V bit-manipulation extensions `B`.
|
|
The official RISC-V specifications can be found here: https://github.com/riscv/riscv-bitmanip
|
|
|
|
The `Zbb` extension is implemented when the `CPU_EXTENSION_RISCV_Zbb` configuration
|
|
generic is _true_. In this case the following instructions are available:
|
|
|
|
* `andn`, `orn`, `xnor`
|
|
* `clz`, `ctz`, `cpop`
|
|
* `max`, `maxu`, `min`, `minu`
|
|
* `sext.b`, `sext.h`, `zext.h`
|
|
* `rol`, `ror`, `rori`
|
|
* `orc.b`, `rev8`
|
|
|
|
[TIP]
|
|
By default, the bit-manipulation unit uses an _iterative_ approach to compute shift-related operations
|
|
like `clz` and `rol`. To increase performance (at the cost of additional hardware resources) the
|
|
<<_fast_shift_en>> generic can be enabled to implement full-parallel logic (like barrel shifters) for all
|
|
shift-related `Zbb` instructions.
|
|
|
[IMPORTANT]
|
[IMPORTANT]
|
Note that any FPU instruction including all FPU-related CSR accesses will raise an illegal instruction exception
|
The `Zbb` extension is frozen but not officially ratified yet. There is no
|
if the FPU is not enabled via the <<_mstatus>> CSR (`FS` bits).
|
software support for this extension in the upstream GCC RISC-V port yet. However, an
|
|
intrinsic library is provided to utilize the provided `Zbb` extension from C-language
|
|
code (see `sw/example/bitmanip_test`).
|
|
|
|
|
==== **`Zicsr`** Control and Status Register Access / Privileged Architecture
|
==== **`Zicsr`** Control and Status Register Access / Privileged Architecture
|
|
|
The CSR access instructions as well as the exception and interrupt system (= the privileged architecture) is implemented when the
|
The CSR access instructions as well as the exception and interrupt system (= the privileged architecture) is implemented when the
|
Line 704... |
Line 732... |
| Floating-point - artihmetic | `Zfinx` | `fmul.s` | 22
|
| Floating-point - artihmetic | `Zfinx` | `fmul.s` | 22
|
| Floating-point - compare | `Zfinx` | `fmin.s` `fmax.s` `feq.s` `flt.s` `fle.s` | 13
|
| Floating-point - compare | `Zfinx` | `fmin.s` `fmax.s` `feq.s` `flt.s` `fle.s` | 13
|
| Floating-point - misc | `Zfinx` | `fsgnj.s` `fsgnjn.s` `fsgnjx.s` `fclass.s` | 12
|
| Floating-point - misc | `Zfinx` | `fsgnj.s` `fsgnjn.s` `fsgnjx.s` `fclass.s` | 12
|
| Floating-point - conversion | `Zfinx` | `fcvt.w.s` `fcvt.wu.s` | 47
|
| Floating-point - conversion | `Zfinx` | `fcvt.w.s` `fcvt.wu.s` | 47
|
| Floating-point - conversion | `Zfinx` | `fcvt.s.w` `fcvt.s.wu` | 48
|
| Floating-point - conversion | `Zfinx` | `fcvt.s.w` `fcvt.s.wu` | 48
|
|
| Basic bit-manip - logic | `Zbb` | `andn` `orn` `xnor` | 3
|
|
| Basic bit-manip - shift | `Zbb` | `clz` `ctz` `cpop` `rol` `ror` `rori` | 4+SA, FAST_SHIFT: 4
|
|
| Basic bit-manip - arith | `Zbb` | `max` `maxu` `min` `minu` | 3
|
|
| Basic bit-manip - misc | `Zbb` | `sext.b` `sext.h` `zext.h` `orc.b` `rev8` | 3
|
|=======================
|
|=======================
|
|
|
[NOTE]
|
[NOTE]
|
The presented values of the *floating-point execution cycles* are average values – obtained from
|
The presented values of the *floating-point execution cycles* are average values – obtained from
|
4096 instruction executions using pseudo-random input values. The execution time for emulating the
|
4096 instruction executions using pseudo-random input values. The execution time for emulating the
|