A1.2.3 · Computer fundamentals
A1.2.3 · 计算机基础
The Purpose and Use of Logic Gates
逻辑门的目的与用途
A logic gate is the smallest decision a computer can make in hardware: one or two binary inputs go in, a fixed rule is applied, one binary output comes out. Every calculation and every stored bit is built from these.
逻辑门是计算机在硬件层面能做的最小决定:一个或两个二进制输入进来,应用一条固定的规则,一个二进制输出出去。每一次计算和每一个被存储的位,都是由它们搭出来的。
A1's guiding question asks what principles underpin how a computer works, from low-level hardware upward. Logic gates are that lowest level: physical Boolean algebra, where 1 means true or on and 0 means false or off.
A1 的引导性问题问的是从底层硬件往上支撑计算机运行的原理。逻辑门就是那个最底层:物理化的布尔代数,其中 1 表示真或开,0 表示假或关。
Explainer
讲解
What a logic gate is
逻辑门是什么
A logic gate is a small circuit, built from transistors acting as switches, that takes one or two binary inputs and produces one binary output by a fixed Boolean rule. In gate work, 1 means true or on and 0 means false or off.
逻辑门是一个小电路,由充当开关的晶体管搭成,它接收一个或两个二进制输入,并按一条固定的布尔规则产生一个二进制输出。在门电路里,1 表示真或开,0 表示假或关。
The word "gate" is the useful image: like a physical gate that lets people through or holds them back, a logic gate lets a 1 through or blocks it, depending on the other input and on the rule the gate follows.
"门"这个词是个有用的比喻:就像一扇实体的门,让人通过或把人挡住,逻辑门也让一个 1 通过或把它挡下,取决于另一个输入以及这个门所遵循的规则。
Explore
探索
The seven gates
七种门
Three are basic (AND, OR, NOT); the other four are built by adding a NOT to a basic gate. Click each to see its standard symbol, its rule, its truth table and one place it is used.
三种是基本门(AND、OR、NOT);另外四种是在基本门后面加一个 NOT 得到的。点击每一个,看它的标准符号、规则、真值表,以及一个使用它的地方。
Explainer
讲解
Their role in binary computing
它们在二进制计算中的作用
| Job in a computer | How gates do it |
|---|---|
| Arithmetic | Inside the ALU, AND, OR and XOR gates are wired into adder circuits that add two binary numbers. Subtraction, multiplication and division are built on top of addition |
| Decision making | An AND gate outputs 1 only when all inputs are 1, which is the hardware form of "if every condition is met". Combining gates builds the conditions behind if and switch statements |
| Memory | A few gates wired in a loop (a flip-flop) hold a stable 0 or 1 until told to change. Scaled up, this becomes registers and RAM |
| Control and signalling | Gates process inputs from sensors and buttons in alarm systems, automatic doors, lifts, traffic lights and communication hardware, turning input combinations into the right response |
| 在计算机中的任务 | 门如何完成它 |
|---|---|
| 算术 | 在 ALU 内部,AND、OR 和 XOR 门被连成加法器电路,用来把两个二进制数相加。减法、乘法和除法都建立在加法之上 |
| 做决定 | 只有当所有输入都为 1 时,AND 门才输出 1,这是"如果每个条件都满足"的硬件形式。组合各种门就搭出了 if 和 switch 语句背后的条件 |
| 存储 | 几个门连成一个回路(触发器),会稳定地保持 0 或 1,直到被告知改变。放大后就成了寄存器和 RAM |
| 控制与信号 | 在报警系统、自动门、电梯、交通灯和通信硬件中,门处理来自传感器和按钮的输入,把输入的组合变成正确的响应 |
A door on a train opens only when the train is stopped AND the button is pressed AND the doors are enabled by the driver. That is a three-input AND gate: the output (unlock) is 1 only when all three inputs are 1.
火车上的车门只有在列车已停稳、并且按钮被按下、并且司机已启用车门时才打开。这就是一个三输入的 AND 门:只有当三个输入都为 1 时,输出(解锁)才为 1。
Check your understanding
检验你的理解
Both inputs to a NAND gate are 1. What is the output?
一个 NAND 门的两个输入都是 1。输出是多少?
Common mistake
常见错误
RecurringTreating OR and XOR as the same because both give 1 when one input is 1. They differ on one row: when both inputs are 1, OR outputs 1 (at least one is on) but XOR outputs 0 (they are not different). "OR" means at least one; "XOR" means exactly one. The same trap sits between NOR and XNOR. Always check the both-inputs-1 row.
反复出现因为 OR 和 XOR 在一个输入为 1 时都给出 1,就当它们一样。它们只在一行不同:当两个输入都为 1 时,OR 输出 1(至少有一个开),但 XOR 输出 0(它们并不不同)。"OR"意思是至少一个;"XOR"意思是恰好一个。NOR 和 XNOR 之间也有同样的陷阱。永远检查"两个输入都为 1"这一行。
Wrong: "An OR gate and an XOR gate both output 1 when an input is 1, so a circuit can use either one."
错误: "OR 门和 XOR 门在有输入为 1 时都输出 1,所以电路里用哪个都行。"
Right: "OR gives 1 whenever one or both inputs are 1, so the both-1 row is also a 1. XOR gives 1 for exactly one input at 1, so the both-1 row is a 0. The two gates match on three rows and split on the fourth."
正确: "OR 在至少一个输入为 1 时输出 1,包括两个都为 1 时。XOR 只有在恰好一个输入为 1 时输出 1,两个都为 1 时输出 0。它们在三行上一致,在第四行上不同。"
Revision questions
复习题
Specimen-paper style. Write an answer, then reveal the marking points and mark yourself.
采用样卷风格。写下答案,然后展开评分要点给自己打分。
[2]State the output of an AND gate and of an OR gate when both inputs are 0.
[2]写出当两个输入都为 0 时,AND 门和 OR 门的输出。
[2]Describe the difference in output between a NAND gate and an AND gate.
[2]描述 NAND 门与 AND 门在输出上的区别。
Marking points
评分要点
- A NAND gate outputs the opposite of an AND gate for every input combination.
- So a NAND gate outputs 0 only when both inputs are 1, and outputs 1 for all other combinations; an AND gate outputs 1 only when both inputs are 1.
- 对每一种输入组合,NAND 门的输出都与 AND 门相反。
- 所以只有当两个输入都为 1 时 NAND 门才输出 0,其他组合都输出 1;而 AND 门只有当两个输入都为 1 时才输出 1。
[3]Describe two uses of logic gates within a computer system.
[3]描述逻辑门在计算机系统中的两种用途。
Marking points
评分要点
- Any two: in the ALU, gates are wired into adder circuits to carry out binary arithmetic; combinations of gates form the conditions behind decision-making (if and switch); gates in a feedback loop (a flip-flop) hold a stable bit, which scaled up becomes registers and RAM; gates process sensor and button inputs in control hardware such as alarms and traffic lights.
- 任选两点:在 ALU 中,门被连成加法器电路来进行二进制算术;门的组合构成决策(if 和 switch)背后的条件;带反馈回路的门(触发器)保持一个稳定的位,放大后成为寄存器和 RAM;在报警器、交通灯等控制硬件中,门处理传感器和按钮的输入。
[3]Explain how logic gates allow a computer to carry out decision making in hardware.
[3]解释逻辑门如何让计算机在硬件层面进行决策。
Marking points
评分要点
- An AND gate outputs 1 only when all of its inputs are 1, which is the hardware form of only if every condition is met.
- By combining gates, a circuit can test any combination of conditions and produce a 1 or 0 output, and that output can then control what the hardware does.
- This is how if statements and switch statements are carried out at the level of the circuits.
- 只有当所有输入都为 1 时,AND 门才输出 1,这是“只有每个条件都满足时”的硬件形式。
- 通过组合各种门,一个电路可以检验条件的任意组合,产生 1 或 0 的输出,而这个输出随后可以控制硬件做什么。
- 这就是 if 语句和 switch 语句在电路层面被执行的方式。
[2]A student says an XNOR gate outputs 1 whenever an XOR gate outputs 0. State whether this is correct and justify your answer.
[2]一名学生说,只要 XOR 门输出 0,XNOR 门就输出 1。说明这是否正确并给出理由。
Marking points
评分要点
- Correct.
- An XNOR gate outputs 1 exactly when the two inputs are the same, and an XOR gate outputs 1 exactly when they are different.
- So on every row, XNOR is the opposite of XOR: XNOR outputs 1 whenever XOR outputs 0.
- 正确。
- XNOR 门恰好在两个输入相同时输出 1,XOR 门恰好在它们不同时输出 1。
- 所以在每一行,XNOR 都是 XOR 的相反:只要 XOR 输出 0,XNOR 就输出 1。
Flashcards
记忆卡片
Active recall for this statement’s key terms.
针对本条考纲陈述关键术语的主动回忆练习。
Keep this statement’s practice with you
把这条考纲陈述的练习保存下来
Free account: unlock every revision question and flashcard for A1.2.3, and every other IB CS 2027 statement.
免费账户:解锁 A1.2.3 以及所有其他 IB CS 2027 考纲陈述的全部复习题和记忆卡片。