01-05-2012, 11:56 AM
DESIGN AND SIMULATION OF 4-BIT BINARY TO GRAY CODE CONVERTOR
THEORY:
Electronics circuits can be divided into two broad categories, digital and analog. Digital involves quantities with discrete values and analog involves quantities with continuous values. The conversion of binary to gray is done simply with exclusive-OR gates by using K-maps. The gray code is unweighted and is not an arithmetic code i.e. there is no specific weights assigned to the bit position.
Like binary numbers the gray code can have any no. of bits .The important thing is that during the conversion the single bit is change between successive gray codes words. Let us take an example in which decimal value is changing from 3 to 4, then the gray code is change from 0010 to 0110, while its binary code changes from 0011 to 0100 a change of simply three bits.
VHDL CODE OF 4-BIT BINARY TO GRAY CODE CONVERTOR:-
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity BINGR4BTM is
Port ( BN : in STD_LOGIC_VECTOR (3 downto 0);
GR : out STD_LOGIC_VECTOR (3 downto 0));
end BINGR4BTM;
architecture Behavioral of BINGR4BTM is
begin
GR(3)<=BN(3);
GR(2)<=BN(3) xor BN(2);
GR(1)<=BN(2) xor BN(1);
GR(0)<=BN(1) xor BN(0);
end Behavioral;
CONCLUSION:
After getting the test bench waveform and RTL schematic of the required experiment (Binary to gray code convertor) the program is successfully downloaded to the FPGA kit.