Sunteți pe pagina 1din 8

CSCI 220: Computer Architecture-I Instructor: Pranava K. Jha BCD Codes Q.

Give representation of the decimal number 853 in each of the following codes. (a) 8421 code (c) 84(-2)(-1) code Decimal digit 8 5 3 8421 code 1000 0101 0011 (b) Excess-three code (d) 753(-6) code. Excess-three code 1011 1000 0110 84(-2)(-1) code 1000 1011 0101 753(-6) code 0110 0100 0010

A code for the decimal number 853 is obtainable by carefully juxtaposing the respective four-bit groups for 8, 5 and 3, respectively. Decimal number 853 8421 code 100001010011 Excess-three code 101110000110 84(-2)(-1) code 100010110101 753(-6) code 011001000010

Q. Encode the decimal digits 0 through 9 with four bits using 832(4) code. Is this code self-complementing? Explain. Decimal digit 0 1 2 3 4 5 6 7 8 9 832(4) code 0 0 1 1 0 1 1 0 0 0 1 1 0 1 1 0 0 0 1 1

0 0 0 0 1 0 1 1 1 1

0 1 0 0 1 0 1 1 0 1

The code is indeed self-complementing. This is because if a decimal digit r receives the code abcd, then the decimal digit 9 r receives the code abcd, where a = 1 a.

1 of 8

Computer Architecture-I: BCD Codes (Instructor: Pranava K. Jha)

Q. Prove that in a four-bit weighted BCD code with all positive weights, at most one weight can exceed 4. Let w1, w2, w3 and w4 be the four positive weights in weighted BCD code. Assume by way of contradiction that there are at least two weights that are greater than 4, i.e., a maximum of two weights are between 1 and 4. Without loss of generality, assume that 1 w1 w2 4, and w3, w4 5. The following table shows that at least one decimal digit cannot be represented in such a code. w1 w2 1 1 1 1 2 2 2 3 3 4 1 2 3 4 2 3 4 3 4 4 Cannot represent 3 or 4. Cannot represent 4. Cannot represent 2. Cannot represent 2 or 3. Cannot represent 1 or 3. Cannot represent 1 or 4. Cannot represent 1 or 3. Cannot represent 1, 2 or 4. Cannot represent 1 or 2. Cannot represent 1, 2 or 3.

The situation is worse if there is just one weight between 1 and 4. Contradiction! Q. Consider the string 100010010111. What decimal number does it represent if it is viewed as a string in (a) BCD, (b) Excess-three code and (c) 84(-2)(-1) code? Examine 100010010111 as a string of four-bit groups as below. 1000 1001 0111 Now replace each four-bit group by the corresponding decimal digit in the respective code. BCD 897 Excess-three code 564 84(-2)(-1) code 871

100010010111

2 of 8

Computer Architecture-I: BCD Codes (Instructor: Pranava K. Jha)

Q. Complete the following table with respect to 7536 BCD code. Decimal digit 0 1 2 3 4 5 6 7 8 9
7536 code 0 0 0 0 1 1 0 1 0 1 1 0 1 0 0 0 1 1 1 1

0 1 0 0 1 0 1 1 0 1

0 1 1 0 1 0 1 0 0 1

7536 code is an example of a self-complementing code. Such a code has the property that the code word for the 9's complement of a digit is obtainable by complementing the individual bits of the digit's code word. Other self-complementing codes include excessthree code and 8 4 21 code. Self-complementing codes were used in early calculators.

Q. A four-input, one-output circuit is to be designed. The inputs are 7536 code groups. The output f is (i) a 1 if the digit D represented is in the range 0 D 3, (ii) a 0 if the digit D is in the range 4 D 9, and (iii) a if the digit D is invalid, i.e., not in the range 0 D 9. Complete the following table for this purpose.

7 w 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1

5 x 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1

3 y 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1

6 z 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1

Digit D 0 3 5 8 2 7 1 4 6 9

Output f 1 1 0 0 1 0 1 0 0 0

3 of 8

Computer Architecture-I: BCD Codes (Instructor: Pranava K. Jha)

Q. Prove that in a self-complementing BCD code, which can have both positive and negative weights, the algebraic sum of all the weights must be 9.

A self-complementing BCD code has the property that the four-bit binary string corresponding to a digit d is obtainable from the four-bit binary string corresponding to (9 d) through bit-wise complementation. If a digit d is representable as the four-bit binary string a3a2a1a0, then the digit (9 d) is representable as (1 a3 )(1 a2) (1 a1) (1 a0), where 0 d 9 and 0 ai 1. Let w3, w2, w1 and w0 be the weights of a self-complementing BCD code. Further, let a3a2a1a0 be the code for the digit 0, whence (1 a3 )(1 a2) (1 a1) (1 a0) is the code for the digit 9. It is clear that 0 = a3w3 + a2w2 + a1w1 + a0w0 . 9 = (1 a3)w3 + (1 a2)w2 + (1 a1)w1 + (1 a0)w0. A simple summation yields: 9 = w3 + w2 + w1 + w0 . QED
Q. Encode the decimal digits 0 through 9 with four bits using the following weighted BCD codes. For each code, state whether it is self-complementing or not: (i) 7635 code, (ii) 8324 code.
7635 code 8324 code

0 1 2 3 4 5 6 7 8 9

0000 0101 1001 0010 0111 1011 0100 1000 1101 0110

0 1 2 3 4 5 6 7 8 9

0000 0111 0010 0100 1001 0110 1011 1101 1000 1111

It is clear that 7635 code is not self-complementing while 8324 code is.

4 of 8

Computer Architecture-I: BCD Codes (Instructor: Pranava K. Jha)

Q. The following block diagram corresponds to a code converter that takes a four-bit representation of a decimal digit in 84(-2)(-1) code and produces the corresponding fourbit representation in 8421 code. A B C D

8 4 -2 -1

8 4 2 1

W X Y Z

Develop simplified expressions for W, X, Y and Z in terms of A, B, C and D. Make use of dont-care conditions. The following table is immediate. 84(-2)(-1) code
A B C D

Decimal digit 0 4 3 2 1 8 7 6 5 9

BCD
W X Y Z

0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1

0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1

0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1

0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1

0 0 0 0 1 0 0 0
1

1 0 0 0 0 1 1 1

0 1 1 0 0 1 1 0

0 1 0 1 0 1 0 1

0 0 1

Karnaugh maps follow.

5 of 8

Computer Architecture-I: BCD Codes (Instructor: Pranava K. Jha)

K-map for W

K-map for X

K-map for Y Simplified expressions and a circuit diagram follow.


w = AB +ACD. x = BC + BD +BCD. y = CD + CD. z = D.

K-map for Z

6 of 8

Computer Architecture-I: BCD Codes (Instructor: Pranava K. Jha)

Q. The following block diagram corresponds to a code converter that takes a four-bit representation of a decimal digit in 8421 code and produces the corresponding four-bit representation in excess-three code. A B C D

8 4 2 1

W W Y Z

Present the truth table for this purpose. Make use of dont-care conditions.

8421 code
A B C D

Decimal digit 0 1 2 3 4 5 6 7 8 9

Excess-three code W X Y Z 0 0 0 0 0 1 1 1 1 1

0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1

0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1

0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1

0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1

0 1 1 1 1 0 0 0 0 1

1 0 0 1 1 0 0 1 1 0

1 0 1 0 1 0 1 0 1 0

7 of 8

Computer Architecture-I: BCD Codes (Instructor: Pranava K. Jha)

Q. Find the binary representation for each of the following BCD numbers:

0100100001100111 001101111000.01110101 (0100 1000 0110 0111)BCD = (4867)10 = (1001100000011)2 (0011 0111 1000.0111 0101)BCD = (378.75)10 = (101111010.11)2

Q. Consider the binary string 100010010111. What decimal number does it represent if it is viewed as a string in (a) BCD, (b) Excess-three code and (c) 84(-2)(-1) code?

Examine 100010010111 as a string of four-bit groups as below. 1000 1001 0111 Now replace each four-bit group by the corresponding decimal digit in the respective code. Binary string 100010010111 8421 (BCD) 897 Excess-three code 564 84(-2)(-1) code 871

8 of 8

S-ar putea să vă placă și