⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 led.vhd

📁 一些很好的FPGA设计实例
💻 VHD
字号:
--**                       数码管演示实验

--文件名:led.vhd

--功  能:分别点亮数码管和发光二极管

--说  明:分为两种显示模式:

--        1.只点亮数码管;

--        2.只点亮发光二极管;

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity led is
    Port (clk : in std_logic;
	       cs  : out std_logic_vector(1 downto 0);      --发光二极管和数码管的片选信号;
			 led : out std_logic_vector(7 downto 0);		 --输出8位LED数据;
			 shift : out std_logic_vector(3 downto 0));	 --数码管位选信号;
end led;

architecture Behavioral of led is

signal clk_shift : std_logic;					 --1Hz;

begin
process(clk)										 --分频器;
variable cnt : integer range 0 to 50000000;
begin
   if clk'event and clk='1' then cnt:=cnt+1;
      if cnt<25000000 then clk_shift<='1';
		elsif cnt<50000000 then clk_shift<='0';
		else cnt:=0;clk_shift<='0';
		end if;
   end if;
end process;

process(clk_shift)
variable cnt : std_logic_vector(2 downto 0);
begin
   if clk_shift'event and clk_shift='1' then 
       cnt:=cnt+1;
			if cnt="001" then
			   cs<="11";
				shift<="1111";
				led<="11111111";		--发光二极管、数码管全灭;
			elsif cnt="010" then 
				cs<="00";
				shift<="1111";
				led<="11111111";	   --数码管上显示 "8.";
			elsif cnt="011" then 
				cs<="10";
				shift<="0111";
				led<="00000000";	   --数码管上显示 "8.";
			elsif cnt="100" then 
				cs<="10";
				shift<="1011";
				led<="00000000";   	--数码管上显示 "8.";
			elsif cnt="101" then
				cs<="10";
				shift<="1101";
				led<="00000000";   	--数码管上显示 "8.";
			elsif cnt="110" then
				cs<="10"; 
				shift<="1110";
				led<="00000000";   	--数码管上显示 "8.";
			elsif cnt="111" then
				cs<="01";
				shift<="1111";			--发光二极管全亮;
				led<="00000000";
			end if;
   end if;
end process;
end Behavioral;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -