---
title: PCIe 与高速互联
url: https://doc.liz6.com/hardware/06-interfaces-and-communication/04-pcie-and-high-speed-interconnects
locale: zh
area: hardware
tags:
- hardware
- 接口与通信
date: 2026-06-30
modified: 2026-07-11
description: PCIe 与高速互联 PCIe 是什么 PCIe (PCI Express) — 现代计算机的高速串行总线，连接 CPU 与 GPU/SSD/网卡等外设。 PCIe 树形拓扑:单 Root Complex 下的设备层级 CPU PCIe RC Memory Controller Switch Endpoint (GPU…
---

# PCIe 与高速互联

## PCIe 是什么

**PCIe (PCI Express)** — 现代计算机的高速串行总线，连接 CPU 与 GPU/SSD/网卡等外设。

<svg viewBox="0 0 720 360" xmlns="http://www.w3.org/2000/svg" font-family="-apple-system,'Source Han Sans CN','Microsoft YaHei',sans-serif" role="img" aria-label="PCIe 树形拓扑:单 Root Complex 下的设备层级">
  <rect width="720" height="360" fill="#ffffff"/>
  <text x="360" y="28" text-anchor="middle" font-size="17" font-weight="700" fill="#1f2933">PCIe 树形拓扑:单 Root Complex 下的设备层级</text>

  <rect x="315" y="50" width="90" height="36" rx="6" fill="#4f46e5"/>
  <text x="360" y="73" text-anchor="middle" font-size="13" font-weight="700" fill="#ffffff">CPU</text>

  <line x1="360" y1="86" x2="360" y2="96" stroke="#94a3b8" stroke-width="1.5"/>
  <line x1="220" y1="96" x2="520" y2="96" stroke="#94a3b8" stroke-width="1.5"/>
  <line x1="220" y1="96" x2="220" y2="100" stroke="#94a3b8" stroke-width="1.5"/>
  <line x1="520" y1="96" x2="520" y2="100" stroke="#94a3b8" stroke-width="1.5"/>

  <rect x="165" y="100" width="110" height="38" rx="6" fill="#eef2ff" stroke="#c7d2fe"/>
  <text x="220" y="123" text-anchor="middle" font-size="12" font-weight="700" fill="#3730a3">PCIe RC</text>
  <rect x="445" y="100" width="150" height="38" rx="6" fill="#e2e8f0"/>
  <text x="520" y="123" text-anchor="middle" font-size="11" fill="#475569">Memory Controller</text>

  <line x1="220" y1="138" x2="220" y2="150" stroke="#94a3b8" stroke-width="1.5"/>
  <line x1="140" y1="150" x2="300" y2="150" stroke="#94a3b8" stroke-width="1.5"/>
  <line x1="140" y1="150" x2="140" y2="155" stroke="#94a3b8" stroke-width="1.5"/>
  <line x1="300" y1="150" x2="300" y2="155" stroke="#94a3b8" stroke-width="1.5"/>

  <rect x="95" y="155" width="90" height="36" rx="6" fill="#f0fdfa" stroke="#99f6e4"/>
  <text x="140" y="177" text-anchor="middle" font-size="12" font-weight="700" fill="#115e59">Switch</text>
  <rect x="235" y="155" width="130" height="36" rx="6" fill="#eef2ff" stroke="#c7d2fe"/>
  <text x="300" y="171" text-anchor="middle" font-size="11" font-weight="700" fill="#3730a3">Endpoint</text>
  <text x="300" y="185" text-anchor="middle" font-size="10" fill="#4f46e5">(GPU)</text>

  <line x1="140" y1="191" x2="140" y2="200" stroke="#94a3b8" stroke-width="1.5"/>
  <line x1="70" y1="200" x2="210" y2="200" stroke="#94a3b8" stroke-width="1.5"/>
  <line x1="70" y1="200" x2="70" y2="205" stroke="#94a3b8" stroke-width="1.5"/>
  <line x1="140" y1="200" x2="140" y2="205" stroke="#94a3b8" stroke-width="1.5"/>
  <line x1="210" y1="200" x2="210" y2="205" stroke="#94a3b8" stroke-width="1.5"/>

  <rect x="40" y="205" width="60" height="36" rx="5" fill="#e2e8f0"/>
  <text x="70" y="227" text-anchor="middle" font-size="11" fill="#334155">EP</text>
  <rect x="110" y="205" width="60" height="36" rx="5" fill="#e2e8f0"/>
  <text x="140" y="227" text-anchor="middle" font-size="11" fill="#334155">EP</text>
  <rect x="180" y="205" width="60" height="36" rx="5" fill="#e2e8f0"/>
  <text x="210" y="227" text-anchor="middle" font-size="11" fill="#334155">EP</text>
  <text x="140" y="255" text-anchor="middle" font-size="11" fill="#64748b">(NVMe SSD、网卡...)</text>

  <rect x="40" y="270" width="640" height="68" rx="8" fill="#eef2ff" stroke="#c7d2fe"/>
  <text x="56" y="292" font-size="12.5" fill="#3730a3">RC = Root Complex(根复合体,通常在 CPU 或 PCH 内);Switch = 交换芯片,向下扩展更多 PCIe 端口</text>
  <text x="56" y="314" font-size="12.5" fill="#3730a3">EP = Endpoint(终端设备),即 Switch 下挂的 NVMe SSD、网卡等末端设备</text>
</svg>

---

## Lane 与 Generation

### Lane (通道)
```
PCIe 的最小单位是 1 条 Lane

x1:  1 lane
x4:  4 lane (常见: NVMe SSD)
x8:  8 lane
x16: 16 lane (常见: GPU)

每条 Lane 是独立的全双工串行链路
  TX+/TX- (发送) + RX+/RX- (接收) = 4 根信号线/Lane

x16 物理上 = 64 根信号线 (16×4)
```

### 各代速度

| Gen | 速率/Lane (单工) | 带宽/Lane (双工) | x16 带宽 | 年代 |
|-----|-------------------|-------------------|----------|------|
| 1.0 | 2.5 GT/s | 250 MB/s | 4 GB/s | 2003 |
| 2.0 | 5.0 GT/s | 500 MB/s | 8 GB/s | 2007 |
| 3.0 | 8.0 GT/s | ~1 GB/s | ~16 GB/s | 2010 |
| 4.0 | 16.0 GT/s | ~2 GB/s | ~32 GB/s | 2017 |
| 5.0 | 32.0 GT/s | ~4 GB/s | ~64 GB/s | 2019 |
| 6.0 | 64.0 GT/s | ~8 GB/s | ~128 GB/s | 2022 (刚商用) |

```
8b/10b (Gen1/2): 2.5 GT/s × 8/10 = 2 Gbps = 250 MB/s
128b/130b (Gen3+): 8 GT/s × 128/130 ≈ 7.88 Gbps ≈ 985 MB/s
→ Gen3+ 编码开销大幅降低

"GT/s" = 每秒千兆次传输 (包括编码开销)
"GB/s" = 每秒千兆字节有效数据
```

### 常见配置
```
消费级 CPU 典型 PCIe 通道数:
  AMD Ryzen: 24~28 lanes (其中 4 接 PCH, 16+4 给 GPU+NVMe)
  Intel Core: 16~20 lanes (其中 4 接 PCH)

显卡: x16 Gen4/5 (但 x8 通常够用, 性能损失 1~3%)
NVMe SSD: x4 Gen4/5 (Gen4 x4 = ~8 GB/s)
万兆网卡: x4 Gen3
```

### 向下兼容
```
Gen4 设备可插入 Gen3 插槽 → 降速到 Gen3
Gen3 设备可插入 Gen4 插槽 → 工作在 Gen3

链路训练 (Link Training):
  上电后两端自动协商 → 确定能跑的最高速度和最大 lane 数
```

---

## 物理层

### 信号
```
每 Lane:
  TX+ TX- : 差分发送 (AC 耦合, 电容隔直)
  RX+ RX- : 差分接收 (AC 耦合)

参考时钟: 100MHz (HCSL 或 LVDS 差分)
  Common Clock (同源) 或 Separate Clock (独立)
  现在多用 SRIS (Separate Refclk Independent SSC)

Gen3+ 使用 128b/130b 编码 + 扰码 (scramble)
无单独时钟线, 接收端从数据中恢复时钟 (CDR)
```

### PCB 设计要点
```
PCIe 走线:
  - 差分对等长 (P/N 差 <5mil)
  - 特性阻抗: 85Ω 差分 (Gen3), 有时也 100Ω
  - 避免参考面不连续 (跨分割)
  - AC 耦合电容 (100nF~220nF) 靠近发送端
  - 过孔尽量少 (每个过孔破坏阻抗)
```

---

## PCIe 协议层

```
三层模型:

事务层 (Transaction Layer):
  产生/消费 TLP (Transaction Layer Packet)
  地址路由 / ID 路由 / 隐式路由

数据链路层 (Data Link Layer):
  保证可靠传输
  ACK/NAK, 重传, CRC 校验
  产生/消费 DLLP

物理层 (Physical Layer):
  8b/10b 或 128b/130b 编码
  串并转换, 链路训练
```

---

## 常见应用

### NVMe over PCIe
```
NVMe 协议运行在 PCIe 上
AHCI (SATA 的传统协议) 跑在 PCIe 上 → 被 NVMe 替代

NVMe 优势:
  - 64K 队列深度 (AHCI 仅 32)
  - 64K 队列数 (AHCI 仅 1)
  - 更低延迟 (无需访问 SATA 控制器)
```

### GPU 连接
```
消费 GPU: x16 PCIe 直连 CPU
  Gen3 x16 = 16 GB/s (RTX 20/30 系列)
  Gen4 x16 = 32 GB/s (RTX 40 系列)
  Gen5 x16 = 64 GB/s (RTX 50 系列)

实际: 游戏场景下 Gen3 x8 几乎无性能损失
      Gen4 对于消费 GPU 主要是未来余量
      计算/ML 场景大带宽更关键 (多 GPU 互联)
```

### Resizable BAR (Smart Access Memory)
```
传统: CPU 只能通过 256MB BAR 窗口访问 GPU 显存
ReBAR: CPU 可一次映射全部 GPU 显存 → 减少拷贝, 提升性能

需要: BIOS 支持 + GPU 驱动支持 + PCIe 支持
```

---

## 与 CPU 的连接

<svg viewBox="0 0 720 410" xmlns="http://www.w3.org/2000/svg" font-family="-apple-system,'Source Han Sans CN','Microsoft YaHei',sans-serif" role="img" aria-label="PCIe 与 CPU 的连接:直连 vs 走 PCH,Intel 与 AMD 对比">
  <rect width="720" height="410" fill="#ffffff"/>
  <text x="360" y="28" text-anchor="middle" font-size="17" font-weight="700" fill="#1f2933">PCIe 与 CPU 的连接:直连 vs 走 PCH(Intel / AMD 对比)</text>

  <rect x="20" y="51" width="60" height="20" rx="5" fill="#334155"/>
  <text x="50" y="65" text-anchor="middle" font-size="11" font-weight="700" fill="#ffffff">Intel</text>

  <rect x="85" y="60" width="110" height="34" rx="6" fill="#4f46e5"/>
  <text x="140" y="81" text-anchor="middle" font-size="13" font-weight="700" fill="#ffffff">CPU</text>
  <rect x="485" y="60" width="130" height="34" rx="6" fill="#0d9488"/>
  <text x="550" y="81" text-anchor="middle" font-size="12" font-weight="700" fill="#ffffff">PCH(芯片组)</text>
  <line x1="195" y1="77" x2="485" y2="77" stroke="#94a3b8" stroke-width="1.5"/>
  <text x="340" y="70" text-anchor="middle" font-size="11" fill="#64748b">DMI(本质=PCIe x8)</text>

  <line x1="140" y1="94" x2="140" y2="106" stroke="#94a3b8" stroke-width="1.5"/>
  <line x1="70" y1="106" x2="225" y2="106" stroke="#94a3b8" stroke-width="1.5"/>
  <line x1="70" y1="106" x2="70" y2="118" stroke="#94a3b8" stroke-width="1.5"/>
  <line x1="225" y1="106" x2="225" y2="118" stroke="#94a3b8" stroke-width="1.5"/>
  <rect x="5" y="118" width="130" height="34" rx="6" fill="#eef2ff" stroke="#c7d2fe"/>
  <text x="70" y="139" text-anchor="middle" font-size="11" font-weight="700" fill="#3730a3">PCIe x16(直连)</text>
  <rect x="145" y="118" width="160" height="34" rx="6" fill="#eef2ff" stroke="#c7d2fe"/>
  <text x="225" y="139" text-anchor="middle" font-size="11" font-weight="700" fill="#3730a3">PCIe x4(NVMe 直连)</text>

  <line x1="550" y1="94" x2="550" y2="106" stroke="#94a3b8" stroke-width="1.5"/>
  <line x1="470" y1="106" x2="630" y2="106" stroke="#94a3b8" stroke-width="1.5"/>
  <line x1="470" y1="106" x2="470" y2="118" stroke="#94a3b8" stroke-width="1.5"/>
  <line x1="630" y1="106" x2="630" y2="118" stroke="#94a3b8" stroke-width="1.5"/>
  <rect x="385" y="118" width="170" height="34" rx="6" fill="#f0fdfa" stroke="#99f6e4"/>
  <text x="470" y="139" text-anchor="middle" font-size="10" font-weight="700" fill="#115e59">SATA/USB/Ethernet/WiFi</text>
  <rect x="555" y="118" width="150" height="34" rx="6" fill="#f0fdfa" stroke="#99f6e4"/>
  <text x="630" y="139" text-anchor="middle" font-size="11" font-weight="700" fill="#115e59">更多 PCIe lanes</text>

  <rect x="20" y="216" width="60" height="20" rx="5" fill="#334155"/>
  <text x="50" y="230" text-anchor="middle" font-size="11" font-weight="700" fill="#ffffff">AMD</text>

  <rect x="85" y="225" width="110" height="34" rx="6" fill="#4f46e5"/>
  <text x="140" y="246" text-anchor="middle" font-size="13" font-weight="700" fill="#ffffff">CPU</text>
  <rect x="485" y="225" width="130" height="34" rx="6" fill="#0d9488"/>
  <text x="550" y="246" text-anchor="middle" font-size="12" font-weight="700" fill="#ffffff">PCH</text>
  <line x1="195" y1="242" x2="485" y2="242" stroke="#94a3b8" stroke-width="1.5"/>
  <text x="340" y="235" text-anchor="middle" font-size="11" fill="#64748b">PCIe x4(IF 总线)</text>

  <line x1="140" y1="259" x2="140" y2="271" stroke="#94a3b8" stroke-width="1.5"/>
  <line x1="70" y1="271" x2="225" y2="271" stroke="#94a3b8" stroke-width="1.5"/>
  <line x1="70" y1="271" x2="70" y2="283" stroke="#94a3b8" stroke-width="1.5"/>
  <line x1="225" y1="271" x2="225" y2="283" stroke="#94a3b8" stroke-width="1.5"/>
  <rect x="5" y="283" width="130" height="34" rx="6" fill="#eef2ff" stroke="#c7d2fe"/>
  <text x="70" y="304" text-anchor="middle" font-size="11" font-weight="700" fill="#3730a3">PCIe x16/x8</text>
  <rect x="145" y="283" width="160" height="34" rx="6" fill="#eef2ff" stroke="#c7d2fe"/>
  <text x="225" y="304" text-anchor="middle" font-size="11" font-weight="700" fill="#3730a3">PCIe x4(NVMe)</text>

  <line x1="550" y1="259" x2="550" y2="283" stroke="#94a3b8" stroke-width="1.5"/>
  <rect x="450" y="283" width="200" height="34" rx="6" fill="#f0fdfa" stroke="#99f6e4"/>
  <text x="550" y="298" text-anchor="middle" font-size="11" font-weight="700" fill="#115e59">类似 Intel 拓扑</text>
  <text x="550" y="311" text-anchor="middle" font-size="9.5" fill="#0f766e">(SATA/USB/更多 lanes)</text>

  <rect x="40" y="330" width="640" height="64" rx="8" fill="#eef2ff" stroke="#c7d2fe"/>
  <text x="56" y="352" font-size="12.5" fill="#3730a3">直连 CPU 的 PCIe(独立 x16 显卡、CPU 直连 NVMe)= 更低延迟,最适合 GPU/NVMe;</text>
  <text x="56" y="374" font-size="12.5" fill="#3730a3">走 PCH 的 PCIe(SATA/USB/网卡等)= 共享 DMI/IF 总线带宽,再上行到 CPU。</text>
</svg>

---
*关键词: PCIe, Lane, GT/s, NVMe, Root Complex, Endpoint, 差分信号, ReBAR, Gen*
