11.2 Gates

COS2621 - Computer Organisation · 11. Digital Logic

Gates

Introduction to Logic Gates

Logic gates are the building blocks of digital circuits. They perform basic logical functions essential for digital operations. The most common types of gates are AND, OR, NOT, NAND, NOR, XOR, and XNOR.

AND Gate

An AND gate outputs true (1) only if all its inputs are true (1). The symbol for an AND gate resembles a flat-ended shape. The truth table for a two-input AND gate is as follows:

ABOutput (A AND B)
000
010
100
111

For example, if A = 1 and B = 1, then the output is 1. If A = 1 and B = 0, the output is 0.

Watch out: Remember that the output of an AND gate is only true when all inputs are true.

OR Gate

An OR gate outputs true (1) if at least one of its inputs is true (1). The symbol for an OR gate has a curved end. The truth table for a two-input OR gate is:

ABOutput (A OR B)
000
011
101
111

For instance, if A = 0 and B = 1, then the output is 1.

NOT Gate

A NOT gate, also known as an inverter, outputs the opposite value of its input. The symbol for a NOT gate is a triangle pointing to a small circle. The truth table is:

AOutput (NOT A)
01
10

If A = 1, the output will be 0.

NAND and NOR Gates

A NAND gate is the opposite of an AND gate. It outputs false (0) only if all its inputs are true (1). The truth table is:

ABOutput (A NAND B)
001
011
101
110

A NOR gate is the opposite of an OR gate. It outputs true (1) only if all inputs are false (0). The truth table is:

ABOutput (A NOR B)
001
010
100
110

XOR and XNOR Gates

An XOR (exclusive OR) gate outputs true (1) if only one input is true (1). The truth table is:

ABOutput (A XOR B)
000
011
101
110

An XNOR gate is the opposite of an XOR gate. It outputs true (1) if both inputs are the same. The truth table is:

ABOutput (A XNOR B)
001
010
100
111

Summary

  • AND gate: true if all inputs are true.
  • OR gate: true if at least one input is true.
  • NOT gate: inverts the input.
  • NAND gate: true unless all inputs are true.
  • NOR gate: true if all inputs are false.
  • XOR gate: true if inputs are different.
  • XNOR gate: true if inputs are the same.

Check your understanding

  • What is the output of an AND gate with inputs 1 and 0?
  • What does a NOT gate output if the input is 0?
  • When does a NAND gate output true?
  • Which of the following represents an AND gate: z'y', (x + y)', (x'y')', (x' + y)'?

Test yourself

5 quick questions on this lesson. Pick an answer to see if you're right.

  1. 1. Give the result of the following binary operation A AND B, where A = 1010 1101 and B = 0011 1001

  2. 2. What is the difference between XOR and XNOR gates?

  3. 3. What is the output of an AND gate with inputs 1 and 0?

  4. 4. What does a NOT gate output if the input is 0?

  5. 5. When does a NAND gate output true?