Thursday 16 January 2014

3 to 8 DECODER (Behavioral)

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_arith.ALL;
use IEEE.STD_LOGIC_signed.ALL;
entity decoder3to8 is
    Port ( e : in  STD_LOGIC;
           s : in  STD_LOGIC_VECTOR (2 downto 0);
           y : out  STD_LOGIC_VECTOR (7 downto 0));
end decoder3to8;
architecture Behavioral of decoder3to8 is
begin
process (e,s)
begin
if e='0' then y<="00000000";
else case s is
when "000"=> y(0)<='1';y(1)<='0';y(2)<='0';y(3)<='0';y(4)<='0';y(5)<='0';y(6)<='0';y(7)<='0';
when "001"=> y(1)<='1';y(2)<='0';y(3)<='0';y(4)<='0';y(5)<='0';y(6)<='0';y(7)<='0';y(0)<='0';
when "010"=> y(2)<='1';y(3)<='0';y(4)<='0';y(5)<='0';y(6)<='0';y(7)<='0';y(0)<='0';y(1)<='0';
when "011"=> y(3)<='1';y(4)<='0';y(5)<='0';y(6)<='0';y(7)<='0';y(0)<='0';y(1)<='0';y(2)<='0';
when "100"=> y(4)<='1';y(5)<='0';y(6)<='0';y(7)<='0';y(0)<='0';y(1)<='0';y(2)<='0';y(3)<='0';
when "101"=> y(5)<='1';y(6)<='0';y(7)<='0';y(0)<='0';y(1)<='0';y(2)<='0';y(3)<='0';y(4)<='0';
when "110"=> y(6)<='1';y(7)<='0';y(0)<='0';y(1)<='0';y(2)<='0';y(3)<='0';y(4)<='0';y(5)<='0';
when others=> y(7)<='1';y(0)<='0';y(1)<='0';y(2)<='0';y(3)<='0';y(4)<='0';y(5)<='0';y(6)<='0';
end case;
end if;
end process;

end Behavioral;

No comments:

Post a Comment