Computer Science 171
Introduction to Computer Science

Denison
CS171 Homework 4


Homework 4

Digital Logic

The goal of this assignment is to create a circuit that will allow us to add two 4-bit numbers, represented as binary integers. We will accomplish this with both a design process, and then use Logisim for realizing our design in logic gates.

Your homework submission will consist of the design portion, in hard copy form, turned in during class on Friday, and the LogiSim circuit, which will consist of a logisim ".circ" file, turned in through the Assignment Inbox by midnight on Friday.

  1. Design a half adder. Start by drawing an In/Out table. For the half-adder, we have two binary inputs, A and B. Recall that the In/Out table is a form of truth table where the inputs head columns in the table and the number of rows is determined by the number of distinct patterns of the inputs. The half adder has two outputs, the sum value and the carry value. You can either draw two tables, one for each output, or you can combine the two outputs into a single table.
  2. Given the In/Out table, write down two boolean expressions, one for each output. The boolean expression is determined by the set of lines where the output has value "1". We build an expression for each such line and join these expressions together by an "or". The expression for a individual line is an "and" expression with a term for each input. If the input has a "0" in the line, we negate the input, and if the input has a "1" in the line, we use the input as a positive term.
  3. Using the boolean expressions given in question 2, build a Logisim circuit for the half adder. Start by going to the Project menu and selecting "Add Circuit ..." and entering the identifier 'HalfAdder' for the new circuit name. Notice the magnifying glass icon on the HalfAdder circuit in the upper left hand pane. Add two input pins on the left hand side of the circuit drawing area, labeled A and B for the two binary inputs to the half adder. You can add label names by selecting the input pin and then using the info area in the lower left pane, where it says 'Label'. The A and B inputs can be wired to multiple downstream logic gates, so this single circuit will have both the output (Q) and the carry (C) output. Use gates and wires to complete the half adder and then on the right hand side of the circuit, create _labeled_ output pins for the Q and C outputs.
  4. Repeat steps 1, 2, and 3 for the full adder. Recall that the full adder has three inputs, A, B, and Cin. The last of these is the carry in from a previous bit addition. If there are three binary inputs and we need to build an In/Out table for a full adder, you should be able to determine how many lines are present in the table. The full adder, like the half adder, has two outputs, the sum (Q) and the carry out (Cout).
  5. At this point, you should select the 'main' circuit window (by double clicking it) and add one half adder and three full adders to build a 4 bit adder. To test the 4 bit adder, we will use two 4-bit inputs and one 4-bit output and a 1 bit output for the carry out of the full 4 bit addition. This is like lining our 4 bit addition into columns and performing addition by hand. We can specify a 4-bit input in a fashion similar to what we do for a 1-bit input. First select the input pin toolbar item. Then, before you place it on the circuit drawing area, go to the lower left pane and change the "bit width" to 4 (from 1). You may then place the two 4-bit inputs on the main circuit. Likewise, you can change the bit width for the output pin item and put a 4-bit output onto the main circuit. The other thing we need to do in Logisim is to take the 4-bits that come from the 4-bit input or 4-bit output and to split them into the individual bits needed to go into the half adder and full adders. We do this with a "splitter". Select the arrow next to the "Base" folder in the upper left pane. This will expand to a number of elements that can be added to circuits. Click on the "splitter" element. Then, before you place the splitter on the main circuit, change the "Bit Width In" parameter (in the lower left pane) to 4, and change the "Fan Out" to 4. You can then place a splitter that takes a 4-bit wide wire and splits it into 4 1-bit wires like we are used to working with.
  6. Be sure and test your 4-bit adder, by using various 4-bit integers and checking their sum and the overall carryout.

Save the circuit that contains the half-adder, full-adder, and 4-bit adder by performing a "Save As" and then submit your homework in a folder named "HW4" in the Assignment Inbox.