Skip to content · ⁨ข้ามไปยังเนื้อหา⁩

Boolean logic · ⁨ตรรกะบูลีน⁩

IGCSE Computer Science · ⁨Computer Science IGCSE⁩ · Topic 10 · ⁨หัวข้อ 10⁩

Video lesson for this topic · ⁨บทเรียนวิดีโอสำหรับหัวข้อนี้⁩ Open the video page · ⁨เปิดหน้าวิดีโอ⁩
8:37

ตรรกะ布尔 (Boolean Logic)

ดูชิปนี้ใกล้ๆ ไม่มีความฉลาดอะไร bênใน มันไม่สามารถคิดได้ ภายในมีสวิตช์ขนาดเล็กนับล้าน และแต่ละสวิตช์สามารถเป็นเพียงสองอย่าง…

English narration · English + 中文 subtitles burned in · ⁨การบรรยายภาษาอังกฤษ · คำบรรยายภาษาอังกฤษ + 中文 ลอยตัวบนภาพ⁩

Syllabus · ⁨หลักสูตร⁩
English
Candidates should be able to: Notes and guidance
1 Identify and use the standard symbols for logic gates • See section 4 for logic gate symbols
2 Define and understand the functions of logic gates • Including: – NOT – AND – OR – NAND – NOR – XOR (EOR) – the binary output produced from all the possible binary inputs • NOT is a single input gate • All other gates are limited to two inputs
3 (a) Use logic gates to create given logic circuits from a: (i) problem statement (ii) logic expression (iii) truth table (b) Complete a truth table from a: (i) problem statement (ii) logic expression (iii) logic circuit • Circuits must be drawn for the statement given, without simplification • Logic circuits will be limited to a maximum of three inputs and one output • An example truth table with three inputs, for completion: A B C Output | 0 0 0 | 0 0 1 | 0 1 0 | 0 1 1 | 1 0 0 | 1 0 1 | 1 1 0 | 1 1 1
(c) Write a logic expression from a: (i) problem statement (ii) logic circuit (iii) truth table
ไทย
ผู้เข้าสอบควรสามารถ: หมายเหตุและคำแนะนำ
1 ระบุและใช้สัญลักษณ์มาตรฐานสำหรับ เกตตรรกะ • ดูส่วนที่ 4 สำหรับสัญลักษณ์เกตตรรกะ
2 นิยามและเข้าใจหน้าที่ของ เกตตรรกะ • รวมถึง: – NOT – AND – OR – NAND – NOR – XOR (EOR) •เอาต์พุตแบบไบนารีที่เกิดขึ้นจากอินพุตแบบไบนerseyที่เป็นไปได้ทั้งหมด • NOT เป็นเกตที่มีอินพุตเดียว • เกตอื่นๆ ถูกจำกัดให้อินพุตได้เพียงสองเท่านั้น
3 (a) ใช้เกตตรรกะเพื่อสร้าง วงจรตรรกะ ที่กำหนดให้ จาก: (i) บทปัญหา (ii)-expression ตรรกะ (iii) ตารางความจริง (b) เติม ตารางความจริง จาก: (i) บทปัญหา (ii) expression ตรรกะ (iii) วงจรตรรกะ • ต้องวาดวงจรตามบทปัญหาที่กำหนด โดยไม่ทำการลดรูป • วงจรตรรกะจะถูกจำกัดให้อินพุตสูงสุดสามอินพุตและเอาต์พุตหนึ่งเอาต์พุต • ตัวอย่างตารางความจริงที่มีสามอินพุตสำหรับการเติม: A B C Output | 0 0 0 | 0 0 1 | 0 1 0 | 0 1 1 | 1 0 0 | 1 0 1 | 1 1 0 | 1 1 1
(c) เขียน expression ตรรกะ จาก: (i) บทปัญหา (ii) วงจรตรรกะ (iii) ตารางจริง

Source: Cambridge International syllabus · ⁨แหล่งที่มา: หลักสูตร Cambridge International⁩

10.1

