Mallard ECE 290: Computer Engineering I - Spring 2007 - HWK #1 Sol...
https://mallard.cites.uiuc.edu/ECE290/material.cgi?SessionID=mding3_...
1 of 4
4/29/2007 4:23 PM
HWK #1 Solutions
Problem 1.1
(a) i.
17
10
= (1,2,2)
3
= 1x9 + 2x3 + 2x1
So to weigh the 17-gram object, we will need
one 9-gram weight, two 3-gram weights, and two
1-gram weights
.
Similarly, 31
10
= (1,0,1,1)
3
= 1x27 + 0x9 + 1x3 + 1x1
So to weigh the 17-gram object, we will need
one 27-gram weight, one 3-gram weight, and one
1-gram weights
.
ii.
This works because the weights (and the number of weights we have) can be used as a basis for base 3
arithmetic.
(b)
We only need one weight each of 1, 3, 9, and 27 grams (i.e. we do not need to have two of each).
i.
17
10
= (1,-1,0,-1)
3
= 1x27 + 0x9 - 1x3 - 1x1
So to weigh the 17-gram object, we will need
one 27-gram weight, one 3-gram weight, and one
1-gram weight
. We will place the 27-gram weight on the opposite side of the scale, and place the 3- and
1-gram weights on the same side of the scale as the object we are weighing.
Systematically, 17
10
= (1,2,2)
3
= (1,3,-1)
3
= (2,0,-1)
3
= (1,-1,0,-1)
3
.
Now, as we have seen before, 31
10
= (1,0,1,1)
3
. Here we need make no change in order to accommodate
our new set of weights.
ii.
The reason is that we can effectively have a -1 coefficient in our base 3 representation (practically, we
would accomplish this by putting the weight on the same side of the scale as the object whose weight we
are trying to measure).
2x3
k
= 3x3
k
- 3
k
= 1x3
k+1
- 1x3
k
.
Problem 1.2
(a)
For a 4-bit standard binary counter, there is 1 bit flip between 0000 and 0001.
2 bit flips between 0001 and 0010.
1 bit flips between 0010 and 0011.
3 bit flips between 0011 and 0100.
...
To count through all 16 numbers, we will have a total of
1+2+1+3+1+2+1+4 + 1+2+1+3+1+2+1+4 = 30 bit flips.
Therefore, the average power consumed when counting from one number to the next is
(30/16) x C
.
For a 4-bit Gray code counter, there is 1 bit flip between all successive numbers.
Therefore, the average power consumed when counting from one number to the next is
(16/16) x C
.