CS 354 Computer Organization and Systems Fall 2017 

Project 1 - Logic

Overview

Logic is at the heart of computer hardware and architecture. We will build some basic logic circuits for several fundamental computer operations In this lab you will develop your logic skills using the freely available and very cool software program Logisim.

Learning Goals and Objectives

  • Improve working knowledge of logic circuits
  • Improve working knowledge of logical expressions
  • Improve working knowledge of truth tables
  • Further appreciate modularity of computer design
  • Work towards an understanding of the role of logic in modern computers

Common Logic Operations

There are two distinct logical states, typically True and False. True is often represented by a 1 or a T and on a computer as a high voltage signal. False is often represented by a 0 or a F and on a computer as a low voltage signal. However, these representations are completely arbitrary.

There are several logical operations commonly used in defining logical circuits. These were originally defined by George Boole about 150 years ago. These can be thought of as functions that have a finite number of inputs and outputs, therefore they can be defined in a table. See section B-1 for more details.

And

AB A and B
000
010
100
111
In Java:

boolean A, B, output;
output = A & B;
The output is 1 when both inputs are 1.

Or

AB A or B
000
011
101
111
In Java:

boolean A, B, output;
output = A | B;
The output is 1 if either of the inputs is 1.

Exclusive Or

AB A xor B
000
011
101
110
In Java:

boolean A, B, output;
output = A ^ B;
The output is 1 if the inputs are different.

Not

Anot A
01
10
In Java:

boolean A, output;
output = !A;
The output is the opposite of the input. This is often called an inverter.

Not And

AB A nand B
001
011
101
110
In Java:

boolean A, B, output;
output = !(A & B);
The nand gate is simply a combination of not-and and produces the inverted output of the and gate.

Not Or

AB A nor B
001
010
100
110
In Java:

boolean A, B, output;
output = !(A | B);
The nand gate is simply a combination of not-and and produces the inverted output of the or gate.

Combinational Logic Circuits

Logical operations can be combined to form boolean expressions or functions. The conventions for order of operations in boolean expressions is to perform inversion, then And, then or. Parentheses can be used to group and specify operations in a clear manner. In turn, these logical expressions can be transformed into a visual representation called a combinational logic circuit. There is an exact corresondance between every boolean expression and a combinational logic circuit and the output values can be obtained directly from a truth table. Logical circuits can then be used to perform computations as we will see during the semester.

Logisim

Logisim is a java-based program that allows one to design, test, and simulate logic circuits. Logisim uses a fairly intuitive GUI to place logic gates, draw connecting wires, set input values, and observe output values. You can download it and run it on your own computer (you will also need a java runtime environment). It is available in the Sleight lab and you can access it by simply running it from a terminal window:

    java -jar /home/sleightlab/logisim.jar
This will open logisim in a new window.

Get acquainted with Logisim by going through the beginner's tutorial. The tutorial guides you through the contruction and testing of a simpe circuit to implement an exclusive-or function using the fundamental AND, OR, and NOT gates. In addition to being able to print your circuit, you can also save your work and reload it later. Print a copy of your annotated XOR circuit to turn in with this lab.

DeMorgan's Laws

Here are DeMorgan's laws expressed as they would be in a Java program. The first of DeMorgan's laws shows how not distributes with or.

! (A || B) = (!A) && (!B)
The second of DeMorgan's laws shows how not distributes with and.
! (A && B) = (!A) || (!B)
You can easily prove these by constructing a truth table for each side of the equality and observing that the outputs match.

For each of these two laws, create a circuit for the the left-hand side and for the right-hand side, then demonstrate the equivalence of each side to prove these laws. Print a copy of these four circuits to turn in with this lab.

Multiplexors

A multiplexor (sometimes called a MUX for short) is a circuit that allows one to select from a set of inputs based on the values of selection inputs. Print a copy of this circuit to turn in with this lab. See page C-10 (in Appendix C) from your text CD and associated discussion for more details. We will see the important role multiplexors play later in the semester.

Create a the circuit in figure C.3.2 for the the two-input MUX. Print a copy of the circuits to turn in with this lab.

Half Adder

The half adder circuit, as the name implies, is about half of the circuitry required for adding numbers expressed in binary notation. We will see more of this when we get to Chapter 3.
ABSumCarry
0000
0110
1010
1101

Create a the half-adder circuit using an AND gate and an XOR gate as shown above. Print a copy of the circuit to turn in with this lab.

Full Adders

The full adder circuit, as the name implies, is the circuitry required for adding numbers expressed in binary notation. We will see more of this when we get to Chapter 3.
ABCarryInSumCarryOut
00000
00110
01010
01101
10010
10101
11001
11111

Create a the full adder circuit using two half-adder circuits from your previous step as shown above. Note the two highlighted blocks are simply half-adders. Print a copy of the circuit to turn in with this lab.

NAND and NOR are Universal Gates

One interesting observation is that the AND, OR, and NOT gates can be implemented using only NAND gates. That is each of the basic logic functions AND, OR, and NOT can be expressed using only NAND gates. This is also true of the NOR gate!

Using only NAND gates, determine logical epressions, truth tables, and build circuits in Logisim to implement the NOT gate, the AND gate, and the OR gate. Print a copy of these three circuits to turn in with this lab.

A Footbal Logic Problem

During the last week of the NFL season, there are often several teams competing for playoff spots. Near the end of the 2004 season, the NFL reported:

Denver can clinch playoff berth with:
1) DEN win, OR
2) DEN tie + BUF loss or tie, OR
3) BUF loss + JAX loss or tie + BAL loss or tie.
This can be coded in Java as follows, assuming there are boolean variables set to determine the win/loss/tie status of each team that final week.
if (DEN_win ||
    DEN_tie && (BUF_loss || BUF_tie) ||
    BUF_loss && (JAX_loss || JAX_tie) && (BAL_loss || BAL_tie))
   System.out.println("Denver Broncos clinch a playoff berth");
Construct a circuit that performs the equivalent logic. Annotate your circuit to make the meanings of the inputs and outputs clear. Print a copy of your circuit to turn in with this lab.

Deliverables

This lab is worth 20 points:

  1. (2 points) XOR Circuit
  2. (2 points) DeMorgan's Laws
  3. (4 points) Multiplexors
  4. (2 points) Half Adder
  5. (2 points) Full Adders
  6. (3 points) Universal Gates
  7. (5 points) Football Logic Problem

Further Explorations for Fun

  1. Using only NOR gates, determine logical epressions, truth tables, and build circuits in Logisim to implement the NOT gate, the AND gate, and the OR gate.
  2. Create multiplexors with 2, 4, 8, 16, and 32 selector lines using only NOT, AND, and OR gates. Can this be done in a modular manner using smaller multiplexors to build larger multiplexors?

References

  1. Logisim
  2. Appendix C


Copyright © 2017, David A. Reimann. All rights reserved.