What is Boolean logic? · ⁨บูลีนลอจิกคืออะไร?⁩

English

Boolean logic 布尔逻辑 works with values that are either true or false. In electronics these are shown as 1 (true) and 0 (false). A logic gate 逻辑门 takes one or more of these inputs and gives one output, following a fixed rule.

A truth table 真值表 lists every possible set of inputs and the output for each. You build it by writing out all the input combinations.

ไทย

布尔 logic ทำงานกับค่าที่เป็น true หรือ false เท่านั้น ในอิเล็กทรอนิกส์จะแทนด้วย 1 (true) และ 0 (false) Logic gate รับอินพุตหนึ่งหรือมากกว่าแล้วส่งเอาต์พุตออกมาหนึ่งตามกฎที่กำหนดไว้

Truth table รวบรวมชุดอินพุตที่เป็นไปได้ทั้งหมดพร้อมเอาต์พุตสำหรับแต่ละชุด สร้างได้โดยการเขียนออกมารวมทุกชุดของอินพุต

วงจรอิเล็กทรอนิกส์ที่สร้างบนบอร์ดทดลอง
Logic gates ถูกสร้างจากวงจรอิเล็กทรอนิกส์เช่นวงจรรอบนี้ ซึ่งแต่ละ gate จะสวิตช์เปิด 1s และ 0s
Vocabulary · ⁨คำศัพท์⁩ Train · ⁨ฝึกฝน⁩
English ไทย
Boolean logic/ˈbuːlɪən ˈlɒdʒɪk/ ตรรกะบูลีน
logic gate/ˈlɒdʒɪk ɡeɪt/ เกตลอจิก
truth table/truːθ ˈteɪbl/ ตารางความจริง
10.2

The six logic gates · ⁨Logic gates ทั้งหกชนิด⁩

English
A logic circuit in action: the half adder

You must know six gates. NOT has one input; all the others have two inputs (A and B).

NOT gate

The NOT gate 非门 reverses the input. Output is 1 when the input is 0.

A Output
0 1
1 0

AND gate

The AND gate 与门 gives output 1 only when both inputs are 1.

A B Output
0 0 0
0 1 0
1 0 0
1 1 1

OR gate

The OR gate 或门 gives output 1 when at least one input is 1.

A B Output
0 0 0
0 1 1
1 0 1
1 1 1

NAND gate

The NAND gate 与非门 is AND followed by NOT. The output is the opposite of AND.

A B Output
0 0 1
0 1 1
1 0 1
1 1 0

NOR gate

The NOR gate 或非门 is OR followed by NOT. The output is the opposite of OR.

A B Output
0 0 1
0 1 0
1 0 0
1 1 0

XOR gate

The XOR gate 异或门 (exclusive OR) gives output 1 when the inputs are different.

A B Output
0 0 0
0 1 1
1 0 1
1 1 0
ไทย
วงจรลอจิกกำลังทำงาน: Half adder

คุณต้องรู้จักประตูลอจิกหกชนิด. NOT มีอินพุตหนึ่งช่อง; ประตูอื่นๆ ทั้งหมดมีอินพุตสองช่อง (A และ B).

สัญลักษณ์ logic gate ทั้งหก — NOT, AND, OR, NAND, NOR และ XOR — แต่ละอันมีอินพุตที่ระบุชื่อและเอาต์พุตหนึ่ง
Logic gate ทั้งหก จุดกลมเล็กบนเอาต์พุตหมายถึงผลลัพธ์ถูกกลับด้าน (NOT, NAND, NOR)
ชิปคอมพิวเตอร์สีดำสามชิ้นพร้อมขารูโลหะเรียงเป็นแถว แต่ละอันพิมพ์รหัสไว้
ชิปลอจิกจริง: ภายในประกอบด้วยเกตลอจิกเช่นบนหน้า này

NOT gate

NOT gate ทำให้อินพุตกลับด้าน เอาต์พุตจะเป็น 1 เมื่ออินพุตเป็น 0

A Output
0 1
1 0

AND gate

