利用VHDL编写的呼吸灯
发布网友
发布时间:2022-05-23 17:31
我来回答
共1个回答
热心网友
时间:2023-11-01 04:21
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
--USE IEEE.STD_LOGIC_ARITH.ALL;
--USE IEEE.STD_LOGIC_UNSIGNED.ALL;
entity led is
port(led1,led2,led3,led4:out bit;clk:in bit);
end led;
architecture led_blink of led is
begin
process(clk)
variable s1:integer:=0;
variable s2:integer:=0;
begin
i1:if (clk'event and clk='1') then
s1:=s1+1;
if(s1>20000) then
s2:=s2+1;
if(s2>2500 and s2<5000) then
led1<='1';
led2<='0';
led3<='1';
led4<='0';
elsif(s2>=5000) then
led1<='0';
led2<='1';
led3<='0';
led4<='1';
s2:=0;
end if;
s1:=0;
end if;
end if i1;
end process;
end led_blink;