CAMP-V: Ultimate RISC-V Bootcamp sponsored by MERL and RISC-V

shazaib9 26 views 42 slides Aug 13, 2024
Slide 1
Slide 1 of 42
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42

About This Presentation

Slides for the CAMP-V, the Ultimate RISC-V Bootcamp.


Slide Content

CAMP-V
ULTIMATE RISC-V BOOTCAMP
and
presents

Welcome
CAMP-V

RISC-V Advocate
Research Associate @ MERL
CPU Design Engineer @ Intensivate
CAMP-V

AGENDA
Introductory Note10:00 AM
MERL Projects Showcase12:30 PM
Speed Programming2:00 PM
RISC-V Assembly Seminar10:30 AM
Lunch Break1:00 PM
Closing Note4:00 PM
CAMP-V
CAMP-V

Research assistant @ MERL
lfx mentee 2023
CAMP-V

Instruction Set Architecture
CAMP-V

Instruction Set Architecture (ISA)
Defines how software controls hardware.
Two types of ISAs.
Complex Instruction Set Computer (CISC)
Reduced Instruction Set Computer (RISC)
CAMP-V

https://www.linkedin.com/posts/sidhant-jha-330223277_instruction-set-architecture-complete-flow-activity-7117942562757255168-v320/
CAMP-V

Complex Instruction Set Computer (CISC)
Supports complex instructions taking multiple clock cycles.
Supports variable-length instructions.
Consists of a few registers.
Example: x86
CAMP-V

Reduced Instruction Set Computer (RISC)
Supports simple instructions taking a single clock cycle.
Supports only fixed-length instructions.
Register count is big.
Example: ARM and RISC-V
CAMP-V

CISC vs RISC
CISC
Reduced code size.
Complex design.
Slower execution.
Greater power
consumption.
RISC
Greater code size.
Simpler design.
Faster execution.
Lower power
consumption.
CAMP-V

Quizizz
Password: merl1234
CAMP-V

RISC-V
CAMP-V

Background
Pronounced “risk-five”.
Developed in 2010 at University of California, Berkeley.
Fifth iteration of the RISC architecture.
Two variants: RV32 and RV64.
Extension based ISA.
RV32I as base extension.
M extension for multiplication instructions.
A extension for atomic instructions.
F extension for single-precision floating-point instructions.
D extension for double-precision floating-point instructions.
These extensions are collectively known as RV32G.
CAMP-V

RV32I Characteristics
32-bit general purpose integer registers named x0 through x31.
ABI names are standardized names for registers.
A RISC-V hart has byte-addressable address space.
32-bit register called a Program Counter (PC).
CAMP-V

Register Conventions
ABI name: zero
Value of the register is always
zero.
x0
CAMP-V

Register Conventions
ABI name: ra
Stores the return address of a
function call.
x1
CAMP-V

Register Conventions
ABI name: sp
Stores the address pointing to the
top of the stack in memory.
x2
CAMP-V

Register Conventions
ABI name: gp
Stores the address pointing to the
segment of memory holding global
variables (aka the data section).
gp
x3
CAMP-V

Register Conventions
ABI name: tp
Stores the address pointing to the
thread-local storage area of
memory containing data unique to
each thread.
x4
CAMP-V

Register Conventions
ABI names: t0-t2, t3-t6
Stores temporary data or data not
to be preserved between function
calls.
x5-x7
x28-x31
CAMP-V

Register Conventions
ABI names: s0/fp
Stores the address pointing to the
bottom of the current stack frame.
x8
CAMP-V

Register Conventions
ABI names: s1, s2-s11
Stores data that is to be preserved
between function calls.
x9
x18-x27
CAMP-V

Register Conventions
ABI name: a0-a7
These store function argument
values.
a0-a1 registers also store the return
values of functions.
x10-x17
CAMP-V

Quizizz
CAMP-V

RISC-V Assembly
CAMP-V

Assembly
Low-level programming language.
Strong correspondence between assembly instructions and machine language.
Direct communication with hardware.
All compilers and interpreters compile or interpret to assembly.
CAMP-V

RISC-V Assembly
Types of instructions
Computational
register-register
register-immediate
Conditional Jumps
Unconditional Jumps
Memory operations
Supplementary
CAMP-V

Computational Instructions
Register-register instructions
Format: inst rd, rs1, rs2
Register-immediate instructions
Format: inst rd, rs1, imm
Arithmetic Comparison Logical Shifts
Register-register add, sub slt, sltu and, or, xor sll, srl, sra
Register-immediate addi slti, sltiu andi, ori, xori slli, srli, srai
CAMP-V

Register-register instruction encoding
Computational Instructions
Register-immediate instruction encoding
CAMP-V

Instruction beq bne blt bltu bge bgeu
Operation == != < < >= >=
Conditional Jumps or Branch Instructions
If the condition is true, jump to the label.
Format: inst rs1, rs2, label
CAMP-V

Conditional Jumps or Branch Instructions
Used in if and loop conditions.
CAMP-V

Branch instruction encoding
Conditional Jumps or Branch Instructions
CAMP-V

Unconditional Jumps
If this instruction is encountered, jump to the label or address.
The address of the instruction following the jump instruction is saved to the
destination register.
jal: Jump and Link
Jump target specified as label.
Format: jal rd, label
jalr: Jump and Link Register
Jump target specified as sum of register value and constant offset.
Format: jalr, rd, rs1, imm
CAMP-V

Unconditional Jumps
Used in function calls.
jal is used to jump to function definition.
jalr is used to return from the function call.
CAMP-V

Unconditional Jumps
jal instruction encoding
jalr instruction encoding
CAMP-V

Instructions for communicating with memory.
Load instruction.
Reads data from memory.
Format: lw rd, imm(rs1)
Store instruction.
Writes data to memory.
Format: sw rs2, imm(rs1)
Memory Operation Instructions
CAMP-V

Memory Operation Instructions
Load instruction encoding
Store instruction encoding
CAMP-V

Supplementary Instructions
To be used in conjunction with other instructions.
lui: Load Upper-Immediate
loads the 20-bit immediate into the upper 20 bits of rd.
Used to build 32-bit constants.
auipc: Add Upper-Immediate to PC
loads the 20-bit immediate into the upper 20-bits, adding this offset to the PC.
Used to build PC-relative addresses.
Format: inst rd, imm
CAMP-V

Supplementary Instructions
Supplementary instruction encoding
CAMP-V

Quizizz
CAMP-V