Advertisement
anderson02021

q1_lista04

Jul 1st, 2021
752
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.34 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3.  
  4. entity mux4_1 is
  5. port(w0,w1,w2,w3:   in std_logic;
  6.        s0,s1:       in std_logic;
  7.            k:       out std_logic);
  8. end mux4_1;
  9.  
  10. architecture comp of mux4_1 is
  11.  
  12. begin
  13.   process(w0,w1,w2,w3,s0,s1)
  14.     begin
  15.     if s0 ='0' and s1 ='0' then k <= w0;
  16.         elsif s0 ='1' and s1 ='0' then k <= w1;
  17.         elsif s0 ='0' and s1='1' then k <= w2;
  18.         else k <=w3;
  19.     end if;
  20.   end process;
  21. end comp;
  22.  
  23. library IEEE;
  24. use IEEE.STD_LOGIC_1164.ALL;
  25.  
  26. entity mux_16_4 is
  27.   port(
  28.       entrada:  in std_logic_vector(15 downto 0);
  29.       selecao:  in std_logic_vector(3 downto 0);
  30.       z:    out std_logic
  31.       );
  32. end  mux_16_4;
  33.  
  34. architecture comp_mux_16_1 of mux_16_4 is
  35.  
  36.     signal z1, z2, z3, z4   :std_logic;
  37.  
  38.     component mux4_1 is
  39.         port(w0,w1,w2,w3:   in std_logic;
  40.                 s0,s1:      in std_logic;
  41.                     k:      out std_logic);
  42.     end component;
  43.  
  44.     begin
  45.         m1: mux4_1 port map(entrada(0),entrada(1),entrada(2),entrada(3),selecao(0),selecao(1),z1);
  46.         m2: mux4_1 port map(entrada(4),entrada(5),entrada(6),entrada(7),selecao(0),selecao(1),z2);
  47.         m3: mux4_1 port map(entrada(8),entrada(9),entrada(10),entrada(11),selecao(0),selecao(1),z3);
  48.         m4: mux4_1 port map(entrada(12),entrada(13),entrada(14),entrada(15),selecao(0),selecao(1),z4);
  49.         m5: mux4_1 port map(z1,z2,z3,z4,selecao(2),selecao(3),z);
  50. end comp_mux_16_1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement