📚 Logic Circuits, Expressions, Truth Tables and Problem Description | IGCSE计算机:逻辑电路、表达式、真值表与问题描述
In the CIE IGCSE Computer Science syllabus, logic gates form the foundation of digital systems. Understanding how to interpret logic circuits, write Boolean expressions, construct truth tables, and translate problem descriptions into logical designs is essential for exam success. This article will guide you through each of these interconnected skills with clear, step-by-step explanations.
在CIE IGCSE计算机科学考试大纲中,逻辑门是数字系统的基础。理解如何解读逻辑电路、编写布尔表达式、构建真值表以及将问题描述转化为逻辑设计,是考试取得好成绩的关键。本文将逐步为你讲解这些相互关联的技能。
1. Basic Logic Gates | 基本逻辑门
There are three fundamental logic gates you must know: the AND gate, the OR gate, and the NOT gate. Each gate produces an output based on one or more inputs, and each has a distinct symbol and Boolean expression.
你必须掌握三种基本逻辑门:与门(AND)、或门(OR)和非门(NOT)。每个门根据一个或多个输入产生输出,并且都有独特的符号和布尔表达式。
- AND gate (与门): Output is 1 only when ALL inputs are 1. Expression: X = A · B (or X = AB)
- OR gate (或门): Output is 1 when AT LEAST ONE input is 1. Expression: X = A + B
- NOT gate (非门): Inverts the input. Output is 1 when input is 0, and vice versa. Expression: X = NOT A = Ā
X = A · B (AND) | X = A + B (OR) | X = Ā (NOT)
In addition, two combined gates appear frequently in IGCSE papers: NAND and NOR. The NAND gate is an AND gate followed by a NOT gate, and the NOR gate is an OR gate followed by a NOT gate.
此外,IGCSE考卷中经常出现两种组合门:与非门(NAND)和或非门(NOR)。与非门是与门后接非门,或非门是或门后接非门。
- NAND gate (与非门): Output is 0 only when ALL inputs are 1. Expression: X = A · B with a bar over the whole expression, i.e. X = (A·B)̄
- NOR gate (或非门): Output is 1 only when ALL inputs are 0. Expression: X = (A + B)̄
2. Truth Tables for Basic Gates | 基本门真值表
A truth table lists all possible input combinations and the corresponding output for a logic circuit. For n inputs, there are 2ⁿ possible combinations. For two inputs, there are 4 rows; for three inputs, there are 8 rows.
真值表列出所有可能的输入组合及逻辑电路对应的输出。对于n个输入,共有2ⁿ种可能的组合。两个输入有4行,三个输入有8行。
| A | B | AND: A·B | OR: A+B | NAND: (A·B)̄ | NOR: (A+B)̄ |
| 0 | 0 | 0 | 0 | 1 | 1 |
| 0 | 1 | 0 | 1 | 1 | 0 |
| 1 | 0 | 0 | 1 | 1 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 |
For the NOT gate, since it has only one input, the truth table has just 2 rows. When A = 0, output = 1; when A = 1, output = 0.
对于非门,因为它只有一个输入,真值表只有2行。当A=0时,输出为1;当A=1时,输出为0。
3. Writing Boolean Expressions from Logic Circuits | 从逻辑电路写出布尔表达式
When given a logic circuit diagram, you must trace the signal flow from left to right, writing the expression for each intermediate point until you reach the final output.
当给定逻辑电路图时,你需要从左到右追踪信号流向,为每个中间节点写出表达式,直到到达最终输出。
Step-by-step method (分步方法):
- Identify each gate and label its output with a temporary variable (e.g., P, Q).
- Write the Boolean expression for each intermediate output.
- Combine them according to how the gates are connected to form the final expression.
例如,假设一个电路有两个输入A和B,先经过AND门得到P = A·B,然后P再与C经过OR门,最终输出X = P + C = A·B + C。
For example, suppose a circuit has inputs A and B going into an AND gate giving P = A·B, and then P goes with another input C into an OR gate. The final output is X = P + C = A·B + C.
X = A·B + C
Always remember to use proper notation: a dot (·) or adjacency means AND, a plus (+) means OR, and a bar (‾) means NOT. Group terms with the same structure carefully, and apply the correct order of operations: NOT first, then AND, then OR (unless brackets indicate otherwise).
始终使用正确的符号:点(·)或相邻表示与,加号(+)表示或,横线(‾)表示非。注意运算的先后顺序:先非、后与、再或(除非括号表明其他顺序)。
4. Constructing Truth Tables from Logic Circuits | 从逻辑电路构建真值表
To construct a truth table from a logic circuit, first write the Boolean expression. Then list all possible input combinations and calculate intermediate and final outputs step by step.
要从逻辑电路构建真值表,首先写出布尔表达式。然后列出所有可能的输入组合,逐步计算中间输出和最终输出。
Consider the expression X = A·B + C. The truth table would be constructed as follows:
| A | B | C | P = A·B | X = P + C |
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 | 1 |
| 0 | 1 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 0 | 0 |
| 1 | 0 | 1 | 0 | 1 |
| 1 | 1 | 0 | 1 | 1 |
| 1 | 1 | 1 | 1 | 1 |
Notice that only when C = 1 or when both A and B are 1, the output X becomes 1. Always include intermediate columns to make your reasoning clear and to avoid errors.
注意,只有当C=1或A和B同时为1时,输出X才为1。始终包含中间列,以使推理清晰并避免错误。
5. Simplifying Boolean Expressions | 简化布尔表达式
Boolean algebra has rules that allow you to simplify expressions, which in turn can reduce the number of gates needed in a circuit. The most important laws for IGCSE are listed below.
布尔代数有允许简化表达式的规则,从而可以减少电路所需的门数。IGCSE最重要的定律如下。
- Identity Law (恒等律): A + 0 = A, A · 1 = A
- Null Law (零律): A + 1 = 1, A · 0 = 0
- Idempotent Law (幂等律): A + A = A, A · A = A
- Complement Law (互补律): A + Ā = 1, A · Ā = 0
- Double Negation (双重否定): NOT (NOT A) = Ā̄ = A
- De Morgan’s Laws (德摩根定律): (A·B)̄ = Ā + B̄, and (A+B)̄ = Ā · B̄
- Distributive Law (分配律): A · (B + C) = A·B + A·C
For example, simplify the expression X = A·B + A·B̄. Using the distributive law, factor out A: X = A·(B + B̄). Since B + B̄ = 1 (Complement Law), we get X = A · 1 = A. The entire circuit simplifies to just a direct connection of A to the output.
例如,简化表达式X = A·B + A·B̄。使用分配律,提取公因式A:X = A·(B + B̄)。因为B + B̄ = 1(互补律),得到X = A · 1 = A。整个电路简化为将A直接连接到输出。
A·B + A·B̄ = A·(B + B̄) = A·1 = A
De Morgan’s Laws are especially important in exams. They allow you to convert between AND/OR forms with inversions. When applying De Morgan’s Law, break the bar, change the operation: AND becomes OR and vice versa, and invert each term.
德摩根定律在考试中尤为重要。它们允许你在带反相的与/或形式之间进行转换。应用德摩根定律时,拆开横线,改变运算符:与变为或,或变为与,并对每一项取反。
6. From Problem Description to Logic Expression | 从问题描述到逻辑表达式
A common exam question type gives you a real-world scenario and asks you to design a logic circuit. The key is to identify the variables, recognise the conditions that produce an output of 1, and then translate them into Boolean algebra.
常见的考试题型是给出一个现实场景,要求你设计逻辑电路。关键是识别变量,找出输出为1的条件,然后将其转化为布尔代数。
Worked example (例题): A factory alarm (X) should sound when either the temperature sensor (T) detects overheating, OR both the pressure sensor (P) AND the safety switch (S) are activated.
工厂警报(X)在以下情况应响起:温度传感器(T)检测到过热,或压力传感器(P)与安全开关(S)同时被激活。
Step 1 (第一步): Identify variables: T = temperature, P = pressure, S = safety switch, X = alarm.
Step 2 (第二步): Identify conditions: X = 1 when T = 1, or when P = 1 AND S = 1.
Step 3 (第三步): Write the expression: X = T + (P · S).
X = T + (P · S)
Step 4 (第四步): Draw the circuit: P and S go into an AND gate; the output of that AND gate and T go into an OR gate. The output of the OR gate is X.
第四步:画出电路:P和S进入与门;与门的输出与T进入或门。或门的输出为X。
Examiners reward clear working. Always define your variables and show each step of your reasoning, even when the question only asks for the final circuit.
考官会根据清晰的解题过程给分。始终定义你的变量,并展示每一步推理,即使题目只要求最终电路。
7. From Logic Circuit to Problem Description | 从逻辑电路到问题描述
The reverse skill is also tested: you may be given a logic circuit and asked to describe, in plain English, the situation it models. To do this, read the truth table and identify the pattern of 1s in the output column.
反向技能也会被考查:你可能被给定一个逻辑电路,并要求用通俗英语描述它所模拟的情况。要做到这点,请阅读真值表并识别输出列中1的模式。
Consider a circuit with expression X = A · B̄ + Ā · B (this is known as XOR, exclusive OR). The output is 1 when exactly one of the inputs is 1. In words: “The output is 1 when inputs A and B are different.” This could describe a light that turns on when two switches are in different positions.
考虑一个表达式为X = A·B̄ + Ā·B的电路(这被称为异或门XOR)。当恰好一个输入为1时,输出为1。用语言描述:”当输入A和B不同时,输出为1。”这可以描述一个当两个开关处于不同位置时亮起的灯。
| A | B | X = A·B̄ + Ā·B |
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
When describing a circuit, use phrases like “the output is 1 when…” or “the circuit can be used as a…” and always include both the logical behaviour and a possible real-world application.
描述电路时,使用类似”输出为1的条件是……”或”该电路可以用作……”的表述,并且始终包含逻辑行为和一个可能的现实应用场景。
8. NAND and NOR as Universal Gates | NAND与NOR作为通用门
NAND and NOR gates are called “universal gates” because any logic circuit can be constructed using only NAND gates, or only NOR gates. This is an important concept for understanding how real chips are built.
NAND和NOR门被称为”通用门”,因为任何逻辑电路都可以仅使用NAND门或仅使用NOR门来构建。这是理解真实芯片如何制造的重要概念。
Using only NAND gates:
- NOT gate (非门): Connect both inputs of a NAND gate together. X = (A·A)̄ = Ā
- AND gate (与门): A NAND gate followed by a NOT gate (another NAND with tied inputs). X = ((A·B)̄)̄ = A·B
- OR gate (或门): Use De Morgan’s Law: A + B = (Ā · B̄)̄. Use NAND gates to create NOT A and NOT B, then feed both into a NAND gate.
To build NOT A using a NAND gate, tie both inputs together: both inputs are A, so the output is NOT (A·A) = NOT A. To build a two-input AND gate, take a NAND gate and feed its output into a second NAND gate with both inputs tied together (acting as a NOT).
要使用NAND门构建非门,将两个输入端连接在一起:两个输入都是A,输出为NOT (A·A) = NOT A。要构建两输入与门,取一个NAND门并将其输出馈送到第二个两端连接在一起的NAND门(充当非门)。
NOT A = (A·A)̄ | AND: A·B = ((A·B)̄)̄ | OR: A+B = (Ā·B̄)̄
In exam questions, you may be asked to redesign a circuit using only NAND gates. Start by drawing the original circuit, then replace each gate with its NAND-only equivalent.
在考题中,你可能被要求仅使用NAND门重新设计电路。首先画出原始电路,然后用仅含NAND的等效电路替换每个门。
9. Common Exam Pitfalls and Tips | 常见考试陷阱与技巧
Many students lose marks not because they don’t understand logic gates, but because of careless mistakes in notation, order, or missing steps. Below are the most common pitfalls and how to avoid them.
许多学生丢分不是因为不懂逻辑门,而是因为符号、顺序或步骤缺失方面的粗心错误。以下是最常见的陷阱及如何避免。
- Forgetting the bar in NAND/NOR (忘记NAND/NOR上的横线): Always check whether the output is inverted by looking for the bubble on the gate symbol.
- Incorrect order of operations (运算顺序错误): Evaluate NOT first, then AND, then OR. Use brackets when unsure.
- Incomplete truth tables (真值表不完整): Always list rows in binary order (000, 001, 010, 011, …) to ensure no combination is missed.
- Misreading gate symbols (误读门符号): Distinguish between AND (flat side) and OR (curved side); look for the bubble for NOT.
- Skipping intermediate columns (省略中间列): Show your working. Partial marks are awarded even if the final output column contains an error.
Another useful tip: draw a vertical line between input columns and output columns in your truth table. This makes the table easier to read and reduces the chance of misalignment.
另一个有用的技巧:在真值表的输入列和输出列之间画一条竖线。这使表格更容易阅读,并减少对不齐的可能性。
10. Worked Exam Style Question | 考试风格例题精解
Let us work through a complete exam-style question from start to finish, demonstrating the full process expected by examiners.
让我们从头到尾完成一道完整的考试风格题目,展示考官期望的完整过程。
Question (题目): A greenhouse automated watering system has three sensors: soil moisture (M), sunlight (L), and temperature (T). The water pump (P) turns on when: (i) soil is dry (M = 1) AND temperature is high (T = 1); OR (ii) soil is dry (M = 1) AND sunlight is low (L = 0). Write down the Boolean expression, construct the truth table, and draw the logic circuit.
题目:温室自动浇水系统有三个传感器:土壤湿度(M)、光照(L)和温度(T)。水泵(P)在以下情况开启:(i)土壤干燥(M=1)且温度高(T=1);或(ii)土壤干燥(M=1)且光照低(L=0)。写出布尔表达式,构建真值表,并画出逻辑电路。
Solution (解答):
Step 1 (第一步): Variable definitions. M = 1 means dry soil, T = 1 means high temperature, L = 0 means low sunlight, P = 1 means pump ON.
Step 2 (第二步): From condition (i), we have M · T. From condition (ii), L = 0 means NOT L = L̄, so we have M · L̄.
Step 3 (第三步): Combine with OR: P = M·T + M·L̄. This can be simplified to P = M·(T + L̄) by factoring out M.
P = M·T + M·L̄ = M·(T + L̄)
Step 4 (第四步): Truth table with intermediate column M·T:
| M | T | L | L̄ | M·T | M·L̄ | P = M·T + M·L̄ |
| 0 | 0 | 0 | 1 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 | 0 | 0 | 0 |
| 1 | 0 | 0 | 1 | 0 | 1 | 1 |
| 1 | 0 | 1 | 0 | 0 | 0 | 0 |
| 1 | 更多咨询请联系16621398022(同微信)
CommentsMore posts |
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导