Top Banner
INDIAN INSTITUTE OF INFORMATION TECHNOLOGY, ALLAHABAD Mid-semester Examination, February 2018 Computer Organization and Architecture (ICOA230C) Max. Time: 2 Hour Max. Marks: 30 ---------------------------------------------------------------------------------------------------- There are five questions in the paper. Answer all. ---------------------------------------------------------------------------------------------------- Q.1. Short answer type questions : [5] a. Use the two's complement system to add the signed numbers 11110010 and 11110011. Determine, in decimal, the sign and value of each number and their sum. Solution: -14, -13 and -27 b. Someone claims that if you type "0100" into a file using a standard text editor, you have written 4 bits to the file, and thus created a binary file. Explain what's correct and incorrect about this statement. Solution: When you type characters in a text editor, it gets translated to the ASCII code. Thus '1', '0', '0', '0' are written in the file as 0x31, 0x30, 0x30, 0x30 (or more properly, 0011 0001 0011 0000 0011 0000 0011 0000). You have written 4 bytes into the file, not 4 bits. However, ASCII files are considered a special case of binary files (where each byte uses the 7-bit ASCII code). c. Register A holds binary value 11011001. Determine the Register B operand and the logic operation to be performed in order to change the value in A to : i. 01101101 ii. 11111101 Solution : i. If B = 1011 0100 and the XOR logic operation is performed with A, then the content of A will be 0110 1101. Thus, A <- A XOR B ii. If B = 1011 0100 and the OR logic operation is performed with A, then the content of A will be 11111101. Thus, A <- A OR B d. In a normal n-bit adder, to find out if an overflow has occured we make use of ________ Solution : XOR gate e. Booth’s algorithm for integer multiplication gives worst performance when the multiplier pattern is (i) 101010…..1010 (ii) 100000……0001 (iii) 111111…..1111 (iv) 011111……1110 Solution : (i) The worst case of an implementation using Booth’s algorithm is when pairs of 01s or 10s occur very frequently in the multiplier.
6

INDIAN INSTITUTE OF INFORMATION …profile.iiita.ac.in/bibhas.ghoshal/lecture_slides_coa/...c. Register A holds binary value 11011001. Determine the Register B operand and the logic

Apr 22, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: INDIAN INSTITUTE OF INFORMATION …profile.iiita.ac.in/bibhas.ghoshal/lecture_slides_coa/...c. Register A holds binary value 11011001. Determine the Register B operand and the logic

INDIAN INSTITUTE OF INFORMATION TECHNOLOGY, ALLAHABADMid-semester Examination, February 2018

Computer Organization and Architecture (ICOA230C)

Max. Time: 2 Hour Max. Marks: 30----------------------------------------------------------------------------------------------------

There are five questions in the paper. Answer all. ----------------------------------------------------------------------------------------------------Q.1. Short answer type questions : [5]

a. Use the two's complement system to add the signed numbers 11110010 and 11110011. Determine, in decimal, the sign and value of each number and their sum.

Solution: -14, -13 and -27

b. Someone claims that if you type "0100" into a file using a standard text editor, you have written 4 bits to the file, and thus created a binary file. Explain what's correct and incorrect about this statement.

Solution: When you type characters in a text editor, it gets translated to the ASCII code. Thus '1', '0', '0', '0' are written in the file as 0x31, 0x30, 0x30, 0x30 (or more properly, 0011 0001 0011 0000 0011 0000 0011 0000). You have written 4 bytes into the file, not 4 bits.

However, ASCII files are considered a special case of binary files (where each byte uses the 7-bit ASCII code).

c. Register A holds binary value 11011001. Determine the Register B operand and the logic operation to be performed in order to change the value in A to :

i. 01101101 ii. 11111101

Solution : i. If B = 1011 0100 and the XOR logic operation is performed with A, then the contentof A will be 0110 1101. Thus, A <- A XOR B

ii. If B = 1011 0100 and the OR logic operation is performed with A, then the content of A will be 11111101. Thus, A <- A OR B

d. In a normal n-bit adder, to find out if an overflow has occured we make use of ________

Solution : XOR gate

e. Booth’s algorithm for integer multiplication gives worst performance when the multiplierpattern is(i) 101010…..1010 (ii) 100000……0001(iii) 111111…..1111 (iv) 011111……1110

Solution : (i)The worst case of an implementation using Booth’s algorithm is when pairs of 01s or 10s occurvery frequently in the multiplier.

Page 2: INDIAN INSTITUTE OF INFORMATION …profile.iiita.ac.in/bibhas.ghoshal/lecture_slides_coa/...c. Register A holds binary value 11011001. Determine the Register B operand and the logic

Q.2. Explain propogate and generate logic used in carry look ahead adder (CLA). Using the recurrence relation, derive the propogate and generate functions for a 4 bit CLA. [5]

Solution : (a) Carry lookahead logic uses the concepts of generating and propagating carries.

The addition of two 1-digit inputs A and B is said to generate if the addition will always carry,regardless of whether there is an input carry (equivalently, regardless of whether any lesssignificant digits in the sum carry).In the case of binary addition, A.B generates if and only if both A and B are 1. If we write G(A.B) torepresent the binary predicate that is true if and only if A.B generates, we have: G(A.B) = A.B

The addition of two 1-digit inputs A and B is said to propagate if the addition will carry wheneverthere is an input carry (equivalently, when the next less significant digit in the sum carries).In the case of binary addition, A + B propagates if and only if at least one of A or B is 1. If wewrite P(A,B) to represent the binary predicate that is true if and only if A + B propagates, wehave: P(A,B) = A + B

