Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

Chapter 6: Appendix B, 11. (page 500)

Assume that X consists of 3 bits : x2, x1, x0. Write four logic functions that are true if and only if

  • X contains only one 0
  • X contains an even number of 0s
  • X when interpreted as an unsigned binary number is less than 4
  • X when interpreted as a signed (two’s complement) number is negative.

Short Answer

Expert verified

X contains only one 0:

X=x2.x1.x0+x2..x1.x0+x2.x1..x0

X contains an even number of zero

X=x2.x1.x0+x2.x1..x0+x2..x1..x0

X interpreted as an unsigned binary number less than 4

Y=x2

X interpreted as a negative number

Y = x2

Step by step solution

01

Determine the logical gates

The basic logic gates are AND, OR, and NOT. AND gate will take two inputs and produce output as 1 only if both the inputs are 1. OR gate will take two inputs and produce output 1 if any of the inputs is 1. NOT gate will take only one input and gives the opposite of the input as the output. 1. All the logical gates will be represented by the truth tables. XOR, NAND, XNOR are the exclusive gates that are derived from the basic gates.

02

Determine the logic functions

Given that the X consists of 3 bits x0, x1, and x2. The logic functions for which that are true if and only if

  • X contains only one 0
  • X contains an even number of 0s
  • X when interpreted as an unsigned binary number is less than 4
  • X when interpreted as a signed (two’s complement) number is negative.

For X contains only one zero, only one of the three bits should be zero. The logical function that satisfies this condition is as follows:

X=x2.x1.x0+x2..x1.x0+x2.x1..x0

For X contains an even number of 0s, two bits of the three bits should be zero. The logical function that satisfies this condition is as follows:

X=x2..x1.x0+.x2.x1..x0+.x2.x1..x0

For X when interpreted as an unsigned binary number is less than 4 is as follows:

Y=.x2

ForX when interpreted as a signed (two’s complement) number is negative. The values will be complements and the logical function is as:

Y=x2

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with Vaia!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

Prove that a two-input multiplexor is also universal by showing how to build the NAND (or NOR) gate using a multiplexor

Perhaps the most likely case of adding many numbers at once in a computer would be when trying to multiply more quickly by using any adders to add many numbers in a single clock cycle. Compared to the multiply algorithm in Chapter 3, a carry save scheme with many adders could multiply more than 10 times faster. This exercise estimates the cost and speed of a combinational multiplier to multiply two positive 16-bit numbers. Assume that you have 16 intermediate terms M15, M14, …, M0, called partial products, that contain the multiplicand ANDed with multiplier bits m15, m14, …, m0. The idea is to use carry save adders to reduce the noperands into 2n/3 in parallel groups of three, and do this repeatedly until you get two large numbers to add together with a traditional adder.

First, show the block organization of the 16-bit carry save adders to add these 16 terms, as shown on the right in Figure B.14.1. Then calculate the delays to add these 16 numbers. Compare this time to the iterative multiplication scheme in Chapter 3 but only assume 16 iterations using a 16-bit adder that has full carry lookahead whose speed was calculated in Exercise B.29.

Question: 6.18 When performing computations on sparse matrices, latency in the memory hierarchy becomes much more of a factor. Sparse matrices lack the spatial locality in the data stream typically found in matrix operations. As a result, new matrix representations have been proposed. One the earliest sparse matrix representations is the Yale Sparse Matrix Format. It stores an initial sparse m × n matrix, M in row form using three one-dimensional arrays. Let R be the number of nonzero entries in M. We construct an array A of length R that contains all nonzero entries of M (in left -to-right top-to-bottom order). We also construct a second array IA of length m + 1 (i.e., one entry per row, plus one). IA(i) contains the index in A of the first nonzero element of row i. Row i of the original matrix extends from A(IA(i)) to A(IA(i+1)−1). The third array, JA, contains the column index of each element of A, so it also is of length R.

6.18.1 [15] consider the sparse matrix X below and write C code that would store this code in Yale Sparse Matrix Format.

Row 1 [1, 2, 0, 0, 0, 0]

Row 2 [0, 0, 1, 1, 0, 0]

Row 3 [0, 0, 0, 0, 9, 0]

Row 4 [2, 0, 0, 0, 0, 2]

Row 5 [0, 0, 3, 3, 0, 7]

Row 6 [1, 3, 0, 0, 0, 1]

6.18.2 [10] In terms of storage space, assuming that each element in matrix X is single precision floating point, compute the amount of storage used to store the Matrix above in Yale Sparse Matrix Format.

6.18.3 [15] Perform matrix multiplication of Matrix X by Matrix Y shown below. [2, 4, 1, 99, 7, 2] Put this computation in a loop, and time its execution. Make sure to increase the number of times this loop is executed to get good resolution in your timing measurement. Compare the runtime of using a naïve representation of the matrix, and the Yale Sparse Matrix Format.

6.18.4 [15] Can you find a more efficient sparse matrix representation (in terms of space and computational overhead)?

B.23 [20] <§§B3, B.4, B.5> Repeat Exercise B.22, but for an unsigned divider rather than a multiplier.

Rewrite the code for fact to use fewer instructions.

See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.

Sign-up for free