You are on page 1of 1

library IEEE;

use IEEE.STD_LOGIC_1164.ALL;

-- Uncomment the following library declaration if using


-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;

-- Uncomment the following library declaration if instantiating


-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;

entity binarytogray is
Port ( B : in STD_LOGIC_VECTOR (3 downto 0);
G : out STD_LOGIC_VECTOR (3 downto 0));
end binarytogray;

architecture Behavioral of binarytogray is

begin
G(0)<=B(1) XOR B(0);
G(1)<=B(2) XOR B(1);
G(2)<=B(3) XOR B(2);
G(3)<=B(3);

end Behavioral;

You might also like