RV64I是RV32I的超集,RV32I是RV64I的子集。RV64I包括RV32I的所有40条指令,另外增加了12条RV32I中没有的指令,还有三条移位指令(slli, srli,srai)也进行小小的改动。

在RV64I中,整数寄存器是64位的,即xlen=64,所以每条指令中的寄存器都是64位运算,立即数符号位扩展也是到64位。

下面介绍一下RV64I中新增的指令,对于同一条指令在RV64I和RV32I中,操作的不同,会在RV32I指令集的介绍中给出备注。

ld

ld rd, offset(rs1)     //x[rd] = M[x[rs1] + sext(offset)][63:0]
双字加载 (Load Doubleword). I-type, RV64I.
从地址 x[rs1] + sign-extend(offset)读取八个字节,写入 x[rd]。
压缩形式: c.ldsp rd, offset; c.ld rd, offset(rs1)

    imm                          
    11 10 9 8 7 6 5 4 3 2 1 0 rs1 func3 rd opcode
name type 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
ld I                                   0 1 1           0 0 0 0 0 1 1

例子:

0000000000000000 <.text>:
    0:    00513503              ld    x10,5(x2)
    4:    fec1b283              ld    x5,-20(x3)

lwu

lwu rd, offset(rs1)    //x[rd] = M[x[rs1] + sext(offset)][31:0]
无符号字加载 (Load Word, Unsigned). I-type, RV64I.
从地址 x[rs1] + sign-extend(offset)读取四个字节,零扩展后写入 x[rd]。

    imm                          
    11 10 9 8 7 6 5 4 3 2 1 0 rs1 func3 rd opcode
name type 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
lwu I                                   1 1 0           0 0 0 0 0 1 1

例子:

0:    00516503              lwu    x10,5(x2)

4:    fec1e283              lwu    x5,-20(x3)

sd

sd rs2, offset(rs1)    //M[x[rs1] + sext(offset) ]=
x[rs2][63: 0]
存双字(Store
D
oubleword).
S-type, RV64I.

x[rs2]中的
8 字节存入内存地址 x[rs1]+sign-extend(offset)。
压缩形式: c.sdsp rs2,
offset; c.sd
rs2,
offset(rs1)

    imm         imm                
    11 10 9 8 7 6 5 rs2 rs1 func3 4 3 2 1 0 opcode
name type 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
sd S                                   0 1 1           0 1 0 0 0 1 1

例子:

0:    00a132a3              sd    x10,5(x2)

4:    fe51b623              sd    x5,-20(x3)

addiw

addiw rd, rs1, immediate    //x[rd] = sext((x[rs1] +
sext(immediate))[31:0])
加立即数字(Add Word Immediate). I-type, RV64I.
把符号位扩展的立即数加到 x[rs1],将结果截断为
32 位,把符号位扩展的结果写入 x[rd]。忽略算术溢出。
压缩形式:
c.addiw
rd,
imm

    imm                          
    11 10 9 8 7 6 5 4 3 2 1 0 rs1 func3 rd opcode
name type 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
addiw I                                   0 0 0           0 0 1 1 0 1 1

例子:

0:    0142851b              addiw    x10,x5,20

4:    fec2851b              addiw    x10,x5,-20

slliw

slliw rd, rs1, shamt    //x[rd] = sext((x[rs1] ≪
shamt)[31: 0])
立即数逻辑左移字(Shift
L
eft Logical Word Immediate).
I-type, RV64I.
把寄存器
x[rs1]左移
shamt 位,空出的位置填入 0,结果截为
32 位,进行有符号扩展后写入x[rd]。仅当 shamt[5]=0
时,指令才是有效的。

                shamt                          
                5 4 3 2 1 0 rs1 func3 rd opcode
name type 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
slliw I 0 0 0 0 0 0                       0 0 1           0 0 1 1 0 1 1

例子:

0:    0064951b              slliw    x10,x9,0x6

4:    0024951b              slliw    x10,x9,0x2

srliw

srliw rd, rs1, shamt     //x[rd] = sext(x[rs1][31: 0] ≫u shamt)

立即数逻辑右移字(Shift Right Logical Word Immediate). I-type, RV64I.

把寄存器 x[rs1]右移 shamt 位,空出的位置填入 0,结果截为 32 位,进行有符号扩展后写入x[rd]。仅当 shamt[5]=0 时,指令才是有效的。

                shamt                          
                5 4 3 2 1 0 rs1 func3 rd opcode
