RISC-V Instruction Formats

news/2024/11/16 11:56:41/

原始内容如下:
RISC-V Instruction Formats
The RISC-V Instruction Set Manual Volume I: User-Level ISA lists 15 instruction formats where some of the formats have multiple variants. For the ‘.insn’ pseudo directive the assembler recognizes some of the formats. Typically, the most general variant of the instruction format is used by the ‘.insn’ directive.

The following table lists the abbreviations used in the table of instruction formats:

opcode
Unsigned immediate or opcode name for 7-bits opcode.
opcode2
Unsigned immediate or opcode name for 2-bits opcode.
func7
Unsigned immediate for 7-bits function code.
func6
Unsigned immediate for 6-bits function code.
func4
Unsigned immediate for 4-bits function code.
func3
Unsigned immediate for 3-bits function code.
func2
Unsigned immediate for 2-bits function code.
rd
Destination register number for operand x, can be GPR or FPR.
rd’
Destination register number for operand x,
only accept s0-s1, a0-a5, fs0-fs1 and fa0-fa5.
rs1
First source register number for operand x, can be GPR or FPR.
rs1’
First source register number for operand x,
only accept s0-s1, a0-a5, fs0-fs1 and fa0-fa5.
rs2
Second source register number for operand x, can be GPR or FPR.
rs2’
Second source register number for operand x,
only accept s0-s1, a0-a5, fs0-fs1 and fa0-fa5.
simm12
Sign-extended 12-bit immediate for operand x.
simm20
Sign-extended 20-bit immediate for operand x.
simm6
Sign-extended 6-bit immediate for operand x.
uimm5
Unsigned 5-bit immediate for operand x.
uimm6
Unsigned 6-bit immediate for operand x.
uimm8
Unsigned 8-bit immediate for operand x.
symbol
Symbol or lable reference for operand x.
The following table lists all available opcode name:

C0
C1
C2
Opcode space for compressed instructions.

LOAD
Opcode space for load instructions.

LOAD_FP
Opcode space for floating-point load instructions.

STORE
Opcode space for store instructions.

STORE_FP
Opcode space for floating-point store instructions.

AUIPC
Opcode space for auipc instruction.

LUI
Opcode space for lui instruction.

BRANCH
Opcode space for branch instructions.

JAL
Opcode space for jal instruction.

JALR
Opcode space for jalr instruction.

OP
Opcode space for ALU instructions.

OP_32
Opcode space for 32-bits ALU instructions.

OP_IMM
Opcode space for ALU with immediate instructions.

OP_IMM_32
Opcode space for 32-bits ALU with immediate instructions.

OP_FP
Opcode space for floating-point operation instructions.

MADD
Opcode space for madd instruction.

MSUB
Opcode space for msub instruction.

NMADD
Opcode space for nmadd instruction.

NMSUB
Opcode space for msub instruction.

AMO
Opcode space for atomic memory operation instructions.

MISC_MEM
Opcode space for misc instructions.

SYSTEM
Opcode space for system instructions.

CUSTOM_0
CUSTOM_1
CUSTOM_2
CUSTOM_3
Opcode space for customize instructions.

An instruction is two or four bytes in length and must be aligned on a 2 byte boundary. The first two bits of the instruction specify the length of the instruction, 00, 01 and 10 indicates a two byte instruction, 11 indicates a four byte instruction.

The following table lists the RISC-V instruction formats that are available with the ‘.insn’ pseudo directive:

