# Lab 7: Logic Circuits

### Contents

• Objectives
• To have completed all previous labs.
• To become comfortable with simple gates using a Logic Gate Simulator
• To be able to obtain truth tables for simple logic circuits
• Deliverables
• A post on your blog for task2. It should contain your truth table(A, B, OUT), screen shot of the circuit and answers to the question.
• A post on your blog for task3. It should contain your truth table (A, B, OUT1, OUT2) and a screen shot of the circuit.
• Completion Time
• Acknowledgements:

## Introduction

Digital logic circuits are the bedrock of computer design. CPU chips such as the Intel Pentium or AMD Athlon are silicon wafers in which millions of circuits are embedded.Everything your computer does depends upon them. In this lab, we will learn how to use the LogicGates applet to draw and test digital logic circuits. Chip manufacturers, such as Intel and AMD, use sophisticated(and extremely expensive) software to help them design and test their chips. But the basic idea is the same. LogicGates can be also used as a standalone Java application. If you use it as an application (not as an applet), you can load and save your programs.

To run it independently, download the zip file with the LogicGates application.

Unzip the archive on your Desktop folder or any folder where you have ownership.

Navigate to the folder containing the LogicGates class files and double click on the run_application.bat file.

# Task1: getting familiar with the logic gate simulator

First, start the LogicGates application. You can load a number of examples by pulling down the example choice pull-down menu.
Load Example 1 simple, as shown here:

Each logic gate has a distinctive shape. The wire coming out of the gate shows its current value. Gates are oriented so that their inputs come in from the left side and their outputs go out from the right side. This cannot be changed nor can the gates be rotated in this applet. Two special boxes exist for input and output. The switch box has a lever in it along with 1 or 0. To flip the lever and change the value, click on the number right in the center. The other box has only 1 or 0 in it. This is the output box that accepts a wire from a gate and displays its value. To propagate new values through the circuit, click on the Run button. It changes to say Stop so that when you click on it again, the simulator stops running. When the circuit is running, you can click on the switches and watch values change throughout the circuit.

To practice using the simulator, we'll build the logic circuit shown below.

First, if your simple example circuit is still running, press the Stop button.Now, clear the screen by clicking on the Clear button. To build the circuit, you'll need three switches, two AND gates, one OR gate, and one output box. To create them, click on the New button, pull down the gate menu and select the gate or other item you want. Then click once where you want the switch, gate, or output box to sit. You can reposition gates, switches, and outputs by dragging them to a new location.

Notice that when you are adding gates, the New button changes to say *New. Most of the buttons in this applet work like this: they show they are still active by displaying an asterisk in front of the label on the button. Because the button stays active, you can click on different gates without having to re-click the New button over and over.Click on the New button again to stop adding components. The asterisk will go away.

Let's also attach labels to the boxes to mimic the circuit diagram above. First click on the Label button, which allows us to label gates and switches. Then click on the top switch. A textfield opens up right above the switch. Type A into it and press Return. Here's what you should see:

Label the middle switch as B and the bottom switch as C. Also label the output X.If you want to be complete, label the top AND gate as D and the bottom AND gate as E. When done labeling, click on the Label button so that the asterisk doesn't appear. Now it's time to connect the gates, so click on the Connect button. Click once on switch A. A red line flashes into view, anchored in the center of the switch and following the mouse pointer around the screen. Click on the top AND gate. Repeat this process and connect all the boxes so they match the screenshot below. If you make a mistake, click on the Disconnect button, then click on a gate. All lines between that gate and all other components will be removed. A gate's output may have any number of wires coming out of it so that it connects to more than one other gate. Merely select the same gate as the left end of a wire more than once.Automatic elbows break lines up into horizontal and vertical segments. To see a version that uses diagonal lines, click on the Stepped button. However, in most circuit fabrication technologies, all wires must lie on a grid so diagonal wires are either impossible or expensive. To see the elbowed lines again, click on the bottom button, which has changed from Stepped to Diagonal. Sometimes the elbows make it hard to see overlapped wires, and that plagues this circuit. So move the bottom AND gate a little to the left until the wires show more clearly. Here's the final picture:

Now run the circuit by clicking the Run button. Click on the switches to change their values. Record the results in a truth table and see if the circuit gives you the same results as shown below.They had better agree! (They will, don't worry.)

 A B C D =( A Λ B) E =(A Λ C) (Output) X =  (D V E) 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 1 0 1 0 1 1 1 1 0 1 0 1 1 1 1 1 1 1

Imagine what a terrible thing it would be if a major chip manufacturer's simulation software didn't give the right values and they sent a chip into production with flaws in it. Well, actually, don't bother imagining: It's already happened! In the early 1990s, Intel recalled their new Pentium processor when scientists and engineers pointed out that in certain calculations the chip gave the wrong answer! Analysts have estimated that this bug in the chip's division algorithm cost the company about \$500 million.

Your first task is to make a simple circuit and observe it's behavior.

1. Start the “LogicGates” applet.
2. Add two switches, one XOR and one output, and connect them.
3. Press the Run button and try out all four combinations of inputs for the switches, observing the results.
4. Now insert a NOT box between XOR and the output.
5. Press the Run button and try out all four values by changing the switch values. Record the results in a truth table so you can see the values.
6. What does this circuit do? Study your truth table to determine its function. (Hint: It yields a true result only when inputs A and B share a particular relationship. What is that relationship? )

Capture a screen shot of your circuit and post it on your blog, with the truth tables. Explain in the post the function of this circuit.

Many students just do not believe DeMorgan’s Lawa so let’s see if the LogicGates simulator can prove one of them.

1. Start the “LogicGates” applet.
2. Add 2 switches and arrange them vertically on the left side of the panel. The top one we’ll call A and the bottom one will be B.
3. Add two outputs. We will implement both (AB)’ and (A’ OR B’) in the same circuit. One output will have the value of (AB)’ and the other will have the value of (A’ OR B’). If the output boxes read the same for all inputs, then we know that (AB)’ = (A’ OR B’).
4. Since (AB)’ is just the NAND gate, add one NAND gate and connect both A and B to it. Then connect the NAND gate to the top output.
5. For the (A’ OR B’) part, we’ll need two NOT gates, connected to A and B.  The output of these NOT gates goes into an OR gate, which then goes into the bottom output.
6. Run through all four combinations of binary values of A and B, writing down the two outputs. Are they the same? Is DeMorgan’s Law true?

Capture a screen shot of your circuit and post it on your blog, with the truth tables.

Check that you have completed your deliverables before you leave.