
锁存器是触发器的基础模块,用于存储 1 位二进制信息。与触发器,边沿触发它是一种电平触发器,即输出状态随输入变化,在输入信号有效电平时持续更新,并在无效电平时保持不变。为避免问题复杂化,对于锁存器,你无需了解更多。
以德州仪器74HC175为例,看看寄存器内部是如何构成的:


RISC-V 的 ADD 指令定义为两个寄存器(
rs1,rs2)相加并将结果存储在目标寄存器(rd)中。硬件通过设计算术逻辑单元(ALU)来实现加法操作,同时更新目标寄存器的值。
现在我们能够粗略回答指令(add rd rs1 rs2)在硬件上是如何实现的:



A register file is an array of processor registers in a central processing unit (CPU). The instruction set architecture of a CPU will almost always define a set of registers which are used to stage data between memory and the functional units on the chip. The register file is part of the architecture and visible to the programmer, as opposed to the concept of transparent caches. In simpler CPUs, these architectural registers correspond one-for-one to the entries in a physical register file (PRF) within the CPU. More complicated CPUs use register renaming, so that the mapping of which physical entry stores a particular architectural register changes dynamically during execution.
What the f**k is this?
可以注意到,“寄存器堆”其实就是一组被有序排列并编号的寄存器。
在RISC-V中,寄存器堆的大小一般为32个寄存器,分别编号为x0-x31。



@ Presented by Yunxiang He
@ ShanghaiTech University