You are on page 1of 2

Binary To Grey

library ieee;
use ieee.std_logic_1164.all;
entity tanmay_binary_to_grey is
port (B3: in std_logic;
B2: in std_logic;
B1: in std_logic;
B0: in std_logic;
G3: out std_logic;
G2: out std_logic;
G1: out std_logic;
G0: out std_logic);
end tanmay_binary_to_grey;
architecture tanmay_binary_to_grey_arch of tanmay_binary_to_grey is
begin
G3 <= B3;
G2 <= B3 XOR B2;
G1 <= B2 XOR B1;
G0 <= B1 XOR B0;
end tanmay_binary_to_grey_arch;
Grey To Binary
library ieee;
use ieee.std_logic_1164.all;
entity tanmay_grey_to_binary is
port (G3: in std_logic;
G2: in std_logic;
G1: in std_logic;
G0: in std_logic;
B3: out std_logic;
B2: out std_logic;
B1: out std_logic;
B0: out std_logic);
end tanmay_grey_to_binary;
architecture tanmay_grey_to_binary_arch of tanmay_grey_to_binary is
begin
B3 <= G3;
B2 <= G3 XOR G2;
B1 <= G3 XOR G2 XOR G1;
B0 <= G3 XOR G2 XOR G1 XOR G0;
end tanmay_grey_to_binary_arch;

You might also like