资料介绍
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