R type: .insn r opcode6, func3, func7, rd, rs1, rs2
±------±----±----±------±—±--------+
| func7 | rs2 | rs1 | func3 | rd | opcode6 |
±------±----±----±------±—±--------+
31 25 20 15 12 7 0
R type with 4 register operands: .insn r opcode6, func3, func2, rd, rs1, rs2, rs3
R4 type: .insn r4 opcode6, func3, func2, rd, rs1, rs2, rs3
±----±------±----±----±------±—±--------+
| rs3 | func2 | rs2 | rs1 | func3 | rd | opcode6 |
±----±------±----±----±------±—±--------+
31 27 25 20 15 12 7 0
I type: .insn i opcode6, func3, rd, rs1, simm12
I type: .insn i opcode6, func3, rd, simm12(rs1)
±-------------±----±------±—±--------+
| simm12[11:0] | rs1 | func3 | rd | opcode6 |
±-------------±----±------±—±--------+
31 20 15 12 7 0
S type: .insn s opcode6, func3, rs2, simm12(rs1)
±-------------±----±----±------±------------±--------+
| simm12[11:5] | rs2 | rs1 | func3 | simm12[4:0] | opcode6 |
±-------------±----±----±------±------------±--------+
31 25 20 15 12 7 0
B type: .insn s opcode6, func3, rs1, rs2, symbol
SB type: .insn sb opcode6, func3, rs1, rs2, symbol
±----------------±----±----±------±---------------±--------+
| simm12[12|10:5] | rs2 | rs1 | func3 | simm12[4:1|11] | opcode6 |
±----------------±----±----±------±---------------±--------+
31 25 20 15 12 7 0
U type: .insn u opcode6, rd, simm20
±-------------------------±—±--------+
| simm20[20|10:1|11|19:12] | rd | opcode6 |
±-------------------------±—±--------+
31 12 7 0
J type: .insn j opcode6, rd, symbol
UJ type: .insn uj opcode6, rd, symbol
±-----------±-------------±-----------±--------------±—±--------+
| simm20[20] | simm20[10:1] | simm20[11] | simm20[19:12] | rd | opcode6 |
±-----------±-------------±-----------±--------------±—±--------+
31 30 21 20 12 7 0
CR type: .insn cr opcode2, func4, rd, rs2
±------±-------±----±--------+
| func4 | rd/rs1 | rs2 | opcode2 |
±------±-------±----±--------+
15 12 7 2 0
CI type: .insn ci opcode2, func3, rd, simm6
±------±---------±-------±-----------±--------+
| func3 | simm6[5] | rd/rs1 | simm6[4:0] | opcode2 |
±------±---------±-------±-----------±--------+
15 13 12 7 2 0
CIW type: .insn ciw opcode2, func3, rd’, uimm8
±------±-----------±----±--------+
| func3 | uimm8[7:0] | rd’ | opcode2 |
±------±------- —±----±--------+
15 13 5 2 0
CSS type: .insn css opcode2, func3, rd, uimm6
±------±-----------±—±--------+
| func3 | uimm6[5:0] | rd | opcode2 |
±------±-----------±—±--------+
15 13 7 2 0
CL type: .insn cl opcode2, func3, rd’, uimm5(rs1’)
±------±-----------±-----±-----------±-----±--------+
| func3 | uimm5[4:2] | rs1’ | uimm5[1:0] | rd’ | opcode2 |
±------±-----------±-----±-----------±-----±--------+
15 13 10 7 5 2 0
CS type: .insn cs opcode2, func3, rs2’, uimm5(rs1’)
±------±-----------±-----±-----------±-----±--------+
| func3 | uimm5[4:2] | rs1’ | uimm5[1:0] | rs2’ | opcode2 |
±------±-----------±-----±-----------±-----±--------+
15 13 10 7 5 2 0
CA type: .insn ca opcode2, func6, func2, rd’, rs2’
±- ----±---------±------±-----±--------+
| func6 | rd’/rs1’ | func2 | rs2’ | opcode2 |
±------±---------±------±-----±--------+
15 10 7 5 2 0
CB type: .insn cb opcode2, func3, rs1’, symbol
±------±-------------±-----±-----------------±--------+
| func3 | simm8[8|4:3] | rs1’ | simm8[7:6|2:1|5] | opcode2 |
±------±-------------±-----±-----------------±--------+
15 13 10 7 2 0
CJ type: .insn cj opcode2, symbol
±------±------------------------------±--------+
| func3 | simm11[11|4|9:8|10|6|7|3:1|5] | opcode2 |
±------±------------------------------±--------+
15 13 2 0
For the complete list of all instruction format variants see The RISC-V Instruction Set Manual Volume I: User-Level ISA.


http://www.ppmy.cn/news/19675.html

相关文章

建模杂谈系列199 APIFunc Task

说明 春节这段时间就完全没干活,偶尔空下来会想一想要做的事。过去的想法和实验都比较分散,现在正是要慢慢的聚拢,归类,各司其职。 内容 1 楔子 如果把要做的事浓缩成一句话,那么就是:通过构建一套数据存储、处理的系统,提供强大的决策支持,产生巨大的经济效益。 …

代码随想录算法训练营Day48动态规划:198.打家劫舍,213.打家劫舍||,337.打家劫舍|||

打家劫舍是dp解决的经典问题 198.打家劫舍 文章链接:代码随想录 (programmercarl.com) 思路:自己的思路是,将数组重新划分为两个数组,分别对两个数组进行01背包计算最大收益,然后比较两个收益,取两者中的…

量化选股——基于多因子模型的量化策略(第1部分—因子测算策略构建)

文章目录1.多因子模型概述2.因子挖掘3.多因子策略4.多因子策略构建基于多因子的策略通用流程Fama-French三因子因子效果测算方法因子测算结论&量化策略构建东西有点多,拆开成多个文章,边写边整合~,应该会分成2部分: 第1部分—…

spring boot前后端交互之数据格式转换

在前后端分离开发的项目种,前端获取数据的方式基本都是通过Ajax。请求方法也有所不同,常见的有POST,GET,PUT,DELETE等。甚至连请求的数据类型都不一样,x-www-form-urlencodeed,form-data,json等。 那么在前后端交互过程中,具体的数据该如何接…

申请Moonbeam Accelerator孵化计划申请答题指导

Moonbeam Accelerator是一个为期10 周的孵化计划,由Moonbeam基金会、Arrington Capital和Rokk3r共同推出,旨在帮助初创团队提高技术、业务、营销、金融和融资技能,助力您的Web3创业之梦。 申请孵化计划有任何限制吗?没有&#xff…

二、Java框架之Spring注解开发

文章目录1. IOC/DI注解开发1.1 Component注解ComponentController Service Repository1.2 纯注解开发模式1.3 注解开发bean管理ScopePostConstruct PreDestroy1.4 注解开发依赖注入Autowired QualifierValuePropertySource1.5 第三方bean管理Beanimport(多个Config类…

Coolify系列02-从0到1超详细手把手教你上手Coolify

重启 如果由于某种原因,你的实例崩溃了,你可以用下面的命令重新启动它: wget -q https://get.coollabs.io/coolify/install.sh \ -O install.sh; sudo bash ./install.sh -r防火墙设置 您需要在防火墙中允许以下端口 Coolify: 3000 (required)Revers…

【HBase入门】8. HBase Java编程(2)——创建表、插入数据、删除数据

前言 本文是HBase Java编程(2)——创建表、插入数据、删除数据。 需求一:使用Java代码创建表 创建一个名为WATER_BILL的表,包含一个列蔟C1。 实现步骤: 1.判断表是否存在——存在,则退出 2.使用TableDe…