Advertisement
felipe4004

mux7seg

May 20th, 2019
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 2.87 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date: 05/17/2019 08:11:16 PM
  6. -- Design Name:
  7. -- Module Name: mux7seg - Behavioral
  8. -- Project Name:
  9. -- Target Devices:
  10. -- Tool Versions:
  11. -- Description:
  12. --
  13. -- Dependencies:
  14. --
  15. -- Revision:
  16. -- Revision 0.01 - File Created
  17. -- Additional Comments:
  18. --
  19. ----------------------------------------------------------------------------------
  20.  
  21.  
  22. library IEEE;
  23. use IEEE.STD_LOGIC_1164.ALL;
  24. use IEEE.NUMERIC_STD.ALL;
  25. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  26.  
  27. entity mux7seg is
  28.     Port (clk   : in STD_LOGIC;
  29.           porta : in STD_LOGIC;
  30.           AA    : in STD_LOGIC_VECTOR (1 downto 0);
  31.           seg   : out STD_LOGIC_VECTOR (6 downto 0);
  32.           an    : out STD_LOGIC_VECTOR (3 downto 0));
  33. end mux7seg;
  34.  
  35. architecture Behavioral of mux7seg is
  36.     signal count : STD_LOGIC_VECTOR (1 downto 0);
  37. begin
  38.  
  39. anodo_process: process (clk)
  40.     begin
  41.         if rising_edge (clk) then
  42.             count <= count +'1';
  43.             case count is
  44.                 when "00" =>
  45.                     an <= "1110";
  46.                         if porta = '0' and AA = "00" then
  47.                             seg <= "1100010";
  48.                         elsif porta = '1' and AA = "00" then
  49.                             seg <= "1101011";
  50.                         else
  51.                             seg <= "0001000";
  52.                         end if;
  53.                    
  54.                 when "01" =>
  55.                     an <= "1101";
  56.                     if porta = '0' and AA = "01" then
  57.                             seg <= "1100010";
  58.                         elsif porta = '1' and AA = "01" then
  59.                             seg <= "1101011";
  60.                         else
  61.                             seg <= "0001000";
  62.                         end if;
  63.                    
  64.                 when "10" =>
  65.                     an <= "1011";
  66.                     if porta = '0' and AA = "10" then
  67.                             seg <= "1100010";
  68.                         elsif porta = '1' and AA = "10" then
  69.                             seg <= "1101011";
  70.                         else
  71.                             seg <= "0001000";
  72.                         end if;
  73.                    
  74.                 when "11" =>
  75.                     an <= "0111";
  76.                     if porta = '0' and AA = "11" then
  77.                             seg <= "1100010";
  78.                         elsif porta = '1' and AA = "11" then
  79.                             seg <= "1101011";
  80.                         else
  81.                             seg <= "0001000";
  82.                         end if;
  83.                     count <= "00";
  84.                 when others =>
  85.                     an <= "1111";
  86.                     count <= "00";
  87.            end case;
  88.        end if;
  89.     end process;
  90.    
  91.    
  92.    
  93. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement