---
title: 组合逻辑电路
url: https://doc.liz6.com/hardware/05-digital-circuits/02-combinational-logic-circuits
locale: zh
area: hardware
tags:
- hardware
- 数字电路
date: 2026-06-30
modified: 2026-07-11
description: 组合逻辑电路 什么是组合逻辑 组合逻辑 — 输出仅取决于当前输入，无记忆功能。 组合逻辑:输出只取决于当前输入 输入 组合逻辑 纯门电路 · 无反馈 输出 与时序逻辑的区别:没有时钟,没有状态保持。 --- 常用组合电路 多路选择器 (MUX) 2选1 MUX:按选择线 S 路由 A 或 B 到输出 Y A B S 选…
---

# 组合逻辑电路

## 什么是组合逻辑

**组合逻辑** — 输出仅取决于当前输入，无记忆功能。

<svg viewBox="0 0 720 210" xmlns="http://www.w3.org/2000/svg" font-family="-apple-system,'Source Han Sans CN','Microsoft YaHei',sans-serif" role="img" aria-label="组合逻辑框图:输入经组合逻辑直接得到输出,无反馈无记忆">
  <defs><marker id="cmb1-ah" markerWidth="10" markerHeight="8" refX="8" refY="3" orient="auto"><path d="M0,0 L8,3 L0,6 Z" fill="#475569"/></marker></defs>
  <rect width="720" height="210" fill="#ffffff"/>
  <text x="360" y="28" text-anchor="middle" font-size="17" font-weight="700" fill="#1f2933">组合逻辑:输出只取决于当前输入</text>
  <rect x="50" y="80" width="110" height="50" rx="8" fill="#e2e8f0"/>
  <text x="105" y="110" text-anchor="middle" font-size="13" font-weight="700" fill="#334155">输入</text>
  <line x1="160" y1="105" x2="245" y2="105" stroke="#475569" stroke-width="1.8" marker-end="url(#cmb1-ah)"/>
  <rect x="250" y="70" width="220" height="70" rx="8" fill="#4f46e5"/>
  <text x="360" y="100" text-anchor="middle" font-size="13" font-weight="700" fill="#ffffff">组合逻辑</text>
  <text x="360" y="120" text-anchor="middle" font-size="11" fill="#e0e7ff">纯门电路 · 无反馈</text>
  <line x1="470" y1="105" x2="555" y2="105" stroke="#475569" stroke-width="1.8" marker-end="url(#cmb1-ah)"/>
  <rect x="560" y="80" width="110" height="50" rx="8" fill="#e2e8f0"/>
  <text x="615" y="110" text-anchor="middle" font-size="13" font-weight="700" fill="#334155">输出</text>
  <rect x="60" y="158" width="600" height="38" rx="8" fill="#eef2ff" stroke="#c7d2fe"/>
  <text x="76" y="182" font-size="12.5" fill="#3730a3">与时序逻辑的区别:没有时钟,没有状态保持。</text>
</svg>

---

## 常用组合电路

### 多路选择器 (MUX)
<svg viewBox="0 0 720 300" xmlns="http://www.w3.org/2000/svg" font-family="-apple-system,'Source Han Sans CN','Microsoft YaHei',sans-serif" role="img" aria-label="2选1多路选择器框图:A、B为数据输入,S为选择线,按S选择A或B输出到Y">
  <defs><marker id="mux1-ah" markerWidth="10" markerHeight="8" refX="8" refY="3" orient="auto"><path d="M0,0 L8,3 L0,6 Z" fill="#475569"/></marker></defs>
  <rect width="720" height="300" fill="#ffffff"/>
  <text x="360" y="28" text-anchor="middle" font-size="17" font-weight="700" fill="#1f2933">2选1 MUX:按选择线 S 路由 A 或 B 到输出 Y</text>
  <rect x="60" y="86" width="70" height="28" rx="6" fill="#eef2ff" stroke="#c7d2fe"/>
  <text x="95" y="105" text-anchor="middle" font-size="12" font-weight="700" fill="#3730a3">A</text>
  <line x1="130" y1="100" x2="248" y2="112" stroke="#475569" stroke-width="1.6" marker-end="url(#mux1-ah)"/>
  <rect x="60" y="126" width="70" height="28" rx="6" fill="#eef2ff" stroke="#c7d2fe"/>
  <text x="95" y="145" text-anchor="middle" font-size="12" font-weight="700" fill="#3730a3">B</text>
  <line x1="130" y1="140" x2="248" y2="130" stroke="#475569" stroke-width="1.6" marker-end="url(#mux1-ah)"/>
  <rect x="60" y="166" width="70" height="28" rx="6" fill="#e2e8f0"/>
  <text x="95" y="185" text-anchor="middle" font-size="12" font-weight="700" fill="#334155">S</text>
  <line x1="130" y1="180" x2="248" y2="150" stroke="#475569" stroke-width="1.6" marker-end="url(#mux1-ah)"/>
  <text x="95" y="212" text-anchor="middle" font-size="10" fill="#64748b">选择线</text>
  <rect x="250" y="80" width="180" height="90" rx="8" fill="#4f46e5"/>
  <text x="340" y="130" text-anchor="middle" font-size="14" font-weight="700" fill="#ffffff">2选1 MUX</text>
  <line x1="430" y1="125" x2="465" y2="125" stroke="#475569" stroke-width="1.8" marker-end="url(#mux1-ah)"/>
  <rect x="470" y="105" width="100" height="40" rx="6" fill="#ccfbf1"/>
  <text x="520" y="130" text-anchor="middle" font-size="13" font-weight="700" fill="#115e59">Y</text>
  <text x="60" y="230" font-size="12" fill="#334155">Y = S ? B : A(S=0 选 A,S=1 选 B) — Y = Ā·S + B·S</text>
  <rect x="60" y="248" width="600" height="36" rx="8" fill="#eef2ff" stroke="#c7d2fe"/>
  <text x="76" y="271" font-size="12.5" fill="#3730a3">应用:信号路由、并行→串行转换、逻辑函数实现</text>
