《Digital Design and Computer Architecture》7.4 多周期CPU(1)

教材学习与翻译:简单的多周期处理器实现
原文来自
Digital Design and Computer Architecture, Second Edition
by David M. Harris, Sarah L. Harris
7.4 MULTICYCLE PROCESSOR

7.4.1 多周期数据通路

我们还是像上次一样,从存储器和结构状态开始设计CPU,如图7.16 。在设计单周期CPU时,指令存储器和数据存储器是分开的,因为指令和数据的读取是在同一个周期中进行的。现在,我们把指令和数据存储器结合起来。这是可以实现的,因为我们可以在一个周期中读取指令,然后在另一个周期中读写数据,同时PC和寄存器中的值保持不变。我们将通过不断添加模块来分析每一条指令的每一步工作,从而逐步搭建数据通路。新添加的连线用黑色线标出(新的控制信号用蓝色标出),已经学过的部分用灰色标出。

Again, we begin our design with the memory and architectural state of the MIPS processor, shown in Figure 7.16. In the single-cycle design, we used separate instruction and data memories because we needed to read the instruction memory and read or write the data memory all in one cycle. Now, we choose to use a combined memory for both instructions and data. This is more realistic, and it is feasible because we can read the instruction in one cycle, then read or write the data in a separate cycle. The PC and register file remain unchanged. We gradually build the datapath by adding components to handle each step of each instruction. The new connections are emphasized in black (or blue, for new control signals), whereas the hardware that has already been studied is shown in gray.
图 7.16

PC存储了当前要执行的指令的地址。指令执行的第一步是将指令从指令存储器中读出来。图7.17展示了:PC直接连接到(指令)存储器的地址输入端口。指令读出后,被存储在一个新的,非结构性的指令寄存器中,供以后的时钟周期使用。指令寄存器接受一个使能信号:IR Write,该信号有效时,寄存器中的值可以被更新。

The PC contains the address of the instruction to execute. The first step is to read this instruction from instruction memory. Figure 7.17 shows that the PC is simply connected to the address input of the instruction memory. The instruction is read and stored in a new nonarchitectural Instruction Register so that it is available for future cycles. The Instruction Register receives an enable signal, called IRWrite, that is asserted when it should be updated with a new instruction.
图7.17

lw指令通路的实现

就像我们对单周期处理器所做的那样,我们要先建立lw指令的数据通路,然后对其进行补充和优化,使之能够处理其他的指令。
对于lw指令,读出指令后的下一步是读取源寄存器中的基址。这个寄存器的由指令的rs域指出,即Instr[25:21]。指令的这几位连接到寄存器组的一个地址输入:A1,如图7.18。寄存器组读取数据后将数据送到输出端口RD1。这个值被存储在另一个非结构性寄存器A中。

As we did with the single-cycle processor, we will work out the datapath connections for the lw instruction. Then we will enhance the datapath to handle the other instructions.
For a lw instruction, the next step is to read the source register containing the base address. This register is specified in the rs field of the instruction, Instr25:21. These bits of the instruction are connected to one of the address inputs, A1, of the register file, as shown in Figure 7.18. The register file reads the register onto RD1. This value is stored in another nonarchitectural register, A.
图7.18

lw指令还需要一个偏移量。偏移量由指令的立即数域指出,即Instr[15:0]。偏移量需要符号扩展至32位,如图7.19。经符号扩展后的32位数据记为SignImm。出于一致性考虑,我们也可以将SignImm存储在另一个非结构性寄存器中。然而,SignImm是Instr的组合函数,在处理当前指令时,SignImm的值不会改变,所以我们没有必要为这个不会改变的值分配一个寄存器。

The lw instruction also requires an offset. The offset is stored in the
immediate field of the instruction, Instr15:0, and must be sign-extended to 32 bits, as shown in Figure 7.19. The 32-bit sign-extended value is called SignImm. To be consistent, we might store SignImm in another nonarchitectural register. However, SignImm is a combinational function of Instr and will not change while the current instruction is being processed, so there is no need to dedicate a register to hold the constant value.
图7.19

要载入的数据的地址是基址和偏移量的和,我们用一个ALU来运算它们的和,如图7.20。为了进行加法运算,ALUControl应设为 010,运算结果ALUResult 存储在一个非结构性寄存器 ALUOut中。

The address of the load is the sum of the base address and offset. We
use an ALU to compute this sum, as shown in Figure 7.20. ALUControl
should be set to 010 to perform an addition. ALUResult is stored in a nonarchitectural register called ALUOut.
图7.20

接下来我们需要将计算结果接入存储器。我们在存储器的地址输入前设置一个多路选择器来选择存储器地址Adr是来自PC还是ALUOut,如图7.21。该选择器的选择控制信号记为IorD,表示“指令”或“数据”。从存储器中读出的数据存储在另一个非结构性寄存器中,该寄存器记为Data。注意到地址选择器让我们能够在lw指令进行时多次访问存储器。第一次是根据PC值获取指令,第二次是根据ALU输出的地址读取数据。因此,IorD必须在这两个过程中取不同的值。在7.4.2中,我们将设计用于生成这些顺序控制信号的有限状态机。

The next step is to load the data from the calculated address in the memory. We add a multiplexer in front of the memory to choose the memory address, Adr, from either the PC or ALUOut, as shown in Figure 7.21. The multiplexer select signal is called IorD, to indicate either an instruction or data address. The data read from the memory is stored in another nonarchitectural register, called Data. Notice that the address multiplexer permits us to reuse the memory during the lw instruction. On the first step, the address is taken from the PC to fetch the instruction. On a later step, the address is taken from ALUOut to load the data. Hence, IorD must have different values on different steps. In Section 7.4.2, we develop the FSM controller that generates these sequences of control signals.

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
数字设计和计算机体系结构都是现代计算机科学领域中的重要资源。数字设计是指使用数字电路和逻辑门设计和实现数字系统、电路和芯片的过程。它涉及到电子工程、计算机科学和通信技术等领域。数字设计通过逻辑门的组合和互连来实现目标功能,可以用于创建各种设备和系统,如计算机处理器、存储器、控制器等。 计算机体系结构是指计算机硬件和软件之间的接口和组织方式。它涉及到计算机硬件的组成、指令系统的设计和计算机系统的整体结构。计算机体系结构包括处理器、存储器、输入输出设备等组件,以及它们之间的连接和通信方式。 数字设计和计算机体系结构资源的重要性在于它们对计算机科学领域的发展和创新起到关键作用。通过数字设计,我们可以设计和实现各种先进的数字系统,为信息技术的发展提供有力支持。计算机体系结构则决定了计算机的性能和功能,能够满足不同应用的需求。 对于学习数字设计和计算机体系结构的学生来说,资源的重要性是不言而喻的。他们需要学习和理解不同的数字设计方法和计算机体系结构原理,掌握相关的工具和技术。而在实践中,他们也需要有足够的资源来设计、仿真和测试他们的电路和系统。 因此,学习者可以从各种学术书籍、教学课件和学术论文中获取相关知识和理论。此外,还可以使用各种数字设计和计算机体系结构仿真工具和软件来实践和验证他们的设计。还可以参加相关的学术会议、研讨会和实验室课程,与其他研究者和学生交流和分享经验。 总而言之,数字设计和计算机体系结构资源的重要性体现在它们对于计算机科学领域的发展和创新起到的关键作用,以及对于学习者的知识获取和实践应用的支持。通过充分利用这些资源,我们可以不断提升自己的学术水平和创新能力。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值