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

VHDL/FPGA/Verilog

开发平台:

Others

  1. ---------------------------------------------------------------------------------------------------
  2. --*************************************************************************************************
  3. --  CreateDate  :  2007-07-12 
  4. --  ModifData   :  2007-07-26 
  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. DATA:     IN STD_LOGIC_VECTOR(7 DOWNTO 0);
  23. Light:  OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
  24. LEDOut:  OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
  25. DigitSelect: OUT STD_LOGIC_VECTOR(3 DOWNTO 0)
  26. );
  27. END LED4;
  28. ---------------------------------------------------------------------------------------------------
  29. ---------------------------------------------------------------------------------------------------
  30. -- The Architecture of Entity Declarations 
  31. ARCHITECTURE LED4_arch OF LED4 IS
  32. SIGNAL LED: STD_LOGIC_VECTOR(3 downto 0);
  33. -- SIGNAL LED1, LED2: STD_LOGIC_VECTOR(3 downto 0);
  34. SIGNAL Refresh: STD_LOGIC_VECTOR(1 downto 0);
  35. BEGIN
  36. -------------------------------------------------
  37. -- Encoder 
  38. -- HEX-to-seven-segment decoder 
  39. -- segment encoding 
  40. --      0 
  41. --     ---  
  42. --  5 |   | 1
  43. --     ---   <- 6
  44. --  4 |   | 2
  45. --     ---  
  46. --      3
  47. PROCESS( LED, Refresh )   
  48. BEGIN
  49. IF( Refresh=0 OR Refresh=1 ) THEN 
  50. CASE LED IS
  51. when "0000"=>LEDOut<= "00111111";    --'0'
  52. when "0001"=>LEDOut<= "00000110";    --'1'
  53. when "0010"=>LEDOut<= "01011011";    --'2'
  54. when "0011"=>LEDOut<= "01001111";    --'3'
  55. when "0100"=>LEDOut<= "01100110";    --'4'
  56. when "0101"=>LEDOut<= "01101101";    --'5'
  57. when "0110"=>LEDOut<= "01111101";    --'6'
  58. when "0111"=>LEDOut<= "00000111";    --'7'
  59. when "1000"=>LEDOut<= "01111111";    --'8'
  60. when "1001"=>LEDOut<= "01101111";    --'9'
  61. when "1010"=>LEDOut<= "01110111";    --'A'
  62. when "1011"=>LEDOut<= "01111100";    --'b'
  63. when "1100"=>LEDOut<= "00111001";    --'C'
  64. when "1101"=>LEDOut<= "01011110";    --'d'
  65. when "1110"=>LEDOut<= "01111001";    --'E'
  66. when "1111"=>LEDOut<= "01110001";    --'F'
  67. when others=>LEDOut<= "00000000";    --' '
  68. END CASE;
  69. ELSIF( Refresh=2 ) THEN 
  70. LEDOut<= "10000000";    --':'
  71. ELSE
  72. LEDOut<= "00111001";    --'C'
  73. END IF;
  74. END PROCESS;
  75. -------------------------------------------------
  76. -- clock 
  77. PROCESS( ClockScan )   
  78. BEGIN
  79. IF( ClockScan'EVENT AND ClockScan = '1' )THEN 
  80. Refresh <= Refresh + 1; 
  81. END IF; 
  82. END PROCESS;
  83. -------------------------------------------------
  84. -- MUX 
  85. LED <= 
  86. DATA(3 DOWNTO 0) when( Refresh=0 ) else
  87. DATA(7 DOWNTO 4);
  88. -------------------------------------------------
  89. --  LED Digit Select 
  90. DigitSelect <= 
  91. "1110" when( Refresh=0 ) else
  92. "1101" when( Refresh=1 ) else
  93. "1011" when( Refresh=2 ) else
  94. "0111";
  95. -------------------------------------------------
  96. -- 
  97. Light <= NOT DATA; 
  98. END LED4_arch;