FPGA的一个VHDL实现1秒LED闪烁一次的程序
#开发软件
3642 人阅读
|
0 人回复
|
2008-03-20
|
|
程序思路很简单,就是利用50MHz的外部时钟输入,经过2次分频得到1秒的精确定时,给LED取反。
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 ut 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 |
|
|
|
|
|
|
|
|