RISCV -3 RV32I/RV64I基本整型指令集

RISCV -3 RV32I/RV64I基本整型指令集

  • 1 RV32I Base Integer Instruction Set
    • 1.1 Programmers’ Model for Base Integer ISA
    • 1.2 Base Instruction Formats
    • 1.3 Immediate Encoding Variants
    • 1.4 Integer Computational Instructions
      • 1.4.1 Integer Register-Immediate Instructions
      • 1.4.2 Integer Register-Register Operations
      • 1.4.3 NOP Instruction
    • 1.5 Control Transfer Instructions
      • 1.5.1 Unconditional Jumps
      • 1.5.2 Conditional Branches
    • 1.6 Load and Store Instructions
    • 1.7 Memory Ordering Instructions
    • 1.8 Environment Call and Breakpoints
    • 1.9 HINT Instructions
  • 2 RV64I Base Integer Instruction Set
    • 2.1 Register State
    • 2.2 Integer Computational Instructions
      • 2.2.1 Integer Register-Immediate Instructions
      • 2.2.2 Integer Register-Register Operations
    • 2.3 Load and Store Instructions
    • 2.4 HINT Instructions
  • 参考文档

RISCV - 1 RV32/64G指令集清单
RISCV - 2 “Zicsr“, CSR Instructions

1 RV32I Base Integer Instruction Set

1.1 Programmers’ Model for Base Integer ISA

Figure 2.1 shows the unprivileged state for the base integer ISA. For RV32I, the 32 x registers are each 32 bits wide, i.e., XLEN=32. Register x0 is hardwired with all bits equal to 0. General purpose registers x1–x31 hold values that various instructions interpret as a collection of Boolean values, or as two’s complement signed binary integers or unsigned binary integers.
图 2.1 显示了基本整数 ISA 的非特权状态。对于 RV32I,32 个 x 寄存器每个都是 32 位宽,即 XLEN=32。通用寄存器 x1-x31 保存的值被各种指令解释为布尔值集合、有符号二进制整数或无符号二进制整数。
There is one additional unprivileged register: the program counter pc holds the address of the current instruction.
还有一个非特权寄存器:程序计数器 pc,用于保存当前指令的地址。
在这里插入图片描述
RC32I的寄存器功能分类:
There is no dedicated stack pointer or subroutine return address link register in the Base Integer ISA; the instruction encoding allows any x register to be used for these purposes. However, the standard software calling convention uses register x1 to hold the return address for a call, with register x5 available as an alternate link register. The standard calling convention uses register x2 as the stack pointer.
在基本整数 ISA 中,没有专用的堆栈指针或子程序返回地址链接寄存器;指令编码允许将任何 x 寄存器用于这些目的。不过,标准软件调用习惯使用寄存器 x1 保存调用的返回地址,寄存器 x5 可作为备用链接寄存器。标准调用习惯使用寄存器 x2 作为堆栈指针。
Hardware might choose to accelerate function calls and returns that use x1 or x5.
硬件可能会加速函数调用和返回选择使用 x1 或 x5 。
The optional compressed 16-bit instruction format is designed around the assumption that x1 is the return address register and x2 is the stack pointer. Software using other conventions will operate correctly but may have greater code size.
可选的压缩 16 位指令格式是根据 x1 是返回地址寄存器、x2 是堆栈指针的假设设计的。使用其他约定的软件也能正常运行,但代码量可能较大。
在这里插入图片描述

1.2 Base Instruction Formats

In the base RV32I ISA, there are four core instruction formats (R/I/S/U), as shown in Figure 2.2. All are a fixed 32 bits in length and must be aligned on a four-byte boundary in memory. An instruction-address-misaligned exception is generated on a taken branch or unconditional jump if the target address is not four-byte aligned. This exception is reported on the branch or jump instruction, not on the target instruction. No instruction-address-misaligned exception is generated for a conditional branch that is not taken.
在基本 RV32I ISA 中,有四种核心指令格式(R/I/S/U),如图 2.2 所示。所有指令的长度都是固定的 32 位,并且必须在内存的四字节边界上对齐。如果目标地址未按四字节对齐,则在执行分支或无条件跳转时会产生指令地址不对齐异常。报告异常的是分支或跳转指令,而不是目标指令。未执行的有条件分支不会产生指令地址对齐异常。
在这里插入图片描述
Figure 2.2: RISC-V base instruction formats. Each immediate subfield is labeled with the bit position (imm[x ]) in the immediate value being produced, rather than the bit position within the instruction’s immediate field as is usually done.
图 2.2: RISC-V 基本指令格式。每个立即数子字段都标有正在产生的立即数的位位置(imm[x ]),而不是通常指令立即字段中的位位置。

1.3 Immediate Encoding Variants

There are a further two variants of the instruction formats (B/J) based on the handling of immediates, as shown in Figure 2.3.
如图 2.3 所示,指令格式 (B/J) 还有两种基于立即数处理的变体。
在这里插入图片描述
Figure 2.4 shows the immediates produced by each of the base instruction formats, and is labeled to show which instruction bit (inst[y ]) produces each bit of the immediate value.
图 2.4 显示了每种基本指令格式产生的立即值,并标注了产生立即数每一位的指令位(inst[y ])。
在这里插入图片描述

1.4 Integer Computational Instructions

Most integer computational instructions operate on XLEN bits of values held in the integer register file. Integer computational instructions are either encoded as register-immediate operations using the I-type format or as register-register operations using the R-type format. The destination is register rd for both register-immediate and register-register instructions. No integer computational instructions cause arithmetic exceptions.
大多数整数计算指令对整数寄存器文件中的 XLEN 位值进行操作。整数运算指令要么使用 I 型格式编码为寄存器-立即数操作,要么使用 R 型格式编码为寄存器-寄存器操作。无论是立即数-寄存器指令还是寄存器-寄存器指令,其目标寄存器都是寄存器 rd。整数运算指令不会导致算术异常。

1.4.1 Integer Register-Immediate Instructions

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

1.4.2 Integer Register-Register Operations

在这里插入图片描述

1.4.3 NOP Instruction

The NOP instruction does not change any architecturally visible state, except for advancing the pc and incrementing any applicable performance counters. NOP is encoded as ADDI x0, x0, 0.
除了推进 pc 和递增任何适用的性能计数器外,NOP 指令不会改变任何架构上可见的状态。NOP 编码为 ADDI x0, x0, 0。
在这里插入图片描述

1.5 Control Transfer Instructions

RV32I provides two types of control transfer instructions: unconditional jumps and conditional branches. Control transfer instructions in RV32I do not have architecturally visible delay slots.
RV32I 提供两种控制转移指令:无条件跳转和有条件分支。RV32I 中的控制转移指令没有架构上可见的延迟槽。

1.5.1 Unconditional Jumps

在这里插入图片描述
在这里插入图片描述

1.5.2 Conditional Branches

在这里插入图片描述

1.6 Load and Store Instructions

RV32I is a load-store architecture, where only load and store instructions access memory and arithmetic instructions only operate on CPU registers. RV32I provides a 32-bit address space that is byte-addressed. The EEI will define what portions of the address space are legal to access with which instructions (e.g., some addresses might be read only, or support word access only). Loads with a destination of x0 must still raise any exceptions and cause any other side effects even though the load value is discarded.
RV32I 是一种加载-存储架构,只有加载和存储指令才能访问内存,算术指令只能在 CPU 寄存器上运行。RV32I 提供字节寻址的 32 位地址空间。EEI 将定义地址空间的哪些部分可以用哪些指令合法访问(例如,某些地址可能只允许读取,或只支持字访问)。目标地址为 x0 的加载,即使加载值被丢弃,仍必须引发任何异常并导致任何其他副作用。
The EEI will define whether the memory system is little-endian or big-endian. In RISC-V, endianness is byte-address invariant.
EEI 将定义内存系统是小端(little-endian)还是大端(big-endian)。在 RISC-V 中,字节地址不变。
在这里插入图片描述
Load and store instructions transfer a value between the registers and memory. Loads are encoded in the I-type format and stores are S-type. The effective address is obtained by adding register rs1 to the sign-extended 12-bit offset. Loads copy a value from memory to register rd. Stores copy the value in register rs2 to memory.
加载和存储指令在寄存器和内存之间传输数值。加载采用 I 型编码格式,存储采用 S 型编码格式。有效地址由寄存器 rs1 加上符号扩展后的 12 位偏移获得。加载将内存中的值复制到寄存器 rd 中。存储时将寄存器 rs2 中的值复制到内存中。

1.7 Memory Ordering Instructions

在这里插入图片描述

1.8 Environment Call and Breakpoints

在这里插入图片描述
These two instructions cause a precise requested trap to the supporting execution environment.
这两条指令会向支持执行环境发出一个精确请求陷阱。
The ECALL instruction is used to make a service request to the execution environment. The EEI will define how parameters for the service request are passed, but usually these will be in defined locations in the integer register file.
ECALL 指令用于向执行环境发出服务请求。EEI 将定义如何传递服务请求的参数,但通常这些参数将放在整数寄存器文件中定义的位置。
The EBREAK instruction is used to return control to a debugging environment.
EBREAK 指令用于将控制返回调试环境。
ECALL and EBREAK were previously named SCALL and SBREAK. The instructions have the same functionality and encoding, but were renamed to reflect that they can be used more generally than to call a supervisor-level operating system or debugger.
ECALL 和 EBREAK 以前的名称是 SCALL 和 SBREAK。这两条指令具有相同的功能和编码,但重新命名是为了反映它们的用途比调用监督级操作系统或调试器更广泛。

1.9 HINT Instructions

RV32I reserves a large encoding space for HINT instructions, which are usually used to communicate performance hints to the microarchitecture. HINTs are encoded as integer computational instructions with rd=x0. Hence, like the NOP instruction, HINTs do not change any architecturally visible state, except for advancing the pc and any applicable performance counters. Implementations are always allowed to ignore the encoded hints.
RV32I 为 HINT 指令保留了较大的编码空间,通常用于向微体系结构传达性能提示。HINT 被编码为 rd=x0 的整数计算指令。因此,与 NOP 指令一样,除了推进 pc 和任何适用的性能计数器外,HINT 不会改变任何架构上可见的状态。在任何情况下,都允许执行程序忽略已编码的提示。

Table 2.3 lists all RV32I HINT code points. 91% of the HINT space is reserved for standard HINTs, but none are presently defined. The remainder of the HINT space is reserved for custom HINTs: no standard HINTs will ever be defined in this subspace.
表 2.3 列出了所有 RV32I HINT 代码点。91% 的 HINT 空间是为标准 HINT 保留的,但目前尚未定义任何标准 HINT。HINT 空间的其余部分保留给自定义 HINT:该子空间将不会定义任何标准 HINT。
在这里插入图片描述

2 RV64I Base Integer Instruction Set

2.1 Register State

RV64I widens the integer registers and supported user address space to 64 bits (XLEN=64).
RV64I 将整数寄存器和支持的用户地址空间扩展到 64 位(XLEN=64)。
在这里插入图片描述
RV64I寄存器功能分类:
在这里插入图片描述

2.2 Integer Computational Instructions

Most integer computational instructions operate on XLEN-bit values. Additional instruction variants are provided to manipulate 32-bit values in RV64I, indicated by a ‘W’ suffix to the opcode.
大多数整数计算指令都在 XLEN 位数值上运行。在 RV64I 中,还提供了其他指令变体来操作 32 位数值,操作码后缀为 “W”。
These “*W” instructions ignore the upper 32 bits of their inputs and always produce 32-bit signed values, i.e. bits XLEN-1 through 31 are equal.
这些 "*W "指令忽略其输入的高 32 位,始终产生 32 位有符号数值,即 XLEN-1 至 31 位相等。

2.2.1 Integer Register-Immediate Instructions

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

2.2.2 Integer Register-Register Operations

在这里插入图片描述

2.3 Load and Store Instructions

RV64I extends the address space to 64 bits. The execution environment will define what portions of the address space are legal to access.
RV64I 将地址空间扩展到 64 位。执行环境将确定地址空间的哪些部分可以合法访问。
在这里插入图片描述
The LD instruction loads a 64-bit value from memory into register rd for RV64I.
LD 指令将内存中的 64 位值加载到 RV64I 的寄存器 rd 中。
The LW instruction loads a 32-bit value from memory and sign-extends this to 64 bits before storing it in register rd for RV64I. The LWU instruction, on the other hand, zero-extends the 32-bit value from memory for RV64I. LH and LHU are defined analogously for 16-bit values, as are LB and LBU for 8-bit values. The SD, SW, SH, and SB instructions store 64-bit, 32-bit, 16-bit, and 8-bit values from the low bits of register rs2 to memory respectively.
LW 指令从内存中加载一个 32 位值,并将其符号扩展到 64 位,然后将其存储到 RV64I 的寄存器 rd 中。而 LWU 指令则是将内存中的 32 位值零扩展到 RV64I。对于 16 位数值,LH 和 LHU 的定义类似;对于 8 位数值,LB 和 LBU 的定义类似。SD、SW、SH 和 SB 指令分别将寄存器 rs2 低位的 64 位、32 位、16 位和 8 位数值存储到内存中。

2.4 HINT Instructions

