Lab 4 - Using Logisim to build an 8-bit Adder

In this lab you will learn more about Logisim, including bundling, splitting, sub-circuits, and debugging.


An 8 bit adder

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.


adder8.circ: 8-bit Adder Demo


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 or tutortial are useful: logisim_tutorial.pdf

Consider the circuit on the left below. This circuit, if created as a sub-circuit, can then be used in other circuits. If you right click on a subcircuit, you can create a truth table of the circuit. If you return to the main circuit, you can place the circuit in the main circuit, seen on the left.

sample.png sample2truth.png sample1cicuit.png

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.

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.


To Do

  1. Build this adder a sub-circuit.
  2. Analyze the circuit to create a truth table
  3. Use the sub-circuit in a main circuit, test with inputs and outputs.
  4. Paste and image of the sub-circuit, it's truth table, and the main circuit in a lab report.

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.


To Do
  1. Create the 4-bit adder in Logisim, re-using the 1-bit adder as a sub-circuit. Ask for help if you are unsure of what to do. Save your work in an appropriately-named circuit.
  2. Paste an image of the working circuit in a lab report.

Bundles and splitters

The problem with the simple solution to a 4-bit adder is that we end up with a complex solution - 9 separate inputs, and 5 separate outputs. Logically what we have is 3 inputs, A[4], B[4], and Cin, and 2 outputs, S[4] and Cout.

What we can do in Logisim is group wires together into a bundle of wires. What we need to facilitate this is splitters to allow us to join and separate wires in bundles.

Read about splitters here: Splitter Documentation


Above are several simple examples using splitters and bundles.

Note that ALL components in Logisim can be set to any bit width from 1 to 32. This greatly simplifies the creation of complex circuits on multiple bit groups.


Above we see a 4-bit not gate. Note in the lower example we can split of the bits in arbitrary groups.

To do
  1. Create a 4-bit adder, using one bit adders. Make the input and outputs to be a 4-bit data bundles.
  2. Turn the 4-bit adder into a sub-circuit. Create 4 bit inputs and outputs to test it.
  3. Past the working diagrams into your lab report.

Build 8-bit adder

Now let us build a 8-bit adder, by reusing the 4-bit adder. Use your 4-bit adder sub-circuits.

To do
  1. Paste the working diagrams into your lab report.
Topic attachments
I Attachment Action Size Date Who Comment
Pngpng add1.png manage 4.7 K 2014-09-15 - 02:11 JimSkon  
Pngpng add4.png manage 11.6 K 2014-09-15 - 02:19 JimSkon  
Circcirc adder8.circ manage 3.2 K 2014-09-15 - 01:39 JimSkon 8-bit Adder Demo
Pngpng adder8.png manage 2.6 K 2014-09-15 - 01:37 JimSkon  
Pngpng sample.png manage 3.1 K 2014-09-15 - 01:53 JimSkon  
Pngpng sample1cicuit.png manage 0.5 K 2014-09-15 - 01:53 JimSkon  
Pngpng sample2truth.png manage 0.9 K 2014-09-15 - 02:00 JimSkon  
Pngpng splitter.png manage 3.9 K 2014-09-15 - 02:56 JimSkon  
Pngpng splitter2.png manage 2.4 K 2014-09-15 - 03:08 JimSkon  
Topic revision: r2 - 2014-09-23 - JimSkon
This site is powered by the TWiki collaboration platformCopyright &© by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback