Friday, September 20, 2013

DLD BY SUPRIYA

Binary to Gray Code Conversion

Consider b1, b2, b3, b4 and b5 is the Binary Number and it is need be converted into Grey Code.
1. In Binary Number Most Significant Bit (MSB) is same as the MSB.
2. By Performing the Exclusive-OR (EX-OR) operation between the First and second bits of the Binary Number  the second bit of the Grey code can be found.
3. The Third bit of the Grey code can be found by performing the Exclusive-OR (EX-OR) operation between the Third and Second bits of the given Binary Number; and so on......

To see the video of this topic , please refer to the following link:


EX-OR Operation:

1. The output of EX-OR gate will be 0 if both the bits are 0 or 1 .
2. The output of EX-OR gate will be 1 if one of the bit in two bits which are being added are1 .

Refer the below image for Binary to Gray Code Conversion





 

Gray Code to Binary Conversion


Consider g0, g1, g2 and g3 is the Grey Code and it is need be converted into Binary Number. The steps for Binary to Grey Code Conversion needs to be reversed to find out the equivalent Binary Number

1.The First MSB of the Grey Codeis same asMost Significant Bit (MSB) of the Binary.

2. If the second Grey Bit is 0 then the second bit of the Binary  bit will be same as that of the First Binary bit; AND if the Second Grey Bit is 1 then the Second Bit of the Binary will be inverse of its previous binary bit.
Refer the below image for easy understanding of Grey to Binary Conversion

For more assistance kindly refer to the given link:



Grey Code | Binary to Grey Code and that to Binary Conversion

Excess 3 code Addition & Subtraction
Code is a symbolic representation of discrete information. Codes are of different types. One of the most important codes is Grey Code. It is a non-weighted code which belongs to a class of codes called minimum change codes. While traversing from one step to another step only one bit in the code group changes. In case of Grey Code  two adjacent code numbers differs from each other by only one bit.
This code it is not applicable in any types of arithmetical operations but it has some applications in analog to digital converters and in some input/output devices.

There are several steps which will make you understand how the codes are formed:
(1) In case of grey code in each step one bit will change from its previous. One thing must be kept in mind that the change of bit always occurs from the right side i.e from L.S.B towards the M.S.B. At first the first three bits are constant i.e 000 and the fourth bit changes from 0 to 1. As we know that for binary digit possible combination is 0 and 1, so keeping first three bit constant the possible combination of 4th bit is over for decimal 0 and 1 respectively.

(2)Now on moving to the next bit from L.S.B i.e 3rd bit, that changes from 0 to 1 which is the decimal equivalent for 2. And one more combination is left for the fourth bit keeping the first three constant i.e 001. We can change 4th bit from 1 to 0. Thus the grey code for decimal number 3 is 0010.

(3)Traverse to the next code. Here only one thing can be donei.e we can change the second bit as all possible combinations are over.

Question may strike in your mind that why can�t we change the third bit again which will also be a one bit change from its previous.
But changing third bit would give the equivalent grey code 0000 which has occurred earlier. So you must remember that a number occurring previously must not be repeated. So the equivalent code for 4 will be 0110. Here only the second bit has changed from the previous code. Now on keeping  first and second bit constant and find the possible combinations of the third and the fourth bit by only changing 1 bit in each steps.

Now for 5 only the fourth bit has changed. Again for 6 only the third bit is changed keeping others constant. Lastly at 7 again the fourth bit has changed from 1 to 0 where all other bits are constant. In 8 you can see that the equivalent grey code is 1100. Here the 1st bit changes from 0 to n1 as all the combination of the 2nd,3rd and 4th bits are completed keeping the 1st constant at 0. Similarly ,the 1st bit is kept constant and all the possible combination changing single bit in each step from right to left is done.



Binary to grey code conversion


Binary to grey code conversion is a very simple process. Several steps are being performed forthis types of conversions. Steps given below elaborate on the idea on this type of conversion.


(1) The first bit of the given binary number will be exactly equal to the M.S.B of the grey code.
(2) Now the second bit of the code will be exclusive-or of the first and second bit of the given binary number, i.e if both the bits are same the result will be 0 and if they are different the result will be 1.

(3)The third bit of grey code will be equal to the exclusive-or of the second and third bit of the given binary number. Thus  the conversion goes on. An example given below can make it more clear :
Let (01001) be the given binary number


Thus the equivalent grey code is 01101.

Now lets consider an example where the M.S.B. of the binary is 0 so for it will be 0 for the most significant grey bit. Next, the XOR of the first and the second bit is done. The bits are different so the resultant grey bit will be 1. Now move to the next step, where XOR of second and third bit is again 1 as they are different. Next, XOR of third and fourth bit is 0 as both the bits are same. Lastly the XOR of fourth and fifth bit is 1 as they are different. That is how the result of binary to gray code conversion of 01001 is done whose equivalent grey code is 01101.

Grey code to binary conversion

Grey code to binary conversion is  a very simple and easy process. Following  thesesteps given below can make it more clear to you:

(1) M.S.B of the given grey code is equal to the M.S.B of the binary number.
(2) Now if the second grey bit is 0 the second binary bit will be same as the previous or the first bit. If the gray bit is 1 the second binary bit will alter. If it was 1 it will be 0 and if it was 0 it will be 1.

(3) This step is repeated for all the bits to do Grey code to binary conversion.

An example given below will make it clear......
Let the grey code be 01101
The M.S.B of the binary will be 0 as the M.S.B of grey is 0. Now moving to the next grey bit. As it is 1 the previous binary bit will alter i.e it will be 1, thus the second binary bit will be 1. Nowlook at the third bit of the grey code. It is again 1 thus the previous bit i.e the second binary bit will again alter and the third bit of the binary number will be 0. Now, 4th bit of the given grey is 0 so the previous binary bit will be unchanged, i.e 4th binary bit will be 0. Now again the 5th grey bit is 1 thus the previous binary bit will alter, it will be 1 from 0. Therefore the equivalent Binary number in case of grey code to binary conversion will be (01001)


0 comments:

Post a Comment