1

What are the differences between Riscv32 & Riscv64? I have been looking into the ISA docs, but cannot find it mentioned clearly anywhere, so pretty confused now.

I cannot find any docs about this from google, unfortunately. Any pointer?

Erik Eidt
  • 23,049
  • 2
  • 29
  • 53
aqua2019
  • 81
  • 1
  • 7
  • its just the width of the register in the core. width of the register also changes the width of the instruction too. – RRON Feb 04 '22 at 12:31
  • RV32 has 32-bit registers and base instruction set of 32-bits per instruction. RV64 has 64-bit registers and also a base instruction set of 32-bits per instruction. RVC, which can be added to either RV32 or RV64 offers 16-bi instructions. As yet, there are no extensions that offset 48- or 64-bit instructions, but the architecture allows them to be made and still fit with the 16- and 32-bit instructions. – Erik Eidt Apr 11 '22 at 23:47
  • 3
    @RRON, that the width of the instruction changes is misinformation. There are some additional instructions e.g. in RV64 though they are 32-bits wide, and the base instruction set remains 32-bit. – Erik Eidt Feb 07 '23 at 15:45

2 Answers2

8

RISC V has lots of options. RV32I and RV64I are base instruction sets, the 32-bit and 64-bit instruction sets, respectively.  There is also a 128 bit version, RV128I, and, a smaller 32-bit version RV32E, which has only 16 general purpose registers, whereas the others have 32 registers.  For all instruction sets, the base set are 32 bit instructions.

To the base instructions sets, they add optional extensions, e.g. for floating point, multiply and divide, etc.., so like RV32IMAC is based on RV32I with the M, A, and C extensions.

The main difference between RV32I, RV64I, and RV128I is the width of the registers, 32, 64, or 128 bits in width — along with an expected increase in address space from larger widths.  All instruction sets use 32-bit instructions, and with the compressed instruction option RVC, add 16-bit instructions to the mix.  No instructions of larger size are defined as standard yet, but there's opcode space for larger instruction, e.g. 48-bit, 64-bit and beyond that can be added to RV32 or RV64 (or RV128).

There are some opcode differences between RV32 and RV64 as well.  The larger widths add a few instructions to deal with the larger sizes.  RV64I, for example, uses the same opcode as RV32I for add, but means 64-bit add instead of 32-bit add, while there is a new opcode in RV64I for doing 32-bit only add (addw).  RV64I uses the same opcodes as RV32I for load and stores (for data of byte, half, and 32-bit word sizes), though includes new opcodes for loading/storing 64-bit data.

Otherwise one benefit of RV64 over RV32 is being able to address large address space than 4GB, which also applies to x86 vs. x64.  Since we can run out of space for data with a 32-bit address space, having a larger address space and being able to do 64-bit computations in 64-bit registers is the gist of why the processor is called a 64-bit processor (despite sharing the instruction size of 32 bits RV32) (this is also largely also true for x86 vs. x64, in that there is a large amount of similarity between them, such as variable length instructions ranging from 1 byte to 10 or so bytes.)

See also:

Erik Eidt
  • 23,049
  • 2
  • 29
  • 53
-1

The main difference between RISCV-64 and RISCV-32 is in the data-path, that the registers of the RISCV-64 CPU are 64 bits wide instead of being 32 bits wide as in RISCV-32 versions.

64-bit CPUs may or may not support 64-bit machine instructions, having uniform instruction length (lets say 32 bit instructions for both RISCV-64 & RISCV-32) is a plus point w.r.t branching and prediction of incoming machine instructions and hence CPU performance.

AZ123
  • 156
  • 2
  • 11
  • It certainly doesn't require all instructions to be 64-bit. IIRC it might allow 64-bit instruction length, but GCC targeting RV64gc only uses 2-byte and 4-byte instruction lengths when compiling `return a+12345` - https://godbolt.org/z/T8hneTd46 . If there was a single 64-bit instruction to add a 32-bit constant to a register, it would be a win here. – Peter Cordes Feb 07 '23 at 04:45
  • 1
    The difference is the register width, not the instruction length. Both the 32- and 64- bit base architectures have 32-bit instructions, with optional 16-bit instructions, along with the potential for 48-bit and 64-bit and even larger instructions. – Erik Eidt Feb 07 '23 at 15:43
  • @ErikEidt the accepted answer does mention that "RV32I and RV64I are base instruction sets, 32-bit and 64-bit respectively." – AZ123 Feb 08 '23 at 00:06
  • 1
    Right, but RV64 is not 64-bit instruction length, just 64-bit registers and 32-bit instructions to support 64-bit data manipulation like 64-bit address space and 64-bit arithmetic (using 32-bit instructions). – Erik Eidt Feb 08 '23 at 01:18
  • @ErikEidt so as the comment above your comment states, " IIRC it might allow 64-bit instruction length", is that wrong then? I'm working on a 64 bit instruction set CPU, and its instruction length is 64-bits. So I can't completely understand your comment. – AZ123 Feb 08 '23 at 14:18
  • 1
    RISC V allows for 64-bit instructions, though none have as yet been defined. However, to be clear, 48-bit, 64-bit and larger instructions are not restricted to RV64, they are possible future extensions of any base instruction set including RV32, much as 16-bit instructions (the compressed extension) can be applied to any base instruction set: RV32, RV64, and RV128. See also: [How does RISC-V variable length of instruction work in detail?](https://stackoverflow.com/a/56874990/471129) – Erik Eidt Feb 08 '23 at 19:34
  • Yes, turns out I wasn't remembering that correctly, supporting 64-bit instructions width is on paper orthogonal to RV64 vs. RV32. The important part of my comment is that in practice RV64 GCC doesn't use 64-bit instructions. It turns out there isn't even an optional extension that defines any, so no `-march` option could enable it. After your edit, your 2nd paragraph is technically correct, but seems to imply that some current 64-bit RISC-V CPUs do actually support 64-bit instruction width. This is not the case. Also, you only ever mention 32 and 64-bit instruction widths, not 16. – Peter Cordes Feb 09 '23 at 01:17
  • In the start of the second paragraph I purposely didn't write RISCV-64, I wrote "64-bit CPUs". @PeterCordes – AZ123 Feb 09 '23 at 16:27