myled.vhd

来自「EP1C3144的点灯基本程序」· VHDL 代码 · 共 49 行

VHD
49
字号
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_ARITH.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;

ENTITY myled IS
PORT (clk:in std_logic;
	  led1:out std_logic;
	  led2:out std_logic;
	  led3:out std_logic
	 );
END;

ARCHITECTURE ledtst OF myled IS
SIGNAL counter:integer range 0 to 60000000;
signal ledtmp1:std_logic;
signal ledtmp2:std_logic;
signal ledtmp3:std_logic;
BEGIN
	PROCESS(clk)
 BEGIN
 if (clk'event and clk='1') then
	counter<=counter+1;
	if(counter<10000000) then
	ledtmp1<='1';
	end if;
	if(counter>=10000000 and counter<20000000) then
	ledtmp2<='1';
	end if;
	if(counter>=20000000 and counter<30000000) then
	ledtmp3<='1';
	end if;
	if(counter>=30000000 and counter<40000000) then
	ledtmp1<='0';
	ledtmp2<='0';
	ledtmp3<='0';
	end if;
	if(counter>=40000000) then
	counter<=0;
	end if;
	
end if;	

end process;
	led1<=ledtmp1;
	led2<=ledtmp2;
	led3<=ledtmp3;
end ledtst;

⌨️ 快捷键说明

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