2.1.11 Define the Boolean operators: AND, OR, NOT, NAND, NOR and XOR

  • DISCLAIMER: the IB requests the logic gates to be represented as circles containing the operator inside, not the complicated sign
  • true = 1
  • false = 0

AND

  • Both inputs are true
    How-Logic-Gates-Work-3.gif
    Logic Gate Symbols
  • a AND b are true

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

OR

  • One input at least is true

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

NOT

  • input is not true
  • only one input
  • converse of input is the output

Input A
Output
0
1
1
0

NAND

  • the inputs are not both true (not AND)

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

NOR

  • not input A (n)or input B are true

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

XOR

  • only one input can be true, not both


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

How do logic gates work?


  1. Identify the inputs.
  2. Sketch a truth table.
  3. Enter the inputs and all possible combinations of 0s and 1s. The total number of combinations is 2 to the power of n, where n is the total number of inputs.
  4. In the following columns write the logic operators and how it combines the inputs.
  5. Use the previous columns filled to identify the new combination of 0s and 1s applying the concepts of the logic operators listed above.
  6. Continue until all gates are passed and the output is detected.


How to: Logic Diagram

  • Identify the inputs. Right them on the left side.
  • Read the description. Identify the operators and in which way they are combined.
    • For example (see example 1):
      • (NOT A) and (A AND B) are the first to draw
      • These outputs are then combined through (OR)
      • NOT (A AND B) - this means to negate one of the first outputs
      • Combine that through the us of OR with the other output to reach the final output.
  • Step by step combine the operators until a final output is reached.

How to: Logic Tables
  • Write all possible combinations for the inputs.
    • use 2 to the power of n, where n is the number of inputs to find how many combinations are possible
  • Identify the first operation
  • Use the inputs to complete the first operation according to the instructions given by the operation
    • e.g. NOT A is the inverse of the input A
  • Identify the next relevant operation and use the previously constructed columns to fill in the new column.
  • Repeat until the final output is reached.

e.g. (A AND B) NAND (NOT A)

Consider the inputs A & B

Input A
Input B
0
0
0
1
1
0
1
1

Combine them using AND

A AND B
0 + 0 = 0
0 + 1 = 0
1 + 0 = 0
1 + 1 = 1

Negate A (NOT A)

Input A
NOT A (Inverse)
0
1
0
1
1
0
1
0

Combine (NOT A) NAND (A AND B)

A AND B
NOT A
Output
0
1
1
0
1
1
0
0
1
1
0
1

Logic gates are important in real life, as they can be used in circuits and programs. For example, lets take the example and see where it would be applicable in real life. These could be logic gates regulating whether too much pollution is caused and a warning alarm should be let off.


Example 1: ((NOT A) OR (A AND B)) OR (NOT(A AND B))

logic gate.jpg


Input A
Input B
NOT A
A AND B
D = (NOT A) OR (A AND B)
E = NOT (A AND B)
D OR E = Output C
0
0
1
0
1
1
1
0
1
1
0
1
1
1
1
0
0
0
0
1
1
1
1
0
1
1
0
1


Example 2: ((A OR C) NOR (A AND B)) NAND (B XOR C)

Example 2.jpg

Input A
Input B
Input C
A OR C
A AND B
(A OR C) NOR (A AND B)
B XOR C
NAND
0
0
0
0
0
1
0
1
0
0
1
1
0
0
1
1
0
1
0
0
0
1
1
0
0
1
1
1
0
0
0
1
1
0
0
1
0
0
0
1
1
0
1
1
0
0
1
1
1
1
0
1
1
0
1
1
1
1
1
1
1
0
0
1

Practice Problem - Real Life Example:

If traffic light A is green (on) traffic light, traffic light C can/must be green too. However, traffic light B can not be green then. Thus, if traffic light B is not on, neither is traffic light D.

Hint:

Input A
Input B
Input C
Input D
A AND C
B AND D
(A AND C) NAND (B AND D)
0
0
0
0
0
0
1
0
0
0
1
0
0
1
0
0
1
0
0
0
1
0
0
1
1
0
0
1
0
1
0
0
0
0
1
0
1
0
1
0
1
1
0
1
1
0
0
0
1
0
1
1
1
0
1
1
1
0
0
0
0
0
1
1
0
0
1
0
0
1
1
0
1
0
1
0
1
1
0
1
1
1
0
1
1
1
0
0
0
0
1
1
1
0
1
0
1
1
1
1
1
0
1
0
1
1
1
1
1
1
1
0


Created By: Lucie Charlotte Magister
Last update: 20/11/2014

Sources: