Advertisement
DomMisterSoja

display7

Apr 9th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.64 KB | None | 0 0
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.numeric_std.all;
  4.  
  5. entity display7 is port
  6. (
  7.   clk, rst : in std_logic;
  8.   an : out std_logic_vector(3 downto 0);
  9.   sseg : out std_logic_vector (7 downto 0);
  10.   in3, in2, in1, in0 : in std_logic_vector(3 downto 0)
  11. );
  12. end display7;
  13.  
  14. architecture arch of display7 is
  15.  
  16.   constant N : integer := 18;
  17.  
  18.   signal q_reg, q_next : unsigned (N-1 downto N-2);
  19.   signal sel : std_logic_vector( 1 downto 0);
  20.   signal mux_out : std_logic_vector (3 downto 0);
  21.  
  22.   begin
  23.  
  24.     process(clk, rst)
  25.       begin
  26.         if rst = '1' then
  27.         q_reg <= (others => '0');
  28.         elsif clk'event and clk = '1' then
  29.         q_reg <= q_next;
  30.         end if;
  31.     end process;
  32.  
  33.     q_next <= q_reg + 1;
  34.     sel <= std_logic_vector(q_reg(N-1 downto N-2));
  35.  
  36.     process(sel, in0, in1, in2, in3)
  37.      begin
  38.       case sel is
  39.         when "00" => an <= "0001";
  40.           mux_out <= in0;
  41.         when "01" => an <= "0010";
  42.           mux_out <= in1;
  43.         when "10" => an <= "0100";
  44.           mux_out <= in2;
  45.         when others => an <= "1000";
  46.           mux_out <= in3;
  47.       end case;
  48.     end process;
  49.  
  50.     with mux_out select
  51.       sseg(7 downto 1) <=
  52.         "1111110" when "0000", -- 0
  53.         "0110000" when "0001", -- 1
  54.         "1101101" when "0010", -- 2
  55.         "1111001" when "0011", -- 3
  56.         "0110011" when "0100", -- 4  
  57.         "1011011" when "0101", -- 5
  58.         "1011111" when "0110", -- 6
  59.         "1110000" when "0111", -- 7
  60.         "1111111" when "1000", -- 8
  61.         "1111011" when "1001", -- 9
  62.         "0001110" when others; -- L
  63.         sseg(0) <= '1';
  64.  
  65. end arch;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement