首页|嵌入式系统|显示技术|模拟IC/电源|元件与制造|其他IC/制程|消费类电子|无线/通信|汽车电子|工业控制|医疗电子|测试测量
首页 > 分享下载 > 嵌入式系统 > led流水灯

led流水灯

资料介绍
led流水灯
/*--------------------------------------------------------
-- Engineer: zhrscut
-- Create Date:
-- Module Name:
-- Tool Versions: Quartus_II 9.1
--------------------------------------------------------*/
module ledshift(clk,rst_n,led);
input clk;
input rst_n;
output[7:0] led;

reg[22:0] cnt; //分频计数器
always @(posedge clk or negedge rst_n)
if(!rst_n) cnt<=23'd0;
else cnt<=cnt+1'b1;

reg clk_r; //LED 流水时钟
always @(posedge clk or negedge rst_n)
if(!rst_n) clk_r<=1'b1;
else if(cnt==23'h7fffff) clk_r<=~clk_r;

reg[7:0] led_r=8'b1000_0000;
always @(posedge clk_r or negedge rst_n)
if(!rst_n) led_r<=8'b1000_0000;
else led_r<={led_r[0],led_r[7:1]};//led 向右移位
assign led=led_r;
endmodule
led流水灯
本地下载

评论