k0b0's record.

Computer Engineering, Arts and Books

RISC-V 基本命令セットRV32Iについて(1) [@20180218更新]

RISC-Vの基本命令セットRV32I

 RISC-VのRV32Iについてメモ。

基本命令フォーマット(Base Instruction Formats)

f:id:k0b0:20180214113535p:plain

整数演算命令(Integer Computational Instructions)

レジスターレジスタ間演算(Integer Register-Register Operations)

f:id:k0b0:20180215145615p:plain

funct7 rs2 rs1 funct3 rd opcode
mnemonic
説明
[31:25] [24:20] [19:15] [14:12] [11:7] [6:0]
0000000 rs2 rs1 000 rd 0110011 ADD 加算
0100000 rs2 rs1 000 rd 0110011 SUB 減算
0000000 rs2 rs1 001 rd 0110011 SLL 左シフト
0000000 rs2 rs1 010 rd 0110011 SLT 符号付き大小比較
結果をレジスタにロード
0000000 rs2 rs1 011 rd 0110011 SLTU 符号なし大小比較
結果をレジスタにロード
0000000 rs2 rs1 100 rd 0110011 XOR 排他的論理和
0000000 rs2 rs1 101 rd 0110011 SRL 右論理シフト
0100000 rs2 rs1 101 rd 0110011 SRA 右算術シフト
0000000 rs2 rs1 110 rd 0110011 OR 論理和
0000000 rs2 rs1 111 rd 0110011 AND 論理積


レジスター即値間演算(Integer Register-Immediate Instructions)

シフト命令(即値)

f:id:k0b0:20180215151005p:plain 

imm imm rs1 funct3 rd opcode
mnemonic
説明
[31:25] [24:20] [19:15] [14:12] [11:7] [6:0]
0000000 shamt rs1 000 rd 0010011 SLLI 即値による左論理シフト
0000000 shamt rs1 001 rd 0010011 SRLI 即値による右論理シフト
0100000 shamt rs1 010 rd 0010011 SRAI 即値による右算術シフト

 

算術論理演算命令(即値)

f:id:k0b0:20180215141841p:plain

imm rs1 funct3 rd opcode
mnemonic
説明
[31:20] [19:15] [14:12] [11:7] [6:0]
imm rs1 000 rd 0010011 ADDI 即値との加算
imm rs1 001 rd 0010011 SLTI 符号付きで即値と大小比較
結果をレジスタにロード
imm rs1 010 rd 0010011 SLTTU 符号なしで即値と大小比較
結果をレジスタにロード
imm rs1 011 rd 0010011 XORI 即値との排他的論理和
imm rs1 100 rd 0010011 ORI 即値との論理和
imm rs1 101 rd 0010011 ANDI

即値との論理積

 
データ転送命令

f:id:k0b0:20180216150811p:plain

imm rd opcode
mnemonic
説明
[31:12] [11:7] [6:0]
imm rd 0110111 LUI 上位への即値ロード
imm rd 0010111 AUIPC PC相対アドレス値の上位をロード

転送制御命令(Control Transfer Instructions)

無条件ジャンプ命令(JAL(jump and link))

f:id:k0b0:20180216154528p:plain

imm imm imm imm rd opcode
mnemonic
説明
[31] [30:21] [20] [19:12] [11:7] [6:0]
offset rd 1101111 JAL オフセットを指定してジャンプ
戻り値(アドレス)をロード
 

条件付ジャンプ命令(JALR (jump and link register))

f:id:k0b0:20180218110842p:plain

imm rs1 funct3 rd opcode
mnemonic
説明
[31:20] [19:15] [14:12] [11:7] [6:0]
offset base 000 rd 1100111 JALR レジスタの指定するアドレスにジャンプ
戻り値(アドレス)をロード

 

参考

Specifications - RISC-V Foundation