CS061 Homework problems

¡Supera tus tareas y exámenes ahora con Quizwiz!

Fill in the truth table for the equations given. The first line is done as an example. Q i = NOT(NOT(X) OR (X AND Y AND Z)) Q2 = NOT((Y OR Z) AND (X AND Y AND Z)) X Y Z Q Qi 0 0 0 0 1

Q1 = NOT( NOT(X) OR (X AND Y AND Z) ) Q2 = NOT( (Y OR Z) AND (X AND Y AND Z) ) Use de Morgan's law to simplify these expressions: Q1 = X AND NOT(X AND Y AND Z) = X AND (X' OR Y' OR Z') = X.Y' + X.Z' Q2 = NOT(Y OR Z) OR NOT(X AND Y AND Z) = Y'.Z' + X' + Y' + Z' = X' + Y' + Z' = (X.Y.Z)' X Y Z Q1 Q2 0 0 0 0 1 0 0 1 0 1 0 1 0 0 1 0 1 1 0 1 1 0 0 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 0

Convert the decimal number 5,621 to unsigned binary:

5621 = 2^12 + 2^10 + 2^8 + 2^7 + 2^6+ 2^5 + 2^4 + 2^2 + 2^0 = 0001 0101 1111 0101 = x15F5

Convert the following hexadecimal representations of 2's complement binary numbers to decimal numbers. a. xFO b x7FF c. xl6 d. x8000

(a) -16 (b) 2047 (c) 22 (d) -32768

Express the negative value —27 as a 2's complement integer, using eight bits. Repeat, using 16 bits. Repeat, using 32 bits. What does this illustrate with respect to the properties of sign extension as they pertain to 2's complement representation?

11100101, 1111111111100101, 11111111111111111111111111100101. Sign extension does not affect the value represented.

Given n bits, how many distinct combinations of the n bits exist?

2^n

Using 5 bits to represent each number, write the representations of 7 and —7 in l's complement, signed magnitude, and 2's complement integers.

If each number is represented with 5 bits, 7 = 00111 in all three systems -7 = 11000 (1's complement) = 10111 (signed magnitude) = 11001 (2's complement)

Fill in the truth table for the logical expression NOT(NOT(A) OR NOT(B)). What single logic gate has the same truth table? A B NOT(NOT(A) OR NOT(B)) 0 0 0 1 1 0 1 1

NOT(NOT(A) OR NOT(B)) = A.B

Create two 16-bit 2's complement integers such that their sum causes an overflow.

Any two 16-bit 2's complement numbers that add to more than +32767 or less than -32768 would be correct.

Write IEEE floating point representation of the following decimal numbers. a. 3.75 b -55 § c. 3.1415927 d. 64,000

(a) 0 10000000 11100000000000000000000 (b) 1 10000100 10111010111000000000000 (c) To 3 binary places of precision: 0 10000000 10010000000000000000000 => b11.001 => 3.125 => cf. 3.142 (d) 0 10000101 00000000000000000000000

Convert these decimal numbers to 8-bit 2's complement binary numbers. a. 102 b. 64 c. 33 d. -128 e. 127

(a) 01100110 (b) 01000000 (c) 00100001 (d) 10000000 (e) 01111111

Write the 6-bit 2's complement representation of —32.

100000.

A company's board consists of 4 people: Abigail (founder & CEO), Benoit, Charlie, and Debra When they take a vote, if there is a majority (either up or down), that vote prevails. If, however, there is a tie, then Abigail's vote is the tie-breaker.

A B C D VOTE 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 1 1 0 0 1 0 0 0 0 1 0 1 0 0 1 1 0 0 0 1 1 1 1 1 0 0 0 0 1 0 0 1 1 1 0 1 0 1 1 0 1 1 1 1 1 0 0 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 For a': the only contribution is from a'.b.c.d For a: the only non-contribution is from a.b'.c'.d' So the full expression is vote = b.c.d + a.(b + c + d) - meaning the motion passes if all three of b, c & d vote for it, with a either for or against; or if a and any one of {b, c, d} vote for it. (this can be deduced from our standard simplification rules, or simply by inspection)

Define a new 8-bit floating point format with 1 sign bit, 4 bits of exponent, using an excess-7 code (that is, the bias is 7), and 3 bits of fraction. If xE5 is the bit pattern for a number in this 8-bit floating point format, what value does it have? (Express as a decimal number.)

Sign = 1 bit; biased Exponent = 4 bits (-7 to +7); normalized Mantissa = 3 bits xE5 => 1110 0101 => 1 (negative); 1100 => (12 - 7) = 5; 101 => 1.101 So we have: - 1.101 x 2^5 = -110100 = -52