name type 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
srliw I 0 0 0 0 0 0                       1 0 1           0 0 1 1 0 1 1

例子:

0:    0064d51b              srliw    x10,x9,0x6

4:    0024d51b              srliw    x10,x9,0x2

sraiw

sraiw rd, rs1, shamt    //x[rd] = sext(x[rs1][31: 0] ≫s shamt)

立即数算术右移字(Shift Right Arithmetic Word Immediate). I-type, RV64I.

把寄存器 x[rs1]的低 32 位右移 shamt 位,空位用 x[rs1][31]填充,结果进行有符号扩展后写入 x[rd]。仅当 shamt[5]=0 时指令有效。

压缩形式: c.srai rd, shamt

                shamt                          
                5 4 3 2 1 0 rs1 func3 rd opcode
name type 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
sraiw I 0 1 0 0 0 0                       1 0 1           0 0 1 1 0 1 1

例子:

0:    4064d51b              sraiw    x10,x9,0x6

4:    4024d51b              sraiw    x10,x9,0x2

addw

addw rd, rs1, rs2   //x[rd] = sext((x[rs1] + x[rs2])[31:0])
加字(Add Word). R-type, RV64I.
把寄存器 x[rs2]加到寄存器 x[rs1]上,将结果截断为 32 位,把符号位扩展的结果写入 x[rd]。忽略算术溢出。
压缩形式: c.addw rd, rs2

                               
    func7 rs2 rs1 func3 rd opcode
name type 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
addw R 0 0 0 0 0 0 0                     0 0 0           0 1 1 1 0 1 1

例子:

0:    0034853b              addw    x10,x9,x3

subw

subw rd, rs1, rs2   //x[rd] = sext((x[rs1] - x[rs2])[31: 0])
减去字(Substract Word). R-type, RV64I.
x[rs1]减去 x[rs2],结果截为 32 位,有符号扩展后写入 x[rd]。忽略算术溢出。
压缩形式: c.subw rd, rs2

                               
    func7 rs2 rs1 func3 rd opcode
name type 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
subw R 0 1 0 0 0 0 0                     0 0 0           0 1 1 1 0 1 1

例子:

4:    4034853b              subw    x10,x9,x3
 

sllw

sllw rd, rs1, rs2     //x[rd] = sext((x[rs1] ≪ x[rs2][4: 0])[31: 0])
逻辑左移字(Shift Left Logical Word). R-type, RV64I.
把寄存器 x[rs1]的低 32 位左移 x[rs2]位,空出的位置填入 0,结果进行有符号扩展后写入x[rd]。 x[rs2]的低 5 位代表移动位数,其高位则被忽略。

                               
    func7 rs2 rs1 func3 rd opcode
name type 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
sllw R 0 0 0 0 0 0 0                     0 0 1           0 1 1 1 0 1 1

例子:

8:    0034953b              sllw    x10,x9,x3
 

srlw

srlw rd, rs1, rs2     //x[rd] = sext(x[rs1][31: 0] ≫u x[rs2][4: 0])

逻辑右移字(Shift Right Logical Word). R-type, RV64I.

把寄存器 x[rs1]的低 32 位右移 x[rs2]位,空出的位置填入 0,结果进行有符号扩展后写入x[rd]。 x[rs2]的低 5 位代表移动位数,其高位则被忽略。

                               
    func7 rs2 rs1 func3 rd opcode
name type 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
srlw R 0 0 0 0 0 0 0                     1 0 1           0 1 1 1 0 1 1

例子:

c:    0034d53b              srlw    x10,x9,x3
 

sraw

sraw rd, rs1, rs2     //x[rd] = sext(x[rs1][31: 0] ≫s x[rs2][4: 0])

算术右移字(Shift Right Arithmetic Word). R-type, RV64I only.

把寄存器 x[rs1]的低 32 位右移 x[rs2]位,空位用 x[rs1][31]填充,结果进行有符号扩展后写
入 x[rd]。 x[rs2]的低 5 位为移动位数,高位则被忽略。

                               
    func7 rs2 rs1 func3 rd opcode
name type 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
sraw R 0 1 0 1 0 0 0                     1 0 1           0 1 1 1 0 1 1

例子:

10:    4034d53b              sraw    x10,x9,x3

