# Introduction

https://www.bilibili.com/video/BV1xw411i7sH/?spm_id_from=333.1391.top_right_bar_window_custom_collection.content.click&vd_source=2c1227d0a7d29725db75d3fc52e6089b

# 计算机架构的方向

  • security
  • energy-efficient
  • low latency, predictable
  • architectures for AI

我们通常设计整个系统,而不是某一层

# 课程关于

计算机是怎样工作的。

作为科学家,应该了解它是怎样工作的,否则没有其他人知道。

Focus on learning experience.

# 内存

内存存取的延迟比计算更高。现代计算机系统的问题更多是关于内存的 。

对于简单的计算,内存访问消耗 6400 倍能量

# Rowhammer attack

PC security facing another “heavy hammer”, Baidu Security discovers a new Rowhammer  attack | by Baidu Security X-Lab | Baidu Security X-Lab | Medium

在内存里,当我们不断存取一个 row 的时候,相邻的 row 会产生 bit flip.

原因是: electrical interference. 当一行电压高的时候,相邻的行损失电能。

大多数 DRAM Modules 存在漏洞

# Goals of Course

  • Enable you to think critically
  • Enable you to think broadly

# Preparation

If you're prepared to see something, you can see something.

If you don't have an background to see an opportunity, the opportunity comes to you will just miss it.

# Architecture

Architecture based on principle, and not upon precedent.

# Combinational Logic

# Transistors

计算机由很多个小结构组成:晶体管

# Mos Transistor

结合

  • Conductors (Metal)
  • Insulators (Oxide)
  • Semiconductors

我们有 2 种 MOS Transistor, n-typep-type

Pass Transistors and Transmission Gates: Revolutionizing Digital Circuit  Design - Quarktwin Electronic Parts

它们像开关一样工作。

# N type MOS Transistor

如果 Gate 被施加高电压,Drain 和 Source 就会被导通。

和技术相关,高电压值可能在 [0.3V, 3V]

如果在临界值,开关的结果可能是随机的。

p-type transistors are good at pulling down the voltage

# P type MOS Transistor

和 N type 工作相反。当 Gate 被施加高电压的时候,会形成断路。

p-type transistors are good at pulling up the voltage

# Logical Gates

我们用 MOS Transistor 构造基本的逻辑门,它们实现了基本的逻辑运算。

# CMOS (NOT Gate)

Complementary MOS 技术。现代计算机普遍使用 CMOS.

nMOS + pMOS=CMOS

<img src="https://nerdsdostuff.com/wp-content/uploads/2024/03/CMOS-Inverter-Circuit-Image.png" alt="CMOS Inverter: Basics, Working and Applications - Nerds Do Stuff" style="zoom:33%;" />

它实现了 not 的逻辑。

逻辑门里圆圈的意思是区反。

image-20250620142217429

# NAND

image-20250620142404131

image-20250620142413977

# AND

image-20250620142431574

image-20250620142442752

# Common Logic Gates

image-20250620144219943

# Power Consumption

  • 动态功耗:电能被用来存储,当信号转换的时候 (0,1 转化)
  • 静态功耗:当 signal 不变的时候的功耗,因为漏电

# Enabling Manufacturing:EUV

制造芯片的技术

# 逻辑运算

# 1bit 全加器

image-20250620145655529 + 是或, * 是 AND

# Duality

每个式子有一个 dual 的,转换方法

  • AND 和 OR 转换
  • 常数 0 和 1 转换

# 简化定理

XY+XYˉ=X,(X+Y)(X+Yˉ)=XX+XY=X,X(X+Y)=X(X+Yˉ)Y=XY,(XYˉ)+Y=X+YXY+X\bar{Y}=X, (X+Y)(X+\bar{Y})=X \\ X+XY=X, X(X+Y)=X \\ (X+\bar{Y})Y=XY, (X\bar{Y})+Y=X+Y

# DeMorgan's Law

(X+Y+Z)=XˉYˉZˉ(XYZ)=Xˉ+Yˉ+Zˉ\overline{(X+Y+Z)}=\bar{X}\bar{Y}\bar{Z} \\ \overline{(XYZ)} = \bar{X}+\bar{Y}+\bar{Z}

# Standard Function Representation

Sum of Pruducts (SOP)

Product of Sums(POS)

Implicant: producto of literals ABCABC

Minterm: product that include all literals

Maxterm: sum that include all literals

可以写成

f=m3+m4+m5+m6+m7=m(3,4,5,6,7)f=m3+m4+m5+m6+m7 = \sum m(3,4,5,6,7)

m3m3 就算 Minterm 二进制是 3 的 literal

F=(A+B+C)(A+B+Cˉ)(A+Bˉ+C)=ΠM(0,1,2)F=(A+B+C)(A+B+\bar{C})(A+\bar{B}+C) \\ = \Pi M(0,1,2)

大写 M 是 Maxterm

# Combinational Building Blocks

# Decoder

input pattern decoder

image-20250620152736413

把数转换成下标

用处:可以把 A 当作内存地址,那么 Y 就知道要激活哪一行。也可以是 opcode 解码

# Multiplexer (MUX), or Selector

image-20250620153200759

如果 S 是 0 那么就是 D0D_0 的输入,否则就是 D1D_1 的输入

MUX 可以被用作 Look Up Table

# Programmable Logic Array

image-20250620154630455

左边是 Minterm, 我们要设置 connection (编成), 是的右边的 Or 连接正确的 Minterm.

如果 minterm 在 SOP 里出现,那我们连接对应的 AND Gate 到 OrGate 上.

# Equality Checker

可以用 XNOR Gate 实现相等检查

image-20250623100632355

# Tri State Buffer

image-20250623101934643

# Sequencial Logic Design

输出还和过去的输入有关

# Storage elements

# Cross Coupled Inverters

image-20250623155600597

# SRAM

image-20250623160048896

# The Big Picture: Storage Elements

  • Latches and Flip-Flops
    • Very fast, very expensive (1 bit costs 10s of transistors)
  • SRAM
    • expensive (1 bit costs 6 transistors)
  • DRAM
    • Cheap
  • hard disk
    • very cheap

# RS Latch

Reset-Set Latch

image-20250623160523591