Name at least three things specified by an ISA.

Some of the microprocessor details specified by its ISA: ● list of instructions ● memory architecture (address space, addressability) ● memory addressing modes ● general purpose register bank (number, size, etc) ● word size ● data types (integer, floating point, etc) ● condition codes

There are 26 characters in the alphabet we use for writing English. What is the least number of bits needed to give each character a unique bit pattern? How many bits would we need to distinguish between upper and lowercase versions of all 26 characters?

For 26 characters, we need at least 5 bits. For 52 characters, we need at least 6 bits.

If the last digit of a 2's complement binary number is 0, then the number is even. If the last two digits of a 2's complement binary number are 00 (e.g., the binary number 01100), what does that tell you about the number?

It is a multiple of 4.

Convert the following 2's complement binary numbers to decimal. a. 1010 b. 01011010 c. 11111110 d. 0011100111010011

(a) -6 (b) 90 (c) -2 (d) 14803

Compute the following. Write your results in binary. a. 0101011 1 AND 1101011 1 b. 10 1 AND 11 0 C. 1110000 0 AND 1011010 0 d. 0001111 1 AND 1011010 0 e. (001 1 AND 0110 ) AND 110 1 f . 001 1 AND (011 0 AND 1101 )

(a) 01010111 (b) 100 (c) 10100000 (d) 00010100 (e) 0000 (f) 0000

Compute the following: a. NOT (1011 ) OR NOT(llOO ) b. NOT (1 0 0 0 AND (110 0 OR 0101) ) C. NOT (NOT (1101 ) ) d. (011 0 OR 0000 ) AND 111 1

(a) 0111 (b) 0111 (c) 1101 (d) 0110

Add the following bit patterns. Leave your results in binary form. a. 1011 + 0001 b. 0000 + 1010 c. 1100 + 0011 d. 0101 + 0110 e. 1111 + 0001

(a) 1100 (b) 1010 (c) 1111 (d) 01011 (e) 10000

Add the following 2's complement binary numbers. Also express the answer in decimal. a. 01 + 1011 b. 11 + 01010101 c. 010 1 + 110 d. 01 + 10

(a) 1100 (binary) or -4 (decimal) (b) 01010100 (binary) or 84 (decimal) (c) 0011 (binary) or 3 (decimal) (d) 11 (binary) or -1 (decimal)

Add the following unsigned binary numbers. Also, express the answer in decimal. a. 01 + 1011 b. 11 + 01010101 c. 0101 + 110 d. 01 + 10

(a) 1100 (binary) or 12 (decimal) (b) 1011000 (binary) or 88 (decimal) (c) 1011 (binary) or 11 (decimal) (d) 11 (binary) or 3 (decimal)

The following binary numbers are 4-bit 2's complement binary numbers. Which of the following operations generate overflow? Justify your answer by translating the operands and results into decimal. a. 1100 + 0011 d. 1000 - 0001 b. 1100 + 0100 e. 0111 + 1001 c. 0111 + 0001

(a) 1100 + 0011 = 1111 -4 + 3 = -1 (b) 1100 + 0100 = 0000 -4 + 4 = 0 (c) 0111 + 0001 = 1000 OVERFLOW! 7 + 1 = -8 (d) 1000 - 0001 = 1000 + 1111 = 0111 -8 - 1 = -8 + (-1) = 7 OVERFLOW! (e) 0111 + 1001 = 0000 7 + -7 = 0

Compute the following: a. 0101011 1 OR 1101011 1 b. 10 1 OR 11 0 c. 1110000 0 OR 1011010 0 d. 0001111 1 OR 1011010 0 e. (010 1 OR 1100 ) OR 110 1 f . 010 1 OR (110 0 OR 1101 )

(a) 11010111 (b) 111 (c) 11110100 (d) 10111111 (e) 1101 (f) 1101

Without changing their values, convert the following 2's complement binary numbers into 8-bit 2's complement numbers. a. 1010 b 011001 c. 1111111000 d. 01

(a) 11111010 (b) 00011001 (c) 11111000 (d) 00000001

a. What is the largest positive number one can represent in an 8-bit 2's complement code? Write your result in binary and decimal. b. What is the greatest magnitude negative number one can represent in an 8-bit 2's complement code? Write your result in binary and decimal. c. What is the largest positive number one can represent in n-bit 2's complement code? d. What is the greatest magnitude negative number one can represent in n-bit 2's complement code?

(a) 127 in decimal, 01111111 in binary. (b) -128 in decimal, 10000000 in binary. (c) (2n−1)-1 (d) -(2n−1)

Write the decimal equivalents for these IEEE floating point numbers. a. 0 10000000 00000000000000000000000 b. 1 1000001 1 0001000000000000000000 0 c. 0 11111111 00000000000000000000000 d. 1 10000000 10010000000000000000000

(a) 2 (b) -17 (c) Positive infinity. NOTE: This was explained in class, not in the text. (d) -3.125

You wish to express -6 4 as a 2's complement number. a. How many bits do you need (the minimum number)? b. With this number of bits, what is the largest positive number you can represent? (Please give answer in both decimal and binary). c. With this number of bits, what is the largest unsigned number you can represent? (Please give answer in both decimal and binary).

(a) 7 bits. (b) 63 in decimal ( 0111111 in binary ) (c) 127 in decimal ( 1111111 in binary )

Refer to Example 2.11 for the following questions. a. What mask value and what operation would one use to indicate that machine 2 is busy? b. What mask value and what operation would one use to indicate that machines 2 and 6 are no longer busy? (Note: This can be done with only one operation.) c. What mask value and what operation would one use to indicate that all machines are busy? d. What mask value and what operation would one use to indicate that all machines are idle? e. Develop a procedure to isolate the status bit of machine 2 as the sign bit. For example, if the BUSYNESS pattern is 01011100, then the output of this procedure is 10000000. If the BUSYNESS pattern is 01110011, then the output is 00000000. In general, if the BUSYNESS pattern is: b7 b6 b5 b4 b3 b2 bl bO the output is: b2 0 0 0 0 0 0 0 • Hint: What happens when you ADD a bit pattern to itself?

(a) AND with 11111011 (b) OR with 01000100 (c) AND with 00000000 (d) OR with 11111111 (e) AND the BUSYNESS pattern with 00000100 to isolate b2. Then add that result to itself 5 times

a. Assume that there are about 400 students in your class. If every student is to be assigned a unique bit pattern, what is the minimum number of bits required to do this? b. How many more students can be admitted to the class without requiring additional bits for each student's unique bit pattern?

(a) For 400 students, we need at least 9 bits. (b) 2^9 = 512, so 112 more students could enter.

Translate the following ASCII codes into strings of characters by interpreting each group of eight bits as an ASCII character. a. x48656c6c6f21 b. x68454c4c4f21 c. x436f6d70757465727321 d. x4c432d32

(a) Hello! (b) hELLO! (c) Computers! (d) LC-2

Perform the following logical operations. Express your answers in hexadecimal notation. a. x5478 AND xFDEA b. xABCD OR xl234 c. NOT((NOT(xDEFA)) AND (NOT(xFFFF))) d. xOOFF XOR x325C

(a) x5468 (b) xBBFD (c) xFFFF (d) x32A3

Given n bits, how many unsigned integers can be represented with the n bits? What is the range of these integers?

2^n integers can be represented. The range would be 0 to (2^n) - 1.

A company's board consists of 4 people: Abigail (the CEO), Benoit, Charlie, and Debra When they take a vote, if there is a majority (either up or down), that vote prevails. If, however, there is a tie, then Abigail's vote is the tie-breaker. Show the table representing all possible combinations of the 4 votes, and the final decision for each.

A B C D VOTE 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 1 1 0 0 1 0 0 0 0 1 0 1 0 0 1 1 0 0 0 1 1 1 1 1 0 0 0 0 1 0 0 1 1 1 0 1 0 1 1 0 1 1 1 1 1 0 0 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 Interpretation: - If Abigail votes against (0): the vote will pass (1) ONLY if all 3 partners vote for it. - If Abigail votes for: the vote will fail ONLY if all 3 partners vote against it (OR: the vote will pass if any one of the 3 partners votes for it) Just from this verbal description, we can deduce the corresponding boolean expression: V = A'.B.C.D + A.(B + C + D)

If A and B are four-bit unsigned binary numbers, 0111 and 1011, complete the table obtained when using a two-bit full adder from Figure 3.15 to calculate each bit of the sum, S, of A and B. Check your answer by adding the decimal value of A and B and comparing the sum with 5. Are the answers the same? Why or why not? Look at 3.15 figure

Cin 1 1 1 0 A 0 1 1 1 B 1 0 1 1 S 0 0 1 0 Cout 1 1 1 1 A = 7, B = 11, A + B = 18. In the above calculation, the result (S) is 2 !! This is because 18 is too large a number to be represented in 4 bits. Hence there is an overflow - Cout[3] = 1.

It was demonstrated in Example 2.5 that shifting a binary number one bit to the left is equivalent to multiplying the number by 2. What operation is performed when a binary number is shifted one bit to the right?

Dividing the number by two.

Why is an ISA unlikely to change between successive generations of microarchitectures that implement it? For example, why would Intel want to make certain that the ISA implemented by the Pentium III is the same as the one implemented by the Pentium II?

