CS 0447–Lab 5: Four-Function Calculator

Description

For this lab, we will use Logisim to make a four-function calculator that operates on 4-bit values.

Steps

  1. The first thing you will do is to use the built-in adder, subtracter, multiplier, and divider components to build a functional circuit.
    1. Create two Pins and select 4 from the Data Bits dropdown box.
    2. Wire each input into the 4 math components listed above. Make sure to change each to 4 data bits as well or Logisim will complain (via an orange wire and message) about Incompatible widths.
    3. Create a Multiplexer with 2 select bits and 4 data bits. Wire the outputs of your circuits to the inputs of the Mux and create a 4-bit output Pin connected to the output of the mux. Wire a 2-bit input pin into the selector of the Mux. (You may wish to move the select location to Top/Right as the default seems to be Bottom/Left.)
    4. Use the finger pointer tool to change the input bits and the selector bits to verify your circuit works.
  2. We will now replace Logisim’s adder component with our very own. We’ll start by building a 1-bit adder from AND/OR/NOT gates and then build a 4-bit ripple carry adder.
    1. We can hide the logic for a circuit into a “chip” of our own creation by going to the Project menu and selecting “Add circuit…”. Call the circuit something like “my 1-bit adder”.
    2. In this new drawing area, you can create a 1-bit input pin for A, B, and Cin.  Label them using the label property.
    3. Create and label two 1-bit outputs, Cout and S.
    4. Using the sum of products equations for carry out and sum, construct the circuit for the 1-bit adder. (You may wish to use the K-map optimized version for carry out since the circuit is simpler). You also may wish to use 2-input gates as well as 3-input gates. (We’ll allow the use of the shortcut rather than building a 3-input gate from two 2-input gates.) You can change the number of inputs from the properties box in the lower left corner.
    5. Test your adder using the finger pointer tool.
  3. Go back to the main circuit by selecting it in the TreeView box in the upper left. We could add our 1-bit adder to the main circuit, but it will be more convenient to build a new circuit called “My 4-bit adder”.
    1. On the blank canvas of the new circuit, click “My 1-bit adder” from the TreeView and add 4 of them in the center of the circuit.
    2. Add two 4-bit input pins for your input sum and one 1-bit input pin for your carry in.
    3. We need to use the splitter component to turn our 4-bit wire into four 1-bit wires. Add one to the canvas and set the Fan Out property to 4 and the Bit Width In property to 4 as well. Wire the input pin into the thick part of the splitter. Each of the 4 numbered outputs is the individual bits that wire carried. Split both inputs.
    4. Wire the split inputs to the appropriate ports of your 1-bit adders. Make sure to match bit 0 from both wires to the same adder. Hovering over the pins in your 1-bit adders will pop up a tooltip telling you the name of the pin we labeled when creating it. String the carry outs of the adders together in the ripple-carry adder configuration.
    5. We need then to combine the four S outputs into one 4-bit output pin. Use the splitter with the same configuration (facing West most likely) to bring the four S bits into a single 4-bit wire. Connect it to a 4-bit output pin.
  4. Go back to the main circuit using the TreeView in the upper left corner of the window. Delete Logisim’s adder and replace it with yours. Wire it up (you may need to use a Constant from the Wiring folder to set the carry in to 0). Test that it works the same as before.
  5. Replace the subtract component with your adder as we explained in class. To make a number negative in two’s complement, recall you will need to:
    1. Invert one input’s bits
    2. Carry in a 1.

What to Demo

By your assigned recitation on April 15 – April 19, upload your circ file to the directory specified below using a program like FileZilla or WinSCP:

Server: unixs.cis.pitt.edu

Login: Your Pitt username (email before @)/Your password

For the Monday section:

Directory: /afs/pitt.edu/home/j/r/jrmst106/submit/447/monday/

For the Tuesday section:

Directory: /afs/pitt.edu/home/j/r/jrmst106/submit/447/tuesday/