Building an ALU Using Logisim

Instructor: Martin Gibbs

Martin has 16 years experience in Human Resources Information Systems and has a PhD in Information Technology Management. He is an adjunct professor of computer science and computer programming.

In this lesson, we will see how to design an ALU (Arithmetic Logic Unit) using Logisim, learn how to add sub-circuits and construct a practical design of a 4-bit ALU.

Initial Setup

In the previous lesson, you have installed Logisim and created half and full adders. Now it's time to build an ALU or Arithmetic Logic Unit. To keep things easy-to-follow and straightforward, we'll be building a 4-bit ALU with four operations: AND, OR, NOT, and addition/subtraction.

Create the Logisim File

The first step is to create a new Logisim file. Save this file as 4-bit ALU.circ. Once you have a blank canvas, let's create sub-circuits for the adders, the AND and the OR.

Next, right-click on the main folder (4-bit ALU) and select Add Circuit, as shown in Figure 1:


Figure 1: Add Sub-Circuit
Logisim - Add New Circuit


Name the circuit Full Adder.

Repeat to add the following circuits as mentioned below:

  • 4-bit Adder/Subtractor
  • 4-bit AND
  • 4-bit OR

Your Logisim explorer window should look as follows:


Logisim Explorer - Elements Added
Logisim-items-added-4alu

Save your work!

Now let's build the sub-circuits.

Adders

We have already created Adders and Half-Adders in the previous lesson. The following diagrams show the setup for the adders.

To open the canvas, double-click on the Full Adder circuit.

Add the following:

  • 1 input pin, labeled In, facing South
  • 2 input pins, labeled A and B, facing East
  • 1 output pin, labeled Result, facing West
  • 1 output pin, labeled Out, facing North
  • 2 XOR gates, facing East (2 inputs, 1 data bit)
  • 2 AND gates, facing South (2 inputs, 1 data bit)
  • 1 OR gate, facing South (2 inputs, 1 data bit)

Arrange and connect them, refer to Figure 2:


Figure 2: Add Full Adder
Logisim Add Full Adder


4-bit Adder/Subtractor

The Adder/Subtractor shown in Figure 2 might look complicated, but we will actually be able to add in the adders we created previously. You can click an element from the explorer menu on the left (e.g., Full Adder), and drag it onto your canvas.

In the 4-bit Adder/Subtractor circuit, add the following:

Drag and drop 4 of the Full Adders you created earlier onto the canvas (the will have + signs on them); arrange vertically


Full Adders


An East-facing pin called Add/Subtract Control (add this to the top left)


Add-Subtract Control


A North-facing Pin called B, with 4 data bits

A South-facing pin called A, with 4 data bits


Pin A


4 East-facing XOR gates, each with 2 inputs


XOR Gates


3 South-facing NOT gates, each 1 data bit


NOT Gates


2 East-facing AND gates, each 1 Data bit and 3 inputs


AND Gates


3 splitters with 4 inputs


Splitters


Output pins for Carry out and Overflow


Output Pins


Connect All Elements

Next, connect all elements as shown in Figure 3. Figure 3 is the completed 4-bit adder/subtractor will all components.


Figure 3: Adder Subtractor
Logisim Adder Subtractor


4-bit OR

In this sub-circuit, we add the following:

  • Two Inputs, A and B, with 4 data bits
  • Two splitters with 4 bits
  • 4 AND gates with two inputs each
  • Another splitter with 4 bits
  • An output pin, Result with 4 bits

Add elements and connect as shown in Figure 4:


Figure 4: 4-Bit OR
Logisim 4-bit OR


4-bit AND

The 4-Bit AND matches the 4-Bit OR subcircuit, except you add 4 AND gates, as shown in Figure 5.


Figure 5: 4-Bit AND
Logisim 4-bit AND


Building the ALU

Now, let's build the final ALU. We build the circuit it from left to right, showing the final output at the end.

Step 1: Add the Two Input Pins

Drop two East-facing input pins on the canvas 4-bits each. Label them A and B, and ensure that each input is 4-bits.


Step 1: Input Pins
Logisim Add Input Pins


Step 2: Add the Adder/Subtractor and Gates

Now we add the sub-circuits created earlier. Select the circuits under the main project folder, referring to the diagram below:


Step 2: Gates
Logisim Add Gates


Then click on the canvas to drop them. Drop each of the following:

  • 4-Bit Adder/Subtractor
  • 4-Bit AND
  • 4-Bit OR

Step 3: Add the Multiplexers

Recall that an ALU needs multiplexers (MUX). These take on or more data inputs and generate a single output. In Logisim, multiplexers are under the Plexers folder. Click the Multiplexer icon and drop two of them onto our canvas.

Each has one Select Bit and 4 Data Bits:


Step 3: Add the MUX
Logisim add MUX


Step 4: Add Controls

Now we need our controls for the multiplexers. Drop two pins on the canvas, north-facing, with 1 data bit. Label them 0 and 1, respectively.


Step 4: Add Control Pins
Logisim Add Control Pins


Step 5: Add a Splitter

Next, we add a splitter into our circuit that takes one line from the second multiplexer and split to 4 inputs to an OR gate - for a 4-bit ALU.


Step 5: Add a Splitter
Logisim add splitter


Step 6: Add Another OR Gate And a Not Gate

Now we add an OR gate after the splitter, which has 4 inputs (from the splitter; we'll add the lines later). To the right of the OR gate, add a NOT gate.

This arrangement accounts for Zero output when ALL of the bits result in zero. The NOT gate following the OR gate achieves this.

Finally, add a single-bit pin after the NOT gate to store the result. Label it ZERO.


Step 6: Add OR and NOT Gates
Logisim add OR and NOT gates


Step 7: Add a Result Pin for the MUX

We handled the zeroes coming from the MUX, but we also need to account for valid combinations of inputs from A, B, and the Control inputs.

To unlock this lesson you must be a Study.com Member.
Create your account

Register to view this lesson

Are you a student or a teacher?

Unlock Your Education

See for yourself why 30 million people use Study.com

Become a Study.com member and start learning now.
Become a Member  Back
What teachers are saying about Study.com
Try it risk-free for 30 days

Earning College Credit

Did you know… We have over 200 college courses that prepare you to earn credit by exam that is accepted by over 1,500 colleges and universities. You can test out of the first two years of college and save thousands off your degree. Anyone can earn credit-by-exam regardless of age or education level.

To learn more, visit our Earning Credit Page

Transferring credit to the school of your choice

Not sure what college you want to attend yet? Study.com has thousands of articles about every imaginable degree, area of study and career path that can help you find the school that's right for you.

Create an account to start this course today
Try it risk-free for 30 days!
Create an account
Support