ISA's don't change much between successive generations, because of the need for backward compatibility. You'd like your new computer to still run all your old software!

Say you go to the store and buy some word processing software. What form is the software actually in? Is it in a high-level programming language? Is it in assembly language? Is it in the ISA of the computer on which you'll run it? Justify your answer.

It is in the ISA of the computer that will run it. We know this because if the word processing software were in a high or low level programming language, then the user would need to compile it or assemble it before using it. That's not how it works. The user just needs to copy the files to run the program, because it is already in the correct machine language, or ISA.

Describe what conditions indicate overflow has occurred when two 2's complement numbers are added.

Overflow has occurred if both operands are positive and the result is negative, or if both operands are negative and the result is positive.

Implement the following functions using AND, OR, and NOT logic gates. The inputs are A, B, and the output is F. a. F has the value 1 only if A has the value 0 and B has the value 1. b. F has the value 1 only if A has the value 1 and B has the value 0. c. Use your answers from (a) and (b) to implement a 1-bit adder. The truth table for the 1-bit adder is given below. A B Sum 0 0 0 0 1 1 1 0 1 1 1 0 d. Is it possible to create a 4-bit adder (a circuit that will correctly add two 4-bit quantities) using only four copies of the logic diagram from (c)? If not, what information is missing? Hint: When A = 1 and B = 1, a sum of 0 is produced. What information is not dropped?

The 1-bit sum truth table is just a xor b => a'.b + a.b' Look at the circuit in HW solutions This circuit will produce the sum bit of a two-bit addition; it will not produce the carry bit into the next column, nor will it accept the carry bit into the current column.

In Example 2.11, what are the masks used for?

The masks are used to set bits (by ORing a 1) and to clear bits (by ANDing a 0).

Given four inputs: a, b, c & d, where (a, b) represents a 2-bit unsigned binary number X; and (c, d) represents a 2-bit unsigned binary number Y (i.e. both X and Y are in the range #0 to #3) - i.e. same inputs as q. 1: Together, these outputs correspond to the unsigned 4-bit product of the two numbers X, Y In this exercise, you are to derive only the two boolean expressions for output columns o0 and o2

a b c d o3 o2 o1 o0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 1 0 0 0 1 0 1 1 0 0 0 1 0 0 1 1 1 0 0 1 1 1 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 1 0 1 0 0 1 0 0 1 0 1 1 0 1 1 0 1 1 0 0 0 0 0 0 1 1 0 1 0 0 1 1 1 1 1 0 0 1 1 0 1 1 1 1 1 0 0 1 o0 = a' . b . c' . d + a' . b . c . d + a . b . c' . d + a . b . c . d = b . d (i.e. the result is odd only if both multiplicands are odd) - simple to implement! o2 = a . b' . c . d' + a . b' . c . d + a . b . c . d' = a . b . c + a . c . d' (i.e. the result is 4 or 6 only for 2 * 2, 2 * 3, or 3 * 2) - see circuit below:

Given four inputs: a, b, c & d, where (a b) represents a 2-bit unsigned binary number X; and (c d) represents a 2-bit unsigned binary number Y (i.e. both X and Y are in the range #0 to #3): The output is z​, which is 1 whenever X > Y, and 0 otherwise (this circuit is part of a "2-bit comparator"). Truth table:

a b c d z 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 1 1 0 0 1 0 0 1 0 1 0 1 0 0 1 1 0 0 0 1 1 1 0 1 0 0 0 1 1 0 0 1 1 1 0 1 0 0 1 0 1 1 0 1 1 0 0 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 The relevant rows (i.e rows with output = 1) in the truth table come from: 01 > 00, 10 > 00, 10 > 01, 11 > 00, 11 > 01, 11 > 10 This gives us the Boolean expression: z = a'.b.c'.d' + a.b'.c'.d' + a.b'.c'd + a.b.c'.d' + a.b.c'.d + a.b.c.d' z = b.c'.d' + a.b'.c' + a.c'.d' + a.c'.d + a.b.c' + a.b.d' z = a.c' + a.b.d' + b.c'.d' (You could have come up with this expression by inspection. Try interpreting it verbally, e.g. the first term says "any 2-bit number whose leading bit is 1 is greater than any 2-bit number whose leading bit is 0" - duh! Now do the same with the other two terms.)


Conjuntos de estudio relacionados

NETWORK+ GUIDE TO NETWORKS CHAPTER 3

View Set

Social Studies Exploration Crossword

View Set

NCLEX 10000 ENDOCRINE AND METABOLIC

View Set

Principles of Management: Ch. 10 Quiz

View Set