RISC-V Instruction Set Architecture Overview
RISC-V Instruction Set Architecture Overview
ISA RISC-V
Andrea Bartolini <[Link]@[Link]>
(Architettura dei) Calcolatori Elettronici, 2023/2024
Instruction Count and CPI
– The Iron Law of processor Performance
Clock Cycles = Instructio n Count Cycles per Instructio n
CPU Time = Instructio n Count CPI Clock Cycle Time
Instructio n Count CPI
=
Clock Rate
B = I 600ps = 1.2
CPU Time
CPU Time I 500ps …by this much
A
Courtesy of Andrea Marongiu
CPI Example
• Computer A: Cycle Time = 250ps, CPI = 2.0
• Computer B: Cycle Time = 500ps, CPI = 1.2
• Same ISA
• Which is faster, and by how much?
CPU Time = Instructio n Count CPI Cycle Time
A A A
= I 2.0 250ps = I 500ps A is faster…
CPU Time = Instructio n Count CPI Cycle Time
B B B
= I 1.2 500ps = I 600ps
B = I 600ps = 1.2
CPU Time
CPU Time I 500ps …by this much
A
Courtesy of Andrea Marongiu
CPI Example
• Computer A: Cycle Time = 250ps, CPI = 2.0
• Computer B: Cycle Time = 500ps, CPI = 1.2
• Same ISA
• Which is faster, and by how much?
CPU Time = Instructio n Count CPI Cycle Time
A A A
= I 2.0 250ps = I 500ps A is faster…
CPU Time = Instructio n Count CPI Cycle Time
B B B
= I 1.2 500ps = I 600ps
B = I 600ps = 1.2
CPU Time
CPU Time I 500ps …by this much
A
Courtesy of Andrea Marongiu
CPI Example
• Computer A: Cycle Time = 250ps, CPI = 2.0
• Computer B: Cycle Time = 500ps, CPI = 1.2
• Same ISA
• Which is faster, and by how much?
CPU Time = Instructio n Count CPI Cycle Time
A A A
= I 2.0 250ps = I 500ps A is faster…
CPU Time = Instructio n Count CPI Cycle Time
B B B
= I 1.2 500ps = I 600ps
B = I 600ps = 1.2
CPU Time
CPU Time I 500ps …by this much
A
Courtesy of Andrea Marongiu
CPI Example
• Computer A: Cycle Time = 250ps, CPI = 2.0
• Computer B: Cycle Time = 500ps, CPI = 1.2
• Same ISA
• Which is faster, and by how much?
CPU Time = Instructio n Count CPI Cycle Time
A A A
= I 2.0 250ps = I 500ps A is faster…
CPU Time = Instructio n Count CPI Cycle Time
B B B
= I 1.2 500ps = I 600ps
B = I 600ps = 1.2
CPU Time
CPU Time I 500ps …by this much
A
Courtesy of Andrea Marongiu
CPI Example
• Computer A: Cycle Time = 250ps, CPI = 2.0
• Computer B: Cycle Time = 500ps, CPI = 1.2
• Same ISA
• Which is faster, and by how much?
CPU Time = Instructio n Count CPI Cycle Time
A A A
= I 2.0 250ps = I 500ps A is faster…
CPU Time = Instructio n Count CPI Cycle Time
B B B
= I 1.2 500ps = I 600ps
B = I 600ps = 1.2
CPU Time
CPU Time I 500ps …by this much
A
Courtesy of Andrea Marongiu
CPI Example
• Computer A: Cycle Time = 250ps, CPI = 2.0
• Computer B: Cycle Time = 500ps, CPI = 1.2
• Same ISA
• Which is faster, and by how much?
CPU Time = Instructio n Count CPI Cycle Time
A A A
= I 2.0 250ps = I 500ps A is faster…
CPU Time = Instructio n Count CPI Cycle Time
B B B
= I 1.2 500ps = I 600ps
B = I 600ps = 1.2
CPU Time
CPU Time I 500ps …by this much
A
Courtesy of Andrea Marongiu
CPI Example
• Computer A: Cycle Time = 250ps, CPI = 2.0
• Computer B: Cycle Time = 500ps, CPI = 1.2
• Same ISA
• Which is faster, and by how much?
CPU Time = Instructio n Count CPI Cycle Time
A A A
= I 2.0 250ps = I 500ps A is faster…
CPU Time = Instructio n Count CPI Cycle Time
B B B
= I 1.2 500ps = I 600ps
B = I 600ps = 1.2
CPU Time
CPU Time I 500ps …by this much
A
Courtesy of Andrea Marongiu
Instruction Set Architecture
CISC, RISC, RISC-V
In the Beginning…
People programmed in assembly and machine code!
• Needed as many addressing modes as possible
• Memory was (and still is) slow
15
Reduced Instruction Set Computer (RISC)
Developed at UC Berkeley as open ISA starting in 2010
RISC-V Design Principles
Now managed by the RISC-V Foundation ([Link])
Simplicity favors regularity • Manages the standardization, trademark, compliancy check
• 32 bit instructions
• Same instruction format works at Typical of many modern ISAs
16/32/64/128-bit data formats
Similar ISAs have a large share of embedded core market
Smaller is faster Applications in consumer electronics, network/storage
• Small register file equipment, cameras, printers, …
16
RISC-V ISA is divided into extensions
• Kept very simple and extendable
I Integer instructions (frozen)
• Wide range of applications from IoT to HPC
E Reduced number of registers • RV + word-width + extensions
Multiplication and Division • RV32IMC: 32bit, integer, multiplication,
M (frozen) compressed
A Atomic instructions (frozen) • User specification:
Single-Precision Floating-Point • Separated into extensions, only I is mandatory
F (frozen)
• Privileged Specification:
Double-Precision Floating-Point • Governs OS functionality: Exceptions,
D (frozen)
Interrupts
C Compressed Instructions (frozen) • Virtual Addressing
• Privilege Levels
X Non Standard Extensions
Working with RISC-V
Ratified Extensions as for today
• [Link]
splay/HOME/Ratified+E
xtensions
Reduced Instruction
Privilege Set: Multiply/Divide
all in one (M) page
Basic Instructions (I) Mode
24
[Link]
Why RISC-V?
CISC RISC
Emphasis on hardware Emphasis on software
Includes multi-clock complex instructions Single-clock, reduced instruction only
Memory-to-memory: "LOAD" and "STORE" Register to register: "LOAD" and "STORE"
incorporated in instructions are independent instructions
Small code sizes, high cycles per instruction Low cycles per istruction, large code sizes
Transistors used for storing complex instructions Spends more transistors on memory registers
26
C code:
add x9,x20,x21
0 21 20 0 9 51
64 22 3 9 3
0000 0100 0000 1011 0 011 0100 1 000 0011
Courtesy of Andrea Marongiu
Shift Operations
imm imm
[10:5] rs2 rs1 funct3 [4:1] opcode
imm[12] imm[11]
◼ PC-relative addressing
◼ Target address = PC + immediate × 2
(Addressing instructions down to halfword)
and the
funct6/7 bits
opcode is which get
same for a differentiated
family of by the funct3
instructions bits
Courtesy of Andrea Marongiu
RISC-V Encoding Summary
[Link]
Courtesy of Andrea Marongiu
FP Instructions in RISC-V
• Separate FP registers: f0, …, f31
• double-precision
• single-precision values stored in the lower 32 bits
Dynamically Translated
J Languages
V Vector Operations
For more updated extensions status:
[Link] N User-Level Interrupts
Working with RISC-V
Work continues on new RISC-V extensions
• Example of the process:
• Vector Operation – V extension Q Quad-precision Floating-Point
B Bit Manipulation
T Transactional Memory
P Packed SIMD
Dynamically Translated
J Languages
[Link]
N User-Level Interrupts
ons Working with RISC-V
Reduced Instruction Set: all in one page
75
More than 1,500 RISC-V Members
across 70 Countries
94 Chip 4 Systems
SoC, IP, FPGA ODM, OEM
4 I/O 13 Industry
Memory, network, storage Cloud, mobile, HPC, ML, automotive
12 Services 81 Research
Fab, design services Universities, Labs, other alliances
March 2021
In 2020, RISC-V membership grew 133% 76