这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » DIY与开源设计 » 电子DIY » haohaolinux的进程帖之LED跑马灯

共1条 1/1 1 跳转至

haohaolinux的进程帖之LED跑马灯

菜鸟
2012-11-03 14:47:49     打赏
程序如下:
module LED2(clk,rst_n,LED);
//programmed by haohaolinux
     input clk,rst_n;
     output [7:0] LED;
 
     reg [7:0] LED;
     reg [23:0] cnt;
 
     //24 bit counter
     always@(posedge clk or negedge rst_n)
          if(!rst_n)
                  cnt <= 24'h0;
         else if(cnt == 24'hffffff)
                  cnt <= 24'h0;
         else
                 cnt <= cnt+1;
   
      always@(posedge clk or negedge rst_n)
            if(!rst_n)
                   LED <= 8'hfe;
            else if(cnt == 24'hffffff)
                   LED <= {LED[6:0],LED[7]};
           else
                   LED <= LED;
   
endmodule



关键词: haohaolinux     进程     帖之     马灯    

共1条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]