RV64I基础整数指令集的更多相关文章

  1. RV32I基础整数指令集

    RV32I是32位基础整数指令集,它支持32位寻址空间,支持字节地址访问,仅支持小端格式(little-endian,高地址高位,低地址地位),寄存器也是32位整数寄存器.RV32I指令集的目的是尽量 ...

  2. [shell基础]——整数比较;字符串比较;文件测试;逻辑测试符

    整数比较方法一:[  ] 或 [[  ]]   (1) 此方法需要使用整数比较运算符.[标注:equal 等于   greater 大于   less-then 小于] (2) 使用时一定要注意前后一 ...

  3. java 基础 整数类型

    1.Java有四种整数类型:byte.short.int和long. 2.Java默认整数计算的结果是int类型. 3.整数的字面量是int类型. 4.若字面量超过int类型的最大值,则字面量是lon ...

  4. Risc-V指令集

    https://riscv.org/specifications/ Risc-V文档包括:用户层指令集文档和特权架构文档,下面这两个文件的官网链接. User-Level ISA Specificat ...

  5. RVZicsr指令集

    Riscv中每个硬件线程(hart)有4096个独立地址空间的状态寄存器.我们可以通过Zicsr指令读写csr寄存器.总共有6条csr读写指令,这些指令之前都在RV32I/RV64I基础指令集里面,在 ...

  6. RV32I指令集

    RV32I是最基本的32位Base指令集,它支持32位寻址空间,支持字节地址访问,仅支持小端格式(little-endian,高地址高位,低地址地位),寄存器也是32位整数寄存器.RV32I指令集的目 ...

  7. RISC-V指令集的诞生,"V"也表示变化(variation)和向量(vectors)

    RISC-V登场,Intel和ARM会怕吗? 张竞扬 摩尔精英 摩尔精英.创始人兼CEO 82 人赞了该文章 在2015年12月的Nature网站上,由U.C. Berkeley等几个大学的研究人员主 ...

  8. Risc-V简要概括

    1.Risc-V硬件平台术语 一个RiscV硬件平台可以包含一个或多个RiscV兼容的核心.其它非RiscV兼容的核心.固定功能的加速器.各种物理存储器结构.I/O设备以及允许这些部件相互连通的互联结 ...

  9. CPU GPU设计工作原理《转》

    我知道这非常长,可是,我坚持看完了.希望有幸看到这文章并对图形方面有兴趣的朋友,也能坚持看完.一定大有收获.毕竟知道它们究竟是怎么"私下勾搭"的.会有利于我们用程序来指挥它们... ...

随机推荐

  1. Plugin org.apache.maven.plugins:maven-resources-plugin:2.6

    创建maven project时工程报错Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its depende ...

  2. xposed 原理分析

    1.添加hook方法 首先是init进程打开 app_process,然后进入XposedInit.java main() - > initForZygote() 加入对ActivityThre ...

  3. template might not exist or might not be accessible by any of the configured Template Resolvers at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:869)

    org.thymeleaf.exceptions.TemplateInputException: Error resolving template [code/leading], template m ...

  4. httpd虚拟主机起不来!!

    前几天在公司,练习负载均衡配置.在配置虚拟主机的web服务(apache) ,创建好虚拟主机的配置文件 ss -tnl  查看监控端口80已起来,通过本地浏览器访问一直显示默认的欢迎页... 一个下午 ...

  5. Jmeter请求

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web=& ...

  6. optimizer.zero_grad()

    # zero the parameter gradients optimizer.zero_grad() # forward + backward + optimize outputs = net(i ...

  7. 【转】阿里云部署java web项目

    主要步骤:1. 购买阿里云服务器2. 远程连接3. 在云服务器上配javaweb环境:jdk,tomcat,MySQL4. 将项目的war文件放到Tomcat下关于云服务器ECS:如果还想在买服务器之 ...

  8. Token认证,如何快速方便获取用户信息

    背景 我们有一个Web项目,这个项目提供了很多的Rest API.也做了权限控制,访问API的请求必须要带上事先认证后获取的Token才可以. 认证的话就在Filter中进行的,会获取请求的Token ...

  9. 传统码头建设企业:Azure DevOps Server 流水线技术沟通

    受某码头建设企业的邀请,与企业软件研发团队就如何利用Azure DevOps Server进行了沟通.结合企业当前技术框架和管理流程,探索利用微软Azure DevOps Server的技术能力,加强 ...

  10. windows xp 安装后不能能ping,浏览器不能上网

    windows xp MSDN版本 下载地址: ed2k://|file|zh-hans_windows_xp_home_with_service_pack_3_x86_cd_x14-92408.is ...