Thursday 15 December 2011

VHDL code for Gray to Binary converter

Below is the VHDL code for  4bit gray to binary code converter. It can done here by using dataflow modelling. You can use the modelling to reverse the conversion eg. binary to gray conversion.

CODE FOR 4 BIT Gray To  Binary Converter

=========================================================================
library ieee;
use ieee.std_logic_1164.all;

entity gray_2_binary is
port(g:in std_logic_vector(3 downto 0);

        b:out std_logic_vector(3 downto 0));
end gray_2_binary;

architecture dataflow of gray_2_binary is
begin

b(3)<=g(3);
b(2)<=b(3) xor g(2);
b(1)<=b(2) xor g(1);
b(0)<=b(1) xor g(0);;
end dataflow;
=========================================================================
Like us on facebook and leave comments

No comments:

Comments System