This project implements a 3-to-8 decoder using VHDL. The decoder takes a 3-bit input (A) and produces an 8-bit output (Y), where only one output bit is HIGH corresponding to the given binary input, and all others are LOW.
A 3-to-8 decoder translates a 3-bit binary input (A) into a one-hot 8-bit output (Y), where only the selected output bit is HIGH (1
) and the rest are LOW (0
).
A(2:0) Input | Y(7:0) Output |
---|---|
000 | 00000001 |
001 | 00000010 |
010 | 00000100 |
011 | 00001000 |
100 | 00010000 |
101 | 00100000 |
110 | 01000000 |
111 | 10000000 |
1
).0
)."00000000"
.library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity decoder3to8 is
Port ( A : in STD_LOGIC_VECTOR(2 downto 0);
Y : out STD_LOGIC_VECTOR(7 downto 0)
);
end decoder3to8;
architecture Behavioral of decoder3to8 is
begin
process(A)
begin
case A is
when "000" => Y <= "00000001";
when "001" => Y <= "00000010";
when "010" => Y <= "00000100";
when "011" => Y <= "00001000";
when "100" => Y <= "00010000";
when "101" => Y <= "00100000";
when "110" => Y <= "01000000";
when "111" => Y <= "10000000";
when others => Y <= "00000000";
end case;
end process;
end Behavioral;
A testbench was written to verify the decoder’s output for all possible input combinations.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity tb_decoder_3to8 is
end tb_decoder_3to8;
architecture behavior of tb_decoder_3to8 is
signal A : STD_LOGIC_VECTOR(2 downto 0) := "000";
signal Y : STD_LOGIC_VECTOR(7 downto 0);
begin
uut: entity work.decoder3to8
port map (
A => A,
Y => Y
);
stim_proc: process
begin
A <= "000"; wait for 10 ns;
A <= "001"; wait for 10 ns;
A <= "010"; wait for 10 ns;
A <= "011"; wait for 10 ns;
A <= "100"; wait for 10 ns;
A <= "101"; wait for 10 ns;
A <= "110"; wait for 10 ns;
A <= "111"; wait for 10 ns;
wait;
end process;
end behavior;
The simulation results confirm that the decoder correctly sets only one output bit HIGH based on the input.
A Input | Y Output |
---|---|
000 | 00000001 |
001 | 00000010 |
010 | 00000100 |
011 | 00001000 |
100 | 00010000 |
101 | 00100000 |
110 | 01000000 |
111 | 10000000 |
set_property IOSTANDARD LVCMOS33 [get_ports {A[2]}]
set_property IOSTANDARD LVCMOS33 [get_ports {A[1]}]
set_property IOSTANDARD LVCMOS33 [get_ports {A[0]}]
set_property IOSTANDARD LVCMOS33 [get_ports {Y[7]}]
set_property IOSTANDARD LVCMOS33 [get_ports {Y[6]}]
set_property IOSTANDARD LVCMOS33 [get_ports {Y[5]}]
set_property IOSTANDARD LVCMOS33 [get_ports {Y[4]}]
set_property IOSTANDARD LVCMOS33 [get_ports {Y[3]}]
set_property IOSTANDARD LVCMOS33 [get_ports {Y[2]}]
set_property IOSTANDARD LVCMOS33 [get_ports {Y[1]}]
set_property IOSTANDARD LVCMOS33 [get_ports {Y[0]}]
set_property DRIVE 12 [get_ports {Y[7]}]
set_property PACKAGE_PIN J15 [get_ports {A[0]}]
set_property PACKAGE_PIN L16 [get_ports {A[1]}]
set_property PACKAGE_PIN M13 [get_ports {A[2]}]
set_property PACKAGE_PIN H17 [get_ports {Y[0]}]
set_property PACKAGE_PIN K15 [get_ports {Y[1]}]
set_property PACKAGE_PIN J13 [get_ports {Y[2]}]
set_property PACKAGE_PIN N14 [get_ports {Y[3]}]
set_property PACKAGE_PIN R18 [get_ports {Y[4]}]
set_property PACKAGE_PIN V17 [get_ports {Y[5]}]
set_property PACKAGE_PIN U17 [get_ports {Y[6]}]
set_property PACKAGE_PIN U16 [get_ports {Y[7]}]
Below are the simulation waveform results and FPGA output images showcasing the decoder’s functionality.
Made by Swaroop Kumar Yadav