Richland College Engineering Technology Rev. 0. Donham Rev. 1 (7/2003) J. Horne Rev. 2 (1/2008) J. radbury Digital Fundamentals CETT 1425 Lab 6 2 s Complement / Digital Calculator Name: Date: Objectives: To design and evaluate a Full Adder circuit. To perform addition and subtraction, using 2 s complement, in a digital system. Suggested Reading Chapter 6, Digital Systems, Principals and Applications; Tocci Equipment and Components Circuit Simulator (MultiSIM or an equivalent) Introduction Digital computers and systems perform various arithmetic operations, including addition and subtraction, on signed numbers represented in binary form. In order to perform a subtraction or operate on negative numbers, the digital system must have a way to represent a signed number. The most common method is to use a 2 s complement system, which includes a sign bit. The typical convention is a 1 in the most significant bit indicates a negative number and a 0 represents a positive number. The basic steps of taking the 2 s complement of a number are to invert each bit in the number and then add 1 to the inverted number. This results in the negative representation of the number. 0 0 1 0 0 binary representation of +4 1 1 0 1 1 invert each bit 0 0 0 0 1 add 1 to inverted number 1 1 1 0 0 2 s complement or binary representation of 4 The basic logic circuits used in for digital addition are a half-adder and a full-adder. The half-adder performs the addition of 2 bits and produces a sum and carry bit output. The full-adder adds 2 bits plus a carry bit. Connecting a series of full-adders can create a parallel binary adder. Page 1 of 8
Procedure: 1. The following is the truth table for a Full Adder. Write a sum-of-products expression for Sum and Cout. Simplify each expression using a K-map or oolean theorems. A Cin Sum Cout 0 0 0 0 0 0 0 1 1 0 0 1 0 1 0 0 1 1 0 1 1 0 0 1 0 1 0 1 0 1 1 1 0 0 1 1 1 1 1 1 Simplified Circuit Expressions Sum = Cout = Page 2 of 8
2. Using the simplified expressions, draw the schematic for a full-adder circuit. Full Adder Circuit (schematic) Page 3 of 8
3. Start MultiSIM or an equivalent circuit simulator. Load the circuit on the following page, which will be provided by your instructor or draw the schematic. This circuit is a simple digital addition/subtraction calculator. Inputs/Outputs: Registers A & are used to store the binary numbers for the arithmetic operations. Register [] = switches 3 (Sign it), 2, 1, 0 (LS) (D Flip-Flops) Register A [A] = switches 7 (Sign it), 6, 5, 4 (LS) (D Flip-Flops) Addition: Switch S set to 0V. Subtraction: Switch S set to +5V Switch C is the clear signal and clears registers A &. Normally +5, momentary 0 clears registers Circuit Operation: Set switch S to add to A (S = 0) or subtract from A (S = +5). Set switches 3, 2, 1, 0 to the binary numerical value to load into the register Set switches 7, 6, 5, 4 to the binary numerical value to load into the A register Toggle switch to cause a rising edge to clock the binary number into the register Toggle switch A to cause a rising edge to clock the binary number into the A register Output LEDs will show the result of the arithmetic operation NOTE: 2 s complement can only be performed on the -Register. The 2 s complement of the register is taken when the Subtract function is selected. Positive values should be selected with switches 3-0 () and 7-4 (A). If the subtract operation is selected, the circuit will automatically calculate and load the 2 s complement of into the adder circuits. Example: 5-3 Load 0101 into A and 0011 into. When the subtract operation is selected, the adder circuit will generate the 2 s complement of. Page 4 of 8
VCC 5V pos/neg J4 A LATCH J3 Key = A J2 Key = 7 J1 Key = 6 Key = 5 J5 J6 Key = 4 LS Key = S J13 LATCH U27 NOT MS Key = U6 REG. J11 Key = 0 J7 Key = 1 J8 Key = 2 J9 Key = 3 J10 Key = C CLR LS U1 RE U2 RE U3 RE U4 RE U14 U13 U17 U16 U20 U19 U23 U22 U15 OR2 U18 OR2 U21 OR2 U24 OR2 RE U7 RE U8 RE U9 RE U5 CARRY A SUM CIN FULL_ADDER U10 CARRY A SUM CIN FULL_ADDER U11 CARRY A SUM CIN FULL_ADDER U12 CARRY A SUM CIN FULL_ADDER Page 5 of 8
4. Use the digital calculator to perform the following arithmetic operations. Calculate the decimal value represented by the output LEDs (Show all of your work). 5. Perform the following calculation recording the results in the table. Show how the decimal value was calculated. (Show conversion steps from 5 to 0101.) 5 + 2 6. Perform the following calculation recording the results in the table. Show how the decimal value was calculated. Remember, put 6 in the register and set the sign switch for logic high. Only can be negated. 7-6 7. Perform the following calculation recording the results in the table. Show how the decimal value was calculated. Only can be negated. 5-7 Page 6 of 8
8. Perform the following calculation recording the results in the table. Show how the decimal value was calculated. Only can be negated. 4 4 9. Perform the following calculation recording the results in the table. Show how the decimal value was calculated. Only can be negated. 4-3 10. Perform the following calculation recording the results in the table. Show how the decimal value was calculated. 1-7 11. This calculator can also be used to add unsigned numbers. Assume that the A and registers as well as the result are unsigned numbers for this step. Perform the following calculation recording the results in the table. Show how the decimal value was calculated. 6 + 7 3 2 1 0 7 6 5 4 MS LS Page 7 of 8
12. Perform the following calculation recording the results in the table. Show how the decimal value was calculated. Assume that the A and registers as well as the output are unsigned numbers. 12 + 8 3 2 1 0 7 6 5 4 MS LS Did the output show the sum of 12 and 8 in binary? If NO explain why. Review Questions: Answer the following questions after the lab is completed. 1. What is the purpose of toggling switches A and after switches 3-0 and 7-4 was set? 2. What is the largest positive SIGNED number that can be represented by this calculator? 3. What is the largest UNSIGNED number that can be represented by this calculator? 4. Subtraction in a 2 s complement system actually involves adding a positive and negative number, which is in 2 s complement format. Evaluate the circuit shown on page 4 and explain how the circuit is calculating the 2 s complement of the register when the Subtract function is selected. Page 8 of 8