Chapter4-1 单周期数据通路

Posted by LvKouKou on October 24, 2022

4-1 单周期数据通路

image-20221024091903238

Datapath Elements

  • 计算部件:组合电路输出随输⼊变化, ⽐如 ALU (+ - × ÷)
  • 状态部件(必须有时钟)
    • 时序逻辑电路
    • 输出随时钟边沿变化
    • ⽐如寄存器 Register

组合电路和时序电路区别:

  • 组合电路:输出只与输入有关
  • 时序电路:输出与时钟有关

image-20221024092450659

单周期CUP

  • 单周期(Single-Cycle) CPU执⾏⼀条指令⽤⼀个时钟周期 (一周期完成一条指令)

  • ==在时钟上升沿保存指令的结果和下⼀条指令的地址==

  • Data path 上的资源每指令周期最多⽤⼀次 (一周期中每个部件/指令只能用一次)

时序逻辑电路 State (sequential) elements

  • 定时⽅式:规定信号何时写⼊状态元件或何时从状态元件读出
    • 边沿触发(edge-triggered)⽅式:状态单元中的值只在时钟边沿改变。 每个时钟周期改变⼀次
  • 最简单的状态单元
    • D触发器: ⼀个时钟输⼊、 ⼀个状态输⼊、 ⼀个状态输出

image-20221024092729965

Clock-to-Q-time:即从输入到输出的时间

存储单元

  1. 寄存器

image-20221024093642526

  1. 寄存器组

image-20221024093734740

寄存器组内部:

image-20221024094603937

  1. 存储器(内存)

    image-20221024094926976

单周期数据通路设计

image-20221024095051716

Memory只有lw和sw的指令需要这个阶段

image-20221024095120452

Stage 1: 取指令单元IF (Instruction Fetch)

image-20221024095626738

Stage 2: 指令译码Instruction Decode

image-20221024095658888

在译码阶段生成控制信号

请注意, 在译码阶段, 使⽤ rs 和 rt 指令的字段地址从寄存器堆的读取端⼝读出寄存器内容, 对所有指令都是⼯作的

  • 因为还没有译码, 所以还不知道指令要做什么 !
  • 提前读出两个源操作数内容, 以防后⾯⽤到两个寄存器的内容。
  • ⼏乎所有指令都会⽤到寄存器内容 (除了 j 指令)

Stage 3: ALU (Arithmetic-Logic Unit)

image-20221024100015727

Stage 4: 内存访问Memory Access

image-20221024100204174

这里的内存是在CPU内的caches,是高速内存(缓存),里面的内容是外部内存的复制,而不是冯诺依曼结构中的CPU、内存、I/P中的CPU外部的低速内存

Stage 5: 写寄存器Register Write

image-20221024100614774

MIPS指令的硬件实现

R-type 指令

image-20221024100740808

image-20221024100756066

I-type instruction addi

image-20221024101148560

I-type instruction ori

image-20221024101223607

image-20221024101304842

实现 load 指令

image-20221024101340485

image-20221024101400794

实现 store 指令

image-20221024101437463

image-20221024101507176

实现 branch 指令

image-20221024101539483

image-20221024101607879

image-20221024101627882

Jump operation

image-20221024101832227

image-20221024101902387image-20221024101922689

# Single Cycle Datapath with Control Unit

image-20221024102116846

R-type Instruction Data/Control Flow

image-20221024102324550

Load Word Instruction Data/Control Flow

image-20221024102305076

Branch Instruction Data/Control Flow

image-20221024102419700

Adding the Jump Operation

image-20221024102547156

MIPS R2000 instruction set 扩展内容

Shift Instructions

  • J/JAL

  • JR/JRAL

  • slti/sltiu

  • LUI

  • Reset(复位), Interrupts(中断), and Exceptions(异常)

Q:前⾯的设计没有包括 JR, JAL, JALR, Shift ,slti/sltiu …这些指令?

A:添加选择器和对应功能

寄存器间接跳转指令 JR( Register-Indirect Jumps )

image-20221024102914503

image-20221024102951229

==jalr跳转地址为rs,jal跳转地址要用26位imm==

Absolute Jumps (J, JAL)

image-20221024103432151

Harvard-Style Datapath forMIPS

image-20221024103508589

Shift Instructions

image-20221024103534325

有立即数的操作slti/sltiu

image-20221030111231267

回顾:3-1中条件码

image-20221030111248802

slt和sltu(两个寄存器比较,无立即数)

image-20221030111359915

LUI

image-20221030111415304

Reset, Interrupts, and Exceptions

Exceptions

image-20221030111452259

完整的MIPS M2000

image-20221030111529186

单周期控制器的设计 Control

image-20221030111618472

Recap: A Summary of Control Signals

image-20221030111642231

image-20221030111652848

控制器的设计

  • 实现⽅式: 组合逻辑电路 输⼊信号: • 指令字段的op和func。 • ALU的zero、 V、 N状态

  • 确定每条指令的控制信号
    • 0
    • 1
    • X(与该指令⽆关)
  • 构建控制信号的真值表

image-20221030111813401

分为主控和ALU控制

主控单元

image-20221030111856490

image-20221030111927858

ALU控制电路

image-20221030111916329

The Complete Single Cycle Data Path with Control

image-20221030111945030

时钟频率

image-20221030112008584

image-20221030112018654

image-20221030112028291

image-20221030112139341

Single Cycle Disadvantages & Advantages

image-20221030112147467

其它可实现的⽅式

image-20221030112207869

单周期计算机的性能

image-20221030112221830

image-20221030112239202

image-20221030112248597

image-20221030112301778

image-20221030112308009