Logic Gates
From CDS 130
Contents 
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 lefthand side are the inputs (in this class we will mostly deal with circuits that have two inputs). The righthand 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


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]).
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 overshoots the "AND" bucket.
See also [3]. ("XOR = Exclusive OR ")
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.


4.9. OR Gate

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.

4.11. NOR Gate

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.

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.

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?
 X = 1, Y = 1
 X = 1, Y = 0
 X = 0, Y = 1
 X = 0, Y = 0
Answer 

X = 1, Y = 1 
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.
 Z = 1, Output = 0
 Z = 0, Output = 0
 Z = 1, Output = 1
 Z = 0, Output = 1

Answer 

Z = 0, Output = 1. 
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.
 Z = 1, Output = 0
 Z = 0, Output = 0
 Z = 1, Output = 1
 Z = 0, Output = 1

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
 W =1, X =1, Y = 0, Z = 1
 W =1, X =1, Y = 1, Z = 1
 W =1, X =0, Y = 1, Z = 1
 W =1, X =0, Y = 1, Z = 0
 W =1, X =1, Y = 0, Z = 0
Answer 

W =1, X =1, Y = 0, Z = 1 
5.4.2. Part 2
If: A = 0, B = 1, C = 0
 W =1, X =1, Y = 0, Z = 1
 W =1, X =1, Y = 1, Z = 1
 W =1, X =0, Y = 1, Z = 1
 W =1, X =0, Y = 1, Z = 0
 W =1, X =1, Y = 0, Z = 0
Answer 

W =1, X =1, Y = 0, Z = 1 
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
 Write down the logic table for the OR, AND, and NAND gates.
 Write down the logic table corresponding to the image shown.
5.7. Logic Circuits
 Write down the logic table for the OR, AND, and NAND gates.
 Write down the logic table corresponding to the image shown.
5.8. Logic Circuits
What are A & B?
6. Activity
6.1. Preparation: Using logic.ly
 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.
 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).
7. References
 How Brain Science Will Change Computing: [5]
 "The Tinkertoy Computer" http://www.amazon.com/gp/product/071672491X