RTL Exercises Spring2010 Solution
RTL Exercises Spring2010 Solution
RTL Exercises Spring2010 Solution
fm 9/20/09
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 5bit 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?
A3
C4 C3
C4
B3
A2
B2
A1
A0
B1
B0
a b
a b
a b
a b
C0
C3
C2
C1
cin
cout cin
cout cin
cout cin
s
s
s
s
cout
S3
S2
S1
S0
2.4
Compare these two 32-bit signed numbers (in 2s complement system). The 20 Xs and the 20
Ys can be replaced by any bit combinations. Example the 20 Xs can be 20 ones and the 20 Ys
can be 20 zeros or vice versa. A is __________ (greater than / less than / cant be compared with) B.
A: 1111_0000_1010_XXXX_XXXX_XXXX_XXXX_XXXX
B: 1111_0000_1011_ YYYY_YYYY_YYYY_YYYY_YYYY
points)
min.
Chunk #1
h
to C
#2
unk
Ch
Ch
unk
#1
unk
to C
#1
hun
k
#2
Chunk #2
Chunk #2
1
2
3
5
6
7
9
10
12
14
Array M
0001
0010
0011
0101
0110
0111
1001
1010
1100
1110
Chunk #1
ee457_Quiz_fl2009.fm 9/20/09
Array N
1001
1010
1100
1110
0001
0010
0011
0101
0110
0111
-7
-6
-4
-2
+1
+2
+3
+5
+6
+7
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
C221
C122
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)
(ii)
(iii)
(iv)
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? __________
EE457 Quiz - Fall 2009 4 / 9
Reset
ee457_Quiz_fl2009.fm 9/20/09
I <= 0;
J <= 0;
ACK
ACK
Sta
rt
Start
DONE
INI
LS2C
3.2
C221
C122
Same as before
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.)
Reset
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.
I <= 0;
J <= 0;
DONE
ACK
ACK
Sta
rt
Start
INI
LS2C
3.3
CBC
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.
EE457 Quiz - Fall 2009 5 / 9