Digital Logic · AI215

Logic Gates: AND, OR, NOT, NAND, NOR, XOR and Universal Gates

Digital Logic Study guides

Logic gates are the basic building blocks of digital circuits. NAND and NOR are universal gates because any logic function can be built from either one alone.

AND outputs 1 only when all inputs are 1 (a 3-input AND is high only for input 111). OR outputs 1 when at least one input is 1. NOT (inverter) outputs the opposite of its single input. NAND is AND followed by NOT: output 0 only when all inputs are 1. NOR is OR followed by NOT: output 1 only when all inputs are 0. XOR outputs 1 when an odd number of inputs are 1 (for two inputs: when the inputs differ); XNOR is its complement and outputs 1 when the inputs are equal.

A universal gate can implement every other gate. NOT from NAND: tie the inputs together. AND from NAND: NAND followed by a NAND used as an inverter. OR from NAND: invert each input with a NAND, then NAND the results (De Morgan). NOR works the same way with the roles swapped. That is why real chips are often built from only NAND or only NOR.

A gate with n inputs has 2^n input combinations; a 3-input gate has 8. Counting gates for a function such as Y = AB + CD + EF + G: every product term with two or more literals needs its own AND gate (AB, CD, EF: three AND gates), the single literal G goes straight to the OR gate, and a 4-input OR gate combines the four terms.

Key points

  • AND: all 1s. OR: any 1. NOT: inverts.
  • NAND = NOT(AND). NOR = NOT(OR).
  • XOR: 1 when an odd number of inputs are 1 (two inputs differ).
  • NAND and NOR are universal gates.
  • n inputs give 2^n input combinations.

Worked example

For A = 1, B = 0: AND = 0, OR = 1, NAND = 1, NOR = 0, XOR = 1, XNOR = 0.

Common questions

Which gates are universal?

NAND and NOR.

How many input combinations does a 3-input gate have?

8, since 2^3 = 8.

Practice questions on this topic

Try these, then open the app to check your answers with explanations.

  1. The output of an OR gate with three inputs, A, B, and C, is low when
    • A. A=0, B=0, C=0
    • B. A=0, B=0, C=1
    • C. A=0, B=1, C=1
    • D. A=1, B=1, C=1
  2. The output of an AND gate with three inputs, A, B, and C, is high when.....
    • A. A=1, B=1, C=0
    • B. A=0, B=0, C=0
    • C. A=1, B=1, C=1
    • D. A=0, B=0, C=1
  3. The output of a NOR gate is high if
    • A. all input is high
    • B. all input is low
    • C. any input is high
    • D. any input is low
  4. The output of a NAND gate is low if
    • A. all input is high
    • B. all input is low
    • C. any input is high
    • D. any input is low
  5. Mention basic logic gates?
    • A. AND,XOR,NOT
    • B. AND,OR,NOT
    • C. XOR,OR,NOT
    • D. AND,OR,NAND
  6. Function of gates can be described by ?
    • A. Truth table
    • B. Boolean function
    • C. Karnaugh map
    • D. all of above