A Basic Computer
From ComputingForScientists
Contents 
1. A Basic Computer
1.1. Objectives
 To understand how logic gates can be configured and combined to create logic tables that correspond to computation.
1.2. Motivation
 Computation can be done using combinations of logic gates.
 The process of translating a problem to a logic table and then translating a logic table to a digital circuit is similar to the process you will use in solving science problems with a computer: convert science questions to a math equation and then convert the math equations to a computer program.
1.3. Motivation
 The last step for making a computer is to combine logic gates to do a computation.
 Once you understand how that works, we will write computer programs that give the computer computation instructions (programming!).
 In our case, we
 learned some of the basic tools (binary numbers, binary addition, bit patterns)
 learned some of the parts in a computer (transistors, logic gates)
 built a simple computer using these parts (will do that today)
 wrote programs to manipulate a computer (starting next week)
Note that between the last two steps there is a lot of effort involved  many of these topics are covered in advanced computer science classes.
1.4. Adding Binary Numbers prelude
 We want to use logic gates to do binary addition, but logic gates use logic tables. How can we relate a logic table to binary addition?
 First let me tell you how I use a logic table to decide what colors to wear.
 In the first four columns, a zero means "black" and a one means "brown".
 In the last column, a zero means "combination does not match", and a one means "combination matches".
 To figure out if the clothing I selected matches, I look for the row in the table that corresponds to my selection. In this case, only the first and last rows feature matching combinations.
Socks  Pants  Shirt  Shoes  Matches?  

0  0  0  0  1  
0  1  0  1  0  
1  0  0  1  0  
0  0  1  1  0  
1  0  0  0  0  
0  1  1  0  0  
1  0  1  0  0  
1  1  1  1  1 
1.5. Adding Binary Numbers Prelude
 Eventually, I got lazy and wanted an easier way to figure out if I was going to match.
 So I installed four light switches that were connected to a bulb in my closet.
 I would then flip the light switches on or off according to the colors of the socks, pants, shirt, and shoes that I selected. If the bulb turned on, I made a matching selection.

1.6. Adding Binary Numbers
 We want to use logic gates to do binary addition but logic gates use logic tables.
 The big question: How can we relate a logic table to binary addition?
1 1 1 1 + 1 1 ____ 1 1 0 A typical binary addition calculation 
Co Ci A + B __ Sp

1.7. To add any binary numbers
The following table tells us what to put for Sp
and Co
given any possible combinations of inputs A
, B
, and Ci
. When you do binary addition by hand, you look at the values of A
, B
, and Ci
and then decide the value of Sp
and Co
. The following table is a list of all possible inputs and the corresponding outputs.
Now that the table is built, we can try to figure out how to combine logic gates to produce this logic table.

Co Ci B + A __ Sp 
1.8. 1bit adder
If you wanted to add 1+1+1
without thinking, you could flip all of the switches down and then look at what happened to the lights. If they both light up, you would say 1+1+1
must be 11
.
The configuration shown below is supposed to be able to produce the logic table shown. The inputs are three switches (on = 1 = down) and the outputs are the light bulbs (on = light).
The combination of logic gates shown represents a computer that can compute the sum of two 1bit numbers. Instead of having a keyboard or buttons to input information, this computer uses switches. Instead of having a monitor or screen to display output, this computer uses light bulbs.
This basic configuration can be built upon to create a computer that computes the sum of two 8bit numbers.

2. Questions
Many of these questions use the program Logicly. This video show how to use the program.
2.1. Decision table
Develop a logic table and corresponding logic circuit for making a decision in the same way that I did for deciding if my outfit matches. Post a screenshot of your circuit. Make sure that you explain what the on/off state of the switches means and what a lit/unlit bulb means. Your logic table must have at least four inputs.
2.2. Bird brain
In this problem you will practice translating a set of statements about a system (a bird) to a logic diagram. Read [1] and answer the following question. Post a screenshot to your wiki page.
Create a circuit using http://logic.ly/demo that reproduces Table 2 at [2]. Label the inputs and outputs appropriately (That is, tell me what a switch in the on or off position in corresponds to in Table 2. What does a lit/unlit bulb correspond to in Table 2?.)
See also [3].
Answer 

2.3. NOR gate using NANDs
Use [4] to create a the NOR gate logic table (given below) using only NAND gates. Post a screenshot showing that your circuit gives the correct result for the first row of the NOR logic table.
Logic table for NOR gate

Student Solution 

Solution: I used Logic_Gates#NOR_Gate_using_NANDs to figure out how to combine NAND gates to give an NOR Gate. 
2.4. OR gate with NANDs
Use [5] to modify the circuit shown that it only uses NAND gates but produces the same result. Post a screenshot on your wiki page.
Student Solution 

3. Activities
3.1. Activity I
Suppose you want a third light bulb to light up only when Sp and Co are on. How would you change the diagram? Hint: You can do this by adding an AND gate and connecting its output to the new bulb. The question is then where to connect the inputs to the new AND gate. If you get it to work, see if you can get the same result using two or more gates and a different wiring configuration.

3.2. Activity II
(Difficult) If you figured out the above problems, try this problem. Suppose that you want to develop a circuit that does this binary addition problem, where A, B, C, and D can be 0 or 1.
A B C D + ________ C3 C2 C1
 How many rows will your logic table need?
 Develop a logic circuit that does the calculation. There should be three light bulbs and four switches.
 Use a LED to show the result of the sum as a decimal number.