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

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, Refresh )   
  51. BEGIN
  52. CASE LED IS
  53. when "0000"=>LEDOut<= "00111111";    --'0'
  54. when "0001"=>LEDOut<= "00000110";    --'1'
  55. when "0010"=>LEDOut<= "01011011";    --'2'
  56. when "0011"=>LEDOut<= "01001111";    --'3'
  57. when "0100"=>LEDOut<= "01100110";    --'4'
  58. when "0101"=>LEDOut<= "01101101";    --'5'
  59. when "0110"=>LEDOut<= "01111101";    --'6'
  60. when "0111"=>LEDOut<= "00000111";    --'7'
  61. when "1000"=>LEDOut<= "01111111";    --'8'
  62. when "1001"=>LEDOut<= "01101111";    --'9'
  63. when "1010"=>LEDOut<= "01110111";    --'A'
  64. when "1011"=>LEDOut<= "01111100";    --'b'
  65. when "1100"=>LEDOut<= "00111001";    --'C'
  66. when "1101"=>LEDOut<= "01011110";    --'d'
  67. when "1110"=>LEDOut<= "01111001";    --'E'
  68. when "1111"=>LEDOut<= "01110001";    --'F'
  69. when others=>LEDOut<= "00000000";    --' '
  70. END CASE;
  71. END PROCESS;
  72. -------------------------------------------------
  73. -- clock 
  74. PROCESS( ClockScan )   
  75. BEGIN
  76. IF( ClockScan'EVENT AND ClockScan = '1' )THEN 
  77. Refresh <= Refresh + 1; 
  78. END IF; 
  79. END PROCESS;
  80. -------------------------------------------------
  81. -- MUX 
  82. LED <= 
  83. LED1 when( Refresh=0 ) else
  84. LED2 when( Refresh=1 ) else
  85. LED3 when( Refresh=2 ) else
  86. LED4;
  87. -------------------------------------------------
  88. --  LED Digit Select 
  89. DigitSelect <= 
  90. "1110" when( Refresh=0 ) else
  91. "1101" when( Refresh=1 ) else
  92. "1011" when( Refresh=2 ) else
  93. "0111";
  94. -------------------------------------------------
  95. -- 
  96. Light <= NOT ( LED1 & LED2 ); 
  97. END LED4_arch;