53
RISC V RV32I BASE INSTRUCTION SET 4/11/2018

BASE INSTRUCTION SET

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: BASE INSTRUCTION SET

RISC V RV32I

BASE INSTRUCTION SET

4/11/2018

Page 2: BASE INSTRUCTION SET

REFERENCE

www.riscv.org

The RISC-V Instruction Set Manual

Volume I: User-Level ISA

Document Version 2.2

4/11/2018

Page 3: BASE INSTRUCTION SET

R-FORMATfunct7 rs2 rs1 funct3 rd opcode

• ADD - Addition

• SUB - Subtraction

• SLL – Logical Left Shift

• SLT – Set Less Than

• SLTU – Set Less Than Unsigned

• XOR – Xor operation

• SRL – Logical Right Shift

• SRA – Arithmetic Right Shift

• OR – or operation

• AND – and operation

4/11/2018

Page 4: BASE INSTRUCTION SET

I -FORMAT

imm[11:0] rs1 funct3 rd opcode

•LB - Load Byte

• LH - Load Half Word

• LW - Load Word

• LBU - Load Byte Unsigned

• LHU - Load Half Word Unsigned

• ADDI - Add Immediate

• SLTI - Set Less Than Immediate

• SLTIU - Set Less Than Immediate Unsigned

• XORI - Xor with immediate

• ORI - OR with immediate

• ANDI - AND immediate

• SLLI - Logical Left Shift with immediate

• SRLI - Logical Right Shift with immediate

• SRAI - Arithmetic Right Shift with immediate

• JALR - Jump and Link register

4/11/2018

Page 5: BASE INSTRUCTION SET

• CSRRW - Atomic Read / Write CSR

• CSRRS - Atomic Read and Set Bits in CSR

• CSRRC - Atomic Read and Clear Bits in CSR

• CSRRWI - Atomic Read / Write CSR with unsigned immediate

• CSRRSI - Atomic Read and Set Bits in CSR with unsigned immediate

• CSRRCI - Atomic Read and Clear Bits in CSR with unsigned immediate

• ECALL - Environmental call

• EBREAK - Environmental break

• FENCE - Fence

• FENCE.I - Fence with immediate

imm[11:0] rs1 funct3 rd opcode

Continue…I -FORMAT

4/11/2018

Page 6: BASE INSTRUCTION SET

S-FORMAT

Imm[11:5] rs2 rs1 funct3 Imm[4:0] opcode

• SB - Store Byte

• SH - Store Half Word

• SW - Store Word

4/11/2018

Page 7: BASE INSTRUCTION SET

B-FORMAT

Imm[11:5] rs2 rs1 funct3 Imm[4:1] imm[11] opcode

• BEQ - Branch Equality

• BNE - Branch Not Equal

• BLT - Branch Less Than

• BGE - Branch Greater Than

• BLTU - Branch Less Than Unsigned

• BGEU – Branch Greater Than Unsigned

4/11/2018

Page 8: BASE INSTRUCTION SET

U-FORMAT

Imm[31:12] rd opcode

• LUI - Load Upper Immediate

• AUIPC - Add Upper Immediate with PC

4/11/2018

Page 9: BASE INSTRUCTION SET

J-FORMAT

Imm[20] imm[10:1]imm[11] imm[19:12] rd opcode

• JAL - Jump And Link

4/11/2018

Page 10: BASE INSTRUCTION SET

EXECUTION OF OPERATIONS IN R-FORMAT

ADD (Addition)

4/11/2018

Page 11: BASE INSTRUCTION SET

SUB (Subtraction) R-FORMAT

4/11/2018

Page 12: BASE INSTRUCTION SET

SLL (Logical Left Shift) R-FORMAT

4/11/2018

Page 13: BASE INSTRUCTION SET

SLT (Set Less Than) R-FORMAT

4/11/2018

Page 14: BASE INSTRUCTION SET

SLTU (Set Less Than Unsigned) R-FORMAT

4/11/2018

Page 15: BASE INSTRUCTION SET

XOR(XOR Operation) R-FORMAT

4/11/2018

Page 16: BASE INSTRUCTION SET

SRL (Logical Right Shift) R-FORMAT

4/11/2018

Page 17: BASE INSTRUCTION SET

SRA(Arithmetic Right Shift) R-FORMAT

4/11/2018

Page 18: BASE INSTRUCTION SET

OR(OR Operation) R-FORMAT

4/11/2018

Page 19: BASE INSTRUCTION SET

AND (AND Operation) R-FORMAT

4/11/2018

Page 20: BASE INSTRUCTION SET

EXECUTION OF INSTRUCTIONS IN I-FORMAT

LB (Load Byte)

4/11/2018

Page 21: BASE INSTRUCTION SET

