LED4.vhd
上传用户:keloyb
上传日期:2022-08-09
资源大小:256k
文件大小:4k
源码类别:

VHDL/FPGA/Verilog

开发平台:

Others

  1. ---------------------------------------------------------------------------------------------------
  2. --*************************************************************************************************
  3. --  CreateDate  :  2007-07-12 
  4. --  ModifData   :  2007-07-12 
  5. --  Description :  LED4 Display 
  6. --  Author      :  Explorer01 
  7. --  Version     :  V1.0  
  8. --*************************************************************************************************
  9. ---------------------------------------------------------------------------------------------------
  10. -- VHDL library Declarations 
  11. LIBRARY IEEE;
  12. USE IEEE.std_logic_1164.ALL;
  13. USE IEEE.std_logic_unsigned.ALL;
  14. ---------------------------------------------------------------------------------------------------
  15. ---------------------------------------------------------------------------------------------------
  16. -- The Entity Declarations 
  17. ENTITY LED4 IS
  18. PORT 
  19. (
  20. RESET:  IN STD_LOGIC; 
  21. ClockScan: IN STD_LOGIC;
  22. LED1: IN STD_LOGIC_VECTOR(3 DOWNTO 0);
  23. LED2: IN STD_LOGIC_VECTOR(3 DOWNTO 0);
  24. LED3: IN STD_LOGIC_VECTOR(3 DOWNTO 0);
  25. LED4: IN STD_LOGIC_VECTOR(3 DOWNTO 0);
  26. Light:  OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
  27. LEDOut:  OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
  28. DigitSelect: OUT STD_LOGIC_VECTOR(3 DOWNTO 0)
  29. );
  30. END LED4;
  31. ---------------------------------------------------------------------------------------------------
  32. ---------------------------------------------------------------------------------------------------
  33. -- The Architecture of Entity Declarations 
  34. ARCHITECTURE LED4_arch OF LED4 IS
  35. SIGNAL LED: STD_LOGIC_VECTOR(3 downto 0);
  36. -- SIGNAL LED2, LED3, LED4: STD_LOGIC_VECTOR(3 downto 0);
  37. SIGNAL Refresh: STD_LOGIC_VECTOR(1 downto 0);
  38. BEGIN
  39. -------------------------------------------------
  40. -- Encoder 
  41. -- HEX-to-seven-segment decoder 
  42. -- segment encoding 
  43. --      0 
  44. --     ---  
  45. --  5 |   | 1
  46. --     ---   <- 6
  47. --  4 |   | 2
  48. --     ---  
  49. --      3
  50. PROCESS( LED )   
  51. BEGIN
  52. IF( Refresh=0 OR Refresh=1 ) THEN 
  53. CASE LED IS
  54. when "0000"=>LEDOut<= "00111111";    --'0'
  55. when "0001"=>LEDOut<= "00000110";    --'1'
  56. when "0010"=>LEDOut<= "01011011";    --'2'
  57. when "0011"=>LEDOut<= "01001111";    --'3'
  58. when "0100"=>LEDOut<= "01100110";    --'4'
  59. when "0101"=>LEDOut<= "01101101";    --'5'
  60. when "0110"=>LEDOut<= "01111101";    --'6'
  61. when "0111"=>LEDOut<= "00000111";    --'7'
  62. when "1000"=>LEDOut<= "01111111";    --'8'
  63. when "1001"=>LEDOut<= "01101111";    --'9'
  64. when "1010"=>LEDOut<= "01110111";    --'A'
  65. when "1011"=>LEDOut<= "01111100";    --'b'
  66. when "1100"=>LEDOut<= "00111001";    --'C'
  67. when "1101"=>LEDOut<= "01011110";    --'d'
  68. when "1110"=>LEDOut<= "01111001";    --'E'
  69. when "1111"=>LEDOut<= "01110001";    --'F'
  70. when others=>LEDOut<= "00000000";    --' '
  71. END CASE;
  72. ELSE
  73. LEDOut<= "00000000";    --' '
  74. END IF;
  75. END PROCESS;
  76. -------------------------------------------------
  77. -- Scan 
  78. -- PROCESS( ClockScan, clock ) 
  79. -- BEGIN
  80. -- IF ClockScan = '0' THEN clock <= '0';
  81. -- ELSE clock <= '1';
  82. -- END IF; 
  83. -- END PROCESS;
  84. -------------------------------------------------
  85. -- clock 
  86. PROCESS( ClockScan )   
  87. BEGIN
  88. IF( ClockScan'EVENT AND ClockScan = '1' )THEN 
  89. Refresh <= Refresh + 1; 
  90. END IF; 
  91. END PROCESS;
  92. -------------------------------------------------
  93. -- MUX 
  94. LED <= 
  95. LED1 when( Refresh=0 ) else
  96. LED2 when( Refresh=1 ) else
  97. LED3 when( Refresh=2 ) else
  98. LED4;
  99. -------------------------------------------------
  100. --  LED Digit Select 
  101. DigitSelect <= 
  102. "1110" when( Refresh=0 ) else
  103. "1101" when( Refresh=1 ) else
  104. "1011" when( Refresh=2 ) else
  105. "0111";
  106. -------------------------------------------------
  107. -- 
  108. Light <= NOT (LED2 & LED1); 
  109. END LED4_arch;