Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 2.04 KB | None | 0 0
  1. LIBRARY ieee;
  2. USE ieee.std_logic_1164.all;
  3.  
  4. entity labZA4pkt is
  5. port(
  6.     SW : IN STD_LOGIC_VECTOR(0 to 7);
  7.     HEX0, HEX1, HEX2, HEX3, HEX4, HEX5 : OUT STD_LOGIC_VECTOR(0 to 6);
  8.     CLK   : in  STD_LOGIC;   -- wejscie zegarowe
  9.     RESET : in  STD_LOGIC ;  -- wejscie kasowania
  10.     SetOrDisplay : in STD_LOGIC;
  11.     AorB : in STD_LOGIC
  12. );
  13. end labZA4pkt;
  14.  
  15.  
  16.  
  17. architecture behaviour of labZA4pkt is
  18. signal DigitA, DigitB : std_logic_vector(0 to 7);
  19.     function hex(SW2 : IN STD_LOGIC_VECTOR(0 to 3)) return STD_LOGIC_VECTOR is
  20.          begin
  21.             if (SW2 = "0000") then return "0000001";
  22.             elsif (SW2 = "0001") then return "1001111";
  23.             elsif (SW2 = "0010") then return "0010010";
  24.             elsif (SW2 = "0011") then return "0000110";
  25.             elsif (SW2 = "0100") then return "1101100";
  26.             elsif (SW2 = "0101") then return "0100100";
  27.             elsif (SW2 = "0110") then return "0100000";
  28.             elsif (SW2 = "0111") then return "0001111";
  29.             elsif (SW2 = "1000") then return "0000000";
  30.             elsif (SW2 = "1001") then return "0000100";
  31.             elsif (SW2 = "1010") then return "0001000"; --b
  32.             elsif (SW2 = "1011") then return "1100000";
  33.             elsif (SW2 = "1100") then return "0110001";
  34.             elsif (SW2 = "1101") then return "1000010";
  35.             elsif (SW2 = "1110") then return "0110000";
  36.             else return "0111000";
  37.             end if;
  38.     end hex;
  39.  
  40.     begin
  41.         p:process(RESET, CLK) is
  42.             begin
  43.             HEX2 <= "0000100";
  44.             HEX5 <= "0001000";
  45.             if RESET = '0' then
  46.                 HEX0 <= "1111111"; -- "0000001"
  47.                 HEX1 <= "1111111";
  48.                 HEX3 <= "1111111";
  49.                 HEX4 <= "1111111";
  50.                 DigitA  <= "UUUUUUUU";
  51.                 DigitB  <= "UUUUUUUU";
  52.             elsif (CLK='1' and CLK'event) then
  53.                 if (SetOrDisplay = '0') then
  54.                     if    (AorB = '0') then DigitA <= SW;
  55.                     elsif (AorB = '1') then DigitB <= Sw;
  56.                 end if;
  57.                 elsif (SetOrDisplay = '1') then  
  58.                     if (AorB = '0') then
  59.                         HEX0 <= hex(DigitA(0 to 3));
  60.                         HEX1 <= hex(DigitA(4 to 7));
  61.                     elsif (AorB = '1') then
  62.                         HEX4 <= hex(DigitB(0 to 3));
  63.                         HEX3 <= hex(DigitB(4 to 7));
  64.                     end if;
  65.                 end if;
  66.             end if;
  67.                    
  68.     end process;
  69. end behaviour;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement