CS 101 Laboratory #3
Digital Circuits
Objective:
To build simple circuits using a logic simulator.
Due date is the beginning of your lab section next week:
- Labs W, X: Tuesday, March 4
- Labs Y, Z: Thursday, March 6
Lab prep: Read this lab assignment.
Written Exercises: Read Brookshear chapter 1, write up these
exercises, and turn them in along with your lab work.
- Do Exercise 3 on page 26.
- Do Exercises 1, 2, and 3 on page 73.
-
Add the following two 8-bit binary numbers: 10111010 and 01101011. Now
convert each of those numbers and their sum to their equivalent
decimal numbers, and verify that you did the addition correctly. Show
your work neatly.
-
What is the output of this program?
This lab will introduce you to a logic simulation tool for
building simple circuits.
You are encouraged to discuss the assignment with other
students, but each student must write up his or her solutions
alone. At the top of the first page of your submission, write your own
name and the names of the students with whom you discussed the
assignment. Please use a stapler if you turn in multiple pages.
For this assignment, you will be working with a logic circuit simulator called
LogicSim. (You may also want to try an
online logic simulator
from the resources site associated with our course textbook.)
-
Start the LogicSim program by finding the LogicSim folder in the
Applications folder and double-clicking on LogicSim.jar. For this
exercise, build a half-adder like the one discussed in Monday's
lecture (basically, build the circuit from Slide 16 rotated
counter-clockwise by 90 degrees).
Select "Settings -> gate design -> US" to get the familiar gate symbols.
Use switches for inputs, and LEDs (lights) for the outputs.
The top output light should be the
sum, and the bottom output light should be the carry.
Click on "simulate" to test your circuit.
Verify that your
circuit works for all possible input combinations.
Once it works, add text labels with your name and the function of the
circuit, and print it. Unfortunately, LogicSim's "print" option
does not work. Instead, take a screen
capture of your completed circuit by typing Apple-# (type 3 while
holding down the Shift and Apple keys). This should create a file on
your desktop called Picture 1 (or Picture 2 if Picture 1 already
exists, etc.). Double click on this file to open it in the Preview
program. From the Preview program, crop the relevant portion of the screen
and print it. Instead of capturing the entire screen followed by cropping,
you can also type Apple-$ (Apple-Shift-4), which will let you select a
rectangular area on the screen to capture.
Hint: In LogicSim, you can use the escape key to stop editing actions,
e.g., quit out of placing a new gate. Also, when adding wiring to
connect two logic gates, you can use the escape key to delete the last
wire segment.
-
Build a full-adder like the one from Slide 17 of Monday's
lecture. There should be three switches on the left. From top to
bottom, these should represent the previous carry bit, the first bit
to add (A), and the second bit to add (B). There should be two output
lights on the right. From top to bottom, these should represent the
sum and the carry bit. Note that it is okay for the wire connecting
the output of one gate to the input of another gate to go from right
to left, even though they usually go from left to right. However, if
you carefully place and maneuver your gates, you can keep all the
wires going from left to right. Verify that your circuit works
correctly for all possible input combinations. As with the previous
exercise, print out your circuit diagram after adding labels with your name
and the function of the circuit.
-
Design your own circuit to control a traffic light. There should be
two switches on the left representing inputs A (top) and B
(bottom). There should be three output lights on the right. From top
to bottom, these represent the Red, Yellow, and Green signals of a
traffic light. If A and B are both 0, then the Red output should be on
(1), and the others should be off (0). If A is 0 and B is 1, then the
Yellow output should be on, and the others should be off. If A is 1
and B is 0, then the Green output should be on, and the others should
be off. You can assume that A and B will never be both 1
simultaneously, so we don't care what output is produced in that
case. When you have finished your circuit,
print out your circuit diagram. Extra credit (this part must be done
alone): implement this circuit using only one logic gate, and turn in
a printout of the circuit.
-
Build a flip-flop like the one from Slide 19 of Monday's
lecture. Verify that it works when you use the switches like buttons
(turning them on and then off shortly after).
Turn in a printout of your circuit.
In your own words,
explain how the flip-flop is able to retain the value assigned to
it.
-
On the first page of what you turn in, indicate approximately how much
time you spent working on this assignment.
Back to Computer
Science 101 Home
Department of Computer
Science