</svg>

### 译码器 (Decoder)
```
n 位输入 → 2ⁿ 位输出 (每次仅1位为1)

  2→4 译码器:
    A1 A0 | Y0 Y1 Y2 Y3
     0  0 |  1  0  0  0
     0  1 |  0  1  0  0
     1  0 |  0  0  1  0
     1  1 |  0  0  0  1

应用: 地址译码 (片选信号)、七段数码管驱动
典型芯片: 74HC138 (3→8), 74HC154 (4→16)
```

### 编码器 (Encoder)
```
译码器的逆操作: 2ⁿ 位输入 → n 位输出

优先编码器: 多个输入同时有效时，输出最高优先级的编码
典型: 74HC148 (8→3 优先编码器)
```

### 加法器

#### 半加器 (Half Adder)
<svg viewBox="0 0 720 240" xmlns="http://www.w3.org/2000/svg" font-family="-apple-system,'Source Han Sans CN','Microsoft YaHei',sans-serif" role="img" aria-label="半加器框图:输入A、B相加,输出和S与进位C">
  <defs><marker id="ha1-ah" markerWidth="10" markerHeight="8" refX="8" refY="3" orient="auto"><path d="M0,0 L8,3 L0,6 Z" fill="#475569"/></marker></defs>
  <rect width="720" height="240" fill="#ffffff"/>
  <text x="360" y="28" text-anchor="middle" font-size="17" font-weight="700" fill="#1f2933">半加器(HA):两位相加,输出和与进位</text>
  <rect x="60" y="86" width="70" height="28" rx="6" fill="#eef2ff" stroke="#c7d2fe"/>
  <text x="95" y="105" text-anchor="middle" font-size="12" font-weight="700" fill="#3730a3">A</text>
  <line x1="130" y1="100" x2="248" y2="100" stroke="#475569" stroke-width="1.6" marker-end="url(#ha1-ah)"/>
  <rect x="60" y="126" width="70" height="28" rx="6" fill="#eef2ff" stroke="#c7d2fe"/>
  <text x="95" y="145" text-anchor="middle" font-size="12" font-weight="700" fill="#3730a3">B</text>
  <line x1="130" y1="140" x2="248" y2="140" stroke="#475569" stroke-width="1.6" marker-end="url(#ha1-ah)"/>
  <rect x="250" y="75" width="180" height="80" rx="8" fill="#4f46e5"/>
  <text x="340" y="112" text-anchor="middle" font-size="14" font-weight="700" fill="#ffffff">半加器</text>
  <text x="340" y="130" text-anchor="middle" font-size="11" fill="#e0e7ff">HA</text>
  <line x1="430" y1="100" x2="465" y2="100" stroke="#475569" stroke-width="1.6" marker-end="url(#ha1-ah)"/>
  <rect x="470" y="85" width="190" height="30" rx="6" fill="#f0fdfa" stroke="#99f6e4"/>
  <text x="565" y="105" text-anchor="middle" font-size="12" font-weight="700" fill="#115e59">S = A⊕B(和)</text>
  <line x1="430" y1="140" x2="465" y2="140" stroke="#475569" stroke-width="1.6" marker-end="url(#ha1-ah)"/>
  <rect x="470" y="126" width="190" height="30" rx="6" fill="#f0fdfa" stroke="#99f6e4"/>
  <text x="565" y="146" text-anchor="middle" font-size="12" font-weight="700" fill="#115e59">C = A·B(进位)</text>
  <rect x="60" y="185" width="600" height="36" rx="8" fill="#ffedd5"/>
  <text x="76" y="208" font-size="12.5" fill="#9a3412">无进位输入,只能做最低位加法</text>
