Advertisement
Synthron

func_lib Package

Jun 18th, 2020
1,874
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.11 KB | None | 0 0
  1. -- Package Declaration
  2. package func_lib is
  3.  
  4.     function f_hex_seg is
  5.     (
  6.         i_int : in integer range 0 to 15
  7.     ) return std_logic_vector(7 downto 0);
  8.    
  9. end package func_lib;
  10.  
  11. -- Package Body Section
  12.  
  13. package body func_lib is
  14.  
  15.     function f_hex_seg is
  16.     (
  17.         i_int : in integer range 0 to 15
  18.         ) return std_logic_vector(7 downto 0) is
  19.     variable v_temp : std_logic_vector(7 downto 0);
  20.     begin
  21.         case i_int is
  22.             when 0 =>
  23.                 v_temp := X"7E";
  24.             when 1 =>
  25.                 v_temp := X"30";
  26.             when 2 =>
  27.                 v_temp := X"6D";
  28.             when 3 =>
  29.                 v_temp := X"79";
  30.             when 4 =>
  31.                 v_temp := X"33";
  32.             when 5 =>
  33.                 v_temp := X"5B";
  34.             when 6 =>
  35.                 v_temp := X"5F";
  36.             when 7 =>
  37.                 v_temp := X"70";
  38.             when 8 =>
  39.                 v_temp := X"7F";
  40.             when 9 =>
  41.                 v_temp := X"7B";
  42.             when 10 => -- A
  43.                 v_temp := X"77";
  44.             when 11 => -- b
  45.                 v_temp := X"1F";
  46.             when 12 => -- C
  47.                 v_temp := X"4E";
  48.             when 13 => -- d
  49.                 v_temp := X"3D";
  50.             when 14 => -- E
  51.                 v_temp := X"4F";
  52.             when 15 => -- F
  53.                 v_temp := X"47";
  54.         end case;  
  55.        
  56.         return v_temp(7 downto 0);
  57.     end function f_hex_seg;
  58.    
  59. end package body func_lib;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement