A digital system works with only two values, 0 and 1. Inside a computer, small circuits called logic gates follow simple rules to make decisions and do calculations. In this chapter you will learn about the six basic logic gates — AND, OR, NOT, NAND, NOR and XOR — and their truth tables.
A digital system works with digital signals. A digital signal has only two values: 0, which means off or low, and 1, which means on or high. This is different from an analogue signal, which can have any value in a range, like the volume of a sound. Computers are digital systems because their circuits can easily tell the difference between on and off. All the work a computer does — calculations, decisions and memory — is done with these two values.
A logic gate is a small electronic circuit that takes one or more binary inputs and gives one binary output. The output follows a fixed rule. For example, an AND gate gives 1 only when all its inputs are 1. Logic gates are the building blocks of a computer: by joining many gates together, we can build adders that add numbers, memory that stores data, and the processor that runs programs.
A truth table shows the output of a logic gate for every possible combination of its inputs. For a gate with two inputs, there are four combinations: 0,0; 0,1; 1,0; and 1,1. The AND gate gives output 1 only when both inputs are 1: 0 AND 0 = 0, 0 AND 1 = 0, 1 AND 0 = 0, 1 AND 1 = 1. The OR gate gives output 1 when at least one input is 1: 0 OR 0 = 0, 0 OR 1 = 1, 1 OR 0 = 1, 1 OR 1 = 1. The NOT gate has one input only: it reverses the input, so NOT 0 = 1 and NOT 1 = 0.
NAND means NOT-AND: it gives the opposite of the AND gate. Its truth table is 0 NAND 0 = 1, 0 NAND 1 = 1, 1 NAND 0 = 1, 1 NAND 1 = 0. NOR means NOT-OR: it gives the opposite of the OR gate. Its truth table is 0 NOR 0 = 1, 0 NOR 1 = 0, 1 NOR 0 = 0, 1 NOR 1 = 0. XOR means exclusive OR: it gives output 1 only when the two inputs are different. Its truth table is 0 XOR 0 = 0, 0 XOR 1 = 1, 1 XOR 0 = 1, 1 XOR 1 = 0. NAND and NOR are called universal gates because any other gate can be made using only NAND gates, or only NOR gates.
Boolean algebra is the branch of maths used to work with logic. It uses only two values, true (1) and false (0), and three main operations: AND, OR and NOT. Boolean algebra is named after the mathematician George Boole. It helps engineers design and simplify logic circuits: a circuit that uses fewer gates is cheaper, faster and more reliable. For example, a Boolean expression can show what a whole circuit does without drawing every gate.
Logic gates are used in many parts of a computer. Adders use XOR and AND gates to add binary numbers. Memory circuits use gates to store 0s and 1s. The control unit of a processor uses gates to decide which instruction to run next. Outside computers, logic gates are used in alarms, traffic lights, washing machines and security systems — anywhere a device must make a simple yes-or-no decision based on its inputs.
| Term | Definition |
|---|---|
| Digital System | A system that works with digital signals, which have only two values: 0 (off or low) and 1 (on or high). |
| Digital Signal | A signal that has only two possible values, 0 or 1. Digital computers use binary signals. |
| Logic Gate | A small electronic circuit that takes one or more binary inputs and gives one binary output, following a fixed logical rule. |
| Boolean Logic | A statement or rule that is either true (1) or false (0), used in logic design. |
| Truth Table | A table that shows the output of a logic gate for every possible combination of its inputs. |
| AND Gate | A logic gate that gives output 1 only when both inputs are 1. |
| OR Gate | A logic gate that gives output 1 when at least one input is 1. |
| NOT Gate | A logic gate that gives the opposite of its input: 1 becomes 0 and 0 becomes 1. |
| NAND Gate | A logic gate that gives the opposite of the AND gate: output 0 only when both inputs are 1. |
| NOR Gate | A logic gate that gives the opposite of the OR gate: output 1 only when both inputs are 0. |
| XOR Gate | A logic gate that gives output 1 when its two inputs are different, and output 0 when they are the same. |
1. Which values does a digital system use?
Answer: B — 0 and 1. A digital system uses only two values, 0 and 1.
2. What is the output of an AND gate when both inputs are 1?
Answer: A — 1. The AND gate gives 1 only when both inputs are 1, so 1 AND 1 = 1.
3. What is the output of an AND gate when the inputs are 1 and 0?
Answer: A — 0. The AND gate gives 1 only when both inputs are 1, so 1 AND 0 = 0.
4. What is the output of an OR gate when the inputs are 1 and 0?
Answer: B — 1. The OR gate gives 1 when at least one input is 1, so 1 OR 0 = 1.
5. What is the output of a NOT gate when the input is 0?
Answer: B — 1. The NOT gate reverses its input, so NOT 0 = 1.
6. What is the output of a NAND gate when both inputs are 1?
Answer: A — 0. NAND is the opposite of AND. AND of 1 and 1 is 1, so NAND gives 0.
7. What is the output of a NOR gate when the inputs are 1 and 0?
Answer: A — 0. NOR is the opposite of OR. OR of 1 and 0 is 1, so NOR gives 0.
8. What is the output of an XOR gate when the inputs are 1 and 0?
Answer: B — 1. XOR gives 1 only when the inputs are different, and 1 and 0 are different.
9. What is the output of an XOR gate when both inputs are 1?
Answer: B — 0. XOR gives 0 when the inputs are the same, and 1 and 1 are the same.
10. Which gates are called universal gates?
Answer: B — NAND and NOR. NAND and NOR are universal gates because any other gate can be built from them.
1. Define a logic gate.
A logic gate is a small electronic circuit that takes one or more binary inputs and gives one binary output. The output follows a fixed rule, such as AND or OR. Logic gates are the building blocks of computer circuits.
2. Write the truth table of the AND gate.
The AND gate gives output 1 only when both inputs are 1. Its truth table is: 0 AND 0 = 0, 0 AND 1 = 0, 1 AND 0 = 0, and 1 AND 1 = 1. For example, a machine that starts only when two switches are both on uses AND logic.
3. Write the truth table of the OR gate.
The OR gate gives output 1 when at least one input is 1. Its truth table is: 0 OR 0 = 0, 0 OR 1 = 1, 1 OR 0 = 1, and 1 OR 1 = 1. For example, a light that turns on when either of two switches is pressed uses OR logic.
4. Write the truth table of the XOR gate.
The XOR gate gives output 1 only when its two inputs are different. Its truth table is: 0 XOR 0 = 0, 0 XOR 1 = 1, 1 XOR 0 = 1, and 1 XOR 1 = 0. It is used in adders to add binary numbers.
5. What is the difference between NAND and NOR gates?
NAND is the opposite of AND: it gives 0 only when both inputs are 1, and 1 in all other cases. NOR is the opposite of OR: it gives 1 only when both inputs are 0, and 0 in all other cases. NAND and NOR are called universal gates because any other gate can be built from them.
Digital systems work with only two values, 0 and 1. A logic gate is a small circuit that takes binary inputs and gives a binary output by a fixed rule. The AND gate gives 1 only when both inputs are 1, the OR gate gives 1 when at least one input is 1, and the NOT gate reverses its input. NAND is the opposite of AND, NOR is the opposite of OR, and XOR gives 1 only when the inputs are different. Boolean algebra is the maths behind logic design, and gates are used in adders, memory and processors.