</svg>

#### 全加器 (Full Adder)
<svg viewBox="0 0 720 280" xmlns="http://www.w3.org/2000/svg" font-family="-apple-system,'Source Han Sans CN','Microsoft YaHei',sans-serif" role="img" aria-label="全加器框图:输入A、B、Cin,输出和S与进位Cout,可级联成多位加法器">
  <defs><marker id="fa1-ah" markerWidth="10" markerHeight="8" refX="8" refY="3" orient="auto"><path d="M0,0 L8,3 L0,6 Z" fill="#475569"/></marker></defs>
  <rect width="720" height="280" fill="#ffffff"/>
  <text x="360" y="28" text-anchor="middle" font-size="17" font-weight="700" fill="#1f2933">全加器(FA):加入进位输入 Cin,可级联</text>
  <rect x="60" y="80" width="70" height="28" rx="6" fill="#eef2ff" stroke="#c7d2fe"/>
  <text x="95" y="99" text-anchor="middle" font-size="12" font-weight="700" fill="#3730a3">A</text>
  <line x1="130" y1="94" x2="248" y2="105" stroke="#475569" stroke-width="1.6" marker-end="url(#fa1-ah)"/>
  <rect x="60" y="120" width="70" height="28" rx="6" fill="#eef2ff" stroke="#c7d2fe"/>
  <text x="95" y="139" text-anchor="middle" font-size="12" font-weight="700" fill="#3730a3">B</text>
  <line x1="130" y1="134" x2="248" y2="130" stroke="#475569" stroke-width="1.6" marker-end="url(#fa1-ah)"/>
  <rect x="60" y="160" width="70" height="28" rx="6" fill="#eef2ff" stroke="#c7d2fe"/>
  <text x="95" y="179" text-anchor="middle" font-size="12" font-weight="700" fill="#3730a3">Cin</text>
  <line x1="130" y1="174" x2="248" y2="155" stroke="#475569" stroke-width="1.6" marker-end="url(#fa1-ah)"/>
  <rect x="250" y="70" width="180" height="120" rx="8" fill="#4f46e5"/>
  <text x="340" y="122" text-anchor="middle" font-size="14" font-weight="700" fill="#ffffff">全加器</text>
  <text x="340" y="142" text-anchor="middle" font-size="11" fill="#e0e7ff">FA</text>
  <line x1="430" y1="100" x2="465" y2="100" stroke="#475569" stroke-width="1.6" marker-end="url(#fa1-ah)"/>
  <rect x="470" y="85" width="190" height="30" rx="6" fill="#f0fdfa" stroke="#99f6e4"/>
  <text x="565" y="105" text-anchor="middle" font-size="11" font-weight="700" fill="#115e59">S = A⊕B⊕Cin(和)</text>
  <line x1="430" y1="160" x2="465" y2="160" stroke="#475569" stroke-width="1.6" marker-end="url(#fa1-ah)"/>
  <rect x="470" y="145" width="190" height="30" rx="6" fill="#f0fdfa" stroke="#99f6e4"/>
  <text x="565" y="165" text-anchor="middle" font-size="10.5" font-weight="700" fill="#115e59">Cout=A·B+(A⊕B)·Cin</text>
  <rect x="60" y="205" width="600" height="55" rx="8" fill="#eef2ff" stroke="#c7d2fe"/>
  <text x="76" y="227" font-size="12.5" fill="#3730a3">Cout = A·B + (A⊕B)·Cin —— 多数为1则进位。</text>
  <text x="76" y="246" font-size="12.5" fill="#3730a3">级联 n 个全加器 = n 位加法器。</text>
</svg>

#### 行波进位 vs 超前进位
```
行波进位 (Ripple Carry):
  进位逐级传递 → 延迟大 (n×t_fa)
  简单、省面积

超前进位 (Carry Lookahead):
  并行计算所有进位 → 延迟小 (O(log n))
  复杂度高、面积大

典型: 74HC283 (4位超前进位加法器)
```

