0% found this document useful (0 votes)
4 views2 pages

Chapter 6 RISCV Study Notes Part1

Chapter 6 discusses the RISC-V instruction formats, focusing on the R-Type format used for arithmetic and logical operations that involve only register values. It explains the structure and fields of the R-Type instruction, including the opcode, source registers, and destination register. The chapter emphasizes the importance of using registers for performance efficiency in CPU operations.

Uploaded by

abdullaharif8061
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Chapter 6 RISCV Study Notes Part1

Chapter 6 discusses the RISC-V instruction formats, focusing on the R-Type format used for arithmetic and logical operations that involve only register values. It explains the structure and fields of the R-Type instruction, including the opcode, source registers, and destination register. The chapter emphasizes the importance of using registers for performance efficiency in CPU operations.

Uploaded by

abdullaharif8061
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Chapter 6 – RISC-V Study Notes (Part 1)

These notes are written in simple English and follow the lecture-slide style. This part
covers the foundations and the complete R-Type instruction format.

1. What is an Instruction?
An instruction is a command given to the CPU telling it to perform a specific task such
as addition, subtraction, loading data from memory, storing data, or jumping to
another instruction.

2. What is an Instruction Format?


An instruction format is the layout of a 32-bit instruction. It tells the CPU where each
piece of information is stored, such as the opcode, registers, and immediate value.
Different instructions require different information, so RISC-V uses different instruction
formats.

Why are different instruction formats needed?


An ADD instruction needs two source registers and one destination register. A LOAD
instruction needs a destination register, a base register, and an offset. A BRANCH
instruction needs two registers and a target address. Because the required information
is different, one format cannot be used for every instruction.

Instruction Formats in RISC-V


1. R-Type (Register) 2. I-Type (Immediate) 3. S-Type (Store) 4. B-Type (Branch) 5.
U-Type (Upper Immediate) 6. J-Type (Jump)

R-Type (Register Format)


Definition
The R-Type instruction format is used for arithmetic, logical, comparison, and shift
operations where both input values are already stored in registers. The result is written
into another register.

What is it?
It is the format used when the processor only works with register values. No immediate
value and no memory address are used.

What does it do?


It performs operations such as add, subtract, multiply, divide, AND, OR, XOR, and shift
operations using two source registers and one destination register.

Why is it used?
Registers are the fastest storage inside the CPU. Working directly with registers avoids
slow memory access and improves performance.

Structure
funct7 | rs2 | rs1 | funct3 | rd | opcode

Fields
opcode: Identifies the instruction category.
rd: Destination register where the result is stored.
rs1: First source register.
rs2: Second source register.
funct3: Helps identify the exact operation.
funct7: Distinguishes similar instructions such as add and sub.

Instructions that use R-Type


add, sub, mul, div, rem, and, or, xor, sll, srl, sra, slt

Assembly Syntax
instruction rd, rs1, rs2
Example: add x5, x1, x2

CPU Execution
1. Fetch the instruction.
2. Decode the opcode.
3. Read rs1 and rs2.
4. Execute the operation in the ALU.
5. Store the result in rd.

Example
Suppose x1 = 15 and x2 = 10.
Instruction: add x5, x1, x2
The CPU adds 15 + 10 and stores 25 in x5.

Important Exam Points


• Uses only registers.
• No immediate value.
• No memory access.
• Used for arithmetic, logical, comparison, and shift operations.

One-Line Definition
R-Type is an instruction format used for register-to-register operations where two
register operands are processed and the result is stored in a destination register.

You might also like