LH (Load Halfword) I-FORMAT

4/11/2018

Page 22: BASE INSTRUCTION SET

LW (Load Word) I-FORMAT

4/11/2018

Page 23: BASE INSTRUCTION SET

LBU(Load Byte Unsigned) I-FORMAT

4/11/2018

Page 24: BASE INSTRUCTION SET

LHU(Load Halfword Unsigned) I-FORMAT

4/11/2018

Page 25: BASE INSTRUCTION SET

ADDI (Addition Immediate) I-FORMAT

4/11/2018

Page 26: BASE INSTRUCTION SET

SLTI(Set Less Than Immediate) I-FORMAT

4/11/2018

Page 27: BASE INSTRUCTION SET

SLTIU(Set Less Than Immediate Unsigned) I-FORMAT

4/11/2018

Page 28: BASE INSTRUCTION SET

XORI(XOR Immediate) I-FORMAT

4/11/2018

Page 29: BASE INSTRUCTION SET

ORI (OR Immediate) I-FORMAT

4/11/2018

Page 30: BASE INSTRUCTION SET

ANDI (AND Immediate) I-FORMAT

4/11/2018

Page 31: BASE INSTRUCTION SET

SLLI(Logical Left Shift With Immediate) I-FORMAT

4/11/2018

Page 32: BASE INSTRUCTION SET

SRLI (Logical Right Shift with Immediate) I-FORMAT

4/11/2018

Page 33: BASE INSTRUCTION SET

SRAI (Arithmetic Right Shift with Immediate) I-FORMAT

4/11/2018

Page 34: BASE INSTRUCTION SET

JALR(Jump And Link Register) I-FORMAT

4/11/2018

Page 35: BASE INSTRUCTION SET

CSRRW (Atomic Read Write CSR) I-FORMAT

4/11/2018

Page 36: BASE INSTRUCTION SET

CSRRS (Atomic Read Write Set Bit) I-FORMAT

4/11/2018

Page 37: BASE INSTRUCTION SET

CSRRC(Atomic Read Write Clear Bit) I-FORMAT

4/11/2018

Page 38: BASE INSTRUCTION SET

CSRRWI (Atomic Read Write With Immediate) I-FORMAT

4/11/2018

Page 39: BASE INSTRUCTION SET

CSRRSI(Atomic Read Write Set Bit with Immediate) I-FORMAT

4/11/2018

Page 40: BASE INSTRUCTION SET

CSRRCI (Atomic Read Write Clear Bit with Immediate) I-FORMAT

4/11/2018

Page 41: BASE INSTRUCTION SET

ECALL – Transfer control to the operating system

EBREAK – Transfer control to the debugger

FENCE – Synchronizes thread

FENCE.I- Synchronizes write to the instruction stream.

imm[11:0] rs1 funct3 rd opcode

I- FORMAT

4/11/2018

Page 42: BASE INSTRUCTION SET

EXECUTION OF INSTRUCTIONS IN S-FORMAT

SB (Store Byte)

4/11/2018

Page 43: BASE INSTRUCTION SET

SH (Store Halfword) S-FORMAT

4/11/2018

Page 44: BASE INSTRUCTION SET

SW (Store Word) S-FORMAT

4/11/2018

Page 45: BASE INSTRUCTION SET

EXECUTION OF INSTRUCTION IN B-FORMAT

BEQ (Branch Equality)

funct3=000;opcode =1100011

4/11/2018

Page 46: BASE INSTRUCTION SET

BNE (Branch Not Equal) B-FORMAT

funct3=001;opcode =1100011

4/11/2018

Page 47: BASE INSTRUCTION SET

BLT(Branch Less Than) B-FORMAT

funct3=100;opcode =1100011

4/11/2018

Page 48: BASE INSTRUCTION SET

BGE (Branch Greater Than) B-FORMAT

funct3=101;opcode =1100011

4/11/2018

Page 49: BASE INSTRUCTION SET

BLTU(Branch Less Than Unsigned) B-FORMAT

funct3=110;opcode =1100011

4/11/2018

Page 50: BASE INSTRUCTION SET

BGEU(Branch Greater Than Unsigned) B-FORMAT

funct3=111;opcode =1100011

4/11/2018

Page 51: BASE INSTRUCTION SET

EXECUTION OF INSTRUCTIONS IN U-FORMAT

LUI (Load Upper Immediate) U-FORMAT

4/11/2018

Page 52: BASE INSTRUCTION SET

AUIPC(Add Upper Immediate With PC) U-FORMAT

4/11/2018

Page 53: BASE INSTRUCTION SET

EXECUTION OF INSTRUCTIONS IN J-FORMAT

JAL (Jump and Link) J-FORMAT

4/11/2018