1. Goals for this week:

  1. Gain experience with the Logisim logic circuit simulator.

  2. Introduce Lab 3.

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

2. Starting Point Code

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

$ cd ~/cs31/inlab
$ mkdir week03
$ cd week03
$ pwd
/home/you/cs31/inlab/week03
$ cp ~richardw/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.

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 will start by demo’ing some the basics of Logisim (adding gates, inputs, and outputs) by implement a simple circuit. You and your partner will next run through the Logisim tutorial to create an XOR circuit.

3.1. Together

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 are going to implement a 1-bit circuit that computes (X AND Y) OR (NOT X), and we will 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.

  2. We will then 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 entering 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, let’s look over the Lab assignment and then get started on it!

After I talk through the assignment, you and your partner should start by running 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 main.

5. Handy References