AND gate จะให้เอาต์พุตเป็น 1 ก็ต่อเมื่ออินพุตทั้งสองเป็น 1 เท่านั้น

Truth table ของ AND: มีแค่ 1 AND 1 ถึงจะได้ 1
AND จะให้ผลลัพธ์เป็น 1 เมื่ออินพุตทั้งสองเป็น 1 เท่านั้น
A B Output
0 0 0
0 1 0
1 0 0
1 1 1

OR gate

OR gate จะให้เอาต์พุตเป็น 1 เมื่อ อย่างน้อยหนึ่ง อินพุตเป็น 1

Truth table ของ OR: 0 OR 0 ได้ 0 ส่วนที่เหลือได้ 1
OR ให้ผลลัพธ์ 1 เมื่ออินพุตใดหนึ่งเป็น 1
A B Output
0 0 0
0 1 1
1 0 1
1 1 1

NAND gate

NAND gate คือ AND ตามด้วย NOT เอาต์พุตจะเป็น ตรงข้าม กับ AND

A B Output
0 0 1
0 1 1
1 0 1
1 1 0

NOR gate

NOR gate คือ OR ตามด้วย NOT เอาต์พุตจะเป็น ตรงข้าม กับ OR

A B Output
0 0 1
0 1 0
1 0 0
1 1 0

XOR gate

XOR gate (exclusive OR) จะให้เอาต์พุตเป็น 1 เมื่ออินพุตมีค่า ไม่เหมือนกัน

A B Output
0 0 0
0 1 1
1 0 1
1 1 0
Explore · ⁨สำรวจ⁩

The logic gates · ⁨ประตูตรรกะ⁩

Switch the inputs and pick a gate to see its output — AND, OR, NOT, NAND, NOR, XOR. · ⁨สลับอินพุตและเลือกประตูเพื่อดูเอาต์พุต — AND, OR, NOT, NAND, NOR, XOR⁩

Vocabulary · ⁨คำศัพท์⁩ Train · ⁨ฝึกฝน⁩
English ไทย
NOT gate/nɒt ɡeɪt/ NOT gate
AND gate/ænd ɡeɪt/ AND gate
OR gate/ɔː ɡeɪt/ OR gate
NAND gate/nænd ɡeɪt/ NAND gate
NOR gate/nɔː ɡeɪt/ NOR gate
XOR gate/ˈeksɔː ɡeɪt/ ประตู XOR
10.3

Logic expressions · ⁨Expression ทางลอจิก⁩

English

A logic expression 逻辑表达式 writes a circuit using letters and gate words. The usual way to write the gates:

Gate In words
NOT A NOT A
A AND B A AND B
A OR B A OR B

For example, the expression (A AND B) OR (NOT C) means: do A AND B, do NOT C, then OR the two results together.

ไทย

Logic expression เขียนวงจรโดยใช้ตัวอักษรและคำของ gate วิธีเขียนมาตรฐานของ gate:

Gate In words
NOT A NOT A
A AND B A AND B
A OR B A OR B

ตัวอย่างเช่น-expression (A AND B) OR (NOT C) หมายความว่า: ทำ A AND B, ทำ NOT C, แล้วนำผลลัพธ์ทั้งสองมา OR together

Expression X equals A AND B OR NOT C วาดเป็นวงจร: AND gate รับ A และ B, NOT gate รับ C, และ OR gate รวมสองอย่างนั้นให้เป็นเอาต์พุต X
Expression X = (A AND B) OR (NOT C) วาดเป็นวงจรลอจิก
Explore · ⁨สำรวจ⁩

Truth tables · ⁨ตารางความจริง⁩

Build the truth table for AND, OR, XOR and NOT — the logic behind every expression. · ⁨สร้างตารางความจริงสำหรับ AND, OR, XOR และ NOT — ตรรกะเบื้องหลังทุกนิพจน์⁩

Vocabulary · ⁨คำศัพท์⁩ Train · ⁨ฝึกฝน⁩
English ไทย
logic expression/ˈlɒdʒɪk ekˈspreʃn/ -expression ลอจิก
10.4

