# Lab Exercises: Logic Circuits & Logisim

Simulating logic circuits using Logisim
Begin by logging into your account, and creating a cs31/weeklylab/week03 subdirectory. Copy over some files from Andy's public/cs31/week03/ directory into your subdirectory:
```    cd
cd cs31
cd weeklylab
mkdir week03
cd week03
pwd
ls
decoder.circ firstcircuit.circ
```

## Goals for this week:

1. Learn how to use Logisim through several exercises
2. Build an XOR circuit with a partner
3. See an introduction to Lab 3
Using the Logisim simulator
This week we will start using Logisim to create circuits using the logic gates (e.g., AND, OR, NOT) we've been talking about in class. We'll see how they work given various inputs. We will learn more Logisim in class, but today I want to step through a few examples.

Note: I suggest working in the CS lab on logisim rather than logging in remotely. Logisim will run very slowly if you are remotely logged in due to X forwarding events (i.e., using ssh -Y on Mac or Linux to enable X-forwarding). Alternatively, you can install logisim on your own computer, and scp your .circ file to/from your computer to your CS account. We are using version 2.7.1. Make sure to install the same version. Also, if you do this, you need to ensure that your circuit file works on logisim running on our system, the lab is where we'll be doing the grading!

The Logisim web page has user documentation that will be very helpful for the next lab assignment. We are using version 2.7.

## Logisim Demo

```\$ logisim    # start new project
```
We will start with firstcircuit.circ, and try builiding a simple AND circuit and some tester circuitry around it.
```\$ logisim  firstcircuit.circ  # edit an existing project
```

Next, we will build a 2-to-4 1 bit decoder in decoder.circ, and see how Logisim can analyze its behavior for us, allowing us to see if our implementation is correct.

```\$ logisim  decoder.circ
```

## Logisim Exercise

Next, step through the Beginner's tutorial and try building the XOR circuit.
Lab 3 Intro
We will go over the lab 3 assignment and requirements.