1. Goals for this week:
-
Gain experience with the Logisim logic circuit simulator.
-
Run through the Logisim tutorial for building an XOR component.
-
Introduce Lab 3.
2. Get In-Lab Code
Start by creating a week03
in your cs31/WeeklyLabs
subdirectory
and copying over some files:
$ cd ~/cs31/week03
$ mkdir week03
$ cd week03
$ pwd
/home/you/cs31/WeeklyLabs/week03
$ cp ~newhall/public/cs31/week03/* ./
$ ls
intro.circ solution.circ
3. Learning Logisim
For this lab, we’ll be using Logisim to
create and test digital circuits using the logic gates (AND
, OR
, NOT
,
etc.) we’ve been talking about in class.
We’ll start by demonstrating the basics of Logisim (adding gates,
inputs, and outputs) to implement a simple circuit. Afterwards, you and
your partner will run through the Logisim tutorial to create an
XOR
circuit.
3.1. Demo
First, open intro.circ
with Logisim. You can do this by starting Logisim then
going to the File→Open menu and navigating to the folder containing the
intro.circ
file.
$ logisim intro.circ &
Together, we’re going to implement a 1-bit circuit that computes (X AND Y) OR
(NOT X)
, and then we’ll add some tester circuitry around it. After we try this
out together, you can open the solution.circ
file to see my solution.
-
Follow the steps in the
intro.circ
file:-
Place an "AND Gate" from the "Gates" menu. Although the size of the gate won’t matter for this example, you might find it easier to work with if you change its size to Medium.
-
Add inputs (green square boxes) to the two inputs on the "AND Gate" and label them as
X
andY
. Change the "Label Location" to "West" so the label shows up to the left of the input. -
Add a "NOT Gate" and attach
X
as an input. (You don’t need to change the size of this gate.) -
Add an "OR Gate" (you may wish to change the size to Medium) and connect the output of
X AND Y
as one input and the output ofNOT X
as the other. -
Add an output (green circle) to the output of the OR gate, label it as "result".
-
-
Next, we’ll create a new circuit interface to the circuit we just built. (Details about creating sub-circuits are in the "Subcircuits" part of the Logisim User’s Guide).
-
Create a new circuit by choosing Project→Add Circuit, and enter the name of the new circuit: "first circuit". You should now see 2 circuits in the subcircuits folder: "main", "first circuit".
-
Copy your circuit into the new "first circuit" window.
-
-
Finally, let’s test the circuit by adding a clock and a counter to run a simulation of all possible input values.
-
Add a "first circuit" to your "main" circuit.
-
Add a Memory→Counter.
-
Set its Data Bits to 2.
-
Connect a Wiring→Probe to the output of Q. To make your circuit more readable, have the probe’s Facing set to South.
-
-
Add a Wiring→Splitter.
-
Set its Fan Out and Bit Width In to 2. Connect the tail of the splitter (hovertext: "Combined end of the splitter") to the Counter’s "Q" output.
-
Connect two probes to the outputs of the splitter. Try to use the Facing of the probes to keep your circuit neat.
-
If you hover with your mouse over the input and outputs of the "first circuit" you added, you will see their labels. Connect one input of the splitter to "X" and the other input of the splitter to "Y". And an output pin to the "result" output of your "first circuit" and label it appropriately.
-
-
Add a Wiring→Clock.
-
Connect the Clock to the Counter at the bottom left input (hovertext: "Clock: value may update on trigger").
-
Add an input pin and connect it to the Counter at the bottom right input (hovertext: "Clear: when 1, resets to 0 asynchronously"). Changing the input to 1 will allow you to reset the Counter.
-
-
Try poking at the Clock.
-
3.2. Advice on Using Logisim
-
Save your changes frequently. Occasionally Logisim freaks out and you need to exit Logisim and restart it. If you have saved your changes as you go, you will not lose your work if this happens.
-
We strongly recommend working in the CS lab on Logisim rather than logging in remotely or installing it on your own machine.
-
If you use your own laptop to run Logisim, it is your responsibility to ensure that your circuit file works on Logisim running on our system, since we will be grading your circuits on the version installed in the CS computer labs.
Logisim is installed on the CS lab machines. If you are interested in running it on your personal computer, you can follow the instructions to install it on your own machine.
If you install Logisim (and git) on your own computer, and use
git
to push/pull your.circ
file to/from your computer and your CS account.Note that course staff can help some with the basic setup steps, but we can’t offer comprehensive support for every student’s personal machine — there are too many of you with too many different environments!
4. Lab 3 Assignment
Next, you and your partner should run through the Logisim tutorial:
Beginner’s Guide to build an XOR
gate using only AND
, OR
, and NOT
gates (plus inputs and outputs). Build your gate as a new component that you
can then deploy in a main circuit.
After about 20 minutes working on the XOR, we’ll introduce the next lab assignment.