Sometimes a slightly different definition of propagate is used. By this definition A + B is said topropagate if the addition will carry whenever there is an input carry, but will not carry if there isno input carry. Fortunately, due to the way generate and propagate bits are used by the carrylookahead logic, it doesn't matter which definition is used. In the case of binary addition, thisdefinition is expressed by: P(A,B) = A XOR B

Given these concepts of generate and propagate, a digit of addition carries precisely when eitherthe addition generates or the next less significant bit carries and the addition propagates. Writtenin boolean algebra, with Ci+1 the carry bit of digit i, and Gi, the propagate and generate bits of digiti respectively, Ci+1 = Gi + (Pi+1.Ci)

(b) The carry look ahead system is obtained by unwinding the recurrence relation for Ci+1

For a4-bit

CLA , consider the two numbers to be added being A= A3 A2A1A0 and B= B3 B2B1B0;

The propagate functions are : p0 = A0 XOR B0 ; p1 = A1 XOR B1; p2 = A2 XOR B2; p3 = A3 XOR B3

The generate functions are g0 = A0 B0 ; g1 = A1 B1; g2 = A2 B2; g3 = A3 B3

The equations for the carries for each block of a 4-bit CLA are as follows :

Page 3: INDIAN INSTITUTE OF INFORMATION …profile.iiita.ac.in/bibhas.ghoshal/lecture_slides_coa/...c. Register A holds binary value 11011001. Determine the Register B operand and the logic

Q.3. Using D flip-flops and logic gates, design a circuit, which generates the following sequence ofnumbers: 001 -> 100 -> 010 -> 101 -> 110 -> 111 -> 011 -> 001 Assume that the circuit never generates 000. This circuit is a pseudo-randon number generator and is widely used in cryptographic applications and simulations. [5]

Solution: Provided at the last page

Q.4. (a) Represent the radix-2 booth recoding of -5. Calculate(-5)*(14) using Booth's algorithm. (b) Use the restoring division algorithm to perform (-7)/3 [7]

Solution : (a) (i) Booth's recording :Bit i Bit (i-1) Recording

0 0 00 1 +11 0 -11 1 0

-5 in two's complement representation : 1011

Booth's recording of -5 = -1 +1 0 1

(ii) Booth's multiplication :Multiply 14 times -5 using 5-bit numbers (10-bit result).14 in binary: 01110-14 in binary: 10010 (so we can add when we need to subtract the multiplicand)-5 in binary: 11011Expected result: -70 in binary: 11101 11010

Page 4: INDIAN INSTITUTE OF INFORMATION …profile.iiita.ac.in/bibhas.ghoshal/lecture_slides_coa/...c. Register A holds binary value 11011001. Determine the Register B operand and the logic

(b)

Q.5. Given a floating-point format with one sign bit, eight exponent bits (k=8), and four fractionbits (n=4). Answer the following questions [8]a. What is the bias?Solution : 2(k-1) -1 = 2(8-1) -1 = 27 -1 = 127

b. What is the smallest positive normalized value?Solution : V=(-1)s×M×2E where s = 0, exp 00000000 or 11111111for smallest positive normalized value, exp = 00000001, frac =0000Therefore, M = 1+frac×2-n =1; E=exp-bias =1- 127= -126

V=1X1.0000X 2-126 = 1/ 2126

c. What is the largest positive normalized value?Solution : V=(-1)s×M×2E where s = 0, exp 00000000 or 11111111for largest positive normalized value, exp = 11111110, frac = 1111Therefore, M = 1+frac×2-n =1; E=exp-bias = 254- 127= 127

V=1X1.1111X 2127 = 11111x 2123

d. What is the largest positive denormalized value?Solution : V=(-1)s×M×2E where s = 0, exp = 00000000 for largest positive de-normalized value, frac = 1111Therefore, M = frac×2-n =1; E=1- bias =1- 127= 126

V=1X0.1111X 2126 = 11111x 2122

e. Consider two floating point numbers represented in the above format : A = 0 10000100 0100B = 1 00111100 1100Perform the operation (A*B) and obtain the result in the provided normalized floating point format.

Page 5: INDIAN INSTITUTE OF INFORMATION …profile.iiita.ac.in/bibhas.ghoshal/lecture_slides_coa/...c. Register A holds binary value 11011001. Determine the Register B operand and the logic

Solution : 0 10000100 0100 x 1 00111100 1100 ------------------------

Step 1 : Mantissa Multiplication (including hidden bit : 1) 1.0100 x 1.1100 ------------ 00000 00000 10100 10100 10100 --------------- 1000110000

Actual result ( including decimal) = 10.00110000

Step 2: add exponents. However, care should be taken to add true exponents (otherwise the bias gets added in twice)

Biased: 10000100 + 00111100

Compute the true components and then add : True exponent = exponent – bias ( for both exponents) = exponent – 127 = exponent - 01111111 first exponent second exponent 10000100 00111100 -01111111 - 01111111 --------------- ------------- 00000101 (+5) 10111101 (-67) Add true exponents 5 + (-67) = -62

Step 3 : Re-bias exponent : -62 + 127 = 65 Unsigned representation for 65 is 01000001

Step 4 : Put the result back together (and add sign bit) :

1 01000001 10.00110000

Step 5 : Normalize the result : Moving the radix point one place to the left increases the exponent by 1

1 01000001 10.00110000 becomes 1 01000010 1.000110000

This is the value stored (not the hidden bit!): 1 01000010 000110000

------------------------------------------------------------------------------------------------------------------------

Page 6: INDIAN INSTITUTE OF INFORMATION …profile.iiita.ac.in/bibhas.ghoshal/lecture_slides_coa/...c. Register A holds binary value 11011001. Determine the Register B operand and the logic