程序如下:
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