All instructions that are microarchitectural HINTs in RV32I (see Section 2.9) are also HINTs in RV64I. The additional computational instructions in RV64I expand both the standard and custom HINT encoding spaces.
所有在 RV32I 中属于微架构 HINT 的指令(参见第 2.9 节)在 RV64I 中也属于 HINT。RV64I 中的附加计算指令扩展了标准和自定义 HINT 编码空间。
Table 5.1 lists all RV64I HINT code points. 91% of the HINT space is reserved for standard HINTs, but none are presently defined. The remainder of the HINT space is reserved for custom HINTs: no standard HINTs will ever be defined in this subspace.
表 5.1 列出了所有 RV64I HINT 代码点。91% 的 HINT 空间是为标准 HINT 保留的,但目前尚未定义任何标准 HINT。其余的 HINT 空间是为自定义 HINT 保留的:该子空间将不会定义任何标准 HINT。
在这里插入图片描述

参考文档

《The RISC-V Instruction Set Manual Volume I: Unprivileged ISA》

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/44599.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

深入浅出多种开发语言对接淘宝京东1688阿里巴巴等电商平台,获取实时商品详情数据API接口介绍

api接口详解大全?优秀的设计是产品变得卓越的原因设计API意味着提供有效的接口,可以帮助API使用者更好地了解、使用和集成,同时帮助人们有效地维护它每个产品都需要使用手册,API也不例外在API领域,可以将设计视为服务器和客户端之…

iPortal 注册登录模块扩展开发

作者:yx 文章目录 前言一、示例代码简介二、对接 iPortal REST API 接口2.1、登录模块扩展开发2.2、注册模块扩展开发 三、页面内容及样式实现四、配置启用定制页面 前言 针对注册登录模块,iPortal 允许用户通过 iFrame 方式接入自行开发的页面&#xf…

pytorch安装GPU版本 (Cuda12.1)教程: Windows、Mac和Linux系统快速安装指南

🌷🍁 博主 libin9iOak带您 Go to New World.✨🍁 🦄 个人主页——libin9iOak的博客🎐 🐳 《面试题大全》 文章图文并茂🦕生动形象🦖简单易学!欢迎大家来踩踩~&#x1f33…

语言尽头的奇幻旅程:如何求解最后一个单词的长度?

本篇博客会讲解力扣“58. 最后一个单词的长度”的解题思路,这是题目链接。 以示例2为例:s " fly me to the moon " 首先,找到字符串末尾的\0。s一开始指向首字符f,我们从这个位置开始,向后遍历&#xff0c…

基于高斯混合模型聚类的风电场短期功率预测方法(Pythonmatlab代码实现)

目录 💥1 概述 📚2 运行结果 2.1 Python 2.2 Matlab 🎉3 参考文献 🌈4 Matlab代码、数据、文章讲解 💥1 概述 文献来源: 摘要:对任意来流条件下的风电场发电功率进行准确预测,是提高电网对风电…

153、仿真-基于51单片机四相步进电机正反转控制系统设计(程序+Proteus仿真+参考论文+流程图+配套资料等)

毕设帮助、开题指导、技术解答(有偿)见文未 目录 一、设计功能 二、Proteus仿真图​ 三、程序源码 资料包括: 需要完整的资料可以点击下面的名片加下我,找我要资源压缩包的百度网盘下载地址及提取码。 方案选择 单片机的选择 方案一:ST…

vuejs源码之模版编译原理

之前我们说过虚拟dom,也就是虚拟dom拿到vnode后所做的事情,而模版编译是如何让虚拟dom拿到vnode。 模版编译的目标就是生成渲染函数,而渲染函数的作用是每次执行它,它就会使用当前最新的状态生成一份新的vnode,然后用…

ES6基础知识八:你是怎么理解ES6中Proxy的?使用场景?

一、介绍 定义: 用于定义基本操作的自定义行为 本质: 修改的是程序默认形为,就形同于在编程语言层面上做修改,属于元编程(meta programming) 元编程(Metaprogramming,又译超编程,是指某类计算…

.360勒索病毒解密方法|勒索病毒解决|勒索病毒恢复|数据库修复

引言: 近年来,随着互联网的普及和信息技术的快速发展,网络安全问题日益严峻。其中,勒索病毒成为网络安全领域的一大威胁。本文91数据恢复将重点介绍一种名为“.360勒索病毒”的恶意软件,并探讨被该病毒加密的数据文件…

quartus工具篇——PLL IP核的使用

quartus工具篇——PLL IP核的使用 1、PLL简介 PLL(Phase-Locked Loop,相位锁环)是FPGA中非常重要的时钟管理单元,其主要功能包括: 频率合成 - PLL可以生成比输入时钟频率高的时钟信号。频率分频 - PLL也可以输出分频后的较低频率时钟。减小时钟抖动 - PLL可以过滤输入时钟中…

踩坑 视觉SLAM 十四讲第二版 ch8 编译及运行问题

1.fmt相关 CMakeLists.txt中&#xff1a;在后面加上 fmt target_link_libraries(optical_flow ${OpenCV_LIBS} fmt ) target_link_libraries(direct_method ${OpenCV_LIBS} ${Pangolin_LIBRARIES} fmt )2.不存在用户定义的从 "std::_Bind<void (OpticalFlowTracker::…

架构重构实践心得

一、前言 大多数的技术研发都对重构有所了解&#xff0c;而每个研发又都有自己的理解。从代码重构到架构重构&#xff0c;我参与了携程大型全链路重构项目&#xff0c;积累了一点经验心得&#xff0c;在此抛砖引玉和大家分享。 二、重构的定义 重构是指在不改变外部行为的情…

改进的北方苍鹰算法优化VMD参数,最小包络熵、样本熵、信息熵、排列熵(适应度函数可自行选择,一键修改)包含MATLAB源代码...

今天给大家带来一期由改进的北方苍鹰算法(SCNGO)优化VMD的两个参数。 同样以西储大学数据集为例&#xff0c;选用105.mat中的X105_BA_time.mat数据中1000个数据点。没有数据的看这篇文章。西储大学轴承诊断数据处理&#xff0c;matlab免费代码获取 选取四种适应度函数进行优化&…

信息安全运维经验

1.备份系统 国外主流&#xff1a;veritas NetBackUp&#xff08;NBU&#xff09;、IBM&#xff08;TSM&#xff09; (191条消息) 【大数据-文摘笔记】Veritas NBU简介_weixin_30501857的博客-CSDN博客 虚拟机玩转 Veritas NetBackup&#xff08;NBU&#xff09;之服务端安装…

【云计算小知识】云环境是什么意思?有什么优点?

随着云计算的快速发展&#xff0c;了解云计算相关知识也是运维人员必备的。那你知道云环境是什么意思&#xff1f;有什么优点&#xff1f;云环境安全威胁有哪些&#xff1f;如何保证云环境的运维安全&#xff1f;这里我们就来简单聊聊。 云环境是什么意思&#xff1f; 云环境是…

水环境综合治理监测系统:筑牢城市水生态安全屏障

水是生命之源&#xff0c;是人类赖以生存的基础。然而&#xff0c;随着工业化、城市化的快速发展&#xff0c;水污染问题日益凸显&#xff0c;给居民的环境卫生以及用水安全带来了巨大的威胁。因此&#xff0c;加强水环境综合治理&#xff0c;保护水资源和维护生态平衡&#xf…

微信小程序导入微信地址

获取用户收货地址。调起用户编辑收货地址原生界面&#xff0c;并在编辑完成后返回用户选择的地址。 1&#xff1a;原生微信小程序接口使用API&#xff1a;wx.chooseAddress(OBJECT) wx.chooseAddress({success (res) {console.log(res.userName)console.log(res.postalCode)c…

一篇文章搞定《APP的启动流程》

一篇文章搞定《APP的启动流程》 前言冷启动、温启动、热启动启动中的重要成员简介zygote进程InstrumentationSystemServer进程ActivityManagerServiceBinderActivityThread 启动的步骤详解一、点击桌面图标二、创建进程三、初始化APP进程四、APP进程与System_server的绑定五、初…

【软件架构】企业架构4A定义

文章目录 前言战略、BA、DA、AA、TA五者的关系1、业务架构&#xff08;BA&#xff09;2、数据架构&#xff08;DA&#xff09;3、应用架构&#xff08;AA&#xff09;4、技术架构&#xff08;TA&#xff09;总结 前言 业务架构是跨系统的业务架构蓝图&#xff0c;应用架构、数…

【Nodejs】nodejs内置模块(中)

1.路劲处理模块 path 1.1 模块概览 在nodejs中&#xff0c;path是个使用频率很高&#xff0c;但却让人又爱又恨的模块。部分因为文档说的不够清晰&#xff0c;部分因为接口的平台差异性。将path的接口按照用途归类&#xff0c;仔细琢磨琢磨&#xff0c;也就没那么费解了。 1.…
最新文章