Experiment-2: Ishaan Aggarwal
Experiment-2: Ishaan Aggarwal
Experiment-2: Ishaan Aggarwal
To design and implement a 4-bit Binary to Gray code converter using Dataflow Modeling.
─
Ishaan Aggarwal
UE195063
ECE Sec-1
1
AIM:
To design and implement a 4-bit Binary to Gray code converter using Dataflow
Modeling.
Code:
2
I. VHDL Code
library IEEE;
use IEEE.std_logic_1164.all;
entity bin2gray is
port( bin : in std_logic_vector(3 downto 0); --binary input
G : out std_logic_vector(3 downto 0) --gray code output
);
end bin2gray;
begin
--xor gates.
G(3) <= bin(3);
G(2) <= bin(3) xor bin(2);
G(1) <= bin(2) xor bin(1);
G(0) <= bin(1) xor bin(0);
end;
entity testb is
end testb;
architecture behavior of testb is
component bin2gray is
port( bin : in std_logic_vector(3 downto 0);
g : out std_logic_vector(3 downto 0)
);
end component;
component gray2bin is
port( g : in std_logic_vector(3 downto 0);
bin : out std_logic_vector(3 downto 0)
);
end component;
begin
uut1: bin2gray port map (
bin => bin,
g => g
);
uut2: gray2bin port map (
g => g,
4
stim_proc: process
begin
bin <= "0000"; wait for 15 ns;
bin <= "0001"; wait for 15 ns;
bin <= "0010"; wait for 15 ns;
bin <= "0011"; wait for 15 ns;
bin <= "0100"; wait for 15 ns;
bin <= "0101"; wait for 15 ns;
bin <= "0110"; wait for 15 ns;
bin <= "0111"; wait for 15 ns;
bin <= "1000"; wait for 15 ns;
bin <= "1001"; wait for 15 ns;
bin <= "1010"; wait for 15 ns;
bin <= "1011"; wait for 15 ns;
bin <= "1100"; wait for 15 ns;
bin <= "1101"; wait for 15 ns;
bin <= "1110"; wait for 15 ns;
bin <= "1111"; wait for 15 ns;
wait;
end process;
end;
5
EDA Playground:
Logisim:
Circuit Diagram:
6
Simulation Cases:
7
Observation Table(Results):