Lab 0 - Introduction to Logisim

CS3410 Fall 2015

Due: In class

Overview

Welcome to Logisim! Logisim is a logic simulator that allows you to design and simulate digital circuits using a graphical user interface. Logisim comes with libraries containing basic gates, memory chips, multiplexers and decoders, and other simple components. In later assignments you will use many of these components to build your final CPU. For this lab, we will guide you through the process of creating your first adder in Logisim.

Step 0: Obtaining Logisim

To get started, follow these instructions to get a copy of Logisim on your working machine.

1. Logisim requires Java 5 or later. If you do not already have it on your computer, Java is available from java.sun.com.

2. Download Logisim from CS3410 class webpage. This is the Cornell version of Logisim and it comes as a jar file that will work on every operating system as long as you have java installed.

3. To execute the program: On Windows and MacOS systems, you will be able to start Logisim by double-clicking the JAR file. If that doesn't work, or if you use Linux or Solaris, you can type ''java -jar logisim-XX.jar'' at the command line.

Step 1: The beginner's guide

Logisim is a simple tool to use, most of the features you will need are well documented in the reference document. You can obtain the guide from the Logisim Documentation page. Start with the Beginner's tutorial. It will show you around the graphical interface, as well as guide you through a simple XOR circuit. Work through the XOR circuit, ask your TA to check this box when you are done.

Checkoff

Show your XOR circuit to your TA.  

Step 2: Add8

Now that you have implemented your first XOR gate in Logisim, let us work on a more complicated circuit -- an 8-bit adder. You may find some of the terms, such as two's complement numbers, are difficult to understand. Don't panic. You will not need to understand it in order to finish this lab. Again, the purpose of lab0 is to get you familiar with the software environment that you will be working in for this class in the next few weeks.

Definition (excerpt from Wikipedia article):
A full adder adds binary numbers and accounts for values carried in as well as out. A one-bit full adder adds three one-bit numbers, often written as A, B, and Cin; A and B are the operands, and Cin is a bit carried in (in theory from a past addition). The full-adder is usually a component in a cascade of adders, which add 8, 16, 32, etc. binary numbers.

In the notation below, A[8] denotes that the input is named "A" and is 8 bits wide. The input should not be named "A[8]". Another incorrect approach is to create eight separate inputs, each named A or some variant. Instead, the correct approach is to create a single input and make it 8 bits wide by changing the "Data Bits" attribute of the input. The attributes appear on the lower left pane of the Logisim window when the input is selected.

Add8: C = A + B + Cin; V = overflow
Inputs: A[8], B[8], Cin
Outputs: C[8], V

The output C is computed by adding A, B, and Cin. A, B, and C are signed two's complement numbers. If overflow occurs, the output V should be asserted. In such cases, the output C should correspond to the value computed if all overflow errors are ignored.

Sub-circuits

Use sub-circuits to make wiring easier by building a 1-bit adder, then a 4-bit adder, and then an 8-bit adder. Using a sub-circuit in Logisim is equivalent to writing a function and using it multiple times when coding. To create a new circuit, select "Project->Add Circuit..." from the toolbar. To use a circuit (A) as a sub-circuit of another (B), double-click on circuit B on the left pane of Logisim (the Explorer Pane). A magnifying glass appears on circuit B's icon, and now the contents of circuit B appear on the right pane (the Canvas). Click once on circuit A in the Explorer Pane, then click anywhere in the canvas to place an instance of circuit A as a sub-circuit of circuit B. As one would expect, any time circuit A is updated, all instances of it appearing in circuit B will change their operation in the same way.

For more information on sub-circuits, the corresponding documentation pages are useful.

Build 1-bit adder

A truth table shows how a logic circuit's output responds to various combinations of inputs. For example, if all inputs to a full adder are '0's, the outputs will also be '0'. Complete the truth table below.
Inputs Outputs
A B Cin Cout S
0 0 0 0 0
1 0 0
0 1 0
1 1 0
0 0 1
1 0 1
0 1 1
1 1 1
The truth table above can also be expressed using boolean algebra.
S = A xor B xor Cin
Cout = (A and B) or (Cin and (A xor B))

A technique called Karnaugh map, named after Maurice Karnaugh, a telecommunciation engineer at Bell labs in 1953, will make the conversion from truth table to boolean algebra very simple. You may peruse the Wikipedia article on Karnaugh maps if you are curious, but this is not necessary at this point.

For now, let us move on to implement the 1-bit adder in Logisim. Create the following circuit in Logisim, then save it as an appropriately-named circuit.

1-bit full adder
Show your 1-bit adder circuit to your TA.  

Build 4-bit adder

A 4-bit adder is as simple as cascading 4 one-bit adders together, with carry-out from one adder fed into the carry-in of the other adder. Later on in the course, we will discuss why this may not be the fastest implementation (for the interested student: why?), but it will serve our needs just fine for now.

4-bit Full Adder
Create the 4-bit adder in Logisim, re-using the 1-bit adder as a sub-circuit. Ask TA for help if you are unsure of what to do. Save your work in an appropriately-named circuit.

Hint: use splitters

Logisim provides a component called splitter in the base library. It creates a correspondence between a multi-bit value and several seperate subsets of those bits. Despite the name, you may use the splitter as a "bundler" as well, joining multiple individual bits into a multi-bit value. You may want to use splitter in your 4-bit adder to help you manage the input and output values. For more information, please refer to the help page for the Splitter.

Hint: use probes

Probes are great for debugging circuits. You can connet them to the in/out busses and set to display values in base 10 for quick checking. Refer to the help page for the Probe for more information.

Hint: use tunnels

Tunnels are not neccessary for this lab. But they become important when the size of your circuit gets bigger. A "tunnel" acts like a wire that binds points with the same label together, except that the wire is not explicitly displayed. This is helpful to keep your circuit clean and organized. For more information, refer to the help page for the Tunnel.

Show your 4-bit adder circuit to your TA.  

Build 8-bit adder

Now let us build a 8-bit adder, by reusing the 4-bit adder.

Show your 8-bit adder circuit to your TA.  

Step 3: Save your work and upload to CMS

Now save your work in four steps as a circ file and upload it to the CMS after showing your work to your TA.

Congratulations! You have successfully finished Lab0. Please make sure you have demonstrated your working adder to your TA and upload your circ file to CMS. We will build more circuits with Logisim in the following weeks. For a bit of fun, check out this youtube video to see an example of a cool project created using Logisim.