码迷,mamicode.com
首页 > 其他好文 > 详细

FPGA之流水灯

时间:2015-10-29 23:29:03      阅读:161      评论:0      收藏:0      [点我收藏+]

标签:

 1 module move_led
 2 (
 3     clk,
 4     rst,
 5     led
 6 );
 7 
 8 input clk;
 9 input rst;
10 
11 output [5:0]led;
12 
13 reg [23:0]count;
14 always @(posedge clk or negedge rst)
15 begin
16     if(!rst) count <= 24d0;
17     else if(count == 24hffffff) count <= 24d0;
18     else count <= count + 1d1;
19 end
20 
21 reg [5:0]led_r;
22 always @(posedge clk or negedge rst)
23 begin
24     if(!rst) led_r <= 6b111_110;
25     else if (count == 24hfffffe) led_r <= {led_r[4:0],led_r[5]};
26     else led_r <= led_r;
27 end
28 
29 assign led = led_r;
30 
31 endmodule

 

FPGA之流水灯

标签:

原文地址:http://www.cnblogs.com/wojiaoxiaodian/p/4921955.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!