• No results found

FINDING DECIMAL EQUIVALENT OF A GIVEN EXCESS-3 CODE

BINARY CODES

FINDING DECIMAL EQUIVALENT OF A GIVEN EXCESS-3 CODE

Corresponding to a given excess-3 code, the equivalent decimal number can be determined by first splitting the number into four-bit groups, starting from the radix point, and then write decimal equivalent of each group. Now subtract 3 from each decimal digit, the result will give decimal equivalent.

Page 94 Binary Codes Chapter 2

Digital Electronics by Ashish Murolia and RK Kanodia For More Details visit www.nodia.co.in

Reflection of Gray Codes

Gray codes are also reflected code. The reflection of Gray code upto 4-bit is shown in Table 2.6.2. Following steps show how an n-bit Gray codes can be obtained using reflection.

1. We can generate an n-bit Gray code by reflecting an n-1 bit Gray code about an axis at the end of the code as shown in Table 1.6.2. The reflected Gray code is nothing but the code written in reverse order.

2. To obtain the first 2n-1 numbers, prefix a ‘0’ to the Gray code

for n-1 bits above the axis.

3. To obtain the remaining 2n-1 numbers, prefixing ‘1’ to the

reflected Gray code for n-1 bits below the axis.

Table 2.6.2 : Generation of higher-bit Gray code numbers

For example to generate a 4-bit Gray code, we reflect 3-bit Gray codes about an axis as shown in second column of 3-bit Gray codes. Then we prefix a ‘0’ to the first eight Gray codes above the axis and then prefix ‘1’ to the reflected eight Gray codes below the axis. It generates the complete four bit Gray codes.

2.6.1

Binary-to-Gray Code Conversion

A given binary number can be converted into its Gray code equivalent by going through the following steps:

Page 96 Binary Codes Chapter 2

Digital Electronics by Ashish Murolia and RK Kanodia For More Details visit www.nodia.co.in (b) _ i1410 =_1110i2

Gray code of 14 =1001

(c) _ i7410 =_1001010i2

Gray code of 74 =1101111

2.6.2

Gray-to-Binary Code Conversion

A given Gray code number can be converted into its binary equivalent by going through the following steps:

M E T H O D O L O G Y

1. The most significant bit(lef-most bit) of the equivalent binary code is the same as the MSB of the given Gray code. 2. Add the MSB of the binary to the next significant bit of the

Gray code, note the sum and ignore the carry.

3. Add the 2nd bit of the binary to the 3rd bit of the Gray; the 3rd bit of the binary to the 4th bit of the Gray code, and so on, each time note the sum and ignore the carry.

4. Continue above step till all Gray bits are used. This sequence of bits is the binary equivalent of the Gray code number. For example the conversion of Gray code 11011 is shown as

below.

EXAMPLE 2.13

Convert the following Gray code number into binary. (a) 101101 (b) 10101111

SOLUTION :

(a)

Page 98 Binary Codes Chapter 2

Digital Electronics by Ashish Murolia and RK Kanodia For More Details visit www.nodia.co.in Suppose the disk is coded in binary as shown in Figure 2.6.1(a).

Consider now what happens when the brushes are on the 111 sector and almost ready to enter the 000 sector. If one brush were slightly ahead of the other, say the 3rd brush, the position would be indicated by a 011 instead of a 111 or 000. Therefore, a 180c error in disk position would result. Since it is physically impossible to have all the brushes precisely aligned, therefore some error would always be present at the edges of the sectors.

The Gray code is used to reduce the error. Suppose the disk is coded in Gray as shown in Figure 2.6.2(b). For example if the brushes are on the sector 010 and almost ready to enter the 110 sector and if the 3rd brush is slightly ahead, the position would be indicated by 110 instead of 010 resulting in a very small error. In this case the only two outputs during the transition are 110 and 010 irrespective of brush alignment. A similar situation occur at the transition between each two adjacent sectors.

2.7 2-4-2-1 CODE

This is a numeric code, where each digit of a decimal number is represented using four bits. It is another self-complementing code. Also, it is a weighted code, the weight of binary symbol 1 depends on its position. The weights of b3, b2, b1, and b0 are 2, 4, 2, and 1, respectively. Thus, this code is referred to as 2-4-2-1 code. Table 2.7.1 shows the decimal digit and their 2-4-2-1 codes.

Table 2.7.1: Decimal digits and their 2-4-2-1 codes

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

Excess-3 Code 0011 0001 0010 0011 0100 1011 1100 1101 1110 1111

2.7.1

Other 4-bit BCD Codes

There are various other weighted 4-bit BCD codes, each developed to have certain properties useful for special applications. These codes are numeric codes, in which each digit of a decimal number is represented by four bits. These codes are weighted codes and the weight of each bit depends on its position.

Table 2.7.2: Decimal digits and its 4-bit BCD codes

Decimal Digit 6311 5421 5311 5211 4221 3321 7421 7421 8421 0 0000 0000 0000 0000 0000 0000 0000 0000 0000 1 0001 0001 0001 0001 0001 0001 0001 0111 0111 2 0011 0010 0011 0011 0010 0010 0010 0110 0110 3 0100 0011 0100 0101 0011 0011 0011 0101 0101 4 0101 0100 0110 0111 1000 0101 0100 0100 0100 READER NOTE

In the 2421 BCD code, the weights are 2-4-2- 1, meaning that bit 1 and bit 3 have the same weight of 2.

Among those 2421, 3321 and 4221 are the self complementing codes.

Page 100 Binary Codes Chapter 2

Digital Electronics by Ashish Murolia and RK Kanodia For More Details visit www.nodia.co.in

2.8 BIQUINARY CODE

It is a weighted 7-bit BCD code. Each digit of a decimal number is represented by seven binary digits. Decimal digits and their biquinary codes are given in Table 2.8.1. Note that these seven bits are divided into two subgroups; one with 2 bit and other with 5 bits. Each of these subgroups contains a single 1. The weights of the bit positions are 50 43210, therefore it is also known as 5043210 code.

Table 2.8.1: The biquinary code

Decimal Digit Biquinary Code

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

This code is a parity data code. Since for each code group there are exactly two 1’s and each subgroup there is only one 1, it has the error-checking feature. Also, there are two positions with weight 0 so, it is possible to encode decimal 0 with a group containing 1’s, unlike other weighted codes. The biquinary code is used in the Abacus.