1. Goals for this week:

  1. Gain experience with the Logisim logic circuit simulator.

  2. Run through the Logisim tutorial for building an XOR component.

  3. Introduce Lab 3.

2. Starting Point Code

Start by creating a week03 in your cs31/weeklylab subdirectory and copying over some files:

$ cd ~/cs31/weeklylab
$ mkdir week03
$ cd week03
$ pwd
/home/you/cs31/weeklylab/week03
$ cp ~kwebb/public/cs31/week03/* ./
$ ls
intro.circ   solution.circ

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.

Note that course staff can help 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!

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.

  1. Follow the steps in the intro.circ file:

    1. 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.

    2. Add inputs (green square boxes) to the two inputs on the "AND Gate" and label them as X and Y. Change the "Label Location" to "West" so the label shows up to the left of the input.

    3. Add a "NOT Gate" and attach X as an input. (You don’t need to change the size of this gate.)

    4. 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 of NOT X as the other.

    5. Add an output (green circle) to the output of the OR gate, label it as "result".

  2. 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).

    1. 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".

    2. Copy your circuit into the new "first circuit" window.

  3. Finally, let’s test the circuit by adding a clock and a counter to run a simulation of all possible input values.

    1. Add a "first circuit" to your "main" circuit.

    2. Add a Memory→Counter.

      1. Set its Data Bits to 2.

      2. Connect a Wiring→Probe to the output of Q. To make your circuit more readable, have the probe’s Facing set to South.

    3. Add a Wiring→Splitter.

      1. 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.

      2. Connect two probes to the outputs of the splitter. Try to use the Facing of the probes to keep your circuit neat.

      3. 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.

    4. Add a Wiring→Clock.

      1. Connect the Clock to the Counter at the bottom left input (hovertext: "Clock: value may update on trigger").

      2. 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.

    5. 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 suggest 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 computer lab.

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.

5. Handy References