日志档案

发表于 2008-2-27 16:51:10

3

标签: FPGA  VHDL  LED  1秒定时  

FPGA的一个VHDL实现1秒LED闪烁一次的程序。

程序思路很简单,就是利用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: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; 

系统分类: CPLD/FPGA   |   用户分类: FPGA   |   来源: 原创   |   【推荐给朋友】

    阅读(1242)    回复(6)  

投一票您将和博主都有获奖机会!

  • emot

    2008-2-28 22:30:17

    没真正学过vhdl。遗憾了。

  • ostrich1983

    2008-2-29 9:24:32

    无语

  • christine

    2008-3-4 16:46:47

    请问您现在何地?我是一家香港猎头公司成都分公司的专业猎头。我这里有非成都本地的相应职位空缺,可否与我联系? MSN:christinejiusa@hotmail.com QQ:785423732 谢谢。

  • kenan052

    2008-3-7 17:14:14

    "PFGA"?是FPGA吧,呵呵,不错。

  • yoyowind

    2008-3-7 19:56:44

    竟然把名字打倒了没发现, 晕死了,抓紧改。

  • lianyq1986

    2008-3-16 14:56:09

    非常感谢你的程序,对我启发很大,谢谢了!