Logic Gates

From CDS 130

Jump to: navigation, search

Logic Gates

Contents

  1. Objectives
  2. Motivation
  3. Priming questions
  4. Notes
    1. Overview
    2. Logic Circuits
    3. Logic Tables
    4. Logic circuit analogy
    5. AND Gate
    6. Using an AND gate
    7. Mechanical Analogy
    8. NAND Gate
    9. OR Gate
    10. Combining logic gates
    11. NOR Gate
    12. NOR Gate using NANDs
    13. XOR Gates
  5. Questions
    1. NAND Gates
    2. Logic Gate Combinations
    3. Logic Gate Combinations
    4. Logic Circuits
      1. Part 1
      2. Part 2
    5. Logic Circuits
    6. Logic Circuits
    7. Logic Circuits
    8. Logic Circuits
  6. Activity
    1. Preparation: Using logic.ly
  7. References

1. Objectives

  • Explain what a logic circuit and logic table are
  • Explain how logic circuits can be combined to do more complex calculations and to manipulate binary numbers
  • Be able to explain how electronic switches are used to create simple logic circuits

2. Motivation

  • The next component needed for computing after the transistor is the logic gate.

3. Priming questions

  • Read "Logic Gates Enable Programming Bacteria as Computers" [1]
  • In Transistors, we combined two transistors to form a circuit with two inputs and one output. The logic table will correspond to a logic gate. How many unique logic tables for a gate with two inputs and one output can be created?

4. Notes

4.1. Overview

This video gives a good overview of logic gates.


4.2. Logic Circuits

  • Using transistors, we can create logic gates.
  • Each gate has one output and several inputs.
  • The relationship between the inputs and the output determines the type of gate. This relationship is defined by a logic table.

4.3. Logic Tables

  • Logic tables are used to define the inputs and outputs of logic circuits
  • Each input and output has two possible states
  • We sometimes use
    • 1 or 0
    • true or false
    • on or off
    • high or low
  • All of the above representations are equivalent!

4.4. Logic circuit analogy

  • Previously we used a hydraulic analogy to help understand how a transistor worked.
  • We use a "circuit analogy" to help us understand how a neuron works.
  • An active research area uses everything we know about logic and computers and attempts to use this to help us understand how the brain works using a "computer analogy".

The last panel shows how a neuron can be conceptualized as a logic circuit. On the left-hand side are the inputs (in this class we will mostly deal with circuits that have two inputs). The right-hand side is the output.


From www.doc.ic.ac.uk on June 25 2017 14:55:26.

Sketch of a synapse.

From www.doc.ic.ac.uk on June 25 2017 14:55:26.

Sketch of a neuron.

From www.doc.ic.ac.uk on June 25 2017 14:55:27.

Logic gate analogy of how a neuron works.

4.5. AND Gate

Image:AND_LOGIC_GATE.svg

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


  • The diagram of the AND gate looks like a capital letter D with two "prongs" on the left (the inputs) and one "prong" on the right (the output). The inputs are either 0 (also known as "false") or 1 (also known as "true").
  • If either of the inputs is 0, then the output of the AND gate is 0. Thus, in order to get an AND gate to output 1, both inputs must be 1.
  • The word AND is not an acronym. The word is capitalized to indicated that we mean a logic gate instead of the english word "and".

4.6. Using an AND gate

