The RISC-V Family: RV32I, RV64I and the Extension Letters
RISC-V is not one instruction set. It is a small base and a shelf of blocks, and the name of a processor says which blocks it has. This page reads those names.
You Will Be Able To
- Read a name such as RV32IMAC or RV64GC: the register width, the base and each added block.
- Say what changes between RV32I and RV64I, and what stays the same.
- Compare a load-store instruction set with one whose instructions do more, using one table.
- Lesson
- S2.17
- Time
- 22 min
- Runs on
- Your browser
- Check
- 6 questions
A team buys a small processor for a motor controller. Its data sheet gives the processor a name of seven letters and digits. The software team has a library built for a name with one more letter. Will the library run?
Before You Start
You need the map of RV32I from S2.1: 32 registers, 40 instructions, and loads and stores as the only way to memory.
You do not need to know any instruction outside the base. This page names the other groups and does not teach them.
| Question | |
|---|---|
| 1 | What does each part of the name RV32IMAC say? |
| 2 | What changes when the 32 becomes 64? |
| 3 | What must software do when the processor lacks the letter M? |
| 4 | May a program built for RV32IMAC run on an RV32IMC processor? |
| 5 | How does a load-store instruction set differ from one with complex instructions? |
The Idea: A Small Base and Named Blocks
A watch and a server need different processors. The watch wants few gates. The server wants fast arithmetic on large numbers. One fixed instruction set would be too large for the first, or too small for the second.
The answer is a base and blocks. The base is the 40 instructions of S2.1. Each block is a group of extra instructions with a name. Such a block is called an ISA extension, or an extension for short.
A processor is described by one short name, its ISA name. It starts with two fixed letters. Then comes the width of a register, then the base, then one letter for each extension.
| ISA name | What it says |
|---|---|
| RV32IM | Registers of 32 bits, the base I, and the extension M. |
| RV32IMC | The same, with the extension C as well. |
| RV32IMAC | The same, with the extensions A and C. |
| RV64GC | Registers of 64 bits, the bundle G of this page, and the extension C. |
The same base also comes with registers of 64 bits. That form is RV64I. It is a second base, not an extension: every register and every address grows to 64 bits.
This way of building is often set against an older one. RISC stands for reduced instruction set computer. CISC stands for complex instruction set computer.
A RISC design has few, simple instructions. A CISC design has many, and some do a great deal each. RISC-V belongs to the first kind, as its name says.
New Words
| Word | Meaning |
|---|---|
| ISA extension | A named group of instructions that is added to a base. Extension for short. |
| ISA name | The short name of what a processor implements: RV, the register width, the base and the extensions. |
| RV64I | The base of RISC-V with registers and addresses of 64 bits. |
| M extension | Multiply and divide. |
| A extension | A read and a write of memory, done as one step that nothing can split. |
| Floating-point extensions | The letters F and D: arithmetic on numbers with a fraction. F works on 32 bits, D on 64. |
| C extension | Short forms of common instructions, 16 bits long. |
| Zicsr | The instructions that read and write the control registers of the processor. |
| General bundle | The letter G: a short way to write I, M, A, F and D together. It includes Zicsr as well. |
| Processor trap | A forced jump out of the program, made by the processor when it cannot run an instruction. Trap for short. |
| Illegal instruction | A word that the processor does not know as an instruction. The processor refuses it with a processor trap. |
| RISC design | Reduced instruction set computer: few, simple instructions of one length, and a load-store design. |
| CISC design | Complex instruction set computer: many instructions of several lengths, some of which work on memory directly. |
One Picture: The Base and Its Blocks
- Processor
- Control / FSM
- Memory
- Bus
- The base
Every RISC-V processor has the base I. The number in front, 32 or 64, is the width of a register.
- M: multiply and divide
The base can only add, subtract, shift and compare. M adds instructions that multiply and divide.
- A: steps that cannot be split
A adds instructions that read and write memory as one step that cannot be split. Module S9 needs them.
- F and D: fractions
F and D add 32 more registers, and arithmetic on numbers with a fraction. F is the short form, D the long.
- C: short instructions
C adds forms of 16 bits for the most common instructions. Programs get smaller.
- Zicsr, and the bundle G
Longer names start with Z. Zicsr adds the instructions for control registers. G is a short way to write a common bundle.
Read the diagram as text
- Base I: 40 integer instructions; registers of 32 or 64 bits
- Letter M: multiply and divide
- Letter A: memory steps that cannot be split, for more than one processor
- Letters F and D: arithmetic on fractions, in registers of their own
- Letter C: short forms, 16 bits long, of common instructions
- Zicsr: instructions for the control registers of the processor
- Letter G: short for I, M, A, F and D together
- Letter M → Base I: adds
- Letter A → Base I: adds
- Letters F and D → Base I: adds
- Letter C → Base I: adds
- Zicsr → Base I: adds
- Letter G → Base I: names a bundle
A block only adds instructions. It never changes what a base instruction does.
The Smallest Example, Worked by Hand
Read two names. Take them apart from left to right.
| Part | In RV32IMAC | In RV64GC |
|---|---|---|
| RV | RISC-V | RISC-V |
| The number | 32: registers of 32 bits | 64: registers of 64 bits |
| The base | I: the 40 integer instructions | inside G |
| The letters | M, A and C | G is I, M, A, F and D. Then C. |
| Multiply instructions? | yes: M | yes: M is inside G |
| Arithmetic on fractions? | no: neither F nor D | yes: F and D are inside G |
The letters come in a fixed order: I, M, A, F, D, C.
Change the width. The second part of the example is one addition, done three times. The first row is the sum of S2.1. The other two push a sum past 32 bits.
00000007 + 00000005 | 32 bits: 0000000c | 64 bits: 000000000000000c | addw: 000000000000000c
ffffffff + 00000001 | 32 bits: 00000000 | 64 bits: 0000000100000000 | addw: 0000000000000000
7fffffff + 00000001 | 32 bits: 80000000 | 64 bits: 0000000080000000 | addw: ffffffff80000000Row 2: in 32 bits, the largest value plus 1 wraps round to 0. In 64 bits there is room, and bit 32 is set.
Row 3, last column: RV64I keeps a second add, called addw. It adds the low 32 bits only, and copies bit 31 into the upper half. So old code that counts in 32 bits gets the answers it expects.
The Rules
Rule 1: An ISA name is RV, a width, a base and the extensions.
RV32IMC: 32 bits, the base I, then M and C.
Rule 2: An extension only adds instructions.
A base instruction does the same thing on every processor of that width.
Rule 3: A program may use only what the processor has.
A word from a missing extension is an illegal instruction, and the processor traps.
Rule 4: A program built for fewer extensions still runs where there are more.
The other direction fails at the first missing instruction.
Rule 5: RV64I widens every register and address to 64 bits.
An instruction is still 32 bits long. Code built for one width does not run on the other.
Rule 6: What an extension does in one instruction, the base must do in several.
Without M, a multiply is a loop of adds and shifts.
Sources for These Rules
Every RISC-V fact on this page is stated as commonly described. That covers the two widths, the letters and what each adds, the bundle G, and the word of the multiply instruction. The RISC-V specifications are not in the reference library. So none of these facts is checked against them. The statements about other instruction sets are common descriptions too, and are not checked.
The plan of this track points to two textbooks for this material. They are Patterson and Hennessy, chapter 2, and Harris and Harris, section 6.2. Those places are not checked either.
Now Run It
The lab at the end of this page multiplies 6 by 7 on RV32I, which has no multiply. It adds 6 into x12 seven times. Register x11 counts the turns.
00000000 | addi x12, x0, 0 | x12 = 00000000
00000004 | beq x11, x0, 0x14 | not taken
00000008 | add x12, x12, x10 | x12 = 00000006
0000000c | addi x11, x11, -1 | x11 = 00000006
00000010 | bne x11, x0, 0x8 | taken: next is 00000008
(15 more rows: five more turns of the loop)
00000008 | add x12, x12, x10 | x12 = 0000002a
0000000c | addi x11, x11, -1 | x11 = 00000000
00000010 | bne x11, x0, 0x8 | not taken
00000014 | ebreak | stop
x12=42 instructions=23Rule 6 at work: read the last row. The answer is 42, and it took 23 instructions. That is 2 to set up, and 3 for each of the 7 turns.
With the M extension, the whole loop is one instruction: mul x12, x10, x11. Neither model of this track has M yet, so that instruction is not run here.
The count grows with the number itself. A multiply by 1000 this way takes 3002 instructions. Real software without M uses shifts, and needs about 32 turns at most.
Why It Is Built This Way
| Question | RISC, as in RISC-V | CISC, as commonly described |
|---|---|---|
| How long is an instruction? | One length: 32 bits. With C, also 16. | Many lengths, from one byte up. |
| What may arithmetic work on? | Registers and immediates only. | Registers, and memory directly. |
| How is memory reached? | By loads and stores only. | By many instructions. |
| How many registers? | Many: 32. | Often fewer: 8 or 16. |
| The sum of S2.1: two words of memory added, and stored | Four instructions: two loads, an add, a store. | About three: the add reads one word from memory itself. |
| What is hard to build? | Little. Each instruction does one small thing. | Finding where each instruction ends, and running the large ones. |
| What does a program cost? | More instructions for the same work. | Fewer instructions, and each may take longer. |
The CISC column is a common description and is not checked. No CISC code is run on this page.
Neither column wins every row. The RISC column trades longer programs for hardware that is simple to build and to check. That trade is why this track can build a whole RISC-V processor in a few lessons.
| Design choice | The alternative | What the choice buys, and costs |
|---|---|---|
| A small base and named extensions | One large instruction set | A tiny processor is still a complete RISC-V. Software must know which letters are there. |
| Extensions only add | Extensions may change old instructions | Old programs keep working. Space for new instructions must be kept free. |
| A second base for 64 bits | A 64-bit extension on top of RV32I | The same assembly reads the same on both. Programs must be built again for the other width. |
The Trap: A Multiply on a Chip with No M
A team tests its software on a board with an RV32IM processor. Every test passes. The product uses a cheaper chip with RV32I. Nobody builds the software again.
The first multiply in the program is the word 02b50633. On the test board, that word multiplies x10 by x11. Here is the same word on a processor with the base only:
00000000 | word 02b50633 | trap, cause 2: illegal instruction | x12 = 00000000Read the row. The processor did not multiply, and it did not skip the word. It took a trap for an illegal instruction, and x12 still holds 0.
This is rule 3. The software was right, and the chip was right. The two were built for different names. The check is one line in the build: give the compiler the ISA name of the real chip.
At Scale
This section looks ahead. Every RISC-V chip prints its ISA name somewhere, and each letter costs area.
The processor of ap_soc
The processor of this track is planned as RV32I with Zicsr. A later module adds a small part of A for a second processor.
Fewer registers
There is a base with only 16 registers, written E in place of I. It is meant for the smallest chips.
Asking the chip
A control register of the processor holds one bit for each letter. Software can read it to learn the name. A later lesson of this module reads it.
Other families
Arm processors are RISC designs as well. The processors of most desktop computers are CISC designs. This is a common description, and it is not checked here.
Try It
Run the lab. Count the rows of one turn of the loop.
Change x11 from 7 to 0 in the line that prepares it. Predict the number of instructions first.
Swap the two numbers, so that x10 holds 7 and x11 holds 6. The answer is the same. Is the count?
00000000 | addi x12, x0, 0 | x12 = 00000000 00000004 | beq x11, x0, 0x14 | not taken 00000008 | add x12, x12, x10 | x12 = 00000006 0000000c | addi x11, x11, -1 | x11 = 00000006 00000010 | bne x11, x0, 0x8 | taken: next is 00000008 00000008 | add x12, x12, x10 | x12 = 0000000c 0000000c | addi x11, x11, -1 | x11 = 00000005 00000010 | bne x11, x0, 0x8 | taken: next is 00000008 00000008 | add x12, x12, x10 | x12 = 00000012 0000000c | addi x11, x11, -1 | x11 = 00000004 00000010 | bne x11, x0, 0x8 | taken: next is 00000008 00000008 | add x12, x12, x10 | x12 = 00000018 0000000c | addi x11, x11, -1 | x11 = 00000003 00000010 | bne x11, x0, 0x8 | taken: next is 00000008 00000008 | add x12, x12, x10 | x12 = 0000001e 0000000c | addi x11, x11, -1 | x11 = 00000002 00000010 | bne x11, x0, 0x8 | taken: next is 00000008 00000008 | add x12, x12, x10 | x12 = 00000024 0000000c | addi x11, x11, -1 | x11 = 00000001 00000010 | bne x11, x0, 0x8 | taken: next is 00000008 00000008 | add x12, x12, x10 | x12 = 0000002a 0000000c | addi x11, x11, -1 | x11 = 00000000 00000010 | bne x11, x0, 0x8 | not taken 00000014 | ebreak | stop x12=42 instructions=23Check Yourself
Common Mistakes
Wrong Read RV32IMC as "32 instructions".
The number is the width of a register in bits.
Fix Read it as: registers of 32 bits, base I, extensions M and C.
Wrong Run software built for RV32IMAC on an RV32IMC chip.
The first instruction from A is an illegal instruction there.
Fix Build the software for the name of the chip, or for fewer letters.
Wrong Expect RV32I code to run on an RV64I processor.
RV64I is a second base. Registers and addresses have another width.
Fix Build the program again for the other width.
Remember
- An ISA name is RV, the register width, the base and one letter for each extension.
- An extension only adds instructions. A word from a missing extension is an illegal instruction.
- RV64I widens registers and addresses to 64 bits. Instructions stay 32 bits long.
- RISC: one instruction length, many registers, loads and stores only. CISC: the opposite on each count.