Home Preview the Site Activities Chapter 1: Data Storage Lab 1: Logic Gates

# Lab 1: Logic Gates

[Purpose | Objectives | Before you begin | Background | Procedure | Applet]

Purpose: To build interactive Boolean circuits to study their behavior.

Objectives: After this lab you should be able to

• Identify the gate symbols for the Boolean operations AND, OR, NOT and XOR.
• Construct a table with the input/output behavior of each individual gate.
• Build and run a simple Boolean circuit simulation to match a diagram of a circuit.
• Build and run a simple Boolean circuit simulation to match an input/output table.
• Build and run a simple Boolean circuit simulation to match a Boolean equation.
• Draw and explain how a flip-flop circuit stores a logical bit.

Before you begin:

• Before beginning this lab you should read Section 1.1: Bits and Storage, pages 20-26.
• This lab requires two reports: Lab1a and Lab1b. As each part is assigned, download and print out each lab report sheet, filling out name, section and date.

Background:

Since it can be expensive to build an actual computer circuit with physical components, computer scientists use software-based Boolean logic simulators to construct and test computer circuit diagrams before the physical version. In this lab you are going to use a Java applet Boolean logic simulator to construct and test computer circuits that illustrate each basic Boolean gate, simple computer circuits and memory flip-flops.

At the lowest level, information flows through computers as electrical signals. All components are connected by wires, and at any instant a single wire is on (conducting electricity) or off (not conducting). We can represent the on/off nature of an electric signal using one bit which is either 0 or 1. One bit gives us enough information to answer a True/False question on a quiz. In the diagram below electricity can flows from the input switch on the right to the output light on the left.

 A zero (0) signal. Electricity is not flowing so the light is off A one (1) signal. Electricity is flowing so the light is on

Input and output values are shown here as input switches and output lights.

 Component Symbols Input/Output Input switch Produces either 1 or 0 output. Output light Shows 0 input as an off light, a 1 input as on.

To process more than one bit of information we use the Boolean operations of AND, OR, NOT and XOR as explained in Section 1.1. A device that produces the output of a Boolean circuit when given the operation's input values is called a gate, so we use the AND, OR, NOT and XOR gates when we build a computer circuit. These allow us to combine information in individual signals. An example of a circuit using the AND is in the diagram below. Both inputs are one so the output is 1.

 An AND gate with two inputs of 1.

The output of a Boolean gate will change as the input values change. If we reset the input switches so the first one is off, then the output light goes off.

 An AND gate with two inputs of 1.

The four Boolean gates are diagrammed using the symbols in this table. All gates and connectors in the simulator take input on the left and produce output on the right.

 Gate Symbol Inputs Output AND 0 0 0 0 1 0 1 0 0 1 1 1 OR 0 0 0 0 1 1 1 0 1 1 1 1 NOT 0 1 1 0 XOR 0 0 0 0 1 1 1 0 1 1 1 0

In building a complex circuit we may need to duplicate a signal, or reroute a wire to make the diagram clear. The diagram below shows the use of two special connectors, a one to two connector that puts a single input signal on two outputs, and a one to one connector that reroutes a signal without changing it.

 One input connected to two outputs.

 Connector Symbol Input/Output One to two Two outputs with same value as input. One to one One output with same value as input.

In this lab you will build computer circuits from the four Boolean gates, the input switch, the output light, and the two connectors, put together Any computer circuit based on on/off, Boolean values can be built from this collection of parts. The LogicGates applet instructions give a tutorial example on how to build a computer circuit from scratch.

A circuit built using the simulator is invalid if there are excess gates or not all the gates are properly connected. The simulator will bring you back to editing the circuit if you try to run it as invalid.

 An invalid circuit

A valid circuit can have multiple paths, or with gate outputs that connect back to themselves or another gate in the circuit. Note that the output of the second circuit is always 1, no matter what the input, once it becomes 1 - this circuit cannot be switched off once on.

 Valid circuit with two paths Valid circuit with gate input to itself

Once we have a circuit build we can run it using different input values. By doing this we can figure out the input/output function of the circuit. The designer of a computer circuit is trying to match a particular input/output function - for example, they might want a circuit that produces an output 1 only if the first input 1 and the second is 0, as in this Boolean table. A Boolean table has columns for each input, a column for the output, and rows for each possible combination of input labeled with the correct output.

 First input Second input Output 0 0 0 0 1 0 1 0 1 1 1 0

This circuit will produce this table by inverting the second input. To show this, we have to evaluate the circuit for the four possible input patterns.

 Input values Circuit simulation Output value Both 0 0 First 0, second 1 0 First 1, second 0 1 First 1, second 1 0

A Boolean circuit can be completely understood from it Boolean table, so computer circuit designers use the tables to create and test circuits. You will be acting as a designer as you build circuits during this lab. From this lab you should learn how to construct Boolean tables from Boolean circuits, and the reverse.

Procedure:

The steps in the procedure are on the Lab Report sheets. As previously instructed in Before you begin, print out the Lab Report sheets, carry out their procedures and fill them out with your results.

Applet:

(To have the applet instructions open in a new window, click here.)

Your browser does not support Java, so nothing is displayed.

(Click here to open larger version of the applet in a new window.)