Advertisement
Guest User

Untitled

a guest
Feb 27th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.38 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date: 14:45:46 12/01/2016
  6. -- Design Name:
  7. -- Module Name: sevSegment - 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. library IEEE;
  21. use IEEE.STD_LOGIC_1164.ALL;
  22. use IEEE.STD_LOGIC_ARITH.ALL;
  23. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  24.  
  25. ---- Uncomment the following library declaration if instantiating
  26. ---- any Xilinx primitives in this code.
  27. --library UNISIM;
  28. --use UNISIM.VComponents.all;
  29.  
  30. entity sevSegment is
  31. port (
  32. clk : in std_logic;
  33. value : in std_logic_vector(15 downto 0);
  34. enable : out std_logic_vector(3 downto 0); -- vector?
  35. sevenSeg : out std_logic_vector(7 downto 0)
  36.  
  37. );
  38. end sevSegment;
  39.  
  40. architecture Behavioral of sevSegment is
  41. constant ZERO : std_logic_vector(7 downto 0) := "00000011";
  42. constant ONE : std_logic_vector(7 downto 0) := "10011111";
  43. constant TWO : std_logic_vector(7 downto 0) := "00100101";
  44. constant THREE : std_logic_vector(7 downto 0) := "00001101";
  45. constant FOUR : std_logic_vector(7 downto 0) := "10011001";
  46. constant FIVE : std_logic_vector(7 downto 0) := "01001001";
  47. constant SIX : std_logic_vector(7 downto 0) := "01000001";
  48. constant SEVEN : std_logic_vector(7 downto 0) := "00011111";
  49. constant EIGHT : std_logic_vector(7 downto 0) := "00000001";
  50. constant NINE : std_logic_vector(7 downto 0) := "00001001";
  51. constant A: std_logic_vector(7 downto 0) := "00010001";
  52. constant B : std_logic_vector(7 downto 0) := "11000001";
  53. constant C : std_logic_vector(7 downto 0) := "01100011";
  54. constant D : std_logic_vector(7 downto 0) := "10000101";
  55. constant E : std_logic_vector(7 downto 0) := "01100001";
  56. constant F : std_logic_vector(7 downto 0) := "01110001";
  57.  
  58.  
  59. signal sigenable : std_logic_vector(3 downto 0) :="1111";
  60. signal sigsevenSeg : std_logic_vector(7 downto 0) :="11111111";
  61. signal valueSlice : std_logic_vector(3 downto 0) :="0000";
  62. begin
  63.  
  64. process (clk,value)
  65. variable x : integer range 1 to 4 := 1;
  66. begin
  67.  
  68. if (clk'event and clk = '1') then
  69. valueSlice <= value( (x*4-1) downto ((x-1)*4));
  70. case valueSlice is
  71. when "0000" => sigsevenSeg <= ZERO;
  72. when "0001" => sigsevenSeg <= ONE;
  73. when "0010" => sigsevenSeg <= TWO;
  74. when "0011" => sigsevenSeg <= THREE;
  75. when "0100" => sigsevenSeg <= FOUR;
  76. when "0101" => sigsevenSeg <= FIVE;
  77. when "0110" => sigsevenSeg <= SIX;
  78. when "0111" => sigsevenSeg <= SEVEN;
  79. when "1000" => sigsevenSeg <= EIGHT;
  80. when "1001" => sigsevenSeg <= NINE;
  81. when "1010" => sigsevenSeg <= A;
  82. when "1011" => sigsevenSeg <= B;
  83. when "1100" => sigsevenSeg <= C;
  84. when "1101" => sigsevenSeg <= D;
  85. when "1110" => sigsevenSeg <= E;
  86. when "1111" => sigsevenSeg <= F;
  87. when others => null;
  88. end case;
  89.  
  90. case x is
  91. when 1 => sigenable <= "1110"; -- AN0
  92. when 2 => sigenable <= "1101"; -- AN1
  93. when 3 => sigenable <= "1011"; -- AN2
  94. when 4 => sigenable <= "0111"; -- AN3
  95. end case;
  96.  
  97. if (x = 4) then
  98. x := 1;
  99. else
  100. x := x+1;
  101. end if;
  102. end if;
  103. enable <= sigenable;
  104. sevenseg <= sigsevenseg;
  105.  
  106. end process;
  107. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement