Sei sulla pagina 1di 3

--codigo Decodificador 74138

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity trabajo1 is
port(A: in std_logic_vector(2 downto 0);
E:in std_logic;
Q:out std_logic_vector (7 downto 0));
end trabajo1;
architecture dataflow of trabajo1 is
begin
process(E)
begin
if(E='0')then
if(A="000")then

Q(0)<='0';Q(1)<='1';Q(2)<='1';Q(3)<='1';Q(4)<='1';Q(5)<='1';Q(6)<='1';Q(7)<='1';
elsif(A="001")then

Q(0)<='1';Q(1)<='0';Q(2)<='1';Q(3)<='1';Q(4)<='1';Q(5)<='1';Q(6)<='1';Q(7)<='1';
elsif(A="010")then

Q(0)<='1';Q(1)<='1';Q(2)<='0';Q(3)<='1';Q(4)<='1';Q(5)<='1';Q(6)<='1';Q(7)<='1';
elsif(A="011")then

Q(0)<='1';Q(1)<='0';Q(2)<='1';Q(3)<='0';Q(4)<='1';Q(5)<='1';Q(6)<='1';Q(7)<='1';
elsif(A="100")then

Q(0)<='1';Q(1)<='1';Q(2)<='1';Q(3)<='1';Q(4)<='0';Q(5)<='1';Q(6)<='1';Q(7)<='1';
elsif(A="101")then

Q(0)<='1';Q(1)<='1';Q(2)<='1';Q(3)<='1';Q(4)<='1';Q(5)<='0';Q(6)<='1';Q(7)<='1';
elsif(A="110")then

Q(0)<='1';Q(1)<='1';Q(2)<='1';Q(3)<='1';Q(4)<='1';Q(5)<='1';Q(6)<='0';Q(7)<='1';
elsif(A="111")then

Q(0)<='1';Q(1)<='1';Q(2)<='1';Q(3)<='1';Q(4)<='1';Q(5)<='1';Q(6)<='1';Q(7)<='0';
end if;
else
Q(0)<='Z';Q(1)<='Z';Q(2)<='Z';Q(3)<='Z';Q(4)<='Z';Q(5)<='Z';Q(6)<='Z';Q(7)<='Z';
end if;
end process;
end dataflow;

--Codigo de un Codificador de 8 a 3
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;

entity trabajo2 is
port(Q:in std_logic_vector(7 downto 0);
E: in std_logic;
A:out std_logic_vector(2 downto 0));
end trabajo2;

architecture dataflow of trabajo2 is


begin
process(E)
begin
if(E='0')then
if(Q="11111110")then
A<="111";
elsif(Q="11111101")then
A<="110";
elsif(Q="11111011")then
A<="101";
elsif(Q="11110111")then
A<="100";
elsif(Q="11101111")then
A<="011";
elsif(Q="11011111")then
A<="010";
elsif(Q="10111111")then
A<="001";
elsif(Q="01110111")then
A<="000";
end if;
else
A<="111";
end if;
end process;
end dataflow;

--codigo multiplexor
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity trabajo3 is
port( I: in std_logic_vector (7 downto 0);
S: in std_logic_vector (2 downto 0);
E : in std_logic;
Q,Qb: out std_logic);
end trabajo3;
architecture dataflow of trabajo3 is
begin
process(E,S)
variable tmp:std_logic;
begin
if(E='0')then
if(S="000")then
tmp:= I(0);
elsif(S="001")then
tmp:= I(1);
elsif(S="010")then
tmp:= I(2);
elsif(S="011")then
tmp:= I(3);
elsif(S="100")then
tmp:= I(4);
elsif(S="101")then
tmp:= I(5);
elsif(S="110")then
tmp:= I(6);
elsif(S="111")then
tmp:= I(7);
end if;
else
tmp:='Z';
end if;
Q<= tmp;
Qb<= not(tmp);
end process;
end dataflow;

Potrebbero piacerti anche