### 比较器
<svg viewBox="0 0 720 300" xmlns="http://www.w3.org/2000/svg" font-family="-apple-system,'Source Han Sans CN','Microsoft YaHei',sans-serif" role="img" aria-label="比较器框图:输入A、B,输出A大于B、等于B、小于B三种比较结果">
  <defs><marker id="cmp1-ah" markerWidth="10" markerHeight="8" refX="8" refY="3" orient="auto"><path d="M0,0 L8,3 L0,6 Z" fill="#475569"/></marker></defs>
  <rect width="720" height="300" fill="#ffffff"/>
  <text x="360" y="28" text-anchor="middle" font-size="17" font-weight="700" fill="#1f2933">比较器:逐位比较,输出三种大小关系</text>
  <rect x="60" y="95" width="70" height="28" rx="6" fill="#eef2ff" stroke="#c7d2fe"/>
  <text x="95" y="114" text-anchor="middle" font-size="12" font-weight="700" fill="#3730a3">A</text>
  <line x1="130" y1="109" x2="248" y2="115" stroke="#475569" stroke-width="1.6" marker-end="url(#cmp1-ah)"/>
  <rect x="60" y="165" width="70" height="28" rx="6" fill="#eef2ff" stroke="#c7d2fe"/>
  <text x="95" y="184" text-anchor="middle" font-size="12" font-weight="700" fill="#3730a3">B</text>
  <line x1="130" y1="179" x2="248" y2="165" stroke="#475569" stroke-width="1.6" marker-end="url(#cmp1-ah)"/>
  <rect x="250" y="75" width="180" height="130" rx="8" fill="#4f46e5"/>
  <text x="340" y="145" text-anchor="middle" font-size="14" font-weight="700" fill="#ffffff">比较器</text>
  <line x1="430" y1="98" x2="465" y2="98" stroke="#475569" stroke-width="1.6" marker-end="url(#cmp1-ah)"/>
  <rect x="470" y="85" width="120" height="26" rx="6" fill="#f0fdfa" stroke="#99f6e4"/>
  <text x="530" y="103" text-anchor="middle" font-size="12" font-weight="700" fill="#115e59">A &gt; B</text>
  <line x1="430" y1="140" x2="465" y2="140" stroke="#475569" stroke-width="1.6" marker-end="url(#cmp1-ah)"/>
  <rect x="470" y="127" width="120" height="26" rx="6" fill="#f0fdfa" stroke="#99f6e4"/>
  <text x="530" y="145" text-anchor="middle" font-size="12" font-weight="700" fill="#115e59">A = B</text>
  <line x1="430" y1="182" x2="465" y2="182" stroke="#475569" stroke-width="1.6" marker-end="url(#cmp1-ah)"/>
  <rect x="470" y="169" width="120" height="26" rx="6" fill="#f0fdfa" stroke="#99f6e4"/>
  <text x="530" y="187" text-anchor="middle" font-size="12" font-weight="700" fill="#115e59">A &lt; B</text>
  <rect x="60" y="225" width="600" height="50" rx="8" fill="#eef2ff" stroke="#c7d2fe"/>
  <text x="76" y="246" font-size="12.5" fill="#3730a3">从高位到低位逐位比较。</text>
  <text x="76" y="264" font-size="12.5" fill="#3730a3">典型芯片:74HC85(4位比较器)。</text>
</svg>

---

## 可编程逻辑

### 基本思想
```
不用搭门电路，用可编程器件实现任意逻辑

PAL/GAL: 与阵列可编程 + 或阵列固定
CPLD: 多块 PAL + 可编程互连
FPGA: 查找表 (LUT) + 触发器 + 可编程互连
```

### FPGA 的 LUT
```
2ⁿ 输入的 LUT 可实现任意 n 输入逻辑函数

3-LUT: 8 个 SRAM 单元存真值表 + 3 级 MUX 树
→ 任意 3 输入布尔函数!

典型: 6-LUT (Xilinx), 4-LUT + 加法器 (Intel ALM)
```

---

## 时序问题

### 传播延迟 (tpd)
```
信号从输入到输出稳定所需的时间

多个门串联: 总延迟 = 各门延迟之和
关键路径: 延迟最长的路径 → 决定电路最高工作频率
```

### 竞争与冒险
```
多条路径延迟不同 → 输出可能出现 glitch

检测: 卡诺图中相邻质蕴含项之间没有覆盖
解决: 加冗余项 或 在输出用时钟同步 (寄存器打一拍)
```

---

## 常见应用

| 电路 | 功能 | 芯片 |
|------|------|------|
| 三态缓冲器 | 控制总线接入 | 74HC125/126 |
| 总线收发器 | 双向数据传输 | 74HC245 |
| 锁存器 | 电平触发保持 | 74HC373/573 |
| 移位寄存器 | 串/并转换 | 74HC595 |

---
*关键词: 组合逻辑, MUX, 译码器, 加法器, 比较器, FPGA, LUT, glitch, 关键路径*