The following is an screenshot showing a set of four circuits created using Logicly (we'll use this program in class). Note that the on/off switches are "on" when the switch is what we normall call the "off" position for a light switch. (Similar to the operation of the electric chair switch [2]).

Image:andoptions.png


Sorry about the "Demo mode" overlay on the video. I have a licence for the software on a computer that is at the office.

4.7. Mechanical Analogy

Water flows into one, both, or none of the two white tubes at the top. When water is flowing into both inputs, the streams intersect and the "AND" bucket fills up. When water is only flowing though one input, the stream over-shoots the "AND" bucket.

See also [3]. ("XOR = Exclusive OR ")

From upload.wikimedia.org on June 25 2017 14:55:27.

4.8. NAND Gate

All digital logic circuits you need can be built from NAND gates.

NAND stands for "Negated AND". The output of the NAND gate is the negation, or reverse of the output of an AND gate. The negation is symbolized by the small circle on the output. The logic table table for the NAND gate is created by replacing swapping 1s with 0s and 0s with 1s in the output column.

Image:NAND_LOGIC_GATE.svg
Input A Input B Output
0 0 1
0 1 1
1 0 1
1 1 0
Image:AND_LOGIC_GATE.svg
Input A Input B Output
0 0 0
0 1 0
1 0 0
1 1 1

4.9. OR Gate

Image:OR_LOGIC_GATE.svg
Input A Input B Output
0 0 0
0 1 1
1 0 1
1 1 1

If either of the inputs is 1, then the output of the OR gate is 1. Thus, in order to get an OR gate to output 0, both inputs to it must be 0.


This unusual video describes how to create an OR gate in a video game [4].

4.10. Combining logic gates

Logic gates may be combined. In this example, there are four inputs, but we set two of them to always be 1.

Here is an example of combining logic gates to get a logic table. Here there are two inputs (A and B) and one output. Note that this combination of NAND gates gives the same logic table as the OR gate. This means that if you need an OR gate, but only have NAND gates, you can still emulate an OR gate by combining the NAND gates as shown.

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

4.11. NOR Gate

Image:NOR_LOGIC_GATE.svg
Input A Input B Output
0 0 1
0 1 0
1 0 0
1 1 0


NOR stands for "Negated OR". Thus, the output of the NOR gate is the negation, or reverse of the output of an OR gate with the same inputs.

4.12. NOR Gate using NANDs

Verify that this will give the correct logic table for a NOR Gate.

Image:NAND_LOGIC_GATE.svg
Input A Input B Output
0 0 1
0 1 1
1 0 1
1 1 0

4.13. XOR Gates

  • XOR stands for "eXclusive OR". (A.K.A. EOR)
  • An XOR gate will output 1 only if one of the inputs is 1 and the other input 0.
  • If both inputs are the same (1 and 1, or 0 and 0), then XOR outputs 0.

Image:XOR_LOGIC_GATE.svg

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

5. Questions

5.1. NAND Gates

In the image below, two NAND Gates are shown. One of the inputs to each of the NAND gates is set to 1. If B = 0 and A = 0, what will the outputs X andY be?

  1. X = 1, Y = 1
  2. X = 1, Y = 0
  3. X = 0, Y = 1
  4. X = 0, Y = 0

5.2. Logic Gate Combinations

In the image below, four NANDS are connected and three of the inputs are set to1. What are the values of Z and Output if B = 0 and A = 0? For reference, the logic table associated with a NAND gate is shown.

  1. Z = 1, Output = 0
  2. Z = 0, Output = 0
  3. Z = 1, Output = 1
  4. Z = 0, Output = 1

Image:NAND_LOGIC_GATE.svg
Input A Input B Output
0 0 1
0 1 1
1 0 1
1 1 0

5.3. Logic Gate Combinations

In the image below, four NANDS are connected and three of the inputs are set to1. What are the values of Z and Output if B = 1 and A = 0? For reference, the logic table associated with a NAND gate is shown.

  1. Z = 1, Output = 0
  2. Z = 0, Output = 0
  3. Z = 1, Output = 1
  4. Z = 0, Output = 1

Image:NAND_LOGIC_GATE.svg
Input A Input B Output
0 0 1
0 1 1
1 0 1
1 1 0

5.4. Logic Circuits

For the two problems given below, determine the values of W, X, Y and Z.

5.4.1. Part 1

If: A = 0, B = 0, C = 1

  1. W =1, X =1, Y = 0, Z = 1
  2. W =1, X =1, Y = 1, Z = 1
  3. W =1, X =0, Y = 1, Z = 1
  4. W =1, X =0, Y = 1, Z = 0
  5. W =1, X =1, Y = 0, Z = 0

5.4.2. Part 2

If: A = 0, B = 1, C = 0

  1. W =1, X =1, Y = 0, Z = 1
  2. W =1, X =1, Y = 1, Z = 1
  3. W =1, X =0, Y = 1, Z = 1
  4. W =1, X =0, Y = 1, Z = 0
  5. W =1, X =1, Y = 0, Z = 0


5.5. Logic Circuits

Consider the following logic circuit, with inputs A, B, C and D, and outputs X and Y. Which output CANNOT BE COMPUTED for ANY assignment of 1 or 0 to inputs A, B, C and D? (Note: Each of the four inputs, A, B, C and D must be assigned a value of either 1 or 0)

A. Output X = 0 and Y = 0 cannot be computed
B. Output X = 0 and Y = 1 cannot be computed
C. Output X = 1 and Y = 0 cannot be computed
D. Output X = 1 and Y = 1 cannot be computed
E. All four outputs can be computed

5.6. Logic Circuits

  1. Write down the logic table for the OR, AND, and NAND gates.
  2. Write down the logic table corresponding to the image shown.

Image:CompoundGate.png


5.7. Logic Circuits

  1. Write down the logic table for the OR, AND, and NAND gates.
  2. Write down the logic table corresponding to the image shown.

Image:CompoundGate2.png

5.8. Logic Circuits

What are A & B?

Image:CompoundGate3.png

6. Activity

6.1. Preparation: Using logic.ly

  1. Start up http://logic.ly/demo and wire together gates, switches, and bulbs as on the image below. Verify that the above four switch configurations give the same result as that shown in the image.
  2. Figure out the XNOR logic table by connecting switches to a XNOR gate and then writing down what various configurations of the switches (input) gives for the light bulb (output).

Image:andoptions.png


7. References

Personal tools