📚 Logic Gates: Key Points for IB and Edexcel Computer Science | 逻辑门:IB与Edexcel计算机科学核心考点精讲
Logic gates are the fundamental building blocks of digital circuits. They process binary inputs (1 and 0) to produce binary outputs according to Boolean functions. A strong grasp of logic gates, truth tables, and combinational logic is essential for both IB Computer Science and Edexcel A Level Computer Science examinations. This article covers every core logic gate, Boolean algebra laws, circuit design techniques, and real-world applications to help you master the topic.
逻辑门是数字电路的基本构建块。它们根据布尔函数处理二进制输入(1 和 0)并产生二进制输出。深刻掌握逻辑门、真值表与组合逻辑对 IB 计算机科学和 Edexcel A Level 计算机科学考试至关重要。本文涵盖所有核心逻辑门、布尔代数定律、电路设计技巧以及实际应用,助你完全掌握这一主题。
1. Introduction to Logic Gates | 逻辑门简介
Logic gates are electronic circuits that perform Boolean operations. Each gate has one or more inputs and a single output. The basic gates are AND, OR, and NOT; all complex digital systems can be built using combinations of these. Additionally, NAND, NOR, XOR, and XNOR gates extend the functionality and often lead to simpler implementations.
逻辑门是执行布尔运算的电子电路。每个门有一个或多个输入和一个输出。基本门为与门、或门和非门;所有复杂数字系统均可通过这些门的组合构建。此外,与非门、或非门、异或门和同或门扩展了功能,并常能简化电路实现。
2. AND Gate | 与门
The AND gate outputs 1 only when all inputs are 1. For a two-input AND gate, the Boolean expression is:
Q = A · B
Truth table:
| A | B | Q |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
与门仅在所有输入均为 1 时输出 1。对于二输入与门,布尔表达式为 Q = A · B。真值表如上所示。
3. OR Gate | 或门
The OR gate produces 1 if at least one input is 1. Its Boolean expression uses the addition symbol:
Q = A + B
Truth table for a two-input OR gate:
| A | B | Q |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
或门只要至少有一个输入为 1,输出即为 1。其布尔表达式使用加号:Q = A + B。二输入或门真值表如上。
4. NOT Gate | 非门
The NOT gate (inverter) has a single input. It negates the input value. The Boolean expression uses a prime or overbar:
Q = A'
Truth table:
| A | Q |
|---|---|
| 0 | 1 |
| 1 | 0 |
非门(反相器)只有一个输入,对输入取反。布尔表达式表示为 Q = A'。真值表如上。
5. NAND Gate | 与非门
The NAND gate is the complement of the AND gate; it outputs 0 only when all inputs are 1. Its Boolean expression indicates the AND operation followed by inversion:
Q = (A · B)'
Truth table:
| A | B | Q |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
与非门是与门的补;仅当所有输入均为 1 时输出 0。其布尔表达式为先与后反:Q = (A · B)'。NAND 门具有功能完备性,可用于实现任何其他逻辑门。
6. NOR Gate | 或非门
The NOR gate is the complement of the OR gate. Its output is 1 only when all inputs are 0. The expression is:
Q = (A + B)'
Truth table:
| A | B | Q |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 0 |
或非门是或门的补。仅当所有输入为 0 时输出 1。表达式为 Q = (A + B)'。与 NAND 类似,NOR 门也具备功能完备性。
7. XOR Gate | 异或门
The XOR (exclusive OR) gate outputs 1 when the inputs differ. The Boolean expression uses the circled plus symbol:
Q = A ⊕ B
Truth table:
| A | B | Q |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
异或门当输入不同时输出 1。表达式用带圆圈的加号:Q = A ⊕ B。从真值表可推导出 XOR 的 SOP 形式为 Q = A'B + AB'。
8. XNOR Gate | 同或门
The XNOR (exclusive NOR) gate outputs 1 when the inputs are identical. It is the complement of XOR:
Q = A ⊙ B = (A ⊕ B)'
Truth table:
| A | B | Q |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
同或门当输入相同时输出 1,是异或门的补。表达式为 Q = A ⊙ B,也等于 (A ⊕ B)'。同或门常用于比较器电路中。
9. Truth Tables & Boolean Expressions | 真值表与布尔表达式
A truth table lists all possible input combinations and the corresponding output. For n inputs, there are 2n rals), and OR them. For example, from the XOR truth table, rows with output 1 are (0,1) and (1,0), giving minterms A'B and AB', so Q = A'B + AB'. Similarly, Product of Sums (POS) uses maxterms for output 0.
真值表列出所有可能的输入组合及对应的输出。对于 n 个输入,有 2n 行。推导布尔表达式的一种常用方法是积之和(SOP):找出输出为 1 的行,写出最小项(文字变量的乘积),再将它们相或。例如,从异或真值表可知输出为 1 的行是 (0,1) 和 (1,0),最小项为 A'B 和 AB',因此 Q = A'B + AB'。类似地,和之积(POS)使用输出为 0 的最大项。
Boolean algebra provides identities for simplification:
- Identity: A + 0 = A, A · 1 = A
- Complement: A + A'
Published by TutorHao | IB Computer Science Revision Series | aleveler.com
广告 / SponsoredIBDP国际文凭计算机科学学生用书 高级及标准水平 Computer Science for the IB Diplo…计算机 备考教辅 · 正版现货 · 与本文内容相关查看详情 / View on Taobao参考价 ¥524.0更多咨询请联系16621398022(同微信)
备考资讯每日更新,关注不错过考纲变化 · 科目分析 · 学习方法
在微信里长按二维码识别关注
或截图后用「扫一扫 → 相册」选择本图公众号:tutorhao