ebook img

RISC-V 手册 v2.1 PDF

164 Pages·2020·5.564 MB·Chinese
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview RISC-V 手册 v2.1

1 2018 RISC-V 手册 一本开源指令集的指南 DAVID PATTERSON, ANDREW WATERMAN 翻译:勾凌睿、黄成、刘志刚 校阅:包云岗 1 参考卡 2 3 目录 参考卡 ..................................................................................................................................................... 1 致谢 ......................................................................................................................................................... 7 关于作者 ................................................................................................................................................. 9 前言 .......................................................................................................................................................10 译者序 ...................................................................................................................................................12 翻译团队 ................................................................................................................................................ 12 第一章 为什么要有RISC-V? ..........................................................................................................13 1.1 导言 ................................................................................................................................................. 13 1.2 模块化与增量型ISA ................................................................................................................... 14 1.3 ISA设计 101 ................................................................................................................................. 15 1.4 全书的总览 .................................................................................................................................... 19 1.5 结束语 ............................................................................................................................................. 20 1.6 扩展阅读 ........................................................................................................................................ 21 第二章 RV32I:RISC-V基础整数指令集 ......................................................................................23 2.1 导言 ................................................................................................................................................. 23 2.2 RV32I指令格式 ............................................................................................................................. 23 2.3 RV32I寄存器 ................................................................................................................................. 26 2.4 RV32I整数计算 ............................................................................................................................. 27 2.5 RV32I的Load和Store .............................................................................................................. 29 2.6 RV32I条件分支 ............................................................................................................................. 30 2.7 RV32I无条件跳转 ........................................................................................................................ 31 2.8 RV32I杂项 ...................................................................................................................................... 31 2.9 使用插入排序比较RV32I,ARM-32,MIPS-32和x86-32指令集 ........................... 32 2.10 结束语 .......................................................................................................................................... 32 2.11 扩展阅读 ...................................................................................................................................... 33 第三章 RISC-V汇编语言 ..................................................................................................................41 3.1 导言 ................................................................................................................................................. 41 3.2 函数调用规范(Calling convention) ................................................................................. 41 3.3 汇编器 ............................................................................................................................................. 43 3.4 链接器 ............................................................................................................................................. 46 3.5 静态链接和动态链接 ................................................................................................................. 49 3.6 加载器 ............................................................................................................................................. 49 3.7 结束语 ............................................................................................................................................. 49 4 3.8 扩展阅读 ........................................................................................................................................ 50 第四章 乘法和除法指令 ................................................................................................................... 51 4.1 导言 ................................................................................................................................................. 51 4.2 结束语 ............................................................................................................................................ 53 4.3 扩展阅读 ........................................................................................................................................ 53 第五章 RV32F和RV32D:单精度和双精度浮点数.................................................................... 55 5.1 导言 ................................................................................................................................................. 55 5.2浮点寄存器 .................................................................................................................................... 55 5.3浮点加载,存储和算术指令 .................................................................................................... 56 5.4浮点转换和搬运 ........................................................................................................................... 60 5.5其他浮点指令 ................................................................................................................................ 60 5.6使用DAXPY程序比较RV32FD,ARM-32,MIPS-32和x86-32 ............................... 62 5.7结束语.............................................................................................................................................. 62 5.8 扩展阅读 ........................................................................................................................................ 62 第六章 原子指令 ................................................................................................................................ 65 6.1 导言 ................................................................................................................................................. 65 6.2 结束语 ............................................................................................................................................ 67 6.3 扩展阅读 ........................................................................................................................................ 67 第七章 压缩指令 ................................................................................................................................ 69 7.1 导言 ................................................................................................................................................. 69 7.2 RV32GC,Thumb-2,microMIPS和x86-32的比较 ...................................................... 71 7.3 结束语 ............................................................................................................................................ 71 7.4 扩展阅读 ........................................................................................................................................ 71 第八章 向量 ........................................................................................................................................ 75 8.1 导言 ................................................................................................................................................. 75 8.2 向量计算指令 ............................................................................................................................... 76 8.3 向量寄存器和动态类型 ............................................................................................................ 76 8.4 向量的Load和Store操作 ...................................................................................................... 78 8.5 向量操作期间的并行性 ............................................................................................................ 78 8.6 向量运算的条件执行 ................................................................................................................. 79 8.7 其他向量指令 ............................................................................................................................... 79 8.8 例子:用RV32V写成的DAXPY程序 ................................................................................. 80 8.9 RV32V,MIPS-32 MSA SIMD和x86-32 AVX SIMD的比较 ......................................... 81 5 8.10 结束语 .......................................................................................................................................... 83 8.11 扩展阅读 ...................................................................................................................................... 84 第九章 RV64:64位地址指令 ........................................................................................................87 9.1 导言 ................................................................................................................................................. 87 9.2使用插入排序来比较RV64与其他64位ISA ..................................................................... 91 9.3程序大小 ......................................................................................................................................... 93 9.4结束语 .............................................................................................................................................. 93 9.5了解更多 ......................................................................................................................................... 94 第十章 RV32/64特权架构 ...............................................................................................................99 10.1 导言 ............................................................................................................................................... 99 10.2 简单嵌入式系统的机器模式 .............................................................................................. 100 10.3 机器模式下的异常处理 ....................................................................................................... 101 10.4 嵌入式系统中的用户模式和进程隔离 ............................................................................ 104 10.5 现代操作系统的监管者模式 .............................................................................................. 105 10.6 基于页面的虚拟内存 ............................................................................................................ 106 10.7 结束语 ....................................................................................................................................... 110 10.8 扩展阅读 ................................................................................................................................... 111 第十一章 RISC-V未来的可选扩展 .............................................................................................. 113 11.1 “B”标准扩展:位操作 ............................................................................................................ 113 11.2 “E”标准扩展:嵌入式 ............................................................................................................ 113 11.3 “H”特权态架构扩展:支持管理程序(Hypervisor) ................................................. 113 11.4 “J”标准扩展:动态翻译语言 ............................................................................................... 113 11.5 “L”标准扩展:十进制浮点 ................................................................................................... 113 11.6 “N”标准扩展:用户态中断 .................................................................................................. 113 11.7 “P”标准扩展:封装的单指令多数据(Packed-SIMD)指令 ................................... 114 11.8 “Q”标准扩展:四精度浮点 .................................................................................................. 114 11.9 结束语 ....................................................................................................................................... 114 附录A RISC-V指令列表 ............................................................................................................. 115 6 对这本 RISC-V 手册的称赞 我喜欢RISC-V和这本书,因为它们优雅——简洁、扼要且完整。书中的评论无偿提供 了一些历史,设计的动机,以及一些对于各种架构的批评。 ——C. Gordan Bell,微软公司成员,Digital PDP-11和 VAX-11指令集架构的设计者 本书讲述了RISC-V可以做到什么,以及为什么它的设计师选择赋予它这些能力。更有 趣的是,作者说出了为什么RISC-V省略了早期计算机中存在的一些东西。这些原因至 少和RISC-V本身能做到什么与忽略了什么一样有意思。 ——Ivan Sutherland,图灵奖获得者,被称作计算机图形学之父 RISC-V会改变世界,这本书会助你成为改变的一部分。 ——Michael B. Taylor,华盛顿大学教授 RISC-V 是学生学习指令集架构和汇编级编程的理想选择,而它们是以后用高级语言工 作的基础。这本写得很清楚的书提供了对RISC-V的很好的介绍,再加上一些对其演化 历史的深刻见解及与其它常见架构的比较。以过去的指令集架构为鉴,RISC-V 的设计 者能够避免一些不必要的、不合理的特征,这让教学过程变得容易。即使它很简洁,它 也足够强大,能在实际应用中广泛使用。很久以前我教过汇编编程的入门课,如果我现 在去教这门课的话,我会很乐意用这本书作为教材。 ——John Mashey,MIPS指令集架构的设计者之一 这本书对于任何使用 RISC-V ISA 的人来说都是十分宝贵的参考。为了便于快速查阅, 操作码按几种有用的格式呈现,这让编写和解释汇编代码变得简单。此外,对于如何使 用这个ISA的解释和示例也让程序员的工作更容易。和其他ISA比较的部分很有意思, 它们解释了RISC-V设计者们做出他们的设计决策的原因。 ——Megan Wachs,博士,SiFive工程师 7 致谢 David Patterson把这本书献给他的父母: ——给我的父亲David,我从他那儿继承了创造 力、运动天赋和为正义奋斗的勇气;以及 ——给我的母亲Lucy,我从她那儿继承了智慧、 乐观和良好的性格。 感谢你们成为我如此伟大的榜样,你们让我明 白了成为好的配偶、父亲和祖父的意义。 8 Andrew Waterman 把这本书献给他的父母 John 和Elizabeth,他们即便在千里之外也支持着他。

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.