# Building a Circuit Library

In this lab we will use Logisim to begin building a library of reusable circuits.

http://ozark.hendrix.edu/~burch/logisim/

This software includes a useful manual (under the help menu), which can also be found online at:

http://ozark.hendrix.edu/~burch/logisim/docs/2.1.0/guide/index.html

## Step 2: Create a Circuit "Library"

Create a directory called "circuits". This is where you will store the circuits you will build.

Tip: Don't bury this directory. Logisim doesn't remember your last opened directory and will make you hunt it down each time you want to access it!

## Step 3: Build a Half Adder

Start Logisim.

Open the Combinational Analysis tool (under the Window menu.)

Use the Inputs tab to create two inputs named a and b.

Use the Outputs tab to create two outputs named sum and cout (short for carry-out.)

Use the Table tab to specify the truth table for

sum = a + b

cout = a * b

## Step 4: Build an Adder

Start a new Logisim project.

Open the Combinational Analysis tool.

Create a circuit with three inputs: a, b, and cin (short for carry-in), and two outputs: sum, and cout.

Use the table tab to specify a truth table with:

sum = a + b + cin

cout = 0 if at most one input is 1, otherwise it's 0.

## Step 5: Build a 4-bit adder

Start a new Logisim project.

Create two 4-bit wide input pins named arg1 and arg2.

Create a 1-bit wide output pin named cout.

Create a 4-bit wide output pin named sum.

Attach West-facing splitters to arg1 and arg2. Before adding these splitters, make sure the bit-width is 4 and the fan-out is 4. Make sure the fan wires are not blue.

Attach an East-facing splitter to sum. It's wires will be blue.

Connect the cout of each adder (or half adder) to the cin of the adder below it. Connect the cout of the last adder to the cout pin.

Connect the sum of each adder (or half adder) to the corresponding wire of the splitter connected to sum.

Connect the a input of each adder (or half adder) to the corresponding wire of the splitter connected to arg1.

Repeat for arg2.

## Step 7: Build an ALU

Build an 8-bit ALU. This circuit has two 8-bit inputs called arg1 and arg2 and a 4-bit input called control. It also has an 8-bit output called result and a 1-bit output called status.

The ALU contains an 8-bit adder, multiplier, subtractor, and divider. It also contains an 8-bit left shifter, right shifter, bitwise conjunction, and complementor. These work on arg1.

The control input is connected to a Demultiplexer that selects which subcircuit's output should be connected to the result pin.

The status output should be cout or the bit shifted out for a shift operation.

Note: Most of these circuits are contained in Logisim's built-in library: