Computer Science 1 2009-2010 Dr. Moore October 13/14 Name _______________________________ Period _______ Adder Logic As a start on building a mini-ALU (arithmetic logical unit) that does 4-bit two’s complement addition and subtraction, let’s first figure out the logic for an adder circuit. 1. Think about the results of adding two bits. How many outputs are there? _________ What are the names of the outputs? ________________________ 2. One output is the sum of the two bits. Write a truth table with the two input bits as the inputs and the sum of those bits for the output. 3. Do you recognize the truth table for the sum as one of the basic or derived logic gates? If so, which one? If not, draw a circuit that implements the truth table. 4. The other output is the carry generated by the addition of the two bits. Write a truth table with the two input bits in as the inputs and the carry generated by the addition of those bits as the output. 5. Do you recognize the truth table for the carry as one of the basic or derived logic gates? If so, which one? If not, draw a circuit that implements the truth table. 6. Now use your answers to 3 and 5 to draw a combined circuit that takes two bits as inputs and produces the sum and carry outputs. This circuit is called a half-adder. 7. Now consider what happens when we add two 8-bit binary numbers. As we work right to left, a carry output from the current column becomes a carry input to the next column to the left. Write a truth table with three inputs (the two bits for the numbers being added and a carry input) and two outputs (the sum and the carry out that result from adding those two bits). This is the truth table for a full-adder circuit. 8. Puzzle! Now see if you can figure out how to put two half-adder circuits plus one more gate together to create a full-adder circuit. You may draw the half-adder as “black box”, since we already constructed it in question 6. 9. Now that you have your full-adder circuit, draw a schematic for how you would connect together four full-adder circuits to construct a 4-bit binary adder. 10. Construct your 4-bit binary adder using the xLogicCircuits Lab 1 virtual circuit board. Follow the step-by-step procedure above and iconify the XOR, half-adder, and full-adder circuits as you create them so that you can use them as building blocks. Make up test problems and use them to test your circuits after each step to ensure that they work properly. 11. Now let’s figure out how we can turn our 4-bit adder into a 4-bit adder/subtractor. In order to subtract B from A, we need to add the two’s complement of B to A. Recall that we form the two’s complement of a binary number by flipping all the bits and adding one. We will convert the adder to an adder/subtractor by adding a control input. When the control input is a 0, the circuit will perform A + B. When the control input is a 1, the circuit will perform A – B. a. What gate can we use that inputs the control input and a B input and outputs the complement of the B input? b. To what input can we connect the control input to add one to the result? c. Add the control input and the necessary gates to your 4-bit adder to convert it to a 4-bit adder/subtractor. Draw your adder/subtractor circuit below and also construct in on the virtual circuit board. d. Test your finished mini-ALU. Write your test cases and the expected results below.