Logic circuits · ⁨วงจรตรรกะ⁩

English

A logic circuit 逻辑电路 joins gates together to carry out a task. The output of one gate can become the input of another. At IGCSE a circuit has up to three inputs and one output.

You must be able to move between four forms:

  • a problem statement 问题陈述 (a description in words),
  • a logic expression,
  • a logic circuit,
  • a truth table.

From a problem statement to a circuit

Read the statement and pick out the conditions and the logic words (and, or, not). For example:

An alarm (X) sounds when the door is open (A) AND the system is switched on (B).

This is X = A AND B, so you draw one AND gate with inputs A and B.

Completing a truth table from a circuit or expression

To fill in a truth table:

  1. Write all the input combinations. For three inputs there are 8 rows (000 up to 111).
  2. Work out each gate's output in order, one column at a time.
  3. The last column is the final output.
A B C A AND B (A AND B) OR 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

Adding a middle "working" column for each gate makes the final output easy to fill in. Always draw the circuit exactly as the statement says, without simplifying it.

Worked example. Complete the truth table for X = (A AND B) OR (NOT C) for the row A = 1, B = 0, C = 0. Work outwards from the brackets, one gate at a time. First A AND B = 1 AND 0 = 0, because AND needs both inputs to be 1. Next NOT C = NOT 0 = 1. Finally OR the two results: 0 OR 1 = 1. So X = 1. Give each intermediate gate its own column rather than trying to do the whole expression in one step: with three inputs there are $2^3 = 8$ rows, and those intermediate columns are where the method marks live even if the final answer slips.

ไทย

Logic circuit เชื่อมต่อ gate เข้าด้วยกันเพื่อดำเนินงาน ผลลัพธ์ของ one gate สามารถกลายเป็นอินพุตของอีก gate ได้ ที่ IGCSE วงจรจะมีอินพุตสูงสุด สามตัว และ เอาต์พุตหนึ่งตัว

Logic circuit: AND gate รับอินพุต A และ B ส่งเข้า-INP ของ OR gate ซึ่งมี INP อื่นคือ C ให้เอาต์พุต X
สร้างวงจรสำหรับ X = (A AND B) OR C — เอาต์พุตของ AND gate ส่งเข้า OR gate

คุณต้องสามารถเปลี่ยนระหว่างรูปแบบทั้งสี่นี้ได้:

  • Problem statement (คำอธิบายเป็นข้อความ)
  • Logic expression,
  • Logic circuit,
  • Truth table.

จาก Problem statement ไปยัง Circuit

อ่านข้อความแล้วดึงเงื่อนไขและคำทางลอจิก (and, or, not) ออกมา ตัวอย่างเช่น:

Alarm (X) จะดังเมื่อประตูเปิด (A) AND ระบบเปิดอยู่ (B)

นี่คือ X = A AND B ดังนั้นคุณวาด AND gate ตัวหนึ่งที่มีอินพุต A และ B

เติมเต็ม Truth table จาก Circuit หรือ Expression

ในการเติม truth table:

  1. เขียน ทุก ชุดของอินพุต สำหรับสามอินพุตจะมี 8 บรรทัด (000 ถึง 111)
  2. คำนวณเอาต์พุตของแต่ละ gate按照顺序, คอลัมน์ละหนึ่งคอลัมน์
  3. คอลัมน์สุดท้ายคือเอาต์พุตสุดท้าย
สามอินพุตให้ 2 x 2 x 2 เท่ากับแปดบรรทัด; ชุดข้อมูลแปดชุดเรียงตามการนับแบบไบนารีจาก 000 ถึง 111 โดยคอลัมน์สุดท้ายสลับทุกบรรทัด
สามอินพุตให้แปดบรรทัด: ทุกชุดข้อมูลที่นับด้วยระบบไบนารี
A B C A AND B (A AND B) OR 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

การเพิ่มคอลัมน์ "Working" กลางสำหรับแต่ละ gate จะทำให้การเติมเอาต์พุตสุดท้ายทำได้ง่ายขึ้นเสมอวาดวงจรให้ตรงกับข้อความที่บอกเป๊ะๆ โดยไม่ลดรูป

ตัวอย่างทำข้อ. เติมตารางความจริงสำหรับ X = (A AND B) OR (NOT C) สำหรับแถว A = 1, B = 0, C = 0. ทำ จากวงเล็บออกไปด้านนอก ก้อนหนึ่งต่อหนึ่ง ก่อนอื่น A AND B = 1 AND 0 = 0 เพราะ AND ต้องมีอินพุตทั้งสองเป็น 1 ต่อมา NOT C = NOT 0 = 1. สุดท้ายนำผลลัพธ์ทั้งสองมา OR กัน: 0 OR 1 = 1. ดังนั้น X = 1. ให้แต่ละ gates ระหว่างกลางมี คอลัมน์ของตัวเอง แทนที่จะพยายามคำนวณทั้ง-expression ในขั้นตอนเดียว: เมื่อมีอินพุตสามตัวจะมี $2^3 = 8$ แถว และคอลัมน์ระหว่างกลางเหล่านั้นคือจุดที่วิธีการทำงานอยู่ แม้คำตอบสุดท้ายจะผิดพลาดก็ตาม

Vocabulary · ⁨คำศัพท์⁩ Train · ⁨ฝึกฝน⁩
English ไทย
logic circuit/ˈlɒdʒɪk ˈsɜːkɪt/ วงจรลอจิก
problem statement/ˈprɒbləm ˈsteɪtmənt/ คำอธิบายปัญหา
10.5

Exam tips · ⁨ข้อแนะนำสำหรับการสอบ⁩

English
  • Learn all six gates and their truth tables: NOT, AND, OR, NAND (NOT AND), NOR (NOT OR), XOR (output 1 when the inputs are different).
  • Build a truth table with all input rows (2 inputs → 4 rows, 3 inputs → 8), counting up in binary, and add a working column for each gate.
  • Turn a problem statement into a logic expression by picking out the AND / OR / NOT words, then draw it exactly as written — do not simplify it.
  • NAND and NOR give the opposite output to AND and OR; a small circle on a gate's output means the result is inverted.
ไทย
  • เรียนรู้ gates ทั้งหกและตารางความจริงของพวกมัน: NOT, AND, OR, NAND (NOT AND), NOR (NOT OR), XOR (เอาต์พุตเป็น 1 เมื่ออินพุตต่างกัน)
  • สร้างตารางความจริงด้วย แถว อินพุตทั้งหมด (2 อินพุต → 4 แถว, 3 อินพุต → 8), นับขึ้นแบบเลขฐานสอง และเพิ่มคอลัมน์การคำนวณสำหรับแต่ละ gate
  • แปลงโจทย์ปัญหาให้เป็นนิพจน์ตรรกศาสตร์โดยการดึงคำ AND / OR / NOT ออกมา แล้ววาดออกมาตามต้นฉบับอย่างชัดเจน — ห้ามลดรูป
  • NAND และ NOR ให้เอาต์พุตที่ ตรงกันข้าม กับ AND และ OR; วงกลมเล็กที่เอาต์พุตของ gate หมายความว่าผลลัพธ์ถูกกลับค่า

Interactive lessons on this topic · ⁨บทเรียนเชิงโต้ตอบสำหรับหัวข้อนี้⁩

Work through it step by step, with instant-check exercises. · ⁨ทำทีละขั้นตอน พร้อมแบบฝึกหัดตรวจสอบผลทันที⁩

Past Papers · ⁨ข้อสอบย้อนหลัง⁩

More topics in IGCSE Computer Science · ⁨Computer Science IGCSE⁩ · ⁨หัวข้อเพิ่มเติมใน IGCSE Computer Science · ⁨Computer Science IGCSE⁩⁩

Log in or create account · ⁨เข้าสู่ระบบหรือสร้างบัญชี⁩

IGCSE, A-Level & AP