RTL Exercises Spring2010 Solution

8

description

Computer System OrganizationComputers System Archtecture

Transcript of RTL Exercises Spring2010 Solution

Page 1: RTL Exercises Spring2010 Solution
Gandhi
Pencil
Gandhi
Pencil
Page 2: RTL Exercises Spring2010 Solution
Page 3: RTL Exercises Spring2010 Solution
Page 4: RTL Exercises Spring2010 Solution
Page 5: RTL Exercises Spring2010 Solution
Gandhi
Pencil
Page 6: RTL Exercises Spring2010 Solution

ee457_Quiz_fl2009.fm 9/20/09

EE457 Quiz - Fall 2009 3 / 9 C Copyright 2009 Gandhi Puvvada

2.3 Signed adder with extra bit for result: Given below is a 4-bit adder design with logic to produce overflow C4 (for unsigned) and V (for signed). You need to alter it as needed to produce the 5-bit result R (R4, R3, R2, R1 R0) treating the numbers as signed. Try to use as minimal extra logic as possible. If there is an overflow V even though the result is 5 bits, then you need to produce that V bit also. Some points to ponder. We can use an additional slice of full-adder, sign-extend A and B and produce the additional result bit S4 (which is perhaps the R4). But perhaps that is not the minimal logic. If the 4-bit result S3 S2 S1 S0 is good (V = 0), then can we sign-extend the result to 5 bits? Will S3 be different from the R3 even if V = 1 for 4-bit addition? If we use another full-adder slice and make it a 5-bit adder, this S3 will still be the same, right? Well if S3 is going to be the same, then can we generate S4 based on S3 and V (the V produced by the 4-bit adder). In SLT implementation, we figured out the true sign of the difference even when D31 (difference bit 31) was wrong (as indicated by V = 1) by conditioning it with V. So what if we do something similar here (knowing that we are now dealing with an adder and not a subtractor)? Are we trying to get correct S3 or correct S4?

To further extend the result by 3 bits (a total of 8 bits: R7 R6 R5 R4 R3 R2 R1 R0), do we need some more logic (say 3 more full-adders), or .... Please comment.____________________________________________________________________________ ____________________________________________________________________________ ____________________________________________________________________________

2.4 Compare these two 32-bit signed numbers (in 2’s complement system). The 20 X’s and the 20 Y’s can be replaced by any bit combinations. Example the 20 X’s can be 20 ones and the 20 Y’s can be 20 zeros or vice versa. A is __________ (greater than / less than / can’t be compared with) B. A: 1111_0000_1010_XXXX_XXXX_XXXX_XXXX_XXXXB: 1111_0000_1011_ YYYY_YYYY_YYYY_YYYY_YYYY

3 ( points) min.

State diagram design:

You are given a sorted array M of ten 4-bit unsigned numbers. M[0] is the smallest and M[9] is the largest. We need to copy the elements of array M to array N. However, while in array N, every number is treated as a signed number represented in 2’s complement notation. You know that sorting will be different for signed numbers. Actually it is interestingly not that different. For example, 1110 is always higher (or greater) than 1100. 1110 = 14 in unsigned numbers; 1110 = -2 in signed numbers 1100 = 12 in unsigned numbers; 1100 = -4 in signed numbers So, if you consider the original array M of unsigned numbers as made up of two separate chunks of sorted numbers, first chunk of numbers starting with "0" in MSB and the second chunk of numbers starting with "1" in MSB, then to resort and arrange them in array N, we need to simply copy the second chunk (of array M) as the first chunk (of array N) and then copy the first chunk (of array M) as the second chunk (of array N).

a bcin

scout

a bcin

scout

a bcin

scout

a bcin

scout

A3 A2 A1 A0B3 B2 B1 B0

S3 S2 S1 S0

C0

V

C1C2C3C4C4 C3

Page 7: RTL Exercises Spring2010 Solution

ee457_Quiz_fl2009.fm 9/20/09

EE457 Quiz - Fall 2009 4 / 9 C Copyright 2009 Gandhi Puvvada

Note: the array M can have only one chunk (i.e. all numbers starting with either "0" or "1")."I" is the index into memory array M. "J" is the index into memory array N. N[J] <= M[I] causes copying of one element.

3.1 Implementation #1: States: (see the state diagram on the next page)

LS2C Locate Start of the 2nd Chunk in array M (increment I until MSB of M[I] is a "1"; but what if there are no numbers starting with a "1"?)

C221 Copy 2 to 1 (= Copy Chunk 2 of M to Chunk 1 of N)C122 Copy 1 to 2 (= Copy Chunk 1 of M to Chunk 2 of N)

After copying one chunk, "I" has to wrap around before you start copying the second chunk. But "J" goes on! So, instead of worrying about what value of "I" indicates the end of the second chunk copying, one can look at the terminal value of "J". In fact, if J is at its terminal value can you go to DONE state whether, you are at C221 or C122? Yes / No.

Wrapping "I" around: You would use __________ (I = 9 / I = 10) as wrap-around condition.

Is it possible for I" to become 9 in LS2C itself? Yes / No

In what kind of situation do you need to initiate wrapping of "I" around in LS2C? ____________________________________________________________________________ ____________________________________________________________________________

In the example M array at the top of this page, M[9] is the first element with its MSB M[I][3] = 1. You detect this in LS2C. Will you transfer this element of M to N in LS2C itself and save a clock, or will you waste a clock and transfer it in C221 state? You will ____________ (save / waste) a clock.

Which of the following 4 M arrays will result in taking the least number of clocks in the three states LS2C, C221, C112 together? _____________ (write the roman numeral(s) for the case(s).How many clocks is that least number of clocks? __________

(i) all elements of the array M start with a "0" in their MSB.(ii) all elements of the array M start with a "1" in their MSB.(iii) the first 9 elements of the array M start with a "0" and the last starts with a "1".(iv) the first element of the array M starts with a "0" and the rest of 9 start with a "1".

Which of the above 4 M arrays will result in taking the maximum number of clocks in the three states LS2C, C221, C112 together? _____________ (write the roman numeral(s) for the case(s).How many clocks is that maximum number of clocks? __________

0001

0011

0110

1001

0010

0101

0111

1100

1 -7

-4

+1

+3

-6

-2

+2

+6

2

5

9

12

3

6 7

10

14

+5

+7

1010

1110

0001

0011

0110

1001

0010

0101

0111

11001010

1110

I JArray NArray M

Chu

nk #

2

Chu

nk #

2

Chu

nk #

1

Chu

nk #

1

Chunk #1 to Chunk #2

Chunk #2 to Chunk #1

Page 8: RTL Exercises Spring2010 Solution

ee457_Quiz_fl2009.fm 9/20/09

EE457 Quiz - Fall 2009 5 / 9 C Copyright 2009 Gandhi Puvvada

3.2 Implementation #2: States:

LS2C Same as before CBC Copy Both Chunks (Of course, copy Chunk 2 of M to Chunk 1 of N first, followed by Chunk 1 of M to Chunk 2 of N.)

Your TA, Mr. Tojan, says that you can combine the two states, C221 and C122, of the previous implementation into a single state CBC as defined above, as basically, in both these states, you copy an element of M into N and advance both "I" and "J". Complete the following state machine.

3.3 Based on the number of clocks taken in different cases, the implementation #2 is _____________________________ (superior to / inferior to / at the same level as) the implementation #1.

StartR

eset

INII <= 0;

Star

t

J <= 0;

LS2C C221 C122

ACK

DONEACK

Start

Res

et

INII <= 0;

Star

t

J <= 0;

LS2C

ACK

DONEACK

CBC