What Is RISC-V? The Open ISA and Its Instruction Formats
The instruction add x5, x6, x7 is the 32-bit number . You can work that out with a pencil, from a PDF that anyone can download, and you can build a processor that executes it without asking anyone's permission or paying anyone a cent. Try the same thing with an Arm or x86 instruction and the first two steps are easy, but the third needs a licence that only Arm can sell you, or does not exist at all.
That is the whole idea behind RISC-V in one paragraph. The rest of this guide unpacks what "open" covers and what it does not, then takes the instruction formats apart bit by bit, because the encoding is where you see the design choices most clearly. It is the first of three pillar guides. The second decodes the extension letters in names like RV64GC, and the third compares RISC-V with Arm and x86 on licensing, performance and power.
What is RISC-V, in plain terms?
A processor only understands numbers. The instruction set architecture, or ISA, is the agreement that says which numbers mean what: this 32-bit pattern adds two registers, that one loads a word from memory, this other one jumps. It also fixes how many registers exist, how memory is addressed and what happens on an interrupt. Software is compiled against the ISA. Hardware is built to obey it. As long as both sides keep to the agreement, any compiler's output runs on any compliant chip.
RISC-V is one such agreement. It started in 2010 as a research project at the University of California, Berkeley, where the team wanted a clean instruction set for teaching and research that they could share freely. The specification moved to the RISC-V Foundation in 2015, and that body is now RISC-V International, incorporated in Switzerland. The base integer set and the main extensions were ratified in 2019, which is roughly when commercial chips started to appear in numbers. RISC-V International's former chief executive, Calista Redmond, put the installed base at about ten billion cores in early 2023.
The design itself is a classic load and store RISC. Arithmetic happens only between registers, memory is touched only by loads and stores, and every base instruction is exactly 32 bits long. RV32I, the 32-bit base, has 32 integer registers, to , and is wired to zero. The unprivileged specification counts 40 unique instructions in RV32I. That is small enough to implement in a student project, and it is the reason so many hobby and research cores exist.
What does “open ISA” actually mean?
It means three concrete things. The specification is published openly: the ISA manual sits in a public repository under a Creative Commons Attribution 4.0 licence. Anyone may implement it without a licence fee, and RISC-V International's own FAQ says there is no fee to use the ISA. And changes to the standard go through an open process run by member companies and individuals, rather than being decided by one vendor.
Compare that with the two incumbents. To build an Arm core, you either license one of Arm's designs, or you buy an architecture licence that lets you design your own core to the Arm specification. Both come with fees and royalties. x86 is narrower still. Intel does not sell x86 licences in the normal sense. AMD builds x86 under a long-standing patent cross-licence with Intel, and VIA, through its stake in Zhaoxin, holds the only other licence of any consequence. If you are not one of those companies, you cannot ship an x86 processor.
What the open ISA does not give you is a free processor. The specification tells you what the hardware must do, not how. Turning it into logic is a large engineering job, and the result belongs to whoever did the work.
Myth: an open ISA means open-source chips
This is the most common misunderstanding about RISC-V, and it leads people to two wrong conclusions: that RISC-V chips must be cheap because "nobody pays for it", and that a RISC-V chip in a product means its design is public. Neither follows.
Look at the second layer in Figure 1. Some cores are fully open. Hazard3, the RISC-V core inside the Raspberry Pi RP2350, is on GitHub under Apache-2.0, and so is lowRISC's Ibex. OnionSoC, the hand-written RV32IM system-on-chip built here at The Science 360, publishes its RTL, testbenches and board logs under the same licence. Other cores are commercial products. SiFive and Andes sell RISC-V cores the way Arm sells Cortex cores, under licence, and their RTL is as private as Arm's.
The chip you buy is a third layer again. An ESP32-C3 runs a RISC-V core, but Espressif's silicon design is not public, and nobody expects it to be. What the open ISA guarantees is that the compiler, the debugger and your knowledge of the instruction set carry over to any RISC-V part, from any vendor, open or closed.
How is a RISC-V instruction built?
Every base instruction is one 32-bit word, and the low seven bits are always the opcode, the field that says which family the instruction belongs to. The remaining 25 bits are laid out in one of six formats, shown in Figure 2.
- R-type is register to register:
add,sub,and,slland friends. Two sources, one destination, plus funct3 and funct7 to pick the exact operation. - I-type swaps rs2 and funct7 for a 12-bit signed immediate. It covers
addi, the loads andjalr. - S-type is for stores. A store has two source registers (the address base and the data) and no destination, so the immediate is split into two pieces to keep rs1 and rs2 where they are.
- B-type is for conditional branches such as
beqandblt. Same shape as S, with the immediate bits shuffled. - U-type holds a 20-bit upper immediate for
luiandauipc. - J-type is
jal, jump and link, with a 20-bit shuffled offset.
Why do the register fields never move?
Look down any column of Figure 2. rd is always bits 11 to 7. rs1 is always bits 19 to 15. rs2 is always bits 24 to 20. A pipelined processor wants to read the register file as early as possible, ideally in the same cycle it is still working out what the instruction is. If the register numbers always sit in the same place, the hardware can just send those bits to the register file every cycle, whether or not the instruction turns out to need them. No multiplexer, no waiting for the opcode decoder. In a core like OnionSoC that is a few gates saved; in a fast core, it is a shorter critical path in the decode stage.
The price is paid in the immediates. To keep rs1 and rs2 fixed, the store immediate has to be cut in two. The branch and jump immediates are cut in stranger ways, and , because the designers also wanted the sign bit of every immediate to sit at bit 31. Sign extension can then start before decode finishes, and most immediate bits land in the same position across formats, which keeps the immediate multiplexers small. The assembler sorts out the shuffle. Humans almost never have to.
Worked example: encoding two instructions by hand
Take add x5, x6, x7, which sets . It is R-type, with opcode , funct3 0 and funct7 0. Each field is shifted to its position and the results are added:
Now addi x5, x6, -1. It is I-type, opcode . The immediate is , which in 12-bit two's complement is twelve ones, :
Figure 3 shows the same two words as fields, bits and hex digits. If you have a RISC-V toolchain, riscv64-unknown-elf-objdump -d on any compiled program will print words like these next to each instruction, and you can check them against the table.
How far can a RISC-V immediate reach?
Fixed 32-bit instructions mean no instruction can carry a full 32-bit constant or address. The ISA works around that with reach. A 12-bit signed immediate covers to , so a load or store can reach 2 KiB either side of its base register. Branch and jump offsets are always even (instructions are at least 2 bytes long once the compressed extension exists), so the hardware does not store bit 0, and 12 stored bits give a 13-bit offset:
Beyond that, two instructions team up. lui puts a 20-bit value in the top of a register and addi adds a signed 12-bit low part, which together can build any 32-bit constant. There is one trap here that catches everyone who writes an assembler: the low part is signed. To load , the low 12 bits are , which addi reads as , so the upper part has to be rounded up by one:
auipc does the same trick relative to the program counter, and paired with jalr it can call any address within 2 GiB, which on a 32-bit machine is all of memory.
Why keep the base ISA so small?
Forty instructions is not much. There is no multiply in RV32I, no floating point, and no atomic memory operation. That is deliberate. The base is frozen, so software written for RV32I will run on every 32-bit RISC-V core ever built. Everything else comes in optional, named extensions: M for multiply and divide, A for atomics, F and D for floating point, C for 16-bit compressed instructions, V for vectors, and a growing list of Z extensions. A tiny microcontroller can implement only what it needs, and a server core can implement nearly all of it.
That is why RISC-V chips are described by strings such as RV32IMC (the ESP32-C3), RV32EC (the WCH CH32V003, which halves the register file to 16) or RV64GC (the SiFive U74 cores in the StarFive JH7110). OnionSoC is RV32IM: base plus multiply and divide, with no compressed instructions yet, which costs it roughly a quarter more code space than a core with C. The extension letters guide decodes every letter and what it costs in hardware.
The flexibility has a cost too: fragmentation. If every vendor picks a different set of extensions, software vendors cannot target "RISC-V" as a single platform. RISC-V International's answer is profiles, named bundles of mandatory extensions. RVA23, ratified in October 2024, is the profile for application processors that run full operating systems, and it makes the vector and hypervisor extensions mandatory.
What does open actually buy you?
For a chip company, it buys freedom from a single supplier and from per-chip royalties on the ISA. For a researcher or student, it buys the right to build, publish and tape out a processor without lawyers. For a programmer, it buys a single, stable target that many vendors compete to implement.
It does not buy a finished, verified, fast core, and that is where most of the real cost of a processor sits. Arm's business is not really selling the right to use an instruction set. It is selling cores that are known to work. A team choosing RISC-V either licenses a commercial core, adopts an open one and takes on its verification, or writes its own. How that trade looks in money, CoreMark per megahertz and power is the subject of the RISC-V vs Arm vs x86 comparison.
Frequently asked questions
Is RISC-V really free?
The instruction set is. The specification is published under a Creative Commons Attribution 4.0 licence and RISC-V International charges no fee to implement it. A finished core design or a chip is a different matter: some cores are open source, many are sold as licensed IP, and every chip is a product you pay for.
Is RISC-V open-source hardware?
Not automatically. RISC-V is an open instruction set, which is a specification. A particular processor that implements it can be open source, like Hazard3, Ibex or OnionSoC under Apache-2.0, or closed, like most commercial cores from SiFive or Andes.
How many instructions does RISC-V have?
The 32-bit base integer set, RV32I, has 40 unique instructions according to the unprivileged specification. Everything else, such as multiply, atomics, floating point, compressed and vector instructions, comes in optional extensions named by letters.
What are the RISC-V instruction formats?
There are six base formats, all 32 bits long: R-type for register to register operations, I-type for immediates, loads and jalr, S-type for stores, B-type for conditional branches, U-type for lui and auipc, and J-type for jal. The opcode is always bits 6 to 0, and rd, rs1 and rs2 sit in the same bit positions in every format that uses them.
Why are RISC-V branch immediates scrambled?
So that the register fields never move and the sign bit of every immediate is always bit 31. The hardware can then read registers and start sign extension before it has fully decoded the instruction, at the cost of a slightly odd bit order that only the assembler has to deal with.
Related on The Science 360
Sources
- RISC-V Unprivileged ISA, RV32I base integer instruction set (40 unique instructions, base formats): docs.riscv.org
- RISC-V ISA manual repository and its Creative Commons Attribution 4.0 licence: github.com/riscv/riscv-isa-manual
- About RISC-V International (history, Swiss incorporation): riscv.org/about
- RISC-V history overview: Wikipedia, RISC-V
- RISC-V installed base of about ten billion cores: Wccftech report
- RVA23 profile ratification, October 2024: riscv.org
- Intel and AMD x86 cross-licence and the VIA licence: Tom's Hardware
- Hazard3 RISC-V core (Apache-2.0): github.com/Wren6991/Hazard3
- Ibex RISC-V core (Apache-2.0): github.com/lowRISC/ibex
- OnionSoC repository (Apache-2.0): github.com/oniondas/onion-soc
- ESP32-C3 product page: espressif.com
- WCH CH32V003 (QingKe RV32EC core) datasheet: wch-ic.com
- StarFive JH7110 datasheet, U74 cores (RV64GC): doc-en.rvspace.org
Header image: OnionSoC Sky130 chip layout, from github.com/oniondas/onion-soc, regraded for this article.