Homework with Solution - Logic and Computer Structures | CS 266, Study notes of Computer Architecture and Organization

HW5 solutions Material Type: Notes; Professor: Theys; Class: Computer Architecture I: Logic and Computer Structures; Subject: Computer Science; University: University of Illinois - Chicago; Term: Fall 2012;

Typology: Study notes

2011/2012

Uploaded on 12/16/2012

billyking100
billyking100 🇺🇸

3

(2)

37 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
University of Illinois at Chicago
CS 266: Computer Architecture I Fall 2012
Homework 5 Solutions
Question 1
The following binary numbers have a sign in the leftmost position and, if negative, are in 2s complement form. Perform
the indicated arithmetic operations and verify answers. Indicate whether overflow occurs for each computation.
a. [10] 100010+111110
Carries:
1
1
1
1
1
1
0
0
0
1
0
+
1
1
1
1
1
0
1
0
0
0
0
0
The carry out into sign bit position is the same as carry out of the sign bit position. Therefore there is no
overflow. Carry out of the sign bit position is discarded.
Verifying the answer:
The 2s complement of 100010 is 011110, which in decimal is 2
+2
+2
+2
=16+8+4+2 =30.
Therefore the decimal equivalent of 100010 is −30.
The 2s complement of 111110 is 000010, which in decimal is 2. Therefore the decimal equivalent of 111110
is −2.
The 2s complement of 100000 is 0100000, which in decimal is 2
=32. Therefore the decimal equivalent of
100000 is −32.
Therefore we have −30+−2=−32.
b. 10001111+100010
Carries:
1
1
1
0
0
1
1
1
1
+
1
0
0
0
1
0
1
1
0
0
0
1
No overflow occurred.
Verifying the answer:
001111
=2
+2
+2
+2

=8+4+2+1 =15
The binary number 100010 is negative, since the leftmost bit is 1. Its 2s complement is 011110.
011110
=2
+2
+2
+2
=16+8+4+2 =30
The binary number 110001 is negative. Its 2s complement is 001111.
001111
=2
+2
+2
+2
=8+4+2+1 =15
Therefore we have 15+−30= −15
c. 10101101–111011
The 2s complement of 111011 is 000101. Therefore we may do the addition 101101+000101, which is
equivalent to the original subtraction.
Carries:
1
1
1
1
0
1
1
0
1
+
0
0
0
1
0
1
1
1
0
0
1
0
There is no overflow since carry into the sign bit position and carry out of the sign bit position are equal.
pf3
pf4

Partial preview of the text

Download Homework with Solution - Logic and Computer Structures | CS 266 and more Study notes Computer Architecture and Organization in PDF only on Docsity!

University of Illinois at Chicago

CS 266: Computer Architecture I Fall 2012

Homework 5 Solutions

Question 1

The following binary numbers have a sign in the leftmost position and, if negative, are in 2s complement form. Perform the indicated arithmetic operations and verify answers. Indicate whether overflow occurs for each computation.

a. [10] 100010 + 111110 Carries: 1 1 1 1 1 1 0 0 0 1 0

  • 1 1 1 1 1 0 1 0 0 0 0 0 The carry out into sign bit position is the same as carry out of the sign bit position. Therefore there is no overflow. Carry out of the sign bit position is discarded. Verifying the answer: The 2s complement of 100010 is 011110 , which in decimal is 2 ⡲^ + 2⡱^ + 2⡰^ + 2⡩^ = 16 + 8 + 4 + 2 = 30. Therefore the decimal equivalent of 100010 is −30. The 2s complement of 111110 is 000010 , which in decimal is 2. Therefore the decimal equivalent of 111110 is −2. The 2s complement of 100000 is 0100000 , which in decimal is 2 ⡳^ = 32. Therefore the decimal equivalent of 100000 is −32. Therefore we have −30 + 䙦−2䙧 = −32.

b. 䙰10䙱 001111 + 100010 Carries: 1 1 1 0 0 1 1 1 1

  • 1 0 0 0 1 0 1 1 0 0 0 1 No overflow occurred. Verifying the answer: 䙦001111䙧⡰ = 䙦2⡱^ + 2⡰^ + 2⡩^ + 2⡨䙧⡩⡨ = 8 + 4 + 2 + 1 = 15 The binary number 100010 is negative, since the leftmost bit is 1. Its 2s complement is 011110. 䙦011110䙧⡰ = 2⡲^ + 2⡱^ + 2⡰^ + 2⡩^ = 16 + 8 + 4 + 2 = 30 The binary number 110001 is negative. Its 2s complement is 001111. 䙦001111䙧⡰ = 2⡱^ + 2⡰^ + 2⡩^ + 2⡨^ = 8 + 4 + 2 + 1 = 15 Therefore we have 15 + 䙦−30䙧 = −

c. 䙰10䙱 101101 – 111011 The 2s complement of 111011 is 000101. Therefore we may do the addition 101101 + 000101, which is equivalent to the original subtraction. Carries: 1 1 1 1 0 1 1 0 1

  • 0 0 0 1 0 1 1 1 0 0 1 0 There is no overflow since carry into the sign bit position and carry out of the sign bit position are equal.

Verifying the answer: The 2s complement of the 101101 is 010011 , which in decimal is 19. Therefore the decimal equivalent of 101101 is −19. The decimal equivalent of 000101 is 5. The 2s complement of 110010 is 001110 , which in decimal is 14. Therefore the decimal equivalent of 110010 is −14. Therefore we have −19 + 5 = −14.

d. 䙰10䙱 101100 – 001101 The 2s complement of 001101 is 110011. Therefore we may do the addition 101100 + 110011, which is equivalent to the original subtraction. Carries: 1 0 1 0 1 1 0 0

  • 1 1 0 0 1 1 0 1 1 1 0 1 The overflow has occurred since we may notice that the carry out to the sign bit position is 0 , and carry out out of the sign bit position is 1. Verifying the answer: The 2s complement of 101100 is 010100 , which in decimal is 20. Therefore the decimal equivalent of 101100 is −20. The decimal equivalent of 001101 is 13. Therefore the decimal equivalent of 110011 is −13. Taking the sum we obtain −20 + 䙦−13䙧 = −33. But with 6 bit 2s complement binary we can only represent numbers in range 䙰−32, 31䙱. Therefore we cannot represent −33 with 6 bits, and there will be an overflow.

Question 2

[30] Use Contraction beginning with a 4-bit adder with carry out to design a 4-bit increment-by-5 circuit with carry out that adds the binary value 0101 to its 4-bits input. The function to be implemented is ᡅ = ᠧ + 0101.

Solution:

The 4-bit adder that does increment-by-5 circuit with carry out is:

By using the contraction we are able to reduce the circuit to the following